public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: covici@ccs.covici.com
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] [~amd64] Confusing behavior from gdb
Date: Sat, 25 Apr 2015 19:42:30 -0400	[thread overview]
Message-ID: <5846.1430005350@ccs.covici.com> (raw)
In-Reply-To: <mhh846$e9m$1@ger.gmane.org>

walt <w41ter@gmail.com> 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
         covici@ccs.covici.com


  reply	other threads:[~2015-04-25 23:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-25 23:31 [gentoo-user] [~amd64] Confusing behavior from gdb walt
2015-04-25 23:42 ` covici [this message]
2015-04-26  2:52   ` Fernando Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5846.1430005350@ccs.covici.com \
    --to=covici@ccs.covici.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox