public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Ensure captured_main has unique address
@ 2018-06-12 15:06 Tom de Vries
  2018-06-12 17:38 ` Change inline frame breakpoint skipping logic (Re: [PATCH] Ensure captured_main has unique address) Pedro Alves
  0 siblings, 1 reply; 14+ messages in thread
From: Tom de Vries @ 2018-06-12 15:06 UTC (permalink / raw)
  To: gdb-patches

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;

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-06-29 18:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 15:06 [PATCH] Ensure captured_main has unique address Tom de Vries
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

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).