walt <[email protected]> wrote:
> I'm ready to swear on a stack of Knuth volumes that gdb has lost its mind.
>
> But, I'm willing to consider the remote possibility that I don't know how
> to use gdb ;) (Because I really don't.)
>
> This is my annotated copy/paste from a single gdb session:
>
> #gdb /bin/mount
> GNU gdb (Gentoo 7.9 vanilla) 7.9
>
> <GNU boilerplate snipped>
>
> (gdb) start
> 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.
> Starting program: /bin/mount
>
> Temporary breakpoint 1, main (argc=1, argv=0x7ffc3508e108)
> at
> /var/tmp/portage/sys-apps/util-linux-2.26.1-r1/work/util-linux-2.26.1/sys-utils/mount.c:789
> 789 {
> (gdb) list mount.c:1020
>
> <I picked line 1020 because I know from previous gdb sessions that it
> calls the print_all function, which is the one I really want to debug>
>
> 1015 !mnt_context_get_target(cxt) &&
> 1016 !argc &&
> 1017 !all) {
> 1018 if (oper || mnt_context_get_options(cxt))
> 1019 usage(stderr);
> 1020 print_all(cxt, types, show_labels);
> 1021 goto done;
> 1022 }
> 1023
> 1024 /* Non-root users are allowed to use -t to print_all(),
>
>
>
> <I want to debug the function named print_all, so I set a breakpoint there>
>
> (gdb) break print_all
> 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.
>
>
>
> <Okay, this is where gdb does something crazy. Note that (see the line above)
> gdb set the breakpoint at mount.c:130, but in fact print_all is defined at
> mount.c:123, seven lines earlier>
>
> (gdb) list mount.c:123
> 118 else
> 119 fputc(*p, stdout);
> 120 }
> 121 }
> 122
> 123 static void print_all(struct libmnt_context *cxt, char *pattern, int
> show_label)
> 124 {
> 125 struct libmnt_table *tb;
> 126 struct libmnt_iter *itr = NULL;
> 127 struct libmnt_fs *fs;
> (gdb)
>
>
> This seems to me to be very buggy behavior, but I'd like to get opinions from
> people who really know gdb, which I don't.
I think it wants to put you on the first real statement of the function.
--
Your life is like a penny. You're going to lose it. The question is:
How do
you spend it?
John Covici
[email protected]