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