This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: split up domain_enum
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 04 Apr 2011 08:09:52 -0600
- Subject: FYI: split up domain_enum
I'm checking this in on the trunk.
It has long bothered me that domain_enum had two purposes -- it includes
constants defining domains, but also constants used only when searching
domains.
This patch splits domain_enum into two parts. I think this yields more
clarity and better type safety. I also gave the previously anonymous
block enum a name, for the same reasons.
Built and regtested on x86-64 (compile farm).
Tom
2011-04-04 Tom Tromey <tromey@redhat.com>
* symtab.h (domain_enum): Split in two...
(enum search_domain): New.
(search_symbols): Update.
* symtab.c (print_symbol_info, symtab_symbol_info): Remove
redundant declarations.
(search_symbols): Change 'kind' argument to search_domain.
Update.
(print_symbol_info): Likewise.
(symtab_symbol_info): Likewise.
* symfile.h (struct quick_symbol_functions)
<pre_expand_symtabs_matching>: Change type of 'kind' argument.
<expand_symtabs_matching>: Likewise.
* psymtab.c (pre_expand_symtabs_matching_psymtabs): Update.
(expand_symtabs_matching_via_partial): Update.
* dwarf2read.c (dw2_pre_expand_symtabs_matching): Update.
(dw2_expand_symtabs_for_function): Update.
* block.h: Moved anonymous enum...
* defs.h (enum block_enum): ... here. Now named.
Index: block.h
===================================================================
RCS file: /cvs/src/src/gdb/block.h,v
retrieving revision 1.22
diff -u -r1.22 block.h
--- block.h 1 Jan 2011 15:32:57 -0000 1.22
+++ block.h 4 Apr 2011 14:05:24 -0000
@@ -129,10 +129,6 @@
#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
#define BLOCKVECTOR_MAP(blocklist) ((blocklist)->map)
-/* Special block numbers */
-
-enum { GLOBAL_BLOCK = 0, STATIC_BLOCK = 1, FIRST_LOCAL_BLOCK = 2 };
-
extern struct symbol *block_linkage_function (const struct block *);
extern int block_inlined_p (const struct block *block);
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.288
diff -u -r1.288 defs.h
--- defs.h 31 Mar 2011 14:32:48 -0000 1.288
+++ defs.h 4 Apr 2011 14:05:24 -0000
@@ -1256,4 +1256,13 @@
extern void initialize_progspace (void);
extern void initialize_inferiors (void);
+/* Special block numbers */
+
+enum block_enum
+{
+ GLOBAL_BLOCK = 0,
+ STATIC_BLOCK = 1,
+ FIRST_LOCAL_BLOCK = 2
+};
+
#endif /* #ifndef DEFS_H */
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.519
diff -u -r1.519 dwarf2read.c
--- dwarf2read.c 1 Apr 2011 17:46:44 -0000 1.519
+++ dwarf2read.c 4 Apr 2011 14:05:25 -0000
@@ -2426,7 +2426,7 @@
static void
dw2_pre_expand_symtabs_matching (struct objfile *objfile,
- int kind, const char *name,
+ enum block_enum block_kind, const char *name,
domain_enum domain)
{
dw2_do_expand_symtabs_matching (objfile, name);
@@ -2572,7 +2572,7 @@
dw2_expand_symtabs_matching (struct objfile *objfile,
int (*file_matcher) (const char *, void *),
int (*name_matcher) (const char *, void *),
- domain_enum kind,
+ enum search_domain kind,
void *data)
{
int i;
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.26
diff -u -r1.26 psymtab.c
--- psymtab.c 23 Mar 2011 18:23:55 -0000 1.26
+++ psymtab.c 4 Apr 2011 14:05:26 -0000
@@ -588,7 +588,8 @@
static void
pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
- int kind, const char *name,
+ enum block_enum block_kind,
+ const char *name,
domain_enum domain)
{
/* Nothing. */
@@ -1244,7 +1245,7 @@
void *),
int (*name_matcher) (const char *,
void *),
- domain_enum kind,
+ enum search_domain kind,
void *data)
{
struct partial_symtab *ps;
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.85
diff -u -r1.85 symfile.h
--- symfile.h 7 Mar 2011 16:17:29 -0000 1.85
+++ symfile.h 4 Apr 2011 14:05:26 -0000
@@ -182,7 +182,8 @@
doesn't make sense to implement both.) The arguments are as for
`lookup_symbol'. */
void (*pre_expand_symtabs_matching) (struct objfile *objfile,
- int kind, const char *name,
+ enum block_enum block_kind,
+ const char *name,
domain_enum domain);
/* Print statistics about any indices loaded for OBJFILE. The
@@ -265,7 +266,7 @@
void (*expand_symtabs_matching) (struct objfile *objfile,
int (*file_matcher) (const char *, void *),
int (*name_matcher) (const char *, void *),
- domain_enum kind,
+ enum search_domain kind,
void *data);
/* Return the symbol table from OBJFILE that contains PC and
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.262
diff -u -r1.262 symtab.c
--- symtab.c 28 Mar 2011 20:21:04 -0000 1.262
+++ symtab.c 4 Apr 2011 14:05:26 -0000
@@ -110,13 +110,8 @@
const char *name,
const domain_enum domain);
-static void print_symbol_info (domain_enum,
- struct symtab *, struct symbol *, int, char *);
-
static void print_msymbol_info (struct minimal_symbol *);
-static void symtab_symbol_info (char *, domain_enum, int);
-
void _initialize_symtab (void);
/* */
@@ -2986,7 +2981,8 @@
separately alphabetized. */
void
-search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
+search_symbols (char *regexp, enum search_domain kind,
+ int nfiles, char *files[],
struct symbol_search **matches)
{
struct symtab *s;
@@ -3017,13 +3013,10 @@
struct cleanup *old_chain = NULL;
struct search_symbols_data datum;
- if (kind < VARIABLES_DOMAIN)
- error (_("must search on specific domain"));
-
- ourtype = types[(int) (kind - VARIABLES_DOMAIN)];
- ourtype2 = types2[(int) (kind - VARIABLES_DOMAIN)];
- ourtype3 = types3[(int) (kind - VARIABLES_DOMAIN)];
- ourtype4 = types4[(int) (kind - VARIABLES_DOMAIN)];
+ ourtype = types[kind];
+ ourtype2 = types2[kind];
+ ourtype3 = types3[kind];
+ ourtype4 = types4[kind];
sr = *matches = NULL;
tail = NULL;
@@ -3257,7 +3250,8 @@
regarding the match to gdb_stdout. */
static void
-print_symbol_info (domain_enum kind, struct symtab *s, struct symbol *sym,
+print_symbol_info (enum search_domain kind,
+ struct symtab *s, struct symbol *sym,
int block, char *last)
{
if (last == NULL || filename_cmp (last, s->filename) != 0)
@@ -3314,7 +3308,7 @@
matches. */
static void
-symtab_symbol_info (char *regexp, domain_enum kind, int from_tty)
+symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
{
static const char * const classnames[] =
{"variable", "function", "type", "method"};
@@ -3331,7 +3325,7 @@
printf_filtered (regexp
? "All %ss matching regular expression \"%s\":\n"
: "All defined %ss:\n",
- classnames[(int) (kind - VARIABLES_DOMAIN)], regexp);
+ classnames[kind], regexp);
for (p = symbols; p != NULL; p = p->next)
{
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.173
diff -u -r1.173 symtab.h
--- symtab.h 28 Mar 2011 20:29:51 -0000 1.173
+++ symtab.h 4 Apr 2011 14:05:32 -0000
@@ -395,11 +395,13 @@
/* LABEL_DOMAIN may be used for names of labels (for gotos). */
- LABEL_DOMAIN,
+ LABEL_DOMAIN
+} domain_enum;
- /* Searching domains. These overlap with VAR_DOMAIN, providing
- some granularity with the search_symbols function. */
+/* Searching domains, used for `search_symbols'. */
+enum search_domain
+{
/* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
TYPES_DOMAIN. */
VARIABLES_DOMAIN,
@@ -409,8 +411,7 @@
/* All defined types */
TYPES_DOMAIN
-}
-domain_enum;
+};
/* An address-class says where to find the value of a symbol. */
@@ -1263,7 +1264,7 @@
struct symbol_search *next;
};
-extern void search_symbols (char *, domain_enum, int, char **,
+extern void search_symbols (char *, enum search_domain, int, char **,
struct symbol_search **);
extern void free_search_symbols (struct symbol_search *);
extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search