Article View: gnu.gdb.bug
Article #426Re: gdb coredumps if bad object file
From: Kevin Rodgers
Date: Tue, 08 Sep 1992 15:53
Date: Tue, 08 Sep 1992 15:53
56 lines
2398 bytes
2398 bytes
In article <9209042155.AA28088@_la.tce.com> pierre@la.tce.com writes:
>I recommend testing for (m) != NULL in the ALL_MSYMBOLS macro
>in objfiles.h (gdb 4.5 at least). All other macros in objefiles.h
>are safe except this one.
>
>It happened to me that I had a bad object file and that an error
>occured in reading in dbx_symfile_init() and then gdb would core dump
>because objfile -> msymbol is NULL.
In 4.6, ALL_MSYMBOLS does test (objfile)->msymbols before calling
ALL_OBJFILE_MSYBMOLS, which actually does the iteration, so that the
remaining object files are processed:
/* Traverse all minimal symbols in one objfile. */
#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
for ((m) = (objfile) -> msymbols; (m)->name != NULL; (m)++)
/* Traverse all minimal symbols in all objfiles. */
#define ALL_MSYMBOLS(objfile, m) \
ALL_OBJFILES (objfile) \
if ((objfile)->msymbols) \
ALL_OBJFILE_MSYMBOLS (objfile, m)
>So, it is safer to replace ALL_MSYMBOLS by the following :
>
>#define ALL_MSYMBOLS(objfile, m) \
> ALL_OBJFILES (objfile) \
> for ((m) = (objfile) -> msymbols; ((m) != NULL) && ((m)->name != NULL); (m)++)
I think the 4.6 implementation is cleaner.
>Maybe an additional fix would be to remove this object file from the
>list.
Yes, but that would be nontrivial :-)
It might also be useful to notify the user when a bad object file is
found. I'm not familiar with gdb's internals, so I can't provide a
complete fix, but here's what I have in mind:
#define ALL_MSYMBOLS(objfile, m) \
ALL_OBJFILES (objfile) \
if (!(objfile)->msymbols) \
; /* emit warning */ \
else \
ALL_OBJFILE_MSYMBOLS (objfile, m)
--
Kevin Rodgers kevin@traffic.den.mmc.com
Martin Marietta MS A16401 (303) 790-3971
116 Inverness Dr. East
Englewood CO 80112 USA GO BUFFS!
Technical Details
Message-ID:
<1992Sep8.155316.9492@den.mmc.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevinReferences:
<9209042155.AA28088@_la.tce.com>Show Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!traffic.den.mmc.com!kevin From: kevin@traffic.den.mmc.com (Kevin Rodgers) Subject: Re: gdb coredumps if bad object file Message-ID: <1992Sep8.155316.9492@den.mmc.com> Sender: gnulists@ai.mit.edu Organization: Martin Marietta Western Internal Systems, Technical Operations References: <9209042155.AA28088@_la.tce.com> Distribution: gnu Date: Tue, 8 Sep 1992 15:53:16 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 57