aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1992-07-08 08:00:30 +0000
committerStu Grossman <grossman@cygnus>1992-07-08 08:00:30 +0000
commit784fd92b3d3474bdace393b07d480fe6d8087111 (patch)
treeb2566888529efe31bc34fecae1799f4d771cfd7f /gdb/symtab.c
parent179798e1e0459d0fd00c93e080aa2745de53d7f4 (diff)
downloadgdb-784fd92b3d3474bdace393b07d480fe6d8087111.zip
gdb-784fd92b3d3474bdace393b07d480fe6d8087111.tar.gz
gdb-784fd92b3d3474bdace393b07d480fe6d8087111.tar.bz2
* dbxread.c (dbx_symfile_init): Init stab_section_info to NULL to
prevent crashes when examining cross-targets. * dbxread.c (process_one_symbol): Include directory name when calling start_subfile for SOL & BINCL symbols. This allows gdb to find include files, and yacc/lex sources when the cwd doesn't match that in which the object was compiled. * objfiles.h (ALL_MSYMBOLS): Don't seg fault when there are no msymbols. * symtab.c (lookup_symtab_1): Rewrite. It now handles include files.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c105
1 files changed, 58 insertions, 47 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 0097d1b..1913c5b 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -134,63 +134,74 @@ lookup_symtab_1 (name)
register struct symtab *s;
register struct partial_symtab *ps;
register char *slash;
- register int len;
register struct objfile *objfile;
- ALL_SYMTABS (objfile, s)
- {
- if (strcmp (name, s->filename) == 0)
- {
- return (s);
- }
- }
+ got_symtab:
- ALL_PSYMTABS (objfile, ps)
- {
- if (strcmp (name, ps -> filename) == 0)
- {
- if (ps -> readin)
- {
- error ("Internal: readin pst for `%s' found when no symtab found.", name);
- }
- return (PSYMTAB_TO_SYMTAB (ps));
- }
- }
+ /* First, search for an exact match */
+
+ ALL_SYMTABS (objfile, s)
+ if (strcmp (name, s->filename) == 0)
+ return s;
slash = strchr (name, '/');
- len = strlen (name);
+
+ /* Now, search for a matching tail (only if name doesn't have any dirs) */
if (!slash)
- {
- ALL_SYMTABS (objfile, s)
- {
- int l = strlen (s->filename);
-
- if (l > len
- && s->filename[l - len -1] == '/'
- && (strcmp (s->filename + l - len, name) == 0))
- {
- return (s);
- }
- }
+ ALL_SYMTABS (objfile, s)
+ {
+ char *p = s -> filename;
+ char *tail = strrchr (p, '/');
- ALL_PSYMTABS (objfile, ps)
- {
- int l = strlen (ps -> filename);
+ if (tail)
+ p = tail + 1;
+
+ if (strcmp (p, name) == 0)
+ return s;
+ }
+
+ /* Same search rules as above apply here, but now we look thru the
+ psymtabs. */
+
+ ALL_PSYMTABS (objfile, ps)
+ if (strcmp (name, ps -> filename) == 0)
+ goto got_psymtab;
+
+ if (!slash)
+ ALL_PSYMTABS (objfile, ps)
+ {
+ char *p = ps -> filename;
+ char *tail = strrchr (p, '/');
+
+ if (tail)
+ p = tail + 1;
+
+ if (strcmp (p, name) == 0)
+ goto got_psymtab;
+ }
- if (l > len
- && ps -> filename[l - len - 1] == '/'
- && (strcmp (ps->filename + l - len, name) == 0))
- {
- if (ps -> readin)
- {
- error ("Internal: readin pst for `%s' found when no symtab found.", name);
- }
- return (PSYMTAB_TO_SYMTAB (ps));
- }
- }
- }
return (NULL);
+
+ got_psymtab:
+
+ if (ps -> readin)
+ error ("Internal: readin pst for `%s' found when no symtab found.", name);
+
+ s = PSYMTAB_TO_SYMTAB (ps);
+
+ if (s)
+ return s;
+
+ /* At this point, we have located the psymtab for this file, but
+ the conversion to a symtab has failed. This usually happens
+ when we are looking up an include file. In this case,
+ PSYMTAB_TO_SYMTAB doesn't return a symtab, even though one has
+ been created. So, we need to run through the symtabs again in
+ order to find the file.
+ XXX - This is a crock, and should be fixed inside of the the
+ symbol parsing routines. */
+ goto got_symtab;
}
/* Lookup the symbol table of a source file named NAME. Try a couple