Article View: gnu.gdb.bug
Article #104patch for N_SO crash
From: Stu Grossman
Date: Mon, 20 Jul 1992 19:58
Date: Mon, 20 Jul 1992 19:58
122 lines
3934 bytes
3934 bytes
The following patch fixes a crash that occurs when reading symbol tables that
have extra N_SO records. This is mainly a problem on Suns when using certain
C or C++ compilers.
Stu
===================================================================
diff -c partial-stab.h-orig partial-stab.h
*** partial-stab.h-orig 1992/07/04 13:58:43
--- partial-stab.h 1992/07/16 20:40:36
***************
*** 198,208 ****
case N_SO: {
unsigned long valu = CUR_SYMBOL_VALUE;
! static int last_so_symnum = -10;
! static int dir_so_symnum = -10;
! int tmp;
char *p;
/* End the current partial symtab and start a new one */
SET_NAMESTRING();
--- 198,226 ----
case N_SO: {
unsigned long valu = CUR_SYMBOL_VALUE;
! static int prev_so_symnum = -10;
! static int first_so_symnum;
char *p;
+ past_first_source_file = 1;
+
+ if (prev_so_symnum != symnum - 1)
+ { /* Here if prev stab wasn't N_SO */
+ first_so_symnum = symnum;
+
+ if (pst)
+ {
+ END_PSYMTAB (pst, psymtab_include_list, includes_used,
+ symnum * symbol_size, valu,
+ dependency_list, dependencies_used);
+ pst = (struct partial_symtab *) 0;
+ includes_used = 0;
+ dependencies_used = 0;
+ }
+ }
+
+ prev_so_symnum = symnum;
+
/* End the current partial symtab and start a new one */
SET_NAMESTRING();
***************
*** 209,224 ****
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
- if (pst)
- {
- END_PSYMTAB (pst, psymtab_include_list, includes_used,
- symnum * symbol_size, valu,
- dependency_list, dependencies_used);
- pst = (struct partial_symtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- }
-
/* Some compilers (including gcc) emit a pair of initial N_SOs.
The first one is a directory name; the second the file name.
If pst exists, is empty, and has a filename ending in '/',
--- 227,232 ----
***************
*** 226,255 ****
p = strrchr (namestring, '/');
if (p && *(p+1) == '\000')
! {
! dir_so_symnum = symnum;
! continue; /* Simply ignore directory name SOs */
! }
/* Some other compilers (C++ ones in particular) emit useless
! SOs for non-existant .c files. */
!
! if (last_so_symnum == symnum - 1)
! continue; /* Ignore repeated SOs */
! last_so_symnum = symnum;
!
! past_first_source_file = 1;
! if (dir_so_symnum == symnum - 1) /* Was prev. SO a directory? */
! tmp = dir_so_symnum;
! else
! tmp = symnum;
! pst = START_PSYMTAB (objfile, section_offsets,
! namestring, valu,
! tmp * symbol_size,
! objfile -> global_psymbols.next,
! objfile -> static_psymbols.next);
! dir_so_symnum = -10;
continue;
}
--- 234,251 ----
p = strrchr (namestring, '/');
if (p && *(p+1) == '\000')
! continue; /* Simply ignore directory name SOs */
/* Some other compilers (C++ ones in particular) emit useless
! SOs for non-existant .c files. We ignore all subsequent SOs that
! immediately follow the first. */
! if (!pst)
! pst = START_PSYMTAB (objfile, section_offsets,
! namestring, valu,
! first_so_symnum * symbol_size,
! objfile -> global_psymbols.next,
! objfile -> static_psymbols.next);
continue;
}
Technical Details
Message-ID:
<9207201958.AA20928@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!grossmanShow Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!grossman From: grossman@cygnus.com (Stu Grossman) Subject: patch for N_SO crash Message-ID: <9207201958.AA20928@cygnus.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Mon, 20 Jul 1992 19:58:09 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 123