From patchwork Thu Jul 18 15:32:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33730 Received: (qmail 30647 invoked by alias); 18 Jul 2019 15:32:39 -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 30623 invoked by uid 89); 18 Jul 2019 15:32:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=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; Thu, 18 Jul 2019 15:32:37 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4655D5617F; Thu, 18 Jul 2019 11:32:36 -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 1nZOWpwI-Trv; Thu, 18 Jul 2019 11:32:36 -0400 (EDT) Received: from murgatroyd.Home (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (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 E59A0560B5; Thu, 18 Jul 2019 11:32:35 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Constify main_name Date: Thu, 18 Jul 2019 09:32:31 -0600 Message-Id: <20190718153231.32628-1-tromey@adacore.com> MIME-Version: 1.0 This patch constifies the return type of main_name. There is a comment indicating that this wasn't possible at some point in the past, but whatever the barrier was, it is gone now. Tested by rebuilding. gdb/ChangeLog 2019-07-18 Tom Tromey * symtab.c (main_name): Constify return type. * symfile.c (set_initial_language): Update. * symtab.h (main_name): Constify return type. --- gdb/ChangeLog | 6 ++++++ gdb/symfile.c | 2 +- gdb/symtab.c | 6 ++++-- gdb/symtab.h | 7 ++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index d2b88fc9e40..c70a5ce34eb 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1706,7 +1706,7 @@ set_initial_language (void) if (lang == language_unknown) { - char *name = main_name (); + const char *name = main_name (); struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL).symbol; if (sym != NULL) diff --git a/gdb/symtab.c b/gdb/symtab.c index 41898992c19..719e5b2ee9a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5741,8 +5741,10 @@ find_main_name (void) set_main_name ("main", language_unknown); } -char * -main_name (void) +/* See symtab.h. */ + +const char * +main_name () { struct main_info *info = get_main_info (); diff --git a/gdb/symtab.h b/gdb/symtab.h index 6780fa37be1..b91454c85c4 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2041,11 +2041,8 @@ extern std::vector search_symbols (const char *, extern bool treg_matches_sym_type_name (const compiled_regex &treg, const struct symbol *sym); -/* The name of the ``main'' function. - FIXME: cagney/2001-03-20: Can't make main_name() const since some - of the calling code currently assumes that the string isn't - const. */ -extern /*const */ char *main_name (void); +/* The name of the ``main'' function. */ +extern const char *main_name (); extern enum language main_language (void); /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.