aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-10-20 14:47:24 +0100
committerPedro Alves <palves@redhat.com>2017-10-20 14:47:24 +0100
commitfcc8fb2f3de370f2def30bb18c98243ed4f3fb8c (patch)
tree62f23e27d2f3647a29113994e3ba76ce3611f1c9
parent808811a36951c6bc2ee9d56124603d7ef88a019e (diff)
downloadgdb-fcc8fb2f3de370f2def30bb18c98243ed4f3fb8c.zip
gdb-fcc8fb2f3de370f2def30bb18c98243ed4f3fb8c.tar.gz
gdb-fcc8fb2f3de370f2def30bb18c98243ed4f3fb8c.tar.bz2
Fix gdb.gdb/ selftest tests when testing optimized GDB builds
After commit bf4692711232 ("Eliminate catch_errors"), GCC started inlining captured_command_loop in captured_main. And setting a breakpoint on captured_command_loop makes the inferior GDB stop in captured_main, _after_ captured_command_loop's call to interp_pre_command_loop, which prints the inferior GDB's prompt, has already executed, confusing the gdb.gdb/ selftest tests: (gdb) FAIL: gdb.gdb/complaints.exp: run until breakpoint at captured_command_loop WARNING: Couldn't test self Debugging GDB with GDB manually, we see: (top-gdb) b captured_command_loop Breakpoint 1 at 0x71ee60: file src/gdb/main.c, line 324. (top-gdb) r [....] (gdb) <<<<<< PROMPT HERE Thread 1 "gdb" hit Breakpoint 1, captured_main (data=<optimized out>) at src/gdb/main.c:1147 1147 captured_command_loop (); (top-gdb) Note the stop at 'captured_main', and the "PROMPT HERE" line. That prompt does not show up when debugging a non-optimized build of GDB. Fix this by preventing inlining of captured_command_loop. Ref: https://sourceware.org/ml/gdb-patches/2017-10/msg00522.html gdb/ChangeLog: 2017-10-20 Pedro Alves <palves@redhat.com> * main.c (captured_command_loop): Add attribute noinline.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/main.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fe95d0a..a5107f7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-20 Pedro Alves <palves@redhat.com>
+
+ * main.c (captured_command_loop): Add attribute noinline.
+
2017-10-19 Simon Marchi <simon.marchi@ericsson.com>
* interps.c (struct interp_factory): Add constructor.
diff --git a/gdb/main.c b/gdb/main.c
index beb8203..835ae24 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -307,6 +307,11 @@ setup_alternate_signal_stack (void)
/* Call command_loop. */
+/* Prevent inlining this function for the benefit of GDB's selftests
+ in the testsuite. Those tests want to run GDB under GDB and stop
+ here. */
+static void captured_command_loop () __attribute__((noinline));
+
static void
captured_command_loop ()
{