[PATCH 14/14] tools/winedump: correct and update a couple of info in PDB symbol stream header

Eric Pouech eric.pouech at gmail.com
Tue Aug 24 04:12:45 CDT 2021


Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 dlls/dbghelp/msc.c     |    4 +--
 include/wine/mscvpdb.h |   14 ++++++----
 tools/winedump/pdb.c   |   69 ++++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 6d623f336ed..72b03960803 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -2392,8 +2392,8 @@ static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols,
         symbols->hash_size       = old->hash_size;
         symbols->srcmodule_size  = old->srcmodule_size;
         symbols->pdbimport_size  = 0;
-        symbols->hash1_file      = old->hash1_file;
-        symbols->hash2_file      = old->hash2_file;
+        symbols->global_file     = old->global_file;
+        symbols->public_file     = old->public_file;
         symbols->gsym_file       = old->gsym_file;
 
         *header_size = sizeof(PDB_SYMBOLS_OLD);
diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h
index 35143291f22..c9ab4abb166 100644
--- a/include/wine/mscvpdb.h
+++ b/include/wine/mscvpdb.h
@@ -2367,8 +2367,8 @@ typedef struct _PDB_SYMBOL_IMPORT
 
 typedef struct _PDB_SYMBOLS_OLD
 {
-    WORD        hash1_file;
-    WORD        hash2_file;
+    WORD        global_file;
+    WORD        public_file;
     WORD        gsym_file;
     WORD        pad;
     DWORD       module_size;
@@ -2381,11 +2381,13 @@ typedef struct _PDB_SYMBOLS
 {
     DWORD       signature;
     DWORD       version;
-    DWORD       unknown;
-    DWORD       hash1_file;
-    DWORD       hash2_file;
+    DWORD       age;
+    WORD        global_file;
+    WORD        flags;
+    WORD        public_file;
+    WORD        bldVer;
     WORD        gsym_file;
-    WORD        unknown1;
+    WORD        rbldVer;
     DWORD       module_size;
     DWORD       offset_size;
     DWORD       hash_size;
diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c
index 05e02c841e3..dc89308bd67 100644
--- a/tools/winedump/pdb.c
+++ b/tools/winedump/pdb.c
@@ -222,6 +222,36 @@ static void *read_string_table(struct pdb_reader* reader)
     return NULL;
 }
 
+static void dump_global_symbol(struct pdb_reader* reader, unsigned file)
+{
+    void*  global = NULL;
+    DWORD  size;
+
+    global = reader->read_file(reader, file);
+    if (!global) return;
+
+    size = pdb_get_file_size(reader, file);
+
+    printf("Global symbols table:\n");
+    dump_data(global, size, "\t");
+    free(global);
+}
+
+static void dump_public_symbol(struct pdb_reader* reader, unsigned file)
+{
+    void*  public = NULL;
+    DWORD  size;
+
+    public = reader->read_file(reader, file);
+    if (!public) return;
+
+    size = pdb_get_file_size(reader, file);
+
+    printf("Public symbols table:\n");
+    dump_data(public, size, "\t");
+    free(public);
+}
+
 static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx)
 {
     PDB_SYMBOLS*    symbols;
@@ -229,6 +259,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
     const char*     file;
     char*           filesimage;
     DWORD           filessize = 0;
+    char            tcver[32];
 
     sidx->FPO = sidx->unk0 = sidx->unk1 = sidx->unk2 = sidx->unk3 = sidx->segments =
         sidx->unk4 = sidx->unk5 = sidx->unk6 = sidx->FPO_EXT = sidx->unk7 = -1;
@@ -246,14 +277,20 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
     default:
         printf("-Unknown symbol info version %d\n", symbols->version);
     }
+    if (symbols->flags & 0x8000) /* new */
+        snprintf(tcver, sizeof(tcver), "%u.%u", (symbols->flags >> 8) & 0x7f, symbols->flags & 0xff);
+    else
+        snprintf(tcver, sizeof(tcver), "old-%x", symbols->flags);
     printf("Symbols:\n"
            "\tsignature:       %08x\n"
            "\tversion:         %u\n"
-           "\tunknown:         %08x\n"
-           "\thash1_file:      %08x\n"
-           "\thash2_file:      %08x\n"
-           "\tgsym_file:       %04x\n"
-           "\tunknown1:        %04x\n"
+           "\tage:             %08x\n"
+           "\tglobal_file:     %u\n"
+           "\tbuilder:         %s\n"
+           "\tpublic_file:     %u\n"
+           "\tbldVer:          %u\n"
+           "\tgsym_file:       %u\n"
+           "\trbldVer:         %u\n"
            "\tmodule_size:     %08x\n"
            "\toffset_size:     %08x\n"
            "\thash_size:       %08x\n"
@@ -264,14 +301,16 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
            "\tunknown2_size:   %08x\n"
            "\tresvd3:          %04x\n"
            "\tmachine:         %s\n"
-           "\tresvd[4]         %08x\n",
+           "\tresvd4           %08x\n",
            symbols->signature,
            symbols->version,
-           symbols->unknown,
-           symbols->hash1_file,
-           symbols->hash2_file,
+           symbols->age,
+           symbols->global_file,
+           tcver, /* from symbols->flags */
+           symbols->public_file,
+           symbols->bldVer,
            symbols->gsym_file,
-           symbols->unknown1,
+           symbols->rbldVer,
            symbols->module_size,
            symbols->offset_size,
            symbols->hash_size,
@@ -558,6 +597,8 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
         file_name += strlen(file_name) + 1;
         file = (char*)((DWORD_PTR)(file_name + strlen(file_name) + 1 + 3) & ~3);
     }
+    dump_global_symbol(reader, symbols->global_file);
+    dump_public_symbol(reader, symbols->public_file);
     free(symbols);
     free(filesimage);
 }
@@ -883,18 +924,22 @@ static void pdb_ds_dump(void)
            reader.u.ds.header->unknown2,
            reader.u.ds.header->toc_page);
 
-    /* files:
-     *  0: JG says old toc pages, I'd say free pages (tbc, low prio)
+    /* files with static indexes:
+     *  0: JG says old toc pages
      *  1: root structure
      *  2: types
      *  3: modules
+     *  4: types (second stream)
      * other known streams:
      * - string table: its index is in the stream table from ROOT object under "/names"
+     * - type hash table: its index is in the types header (2 and 4)
+     * - global and public streams: from symbol stream header
      * those streams get their indexes out of the PDB_STREAM_INDEXES object
      * - FPO data
      * - segments
      * - extended FPO data
      */
+    reader.file_used[0] |= 1; /* mark stream #0 as read */
     reader.u.ds.root = reader.read_file(&reader, 1);
     if (reader.u.ds.root)
     {




More information about the wine-devel mailing list