This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[4/4] RFC: constify a quick function
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 30 Jun 2010 16:47:39 -0600
- Subject: [4/4] RFC: constify a quick function
- Reply-to: tromey at redhat dot com
This is just a small cleanup for a buglet I noticed while cleaning up
the patch series.
The quick function find_symbol_file returns a "char *", but I think it
really ought to return a "const char *". This patch implements that
change.
Tom
b/gdb/ChangeLog:
2010-06-30 Tom Tromey <tromey@redhat.com>
* symfile.c (set_initial_language): Update.
(deduce_language_from_filename): Argument type now const.
* symtab.h (find_main_filename): Update.
(deduce_language_from_filename): Update.
* symtab.c (find_main_filename): Make result const.
* dwarf2read.c (dw2_find_symbol_file): Change return type.
* psymtab.c (find_symbol_file_from_partial): Change return type.
* symfile.h (struct quick_symbol_functions) <find_symbol_file>:
Make result const.
>From f594ce100ef85a24fe239262aae72e7834a75ce8 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Wed, 30 Jun 2010 16:20:42 -0600
Subject: [PATCH 4/4] constify find_symbol_file
---
gdb/ChangeLog | 12 ++++++++++++
gdb/dwarf2read.c | 5 ++---
gdb/psymtab.c | 2 +-
gdb/symfile.c | 4 ++--
gdb/symfile.h | 2 +-
gdb/symtab.c | 6 ++++--
gdb/symtab.h | 4 ++--
7 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c2626a7..6468284 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2171,7 +2171,7 @@ dw2_expand_symtabs_with_filename (struct objfile *objfile,
}
}
-static char *
+static const char *
dw2_find_symbol_file (struct objfile *objfile, const char *name)
{
struct dwarf2_per_cu_data *cu;
@@ -2197,8 +2197,7 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name)
if (!cu->v.quick->lines)
return NULL;
- return (char *) cu->v.quick->file_names[cu->v.quick->lines->num_file_names
- - 1];
+ return cu->v.quick->file_names[cu->v.quick->lines->num_file_names - 1];
}
static void
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ca06130..c120894 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -949,7 +949,7 @@ psymtab_to_fullname (struct partial_symtab *ps)
return NULL;
}
-static char *
+static const char *
find_symbol_file_from_partial (struct objfile *objfile, const char *name)
{
struct partial_symtab *pst;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index af1b42c..babe9cf 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1538,7 +1538,7 @@ symbol_file_command (char *args, int from_tty)
void
set_initial_language (void)
{
- char *filename;
+ const char *filename;
enum language lang = language_unknown;
filename = find_main_filename ();
@@ -2665,7 +2665,7 @@ init_filename_language_table (void)
}
enum language
-deduce_language_from_filename (char *filename)
+deduce_language_from_filename (const char *filename)
{
int i;
char *cp;
diff --git a/gdb/symfile.h b/gdb/symfile.h
index d0fbb65..5815354 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -210,7 +210,7 @@ struct quick_symbol_functions
/* Return the file name of the file holding the symbol in OBJFILE
named NAME. If no such symbol exists in OBJFILE, return NULL. */
- char *(*find_symbol_file) (struct objfile *objfile, const char *name);
+ const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
/* This method is specific to Ada. It walks the partial symbol
tables of OBJFILE looking for a name match. WILD_MATCH and
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 4e48e48..07910db 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1617,14 +1617,16 @@ basic_lookup_transparent_type (const char *name)
/* FIXME: What about languages without main() or specially linked
executables that have no main() ? */
-char *
+const char *
find_main_filename (void)
{
struct objfile *objfile;
- char *result, *name = main_name ();
+ char *name = main_name ();
ALL_OBJFILES (objfile)
{
+ const char *result;
+
if (!objfile->sf)
continue;
result = objfile->sf->qf->find_symbol_file (objfile, name);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bedc10a..f8c9496 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1137,7 +1137,7 @@ extern char **make_source_files_completion_list (char *, char *);
int matching_obj_sections (struct obj_section *, struct obj_section *);
-extern char *find_main_filename (void);
+extern const char *find_main_filename (void);
extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
@@ -1150,7 +1150,7 @@ extern void skip_prologue_sal (struct symtab_and_line *);
extern void clear_symtab_users (void);
-extern enum language deduce_language_from_filename (char *);
+extern enum language deduce_language_from_filename (const char *);
/* symtab.c */
--
1.6.2.5