public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] Ensure captured_main has unique address
Date: Tue, 12 Jun 2018 15:06:00 -0000	[thread overview]
Message-ID: <20180612150620.wloegrt5dgpdugi2@localhost.localdomain> (raw)

Hi,

atm selftest.exp fails for me.

One of the reasons is that after setting a breakpoint in captured_main, we
stop at:
...
Breakpoint 1, captured_main_1 (context=<optimized out>) at src/gdb/main.c:492
...
while selftest_setup expects to stop at captured_main.

The problem is that captured_main_1 has been inlined into captured_main, and
captured_main has been inlined into gdb_main:
...
$ nm ./build/gdb/gdb | egrep ' [tT] .*captured_main|gdb_main' | c++filt
000000000061b950 T gdb_main(captured_main_args*)
...

The reason that we seem to be stopping at inline function captured_main_1 has
probably something to do with commit "Don't elide all inlined frames", which
shows us the frames of inlined functions as if they were not inlined.  Indeed,
the two inlined functions show up in the backtrace:
...
(gdb) bt
#0  captured_main_1 (context=<optimized out>) at main.c:492
#1  captured_main (data=<optimized out>) at main.c:1147
#2  gdb_main (args=args@entry=0x7fffffffdb80) at main.c:1173
#3  0x000000000040fea5 in main (argc=<optimized out>, argv=<optimized out>)
    at gdb.c:32
...

[ For contrast, If I use my distro gdb to debug build/gdb/gdb instead, we just
get:
...
Breakpoint 1, gdb_main (args=args@entry=0x7fffffffdb80)
    at src/gdb/main.c:1173
1173          captured_main (args);
...
]

Either way, this patch fixes the problem by ensuring that captured_main has a
unique address:
...
$ nm ./build/gdb/gdb | egrep ' [tT] .*captured_main|gdb_main' | c++filt
000000000061ca20 T gdb_main(captured_main_args*)
000000000061c980 t captured_main(void*)
000000000061b950 t captured_main_1(captured_main_args*)
...

Tested selftest.exp (with two other selftest.exp related fixes applied).

OK for trunk?

Thanks,
- Tom

[gdb] Ensure captured_main has unique address

2018-06-12  Tom de Vries  <tdevries@suse.de>

	* main.c (captured_main, captured_main_1): Add
	__attribute__((noinline)).

---
 gdb/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/main.c b/gdb/main.c
index 9694af2426..f35dffd428 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -447,7 +447,7 @@ struct cmdarg
   char *string;
 };
 
-static void
+static void __attribute__((noinline))
 captured_main_1 (struct captured_main_args *context)
 {
   int argc = context->argc;
@@ -1139,7 +1139,7 @@ captured_main_1 (struct captured_main_args *context)
     }
 }
 
-static void
+static void __attribute__((noinline))
 captured_main (void *data)
 {
   struct captured_main_args *context = (struct captured_main_args *) data;

             reply	other threads:[~2018-06-12 15:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 15:06 Tom de Vries [this message]
2018-06-12 17:38 ` Change inline frame breakpoint skipping logic (Re: [PATCH] Ensure captured_main has unique address) Pedro Alves
2018-06-14 13:22   ` Tom de Vries
2018-06-19 16:36     ` [pushed] Change inline frame breakpoint skipping logic (fix gdb.gdb/selftest.exp) Pedro Alves
2018-06-25 21:04       ` Joel Brobecker
2018-06-26 19:02         ` Pedro Alves
2018-06-26 22:02           ` Joel Brobecker
2018-06-27 16:28             ` Pedro Alves
2018-06-28 14:48               ` Pedro Alves
2018-06-28 14:50                 ` [PATCH 1/2] Fix running to breakpoint set in inline function by lineno/address Pedro Alves
2018-06-28 17:32                   ` Joel Brobecker
2018-06-28 14:50                 ` [PATCH 2/2] "break LINENO/*ADDRESS", inline functions and "info break" output Pedro Alves
2018-06-28 17:42                   ` Joel Brobecker
2018-06-29 18:43                     ` Pedro Alves

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=20180612150620.wloegrt5dgpdugi2@localhost.localdomain \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).