From patchwork Fri Sep 20 19:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34616 Received: (qmail 117288 invoked by alias); 20 Sep 2019 19:20:23 -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 117263 invoked by uid 89); 20 Sep 2019 19:20:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=hs, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Sep 2019 19:20:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6378956075; Fri, 20 Sep 2019 15:20:20 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id C1KMwWddjA5P; Fri, 20 Sep 2019 15:20:20 -0400 (EDT) Received: from murgatroyd.Home (71-218-73-27.hlrn.qwest.net [71.218.73.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 1073856079; Fri, 20 Sep 2019 15:20:19 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 3/8] Don't call decode_line_with_current_source from select_source_symtab Date: Fri, 20 Sep 2019 13:20:12 -0600 Message-Id: <20190920192017.15293-4-tromey@adacore.com> In-Reply-To: <20190920192017.15293-1-tromey@adacore.com> References: <20190920192017.15293-1-tromey@adacore.com> MIME-Version: 1.0 select_source_symtab currently calls decode_line_with_current_source. However, this function iterates over all program spaces, and so it is possible that it will return a "main" from some other program space. This patch changes select_source_symtab to simply use the symbol it already found in the current program space. 2019-08-21 Tom Tromey * source.c (select_source_symtab): Don't call decode_line_with_current_source. --- gdb/ChangeLog | 5 +++++ gdb/source.c | 11 ++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gdb/source.c b/gdb/source.c index 0171f2748b4..77eced31628 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -251,17 +251,14 @@ select_source_symtab (struct symtab *s) /* Make the default place to list be the function `main' if one exists. */ - if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0).symbol) + block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0); + if (bsym.symbol != nullptr && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK) { - std::vector sals - = decode_line_with_current_source (main_name (), - DECODE_LINE_FUNFIRSTLINE); - const symtab_and_line &sal = sals[0]; + symtab_and_line sal = find_function_start_sal (bsym.symbol, true); current_source_pspace = sal.pspace; current_source_symtab = sal.symtab; current_source_line = std::max (sal.line - (lines_to_list - 1), 1); - if (current_source_symtab) - return; + return; } /* Alright; find the last file in the symtab list (ignoring .h's