Eric Pouech : winedbg: Show dwarf version(s) used for a module.

Alexandre Julliard julliard at winehq.org
Wed Sep 15 16:21:33 CDT 2021


Module: wine
Branch: master
Commit: 0646e156655b1d21e672f09b4854221091c4fb91
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0646e156655b1d21e672f09b4854221091c4fb91

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Wed Sep 15 10:38:40 2021 +0200

winedbg: Show dwarf version(s) used for a module.

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dbghelp/dwarf.c    | 10 +++++++++-
 programs/winedbg/info.c | 13 ++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index a9ff9ff2354..90addb9a6b7 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -182,6 +182,7 @@ typedef struct dwarf2_parse_module_context_s
     const struct elf_thunk_area*thunks;
     struct symt*                symt_cache[sc_num]; /* void, unknown */
     struct vector               unit_contexts;
+    DWORD                       cu_versions;
 } dwarf2_parse_module_context_t;
 
 enum unit_status
@@ -2517,6 +2518,8 @@ static BOOL dwarf2_parse_compilation_unit_head(dwarf2_parse_context_t* ctx,
     TRACE("- word_size:     %u\n",  ctx->head.word_size);
     TRACE("- offset_size:   %u\n",  ctx->head.offset_size);
 
+    if (ctx->head.version >= 2)
+        ctx->module_ctx->cu_versions |= 1 << (ctx->head.version - 2);
     if (max_supported_dwarf_version == 0)
     {
         char* env = getenv("DBGHELP_DWARF_VERSION");
@@ -3732,6 +3735,7 @@ BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset,
     module_ctx.symt_cache[sc_void] = &symt_new_basic(module_ctx.module, btVoid, "void", 0)->symt;
     module_ctx.symt_cache[sc_unknown] = &symt_new_basic(module_ctx.module, btNoType, "# unknown", 0)->symt;
     vector_init(&module_ctx.unit_contexts, sizeof(dwarf2_parse_context_t), 16);
+    module_ctx.cu_versions = 0;
 
     /* phase I: parse all CU heads */
     mod_ctx.data = section[section_debug].address;
@@ -3749,7 +3753,11 @@ BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset,
         dwarf2_parse_compilation_unit((dwarf2_parse_context_t*)vector_at(&module_ctx.unit_contexts, i));
 
     dwarf2_modfmt->module->module.SymType = SymDia;
-    dwarf2_modfmt->module->module.CVSig = 'D' | ('W' << 8) | ('A' << 16) | ('R' << 24);
+    /* hide dwarf versions in CVSig
+     * bits 24-31 will be set according to found dwarf version
+     * different CU can have different dwarf version, so use a bit per version (version 2 => b24)
+     */
+    dwarf2_modfmt->module->module.CVSig = 'D' | ('W' << 8) | ('F' << 16) | ((module_ctx.cu_versions & 0xFF) << 24);
     /* FIXME: we could have a finer grain here */
     dwarf2_modfmt->module->module.GlobalSymbols = TRUE;
     dwarf2_modfmt->module->module.TypeInfo = TRUE;
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c
index a6335092d84..36da71c4713 100644
--- a/programs/winedbg/info.c
+++ b/programs/winedbg/info.c
@@ -137,10 +137,21 @@ static const char* get_symtype_str(const IMAGEHLP_MODULE64* mi)
         case 'S' | ('T' << 8) | ('A' << 16) | ('B' << 24):
             return "Stabs";
         case 'D' | ('W' << 8) | ('A' << 16) | ('R' << 24):
+            /* previous versions of dbghelp used to report this... */
             return "Dwarf";
         default:
+            if ((mi->CVSig & 0x00FFFFFF) == ('D' | ('W' << 8) | ('F' << 16)))
+            {
+                static char tmp[64];
+                DWORD versbit = mi->CVSig >> 24;
+                strcpy(tmp, "Dwarf");
+                if (versbit & 1) strcat(tmp, "-2");
+                if (versbit & 2) strcat(tmp, "-3");
+                if (versbit & 4) strcat(tmp, "-4");
+                if (versbit & 8) strcat(tmp, "-5");
+                return tmp;
+            }
             return "DIA";
-
         }
     }
 }




More information about the wine-cvs mailing list