]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* dbxread.c (dbx_symfile_init): Init stab_section_info to NULL to
authorStu Grossman <grossman@cygnus>
Wed, 8 Jul 1992 08:00:30 +0000 (08:00 +0000)
committerStu Grossman <grossman@cygnus>
Wed, 8 Jul 1992 08:00:30 +0000 (08:00 +0000)
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.

gdb/ChangeLog
gdb/dbxread.c
gdb/objfiles.h
gdb/symtab.c

index cfb34ca664b185a5ccf4f4c9d9226439720b412a..47e8834bce72d849d2efddfb3616a22753acadcd 100644 (file)
@@ -1,3 +1,16 @@
+Wed Jul  8 00:11:02 1992  Stu Grossman  (grossman at cygnus.com)
+
+       * 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.
+
 Tue Jul  7 09:00:42 1992  Fred Fish  (fnf@cygnus.com)
 
        * maint.c (maintenance_command, maintenance_info_command):
index 967234356176915ca50b38ede18acc48e6738261..e7cc1ae145208dcb2f72e11dc4638d8a8824d17f 100644 (file)
@@ -545,6 +545,7 @@ dbx_symfile_init (objfile)
 #endif
   /* FIXME POKING INSIDE BFD DATA STRUCTURES */
 
+  DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
   DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
   if (!DBX_TEXT_SECT (objfile))
     error ("Can't find .text section in symbol file");
@@ -1800,17 +1801,17 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
         (whose name was given in the N_SO symbol.)  */
       /* Relocate for dynamic loading */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-      start_subfile (name, NULL);
+      start_subfile (name, current_subfile->dirname);
       break;
 
     case N_BINCL:
       push_subfile ();
       add_new_header_file (name, valu);
-      start_subfile (name, NULL);
+      start_subfile (name, current_subfile->dirname);
       break;
 
     case N_EINCL:
-      start_subfile (pop_subfile (), NULL);
+      start_subfile (pop_subfile (), current_subfile->dirname);
       break;
 
     case N_EXCL:
index 68bfd9ab3e7cf4267296181c13b357cacaebe4b3..53e67866fd5737874e169a85f20f4c52a29f747e 100644 (file)
@@ -358,6 +358,7 @@ have_minimal_symbols PARAMS ((void));
 
 #define        ALL_MSYMBOLS(objfile, m) \
   ALL_OBJFILES (objfile)        \
-    ALL_OBJFILE_MSYMBOLS (objfile, m)
+    if ((objfile)->msymbols)    \
+      ALL_OBJFILE_MSYMBOLS (objfile, m)
 
 #endif /* !defined (OBJFILES_H) */
index 0097d1b489d830dc868a44e32add00bcb41ea7ea..1913c5bb1cf3ffc72aef875cecef2916c65c181b 100644 (file)
@@ -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