|
From: <sv...@va...> - 2008-01-09 17:51:54
|
Author: sewardj
Date: 2008-01-09 17:51:55 +0000 (Wed, 09 Jan 2008)
New Revision: 7330
Log:
Fix more ppc64-linux regressions, and improve reporting of errors that
occur when reading symbol table or debug info from files.
Modified:
branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h
branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c
branches/DATASYMS/coregrind/m_debuginfo/readelf.c
branches/DATASYMS/coregrind/m_debuginfo/storage.c
Modified: branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-01-09 14:50:32 UTC (rev 7329)
+++ branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-01-09 17:51:55 UTC (rev 7330)
@@ -451,14 +451,14 @@
VG_(memset)(buf1k, 0, sizeof(buf1k));
fd = VG_(open)( filename, VKI_O_RDONLY, 0 );
if (fd.isError) {
- ML_(symerr)("can't open file to inspect ELF header");
+ ML_(symerr)(NULL, True, "can't open file to inspect ELF header");
return;
}
nread = VG_(read)( fd.res, buf1k, sizeof(buf1k) );
VG_(close)( fd.res );
if (nread <= 0) {
- ML_(symerr)("can't read file to inspect ELF header");
+ ML_(symerr)(NULL, True, "can't read file to inspect ELF header");
return;
}
vg_assert(nread > 0 && nread <= sizeof(buf1k) );
Modified: branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h 2008-01-09 14:50:32 UTC (rev 7329)
+++ branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h 2008-01-09 17:51:55 UTC (rev 7330)
@@ -371,8 +371,10 @@
/* ------ Misc ------ */
/* Show a non-fatal debug info reading error. Use vg_panic if
- terminal. */
-extern void ML_(symerr) ( HChar* msg );
+ terminal. 'serious' errors are always shown, not 'serious' ones
+ are shown only at verbosity level 2 and above. */
+extern
+void ML_(symerr) ( struct _DebugInfo* di, Bool serious, HChar* msg );
/* Print a symbol. */
extern void ML_(ppSym) ( Int idx, DiSym* sym );
Modified: branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c 2008-01-09 14:50:32 UTC (rev 7329)
+++ branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c 2008-01-09 17:51:55 UTC (rev 7330)
@@ -497,7 +497,8 @@
/* Check the length of the block. */
if (info.li_length > noLargerThan) {
- ML_(symerr)("DWARF line info appears to be corrupt "
+ ML_(symerr)(di, True,
+ "DWARF line info appears to be corrupt "
"- the section is too small");
goto out;
}
@@ -510,7 +511,8 @@
(Int)info.li_version);
if (info.li_version != 2) {
- ML_(symerr)("Only DWARF version 2 line info "
+ ML_(symerr)(di, True,
+ "Only DWARF version 2 line info "
"is currently supported.");
goto out;
}
@@ -642,7 +644,8 @@
VG_(printf)("\n");
if (*data != 0) {
- ML_(symerr)("can't find NUL at end of DWARF2 directory table");
+ ML_(symerr)(di, True,
+ "can't find NUL at end of DWARF2 directory table");
goto out;
}
data ++;
@@ -683,7 +686,8 @@
VG_(printf)("\n");
if (*data != 0) {
- ML_(symerr)("can't find NUL at end of DWARF2 file name table");
+ ML_(symerr)(di, True,
+ "can't find NUL at end of DWARF2 file name table");
goto out;
}
data ++;
@@ -1132,7 +1136,8 @@
/* Make sure we at least have a header for the first block */
if (debug_info_sz < 4) {
- ML_(symerr)( "Last block truncated in .debug_info; ignoring" );
+ ML_(symerr)( di, True,
+ "Last block truncated in .debug_info; ignoring" );
return;
}
@@ -1146,14 +1151,16 @@
blklen = read_initial_length_field( block_img, &blklen_is_64 );
blklen_len = blklen_is_64 ? 12 : 4;
if ( block_img + blklen + blklen_len > end_img ) {
- ML_(symerr)( "Last block truncated in .debug_info; ignoring" );
+ ML_(symerr)( di, True,
+ "Last block truncated in .debug_info; ignoring" );
return;
}
/* version should be 2 */
ver = *((UShort*)( block_img + blklen_len ));
if ( ver != 2 ) {
- ML_(symerr)( "Ignoring non-dwarf2 block in .debug_info" );
+ ML_(symerr)( di, True,
+ "Ignoring non-dwarf2 block in .debug_info" );
continue;
}
Modified: branches/DATASYMS/coregrind/m_debuginfo/readelf.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readelf.c 2008-01-09 14:50:32 UTC (rev 7329)
+++ branches/DATASYMS/coregrind/m_debuginfo/readelf.c 2008-01-09 17:51:55 UTC (rev 7330)
@@ -413,7 +413,7 @@
Char buf[80];
vg_assert(VG_(strlen)(tab_name) < 40);
VG_(sprintf)(buf, " object doesn't have a %s", tab_name);
- ML_(symerr)(buf);
+ ML_(symerr)(di, False, buf);
return;
}
@@ -517,7 +517,7 @@
Char buf[80];
vg_assert(VG_(strlen)(tab_name) < 40);
VG_(sprintf)(buf, " object doesn't have a %s", tab_name);
- ML_(symerr)(buf);
+ ML_(symerr)(di, False, buf);
return;
}
@@ -934,13 +934,13 @@
fd = VG_(open)(di->filename, VKI_O_RDONLY, 0);
if (fd.isError) {
- ML_(symerr)("Can't open .so/.exe to read symbols?!");
+ ML_(symerr)(di, True, "Can't open .so/.exe to read symbols?!");
return False;
}
n_oimage = VG_(fsize)(fd.res);
if (n_oimage <= 0) {
- ML_(symerr)("Can't stat .so/.exe (to determine its size)?!");
+ ML_(symerr)(di, True, "Can't stat .so/.exe (to determine its size)?!");
VG_(close)(fd.res);
return False;
}
@@ -977,7 +977,7 @@
ok &= ML_(is_elf_object_file)(ehdr_img, n_oimage);
if (!ok) {
- ML_(symerr)("Invalid ELF Header");
+ ML_(symerr)(di, True, "Invalid ELF Header");
goto out;
}
@@ -1004,7 +1004,7 @@
|| !contained_within(
oimage, n_oimage,
(Addr)phdr_img, phdr_nent * phdr_ent_szB)) {
- ML_(symerr)("Missing or invalid ELF Program Header Table");
+ ML_(symerr)(di, True, "Missing or invalid ELF Program Header Table");
goto out;
}
@@ -1012,7 +1012,7 @@
|| !contained_within(
oimage, n_oimage,
(Addr)shdr_img, shdr_nent * shdr_ent_szB)) {
- ML_(symerr)("Missing or invalid ELF Section Header Table");
+ ML_(symerr)(di, True, "Missing or invalid ELF Section Header Table");
goto out;
}
@@ -1026,7 +1026,7 @@
if (!contained_within( oimage, n_oimage,
(Addr)shdr_strtab_img,
1/*bogus, but we don't know the real size*/ )) {
- ML_(symerr)("Invalid ELF Section Header String Table");
+ ML_(symerr)(di, True, "Invalid ELF Section Header String Table");
goto out;
}
@@ -1050,7 +1050,8 @@
if (debug)
VG_(printf)("Comparing %p %p\n", prev_svma, phdr->p_vaddr);
if (phdr->p_vaddr < prev_svma) {
- ML_(symerr)("ELF Program Headers are not in ascending order");
+ ML_(symerr)(di, True,
+ "ELF Program Headers are not in ascending order");
goto out;
}
prev_svma = phdr->p_vaddr;
@@ -1177,12 +1178,13 @@
/* Check for sane-sized segments. SHT_NOBITS sections have zero
size in the file. */
if ((foff >= n_oimage) || (foff + (bits ? size : 0) > n_oimage)) {
- ML_(symerr)("ELF Section extends beyond image end");
+ ML_(symerr)(di, True, "ELF Section extends beyond image end");
goto out;
}
# define BAD(_secname) \
- do { ML_(symerr)("Can't make sense of " _secname \
+ do { ML_(symerr)(di, True, \
+ "Can't make sense of " _secname \
" section mapping"); \
goto out; \
} while (0)
@@ -1222,6 +1224,11 @@
di->bss_size = size;
if (debug)
VG_(printf)("acquiring .bss avma = %p\n", di->bss_avma);
+ } else
+ if ((!inrw) && (!inrx) && size > 0 && di->bss_size == 0) {
+ /* File contains a .bss, but it didn't get mapped. Ignore. */
+ di->bss_avma = 0;
+ di->bss_size = 0;
} else {
BAD(".bss");
}
@@ -1252,7 +1259,7 @@
BAD(".plt");
}
}
-# elif defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
+# elif defined(VGP_ppc32_linux)
/* Accept .plt where mapped as rw (data) */
if (0 == VG_(strcmp)(name, ".plt")) {
if (inrw && size > 0 && di->plt_size == 0) {
@@ -1264,6 +1271,25 @@
BAD(".plt");
}
}
+# elif defined(VGP_ppc64_linux)
+ /* Accept .plt where mapped as rw (data), or unmapped */
+ if (0 == VG_(strcmp)(name, ".plt")) {
+ if (inrw && size > 0 && di->plt_size == 0) {
+ di->plt_avma = di->rw_map_avma + foff - di->rw_map_foff;
+ di->plt_size = size;
+ if (debug)
+ VG_(printf)("acquiring .plt avma = %p\n", di->plt_avma);
+ } else
+ if ((!inrw) && (!inrx) && size > 0 && di->plt_size == 0) {
+ /* File contains a .plt, but it didn't get mapped.
+ Presumably it is not required on this platform. At
+ least don't reject the situation as invalid. */
+ di->plt_avma = 0;
+ di->plt_size = 0;
+ } else {
+ BAD(".plt");
+ }
+ }
# else
# error "Unsupported platform"
# endif
@@ -1382,7 +1408,8 @@
/* SHT_NOBITS sections have zero size in the file. */ \
if ( shdr->sh_offset \
+ (nobits ? 0 : sec_size) > n_oimage ) { \
- ML_(symerr)(" section beyond image end?!"); \
+ ML_(symerr)(di, True, \
+ " section beyond image end?!"); \
goto out; \
} \
} \
@@ -1448,7 +1475,8 @@
|| !contained_within(
dimage, n_dimage,
(Addr)phdr_dimg, phdr_dnent * phdr_dent_szB)) {
- ML_(symerr)("Missing or invalid ELF Program Header Table"
+ ML_(symerr)(di, True,
+ "Missing or invalid ELF Program Header Table"
" (debuginfo file)");
goto out;
}
@@ -1457,7 +1485,8 @@
|| !contained_within(
dimage, n_dimage,
(Addr)shdr_dimg, shdr_dnent * shdr_dent_szB)) {
- ML_(symerr)("Missing or invalid ELF Section Header Table"
+ ML_(symerr)(di, True,
+ "Missing or invalid ELF Section Header Table"
" (debuginfo file)");
goto out;
}
@@ -1473,7 +1502,8 @@
dimage, n_dimage,
(Addr)shdr_strtab_dimg,
1/*bogus, but we don't know the real size*/ )) {
- ML_(symerr)("Invalid ELF Section Header String Table"
+ ML_(symerr)(di, True,
+ "Invalid ELF Section Header String Table"
" (debuginfo file)");
goto out;
}
@@ -1523,7 +1553,8 @@
/* SHT_NOBITS sections have zero size in the file. */ \
if ( shdr->sh_offset \
+ (nobits ? 0 : sec_size) > n_dimage ) { \
- ML_(symerr)(" section beyond image end?!"); \
+ ML_(symerr)(di, True, \
+ " section beyond image end?!"); \
goto out; \
} \
} \
Modified: branches/DATASYMS/coregrind/m_debuginfo/storage.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/storage.c 2008-01-09 14:50:32 UTC (rev 7329)
+++ branches/DATASYMS/coregrind/m_debuginfo/storage.c 2008-01-09 17:51:55 UTC (rev 7330)
@@ -52,13 +52,36 @@
/*------------------------------------------------------------*/
/* Show a non-fatal debug info reading error. Use vg_panic if
- terminal. */
-void ML_(symerr) ( HChar* msg )
+ terminal. 'serious' errors are shown regardless of the
+ verbosity setting. */
+void ML_(symerr) ( struct _DebugInfo* di, Bool serious, HChar* msg )
{
- if (VG_(clo_verbosity) > 1)
+ /* XML mode hides everything :-( */
+ if (VG_(clo_xml))
+ return;
+
+ if (serious) {
+
+ VG_(message)(Vg_DebugMsg, "WARNING: Serious error when "
+ "reading debug info");
+ if (VG_(clo_verbosity) < 2) {
+ /* Need to show what the file name is, at verbosity levels 2
+ or below, since that won't already have been shown */
+ VG_(message)(Vg_DebugMsg,
+ "When reading debug info from %s:",
+ (di && di->filename) ? di->filename : (UChar*)"???");
+ }
VG_(message)(Vg_DebugMsg, "%s", msg);
+
+ } else { /* !serious */
+
+ if (VG_(clo_verbosity) >= 2)
+ VG_(message)(Vg_DebugMsg, "%s", msg);
+
+ }
}
+
/* Print a symbol. */
void ML_(ppSym) ( Int idx, DiSym* sym )
{
|