1 |
walt <w41ter@×××××.com> wrote: |
2 |
|
3 |
> I'm ready to swear on a stack of Knuth volumes that gdb has lost its mind. |
4 |
> |
5 |
> But, I'm willing to consider the remote possibility that I don't know how |
6 |
> to use gdb ;) (Because I really don't.) |
7 |
> |
8 |
> This is my annotated copy/paste from a single gdb session: |
9 |
> |
10 |
> #gdb /bin/mount |
11 |
> GNU gdb (Gentoo 7.9 vanilla) 7.9 |
12 |
> |
13 |
> <GNU boilerplate snipped> |
14 |
> |
15 |
> (gdb) start |
16 |
> Temporary breakpoint 1 at 0x403000: file /var/tmp/portage/sys-apps/util-linux-2.26.1-r1/work/util-linux-2.26.1/sys-utils/mount.c, line 789. |
17 |
> Starting program: /bin/mount |
18 |
> |
19 |
> Temporary breakpoint 1, main (argc=1, argv=0x7ffc3508e108) |
20 |
> at /var/tmp/portage/sys-apps/util-linux-2.26.1-r1/work/util-linux-2.26.1/sys-utils/mount.c:789 |
21 |
> 789 { |
22 |
> (gdb) list mount.c:1020 |
23 |
> |
24 |
> <I picked line 1020 because I know from previous gdb sessions that it |
25 |
> calls the print_all function, which is the one I really want to debug> |
26 |
> |
27 |
> 1015 !mnt_context_get_target(cxt) && |
28 |
> 1016 !argc && |
29 |
> 1017 !all) { |
30 |
> 1018 if (oper || mnt_context_get_options(cxt)) |
31 |
> 1019 usage(stderr); |
32 |
> 1020 print_all(cxt, types, show_labels); |
33 |
> 1021 goto done; |
34 |
> 1022 } |
35 |
> 1023 |
36 |
> 1024 /* Non-root users are allowed to use -t to print_all(), |
37 |
> |
38 |
> |
39 |
> |
40 |
> <I want to debug the function named print_all, so I set a breakpoint there> |
41 |
> |
42 |
> (gdb) break print_all |
43 |
> Breakpoint 2 at 0x4037fd: file /var/tmp/portage/sys-apps/util-linux-2.26.1-r1/work/util-linux-2.26.1/sys-utils/mount.c, line 130. |
44 |
> |
45 |
> |
46 |
> |
47 |
> <Okay, this is where gdb does something crazy. Note that (see the line above) |
48 |
> gdb set the breakpoint at mount.c:130, but in fact print_all is defined at |
49 |
> mount.c:123, seven lines earlier> |
50 |
> |
51 |
> (gdb) list mount.c:123 |
52 |
> 118 else |
53 |
> 119 fputc(*p, stdout); |
54 |
> 120 } |
55 |
> 121 } |
56 |
> 122 |
57 |
> 123 static void print_all(struct libmnt_context *cxt, char *pattern, int show_label) |
58 |
> 124 { |
59 |
> 125 struct libmnt_table *tb; |
60 |
> 126 struct libmnt_iter *itr = NULL; |
61 |
> 127 struct libmnt_fs *fs; |
62 |
> (gdb) |
63 |
> |
64 |
> |
65 |
> This seems to me to be very buggy behavior, but I'd like to get opinions from |
66 |
> people who really know gdb, which I don't. |
67 |
|
68 |
I think it wants to put you on the first real statement of the function. |
69 |
|
70 |
-- |
71 |
Your life is like a penny. You're going to lose it. The question is: |
72 |
How do |
73 |
you spend it? |
74 |
|
75 |
John Covici |
76 |
covici@××××××××××.com |