From patchwork Fri Oct 20 14:31:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23730 Received: (qmail 32003 invoked by alias); 20 Oct 2017 14:31:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31992 invoked by uid 89); 20 Oct 2017 14:31:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2131 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Oct 2017 14:31:12 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF386C059B7A for ; Fri, 20 Oct 2017 14:31:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF386C059B7A Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 557FA600C2 for ; Fri, 20 Oct 2017 14:31:10 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] Fix gdb.gdb/ selftest tests when testing optimized GDB builds Date: Fri, 20 Oct 2017 15:31:09 +0100 Message-Id: <1508509869-7929-1-git-send-email-palves@redhat.com> 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=) 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 * main.c (captured_command_loop): Add attribute noinline. --- gdb/ChangeLog | 4 ++++ gdb/main.c | 5 +++++ 2 files changed, 9 insertions(+) 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 + + * main.c (captured_command_loop): Add attribute noinline. + 2017-10-19 Simon Marchi * 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 () {