From: Eric Pouech <epouech@codeweavers.com> Signed-off-by: Eric Pouech <epouech@codeweavers.com> (imported from commit 2e55986ca4a61c952260cde0d6e50b71f2ceaa70) --- tools/winedump/main.c | 37 +++++++++++++++++++++++++++++++++++++ tools/winedump/msc.c | 5 +++-- tools/winedump/pdb.c | 19 +++++++++++++------ tools/winedump/winedump.h | 3 ++- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/tools/winedump/main.c b/tools/winedump/main.c index 99b1221fdac..4465eb5374d 100644 --- a/tools/winedump/main.c +++ b/tools/winedump/main.c @@ -402,6 +402,43 @@ BOOL globals_dump_sect(const char* s) return FALSE; } +BOOL globals_dump_sect_with_range(const char* s, unsigned *from, unsigned *to) +{ + const char** sect; + size_t slen; + + if (!s || !globals.dumpsect) return FALSE; + if (globals_dump_sect(s)) return TRUE; + slen = strlen(s); + for (sect = globals.dumpsect; *sect; sect++) + { + if (!memcmp(*sect, s, slen)) + { + if (sscanf(*sect + slen, ":%i-%i", from, to) == 2) + { + if (*from > *to) + { + printf("Invalid range %x-%x\n", *from, *to); + return FALSE; + } + return TRUE; + } + if (sscanf(*sect + slen, ":%i+%i", from, to) == 2) + { + *to += *from; + return TRUE; + } + if (sscanf(*sect + slen, ":%i", from) == 1) + { + *to = *from + 1; + return TRUE; + } + } + } + + return FALSE; +} + /******************************************************************* * main */ diff --git a/tools/winedump/msc.c b/tools/winedump/msc.c index febee0d4a8a..7dd89e3b6da 100644 --- a/tools/winedump/msc.c +++ b/tools/winedump/msc.c @@ -1186,7 +1186,7 @@ BOOL codeview_dump_types_from_offsets(const void* table, const DWORD* offsets, u return TRUE; } -BOOL codeview_dump_types_from_block(const void* table, unsigned long len) +BOOL codeview_dump_types_from_block(const void* table, unsigned long len, unsigned int from, unsigned int to) { unsigned int curr_type = 0x1000; const unsigned char*ptr = table; @@ -1195,7 +1195,8 @@ BOOL codeview_dump_types_from_block(const void* table, unsigned long len) { const union codeview_type* type = (const union codeview_type*)ptr; - codeview_dump_one_type(curr_type, type); + if (from <= curr_type && curr_type < to) + codeview_dump_one_type(curr_type, type); curr_type++; ptr += type->generic.len + 2; } diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 9bfbb05449a..1f5f5629257 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -786,11 +786,16 @@ static void pdb_dump_symbols(struct pdb_reader* reader) /* Read global symbol table */ modimage = reader->read_stream(reader, symbols->gsym_stream); - if (modimage && globals_dump_sect("DBI")) + if (modimage) { - printf("\t------------globals-------------\n"); - codeview_dump_symbols(modimage, 0, pdb_get_stream_size(reader, symbols->gsym_stream)); - free(modimage); + unsigned from = 0, to = pdb_get_stream_size(reader, symbols->gsym_stream); + + if (globals_dump_sect_with_range("DBI", &from, &to)) + { + printf("\t------------globals-------------\n"); + codeview_dump_symbols(modimage, from, to); + free(modimage); + } } /* Read per-module symbol / linenumber tables */ @@ -1003,8 +1008,10 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch { PDB_TYPES* types = NULL; BOOL used = has_stream_been_read(reader, strmidx); + unsigned from = 0x1000, to = ~0u; + + if (!globals_dump_sect_with_range(strmidx == 2 ? "TPI" : "IPI", &from, &to)) return; - if (!globals_dump_sect(strmidx == 2 ? "TPI" : "IPI")) return; if (pdb_get_stream_size(reader, strmidx) < sizeof(*types)) { if (strmidx == 2) @@ -1064,7 +1071,7 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch types->search_size, types->type_remap_offset, types->type_remap_size); - codeview_dump_types_from_block((const char*)types + types->type_offset, types->type_size); + codeview_dump_types_from_block((const char*)types + types->type_offset, types->type_size, from, to); pdb_dump_types_hash(reader, types, strmname); free(types); } diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h index 61a3e55e67d..e6883859f94 100644 --- a/tools/winedump/winedump.h +++ b/tools/winedump/winedump.h @@ -143,6 +143,7 @@ extern void *dump_base; extern size_t dump_total_len; BOOL globals_dump_sect(const char*); +BOOL globals_dump_sect_with_range(const char *, unsigned *, unsigned *); /* Names to use for output DLL */ #define OUTPUT_DLL_NAME \ @@ -276,7 +277,7 @@ extern void tlb_dump_resource( void *ptr, size_t size, const char *prefix ); BOOL codeview_dump_symbols(const void* root, unsigned long start, unsigned long size); BOOL codeview_dump_types_from_offsets(const void* table, const DWORD* offsets, unsigned num_types); -BOOL codeview_dump_types_from_block(const void* table, unsigned long len); +BOOL codeview_dump_types_from_block(const void* table, unsigned long len, unsigned int cvtyp_from, unsigned int cvtyp_to); void codeview_dump_linetab(const char* linetab, BOOL pascal_str, const char* pfx); void codeview_dump_linetab2(const char* linetab, DWORD size, const PDB_STRING_TABLE*, const char* pfx); const char* pdb_get_string_table_entry(const PDB_STRING_TABLE* table, unsigned ofs); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10020