Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dfb58e2

Browse files
author
sewardj
committedFeb 18, 2015
Messaging cleanup for the PDB reader. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14945 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent 52e770f commit dfb58e2

File tree

1 file changed

+82
-83
lines changed

1 file changed

+82
-83
lines changed
 

‎coregrind/m_debuginfo/readpdb.c

Lines changed: 82 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static void* pdb_ds_read( const struct pdb_reader* pdb,
978978

979979
if (!size) return NULL;
980980
if (size > 512 * 1024 * 1024) {
981-
VG_(umsg)("Warning: pdb_ds_read: implausible size "
981+
VG_(umsg)("LOAD_PDB_DEBUGINFO: pdb_ds_read: implausible size "
982982
"(%u); skipping -- possible invalid .pdb file?\n", size);
983983
return NULL;
984984
}
@@ -1125,14 +1125,14 @@ void pdb_check_root_version_and_timestamp( const HChar* pdbname,
11251125
break;
11261126
default:
11271127
if (VG_(clo_verbosity) > 1)
1128-
VG_(message)(Vg_UserMsg,
1129-
"Unknown .pdb root block version %d\n", version );
1128+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
1129+
"Unknown .pdb root block version %d\n", version );
11301130
}
11311131
if ( TimeDateStamp != pdbmtime ) {
11321132
if (VG_(clo_verbosity) > 1)
1133-
VG_(message)(Vg_UserMsg,
1134-
"Wrong time stamp of .PDB file %s (0x%08x, 0x%08llx)\n",
1135-
pdbname, TimeDateStamp, pdbmtime );
1133+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Wrong time stamp of .PDB file "
1134+
"%s (0x%08x, 0x%08llx)\n",
1135+
pdbname, TimeDateStamp, pdbmtime );
11361136
}
11371137
}
11381138

@@ -1218,9 +1218,8 @@ static ULong DEBUG_SnarfCodeView(
12181218
ULong n_syms_read = 0;
12191219

12201220
if (debug)
1221-
VG_(message)(Vg_UserMsg,
1222-
"BEGIN SnarfCodeView addr=%p offset=%d length=%d\n",
1223-
root, offset, size );
1221+
VG_(umsg)("BEGIN SnarfCodeView addr=%p offset=%d length=%d\n",
1222+
root, offset, size );
12241223

12251224
VG_(memset)(&vsym, 0, sizeof(vsym)); /* avoid holes */
12261225
/*
@@ -1260,7 +1259,7 @@ static ULong DEBUG_SnarfCodeView(
12601259
symname[sym->data_v1.p_name.namelen] = '\0';
12611260

12621261
if (debug)
1263-
VG_(message)(Vg_UserMsg, " Data %s\n", symname );
1262+
VG_(umsg)(" Data %s\n", symname );
12641263

12651264
if (0 /*VG_(needs).data_syms*/) {
12661265
nmstr = ML_(addStr)(di, symname, sym->data_v1.p_name.namelen);
@@ -1285,8 +1284,7 @@ static ULong DEBUG_SnarfCodeView(
12851284
symname[k] = '\0';
12861285

12871286
if (debug)
1288-
VG_(message)(Vg_UserMsg,
1289-
" S_GDATA_V2/S_LDATA_V2/S_PUB_V2 %s\n", symname );
1287+
VG_(umsg)(" S_GDATA_V2/S_LDATA_V2/S_PUB_V2 %s\n", symname );
12901288

12911289
if (sym->generic.id==S_PUB_V2 /*VG_(needs).data_syms*/) {
12921290
nmstr = ML_(addStr)(di, symname, k);
@@ -1317,9 +1315,8 @@ static ULong DEBUG_SnarfCodeView(
13171315
symname[k] = '\0';
13181316

13191317
if (debug)
1320-
VG_(message)(Vg_UserMsg,
1321-
" S_PUB_FUNC1_V3/S_PUB_FUNC2_V3/S_PUB_V3 %s\n",
1322-
symname );
1318+
VG_(umsg)(" S_PUB_FUNC1_V3/S_PUB_FUNC2_V3/S_PUB_V3 %s\n",
1319+
symname );
13231320

13241321
if (1 /*sym->generic.id==S_PUB_FUNC1_V3
13251322
|| sym->generic.id==S_PUB_FUNC2_V3*/) {
@@ -1369,9 +1366,8 @@ static ULong DEBUG_SnarfCodeView(
13691366
vsym.isText = True;
13701367
vsym.isIFunc = False;
13711368
if (debug)
1372-
VG_(message)(Vg_UserMsg,
1373-
" Adding function %s addr=%#lx length=%d\n",
1374-
symname, vsym.avmas.main, vsym.size );
1369+
VG_(umsg)(" Adding function %s addr=%#lx length=%d\n",
1370+
symname, vsym.avmas.main, vsym.size );
13751371
ML_(addSym)( di, &vsym );
13761372
n_syms_read++;
13771373
break;
@@ -1391,17 +1387,15 @@ static ULong DEBUG_SnarfCodeView(
13911387
vsym.isText = True;
13921388
vsym.isIFunc = False;
13931389
if (debug)
1394-
VG_(message)(Vg_UserMsg,
1395-
" Adding function %s addr=%#lx length=%d\n",
1396-
symname, vsym.avmas.main, vsym.size );
1390+
VG_(umsg)(" Adding function %s addr=%#lx length=%d\n",
1391+
symname, vsym.avmas.main, vsym.size );
13971392
ML_(addSym)( di, &vsym );
13981393
n_syms_read++;
13991394
break;
14001395
case S_LPROC_V3:
14011396
case S_GPROC_V3: {
14021397
if (debug)
1403-
VG_(message)(Vg_UserMsg,
1404-
" S_LPROC_V3/S_GPROC_V3 %s\n", sym->proc_v3.name );
1398+
VG_(umsg)(" S_LPROC_V3/S_GPROC_V3 %s\n", sym->proc_v3.name );
14051399

14061400
if (1) {
14071401
nmstr = ML_(addStr)(di, sym->proc_v3.name,
@@ -1488,9 +1482,8 @@ static ULong DEBUG_SnarfCodeView(
14881482
} /* for ( i = offset; i < size; i += length ) */
14891483

14901484
if (debug)
1491-
VG_(message)(Vg_UserMsg,
1492-
"END SnarfCodeView addr=%p offset=%d length=%d\n",
1493-
root, offset, size );
1485+
VG_(umsg)("END SnarfCodeView addr=%p offset=%d length=%d\n",
1486+
root, offset, size );
14941487
return n_syms_read;
14951488
}
14961489

@@ -1542,9 +1535,7 @@ static ULong DEBUG_SnarfLinetab(
15421535
ULong n_lines_read = 0;
15431536

15441537
if (debug)
1545-
VG_(message)(Vg_UserMsg,
1546-
"BEGIN SnarfLineTab linetab=%p size=%d\n",
1547-
linetab, size );
1538+
VG_(umsg)("BEGIN SnarfLineTab linetab=%p size=%d\n", linetab, size);
15481539

15491540
/*
15501541
* Now get the important bits.
@@ -1615,7 +1606,7 @@ static ULong DEBUG_SnarfLinetab(
16151606
UInt j;
16161607

16171608
if (debug)
1618-
VG_(message)(Vg_UserMsg,
1609+
VG_(umsg)(
16191610
" Adding %d lines for file %s segment %d addr=%#x end=%#x\n",
16201611
linecount, filename, segno, start[k].start, start[k].end );
16211612

@@ -1627,10 +1618,10 @@ static ULong DEBUG_SnarfLinetab(
16271618
? pnt2.ui[j+1]
16281619
: start[k].end);
16291620
if (debug)
1630-
VG_(message)(Vg_UserMsg,
1621+
VG_(umsg)(
16311622
" Adding line %d addr=%#lx end=%#lx\n",
1632-
((const unsigned short *)(pnt2.ui + linecount))[j],
1633-
startaddr, endaddr );
1623+
((const unsigned short *)(pnt2.ui + linecount))[j],
1624+
startaddr, endaddr );
16341625
ML_(addLineInfo)(
16351626
di,
16361627
fnmdirstr_ix,
@@ -1643,9 +1634,8 @@ static ULong DEBUG_SnarfLinetab(
16431634
}
16441635

16451636
if (debug)
1646-
VG_(message)(Vg_UserMsg,
1647-
"END SnarfLineTab linetab=%p size=%d\n",
1648-
linetab, size );
1637+
VG_(umsg)("END SnarfLineTab linetab=%p size=%d\n",
1638+
linetab, size );
16491639

16501640
return n_lines_read;
16511641
}
@@ -1859,7 +1849,9 @@ static unsigned get_stream_by_name(const struct pdb_reader* pdb, const char* nam
18591849
pdw += *ok_bits++ + 1;
18601850
if (*pdw++ != 0)
18611851
{
1862-
VG_(printf)("unexpected value\n");
1852+
if (VG_(clo_verbosity) > 1)
1853+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
1854+
"get_stream_by_name: unexpected value\n");
18631855
return -1;
18641856
}
18651857

@@ -1884,8 +1876,13 @@ static void *read_string_table(const struct pdb_reader* pdb)
18841876
stream_idx = get_stream_by_name(pdb, "/names");
18851877
if (stream_idx == -1) return NULL;
18861878
ret = pdb->read_file(pdb, stream_idx,0);
1887-
if (ret && *(const DWORD*)ret == 0xeffeeffe) return ret;
1888-
VG_(printf)("wrong header %x expecting 0xeffeeffe\n", *(const DWORD*)ret);
1879+
if (ret && *(const DWORD*)ret == 0xeffeeffe) {
1880+
return ret;
1881+
}
1882+
if (VG_(clo_verbosity) > 1)
1883+
VG_(umsg)("LOAD_PDB_DEBUGINFO: read_string_table: "
1884+
"wrong header 0x%08x, expecting 0xeffeeffe\n",
1885+
*(const DWORD*)ret);
18891886
ML_(dinfo_free)( ret );
18901887
return NULL;
18911888
}
@@ -1920,10 +1917,12 @@ static void pdb_dump( const struct pdb_reader* pdb,
19201917
sources. */
19211918
char* filesimage;
19221919
DWORD filessize;
1923-
if (!(filesimage = read_string_table(pdb)))
1924-
VG_(printf)("string table not found\n");
1925-
else
1920+
if (!(filesimage = read_string_table(pdb))) {
1921+
VG_(umsg)("LOAD_PDB_DEBUGINFO: pdb_dump: string table not found\n");
1922+
}
1923+
else {
19261924
filessize = *(const DWORD*)(filesimage + 8);
1925+
}
19271926

19281927
/* Since we just use the FPO data without reformatting, at least
19291928
do a basic sanity check on the struct layout. */
@@ -2100,9 +2099,8 @@ static void pdb_dump( const struct pdb_reader* pdb,
21002099
break;
21012100
default:
21022101
if (VG_(clo_verbosity) > 1)
2103-
VG_(message)(Vg_UserMsg,
2104-
"Unknown .pdb type info version %ld\n",
2105-
types.version );
2102+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
2103+
"Unknown .pdb type info version %ld\n", types.version );
21062104
}
21072105

21082106
header_size = 0;
@@ -2115,9 +2113,9 @@ static void pdb_dump( const struct pdb_reader* pdb,
21152113
break;
21162114
default:
21172115
if (VG_(clo_verbosity) > 1)
2118-
VG_(message)(Vg_UserMsg,
2119-
"Unknown .pdb symbol info version %ld\n",
2120-
symbols.version );
2116+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
2117+
"Unknown .pdb symbol info version %ld\n",
2118+
symbols.version );
21212119
}
21222120

21232121
/*
@@ -2128,7 +2126,7 @@ static void pdb_dump( const struct pdb_reader* pdb,
21282126
if (debug)
21292127
VG_(umsg)("\n");
21302128
if (VG_(clo_verbosity) > 1)
2131-
VG_(message)(Vg_UserMsg, "Reading global symbols\n" );
2129+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Reading global symbols\n" );
21322130
DEBUG_SnarfCodeView( di, pe_avma, sectp_avma, modimage, 0, len_modimage );
21332131
ML_(dinfo_free)( modimage );
21342132
}
@@ -2169,7 +2167,7 @@ static void pdb_dump( const struct pdb_reader* pdb,
21692167
if (debug)
21702168
VG_(umsg)("\n");
21712169
if (VG_(clo_verbosity) > 1)
2172-
VG_(message)(Vg_UserMsg, "Reading symbols for %s\n",
2170+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Reading symbols for %s\n",
21732171
file_name );
21742172
n_syms_read
21752173
+= DEBUG_SnarfCodeView( di, pe_avma, sectp_avma, modimage,
@@ -2181,7 +2179,8 @@ static void pdb_dump( const struct pdb_reader* pdb,
21812179
if (debug)
21822180
VG_(umsg)("\n");
21832181
if (VG_(clo_verbosity) > 1)
2184-
VG_(message)(Vg_UserMsg, "Reading lines for %s\n", file_name );
2182+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
2183+
"Reading lines for %s\n", file_name );
21852184
n_lines_read
21862185
+= DEBUG_SnarfLinetab( di, pe_avma, sectp_avma,
21872186
modimage + symbol_size, lineno_size );
@@ -2221,14 +2220,14 @@ static void pdb_dump( const struct pdb_reader* pdb,
22212220
if ( pdb->u.jg.toc ) ML_(dinfo_free)( pdb->u.jg.toc );
22222221

22232222
if (VG_(clo_verbosity) > 1) {
2224-
VG_(message)(Vg_DebugMsg,
2225-
" # symbols read = %llu\n", n_syms_read );
2226-
VG_(message)(Vg_DebugMsg,
2227-
" # lines read = %llu\n", n_lines_read );
2228-
VG_(message)(Vg_DebugMsg,
2229-
" # line2s read = %llu\n", n_line2s_read );
2230-
VG_(message)(Vg_DebugMsg,
2231-
" # fpos read = %llu\n", n_fpos_read );
2223+
VG_(dmsg)("LOAD_PDB_DEBUGINFO:"
2224+
" # symbols read = %llu\n", n_syms_read );
2225+
VG_(dmsg)("LOAD_PDB_DEBUGINFO:"
2226+
" # lines read = %llu\n", n_lines_read );
2227+
VG_(dmsg)("LOAD_PDB_DEBUGINFO:"
2228+
" # line2s read = %llu\n", n_line2s_read );
2229+
VG_(dmsg)("LOAD_PDB_DEBUGINFO:"
2230+
" # fpos read = %llu\n", n_fpos_read );
22322231
}
22332232
}
22342233

@@ -2263,7 +2262,7 @@ Bool ML_(read_pdb_debug_info)(
22632262
IMAGE_SECTION_HEADER* pe_sechdr_avma;
22642263

22652264
if (VG_(clo_verbosity) > 1)
2266-
VG_(message)(Vg_UserMsg, "Processing PDB file %s\n", pdbname );
2265+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Processing PDB file %s\n", pdbname );
22672266

22682267
dos_avma = (IMAGE_DOS_HEADER *)obj_avma;
22692268
if (dos_avma->e_magic != IMAGE_DOS_SIGNATURE)
@@ -2303,10 +2302,10 @@ Bool ML_(read_pdb_debug_info)(
23032302
char name[9];
23042303
VG_(memcpy)(name, pe_sechdr_avma->Name, 8);
23052304
name[8] = '\0';
2306-
VG_(message)(Vg_UserMsg,
2307-
" Scanning PE section %ps at avma %#lx svma %#lx\n",
2308-
name, obj_avma + pe_sechdr_avma->VirtualAddress,
2309-
pe_sechdr_avma->VirtualAddress);
2305+
VG_(umsg)("LOAD_PDB_DEBUGINFO:"
2306+
" Scanning PE section %ps at avma %#lx svma %#lx\n",
2307+
name, obj_avma + pe_sechdr_avma->VirtualAddress,
2308+
pe_sechdr_avma->VirtualAddress);
23102309
}
23112310

23122311
if (pe_sechdr_avma->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
@@ -2385,22 +2384,22 @@ Bool ML_(read_pdb_debug_info)(
23852384
for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
23862385
const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
23872386
if (map->rx)
2388-
VG_(message)(Vg_DebugMsg,
2389-
"rx_map: avma %#lx size %7lu foff %llu\n",
2390-
map->avma, map->size, (Off64T)map->foff);
2387+
VG_(dmsg)("LOAD_PDB_DEBUGINFO: "
2388+
"rx_map: avma %#lx size %7lu foff %llu\n",
2389+
map->avma, map->size, (Off64T)map->foff);
23912390
}
23922391
for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
23932392
const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
23942393
if (map->rw)
2395-
VG_(message)(Vg_DebugMsg,
2396-
"rw_map: avma %#lx size %7lu foff %llu\n",
2397-
map->avma, map->size, (Off64T)map->foff);
2394+
VG_(dmsg)("LOAD_PDB_DEBUGINFO: "
2395+
"rw_map: avma %#lx size %7lu foff %llu\n",
2396+
map->avma, map->size, (Off64T)map->foff);
23982397
}
23992398

2400-
VG_(message)(Vg_DebugMsg,
2401-
" text: avma %#lx svma %#lx size %7lu bias %#lx\n",
2402-
di->text_avma, di->text_svma,
2403-
di->text_size, di->text_bias);
2399+
VG_(dmsg)("LOAD_PDB_DEBUGINFO: "
2400+
" text: avma %#lx svma %#lx size %7lu bias %#lx\n",
2401+
di->text_avma, di->text_svma,
2402+
di->text_size, di->text_bias);
24042403
}
24052404

24062405
/*
@@ -2495,8 +2494,8 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
24952494
VG_(memset)(tmpname, 0, sizeof(tmpname));
24962495
fd = VG_(mkstemp)( tmpnameroot, tmpname );
24972496
if (fd == -1) {
2498-
VG_(message)(Vg_UserMsg,
2499-
"Find PDB file: Can't create temporary file %s\n", tmpname);
2497+
VG_(umsg)("LOAD_PDB_DEBUGINFO: "
2498+
"Find PDB file: Can't create temporary file %s\n", tmpname);
25002499
goto out;
25012500
}
25022501
do_cleanup = True;
@@ -2520,8 +2519,8 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
25202519

25212520
r = VG_(system)( cmd );
25222521
if (r) {
2523-
VG_(message)(Vg_DebugMsg,
2524-
"Find PDB file: Command failed:\n %s\n", cmd);
2522+
VG_(dmsg)("LOAD_PDB_DEBUGINFO: "
2523+
"Find PDB file: Command failed:\n %s\n", cmd);
25252524
goto out;
25262525
}
25272526

@@ -2531,18 +2530,18 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
25312530

25322531
SysRes sr = VG_(stat)(tmpname, &stat_buf);
25332532
if (sr_isError(sr)) {
2534-
VG_(umsg)("Find PDB file: can't stat %s\n", tmpname);
2533+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Find PDB file: can't stat %s\n", tmpname);
25352534
goto out;
25362535
}
25372536

25382537
Int szB = (Int)stat_buf.size;
25392538
if (szB == 0) {
2540-
VG_(umsg)("Find PDB file: %s is empty\n", tmpname);
2539+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Find PDB file: %s is empty\n", tmpname);
25412540
goto out;
25422541
}
25432542
/* 6 == strlen("X.pdb\n") */
25442543
if (szB < 6 || szB > 1024/*let's say*/) {
2545-
VG_(umsg)("Find PDB file: %s has implausible size %d\n",
2544+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Find PDB file: %s has implausible size %d\n",
25462545
tmpname, szB);
25472546
goto out;
25482547
}
@@ -2552,7 +2551,7 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
25522551

25532552
Int nread = VG_(read)(fd, pdbname, szB);
25542553
if (nread != szB) {
2555-
VG_(umsg)("Find PDB file: read of %s failed\n", tmpname);
2554+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Find PDB file: read of %s failed\n", tmpname);
25562555
goto out;
25572556
}
25582557
vg_assert(pdbname[szB] == 0);
@@ -2567,7 +2566,7 @@ HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
25672566
if (pdbname[i] == '\n') saw_n_crs++;
25682567
}
25692568
if (!saw_dot || saw_n_crs != 1 || pdbname[szB-1] != '\n') {
2570-
VG_(umsg)("Find PDB file: can't make sense of: %s\n", pdbname);
2569+
VG_(umsg)("LOAD_PDB_DEBUGINFO: Find PDB file: can't make sense of: %s\n", pdbname);
25712570
goto out;
25722571
}
25732572
/* Change the \n to a terminating zero, so we have a "normal" string */

0 commit comments

Comments
 (0)
Please sign in to comment.