From patchwork Thu Dec 12 02:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36762 Received: (qmail 1384 invoked by alias); 12 Dec 2019 02:35:20 -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 1031 invoked by uid 89); 12 Dec 2019 02:35:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.1 spammy=reimplement, Reimplement X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2019 02:35:16 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 70E38206E6; Wed, 11 Dec 2019 21:35:12 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id C668F209FE for ; Wed, 11 Dec 2019 21:35:05 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id B2CE120AF6 for ; Wed, 11 Dec 2019 21:35:05 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Wed, 11 Dec 2019 21:35:02 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] Reimplement tui_get_begin_asm_address X-Gerrit-Change-Id: I77dc13d49148e8dec5aa3eeb357ce3968a68d0bd X-Gerrit-Change-Number: 643 X-Gerrit-ChangeURL: X-Gerrit-Commit: ea92866a3245cde8ecb43161d836e246c58e1ac8 In-Reply-To: References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191212023505.B2CE120AF6@gnutoolchain-gerrit.osci.io> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/643 ...................................................................... Reimplement tui_get_begin_asm_address tui_get_begin_asm_address looks for the inferior's "main" to display it. I think this is incorrect in two ways. First, it should probably instead use the user's most recent source context, if one has been set. Second, it uses a hard-coded list of "main" names, but gdb already has a better approach to handling this. This patch fixes both of these problems. 2019-12-11 Tom Tromey * tui/tui-disasm.c (tui_get_begin_asm_address): Use get_current_source_symtab_and_line, and main_name. Change-Id: I77dc13d49148e8dec5aa3eeb357ce3968a68d0bd --- M gdb/ChangeLog M gdb/tui/tui-disasm.c 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1954ad0..58eb3bb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2019-12-11 Tom Tromey + * tui/tui-disasm.c (tui_get_begin_asm_address): Use + get_current_source_symtab_and_line, and main_name. + +2019-12-11 Tom Tromey + * tui/tui.c (tui_show_source): Update. * tui/tui-winsource.h (tui_update_source_windows_with_line): Update. * tui/tui-winsource.c (tui_update_source_windows_with_line): Take diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 376343b..d8f2d38 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -258,25 +258,28 @@ { struct tui_locator_window *locator; struct gdbarch *gdbarch = get_current_arch (); - CORE_ADDR addr; + CORE_ADDR addr = 0; locator = tui_locator_win_info_ptr (); if (locator->addr == 0) { - struct bound_minimal_symbol main_symbol; + if (have_full_symbols () || have_partial_symbols ()) + { + set_default_source_symtab_and_line (); + struct symtab_and_line sal = get_current_source_symtab_and_line (); - /* Find address of the start of program. - Note: this should be language specific. */ - main_symbol = lookup_minimal_symbol ("main", NULL, NULL); - if (main_symbol.minsym == 0) - main_symbol = lookup_minimal_symbol ("MAIN", NULL, NULL); - if (main_symbol.minsym == 0) - main_symbol = lookup_minimal_symbol ("_start", NULL, NULL); - if (main_symbol.minsym) - addr = BMSYMBOL_VALUE_ADDRESS (main_symbol); - else - addr = 0; + if (sal.symtab != nullptr) + find_line_pc (sal.symtab, sal.line, &addr); + } + + if (addr == 0) + { + struct bound_minimal_symbol main_symbol + = lookup_minimal_symbol (main_name (), nullptr, nullptr); + if (main_symbol.minsym != nullptr) + addr = BMSYMBOL_VALUE_ADDRESS (main_symbol); + } } else /* The target is executing. */ {