* [FYI] Constify main_name
@ 2019-07-18 15:32 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-07-18 15:32 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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 <tromey@adacore.com>
* 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<symbol_search> 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.
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-18 15:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18 15:32 [FYI] Constify main_name Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).