From patchwork Tue Jun 12 15:06:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 27752 Received: (qmail 50673 invoked by alias); 12 Jun 2018 15:06:29 -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 50398 invoked by uid 89); 12 Jun 2018 15:06:29 -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, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Jun 2018 15:06:23 +0000 Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C7729ABC3 for ; Tue, 12 Jun 2018 15:06:20 +0000 (UTC) Date: Tue, 12 Jun 2018 17:06:20 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] Ensure captured_main has unique address Message-ID: <20180612150620.wloegrt5dgpdugi2@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes 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=) 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=) at main.c:492 #1 captured_main (data=) at main.c:1147 #2 gdb_main (args=args@entry=0x7fffffffdb80) at main.c:1173 #3 0x000000000040fea5 in main (argc=, argv=) 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 * 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;