[PATCH 0/4] MR2079: Be consistent in naming bits inside PDB files.
This series tidy up some naming used to describe the PDB internals. We are not consistent in the various names added over the years. Let's try to be a bit more clear. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2079
From: Eric Pouech <eric.pouech(a)gmail.com> No longer calling it sometimes 'page'. Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- dlls/dbghelp/msc.c | 2 +- include/wine/mscvpdb.h | 4 ++-- tools/winedump/pdb.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 9debc34e77c..1b998ab5e36 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -3555,7 +3555,7 @@ static BOOL pdb_init(const struct pdb_lookup* pdb_lookup, struct pdb_file_info* struct PDB_DS_ROOT* root; pdb_file->u.ds.toc = - pdb_ds_read(pdb, (const UINT*)((const char*)pdb + pdb->toc_page * pdb->block_size), + pdb_ds_read(pdb, (const UINT*)((const char*)pdb + pdb->toc_block * pdb->block_size), pdb->toc_size); root = pdb_read_ds_file(pdb, pdb_file->u.ds.toc, 1); if (!root) diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 90adc3ee465..7e3af84034f 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2398,10 +2398,10 @@ struct PDB_DS_HEADER char signature[32]; unsigned int block_size; unsigned int unknown1; - unsigned int num_pages; + unsigned int num_blocks; unsigned int toc_size; unsigned int unknown2; - unsigned int toc_page; + unsigned int toc_block; }; struct PDB_JG_TOC diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index ab844fd8555..0060d9d48be 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -1120,7 +1120,7 @@ static BOOL pdb_ds_init(struct pdb_reader* reader) if (!reader->u.ds.header) return FALSE; reader->read_file = pdb_ds_read_file; reader->u.ds.toc = pdb_ds_read(reader->u.ds.header, - (const UINT *)((const char*)reader->u.ds.header + reader->u.ds.header->toc_page * reader->u.ds.header->block_size), + (const UINT *)((const char*)reader->u.ds.header + reader->u.ds.header->toc_block * reader->u.ds.header->block_size), reader->u.ds.header->toc_size); memset(reader->file_used, 0, sizeof(reader->file_used)); return TRUE; @@ -1137,20 +1137,20 @@ static void pdb_ds_dump(void) "\tsignature: %.*s\n" "\tblock_size: %08x\n" "\tunknown1: %08x\n" - "\tnum_pages: %08x\n" + "\tnum_blocks: %08x\n" "\ttoc_size: %08x\n" "\tunknown2: %08x\n" - "\ttoc_page: %08x\n", + "\ttoc_block: %08x\n", (int)sizeof(pdb7) - 1, reader.u.ds.header->signature, reader.u.ds.header->block_size, reader.u.ds.header->unknown1, - reader.u.ds.header->num_pages, + reader.u.ds.header->num_blocks, reader.u.ds.header->toc_size, reader.u.ds.header->unknown2, - reader.u.ds.header->toc_page); + reader.u.ds.header->toc_block); /* files with static indexes: - * 0: JG says old toc pages + * 0: JG says old toc blocks * 1: root structure * 2: types * 3: modules -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2079
From: Eric Pouech <eric.pouech(a)gmail.com> Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- include/wine/mscvpdb.h | 4 ++-- tools/winedump/pdb.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 7e3af84034f..10d1438e0ea 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2387,7 +2387,7 @@ struct PDB_JG_HEADER char ident[40]; unsigned int signature; unsigned int block_size; - unsigned short free_list; + unsigned short free_list_block; unsigned short total_alloc; struct PDB_FILE toc; unsigned short toc_block[1]; @@ -2397,7 +2397,7 @@ struct PDB_DS_HEADER { char signature[32]; unsigned int block_size; - unsigned int unknown1; + unsigned int free_list_block; unsigned int num_blocks; unsigned int toc_size; unsigned int unknown2; diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 0060d9d48be..3bf4f7a0606 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -997,15 +997,15 @@ static void pdb_jg_dump(void) */ pdb_jg_init(&reader); printf("Header (JG):\n" - "\tident: %.*s\n" - "\tsignature: %08x\n" - "\tblock_size: %08x\n" - "\tfree_list: %04x\n" - "\ttotal_alloc:%04x\n", + "\tident: %.*s\n" + "\tsignature: %08x\n" + "\tblock_size: %08x\n" + "\tfree_list_block: %04x\n" + "\ttotal_alloc: %04x\n", (int)sizeof(pdb2) - 1, reader.u.jg.header->ident, reader.u.jg.header->signature, reader.u.jg.header->block_size, - reader.u.jg.header->free_list, + reader.u.jg.header->free_list_block, reader.u.jg.header->total_alloc); reader.u.jg.root = reader.read_file(&reader, 1); @@ -1136,14 +1136,14 @@ static void pdb_ds_dump(void) printf("Header (DS)\n" "\tsignature: %.*s\n" "\tblock_size: %08x\n" - "\tunknown1: %08x\n" + "\tfree_list_block: %08x\n" "\tnum_blocks: %08x\n" "\ttoc_size: %08x\n" "\tunknown2: %08x\n" "\ttoc_block: %08x\n", (int)sizeof(pdb7) - 1, reader.u.ds.header->signature, reader.u.ds.header->block_size, - reader.u.ds.header->unknown1, + reader.u.ds.header->free_list_block, reader.u.ds.header->num_blocks, reader.u.ds.header->toc_size, reader.u.ds.header->unknown2, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2079
From: Eric Pouech <eric.pouech(a)gmail.com> We were using either _size or _len depending on which one. Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- dlls/dbghelp/msc.c | 18 ++++++------ include/wine/mscvpdb.h | 12 ++++---- tools/winedump/pdb.c | 64 +++++++++++++++++++++--------------------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 1b998ab5e36..66b88e3de07 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -782,8 +782,8 @@ static BOOL codeview_type_extract_name(const union codeview_type* cvtype, static unsigned pdb_read_hash_value(const struct codeview_type_parse* ctp, unsigned idx) { - const void* where = ctp->hash_stream + ctp->header.hash_offset + (idx - ctp->header.first_index) * ctp->header.hash_size; - switch (ctp->header.hash_size) + const void* where = ctp->hash_stream + ctp->header.hash_offset + (idx - ctp->header.first_index) * ctp->header.hash_value_size; + switch (ctp->header.hash_value_size) { case 2: return *(unsigned short*)where; case 4: return *(unsigned*)where; @@ -2888,16 +2888,16 @@ static BOOL codeview_snarf_sym_hashtable(const struct msc_debug_info* msc_dbg, c if (hashsize < sizeof(DBI_HASH_HEADER) || hash_hdr->signature != 0xFFFFFFFF || hash_hdr->version != 0xeffe0000 + 19990810 || - (hash_hdr->size_hash_records % sizeof(DBI_HASH_RECORD)) != 0 || - sizeof(DBI_HASH_HEADER) + hash_hdr->size_hash_records + DBI_BITMAP_HASH_SIZE > hashsize || - (hashsize - (sizeof(DBI_HASH_HEADER) + hash_hdr->size_hash_records + DBI_BITMAP_HASH_SIZE)) % sizeof(unsigned)) + (hash_hdr->hash_records_size % sizeof(DBI_HASH_RECORD)) != 0 || + sizeof(DBI_HASH_HEADER) + hash_hdr->hash_records_size + DBI_BITMAP_HASH_SIZE > hashsize || + (hashsize - (sizeof(DBI_HASH_HEADER) + hash_hdr->hash_records_size + DBI_BITMAP_HASH_SIZE)) % sizeof(unsigned)) { FIXME("Incorrect hash structure\n"); return FALSE; } hr = (DBI_HASH_RECORD*)(hash_hdr + 1); - num_hash_records = hash_hdr->size_hash_records / sizeof(DBI_HASH_RECORD); + num_hash_records = hash_hdr->hash_records_size / sizeof(DBI_HASH_RECORD); /* Only iterate over the records listed in the hash table. * We assume that records present in stream, but not listed in hash table, are @@ -3387,9 +3387,9 @@ static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg, ERR("-Unknown type info version %d\n", ctp->header.version); return FALSE; } - if (ctp->header.hash_size != 2 && ctp->header.hash_size != 4) + if (ctp->header.hash_value_size != 2 && ctp->header.hash_value_size != 4) { - ERR("-Unsupported hash of size %u\n", ctp->header.hash_size); + ERR("-Unsupported hash of size %u\n", ctp->header.hash_value_size); return FALSE; } ctp->hash_stream = pdb_read_file(pdb_file, ctp->header.hash_file); @@ -3429,7 +3429,7 @@ static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg, /* parse the remap table * => move listed type_id at first position of their hash buckets so that we force remap to them */ - if (ctp->header.type_remap_len) + if (ctp->header.type_remap_size) { const unsigned* remap = (const unsigned*)((const BYTE*)ctp->hash_stream + ctp->header.type_remap_offset); unsigned i, capa, count_present; diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 10d1438e0ea..85b115876c6 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -2454,14 +2454,14 @@ typedef struct _PDB_TYPES unsigned int type_size; unsigned short hash_file; unsigned short pad; - unsigned int hash_size; + unsigned int hash_value_size; unsigned int hash_num_buckets; unsigned int hash_offset; - unsigned int hash_len; + unsigned int hash_size; unsigned int search_offset; - unsigned int search_len; + unsigned int search_size; unsigned int type_remap_offset; - unsigned int type_remap_len; + unsigned int type_remap_size; } PDB_TYPES, *PPDB_TYPES; typedef struct _PDB_SYMBOL_RANGE @@ -2631,11 +2631,11 @@ typedef struct { unsigned signature; unsigned version; - unsigned size_hash_records; + unsigned hash_records_size; unsigned unknown; } DBI_HASH_HEADER; /* This header is followed by: - * - DBI_HASH_RECORDS (on hdr:size_hash_records bytes) + * - DBI_HASH_RECORDS (on hdr:hash_records_size bytes) * - a bitmap of DBI_MAX_HASH + 1 entries (on DBI_BITMAP_HASH_SIZE bytes) * - a table (one entry per present bit in bitmap) as index into hdr:num_records */ diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 3bf4f7a0606..5687766fd1e 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -240,25 +240,25 @@ static void dump_dbi_hash_table(const BYTE* root, unsigned size, const char* nam printf("%s%s symbols hash:\n", pfx, name); printf("%s\tSignature: 0x%x\n", pfx, hdr->signature); printf("%s\tVersion: 0x%x (%u)\n", pfx, hdr->version, hdr->version - 0xeffe0000); - printf("%s\tSize of hash records: %u\n", pfx, hdr->size_hash_records); + printf("%s\tSize of hash records: %u\n", pfx, hdr->hash_records_size); printf("%s\tUnknown: %u\n", pfx, hdr->unknown); if (hdr->signature != 0xFFFFFFFF || hdr->version != 0xeffe0000 + 19990810 || - (hdr->size_hash_records % sizeof(DBI_HASH_RECORD)) != 0 || - sizeof(DBI_HASH_HEADER) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE > size || - (size - (sizeof(DBI_HASH_HEADER) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE)) % sizeof(unsigned)) + (hdr->hash_records_size % sizeof(DBI_HASH_RECORD)) != 0 || + sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE > size || + (size - (sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE)) % sizeof(unsigned)) { printf("%s\t\tIncorrect hash structure\n", pfx); } else { unsigned i; - unsigned num_hash_records = hdr->size_hash_records / sizeof(DBI_HASH_RECORD); + unsigned num_hash_records = hdr->hash_records_size / sizeof(DBI_HASH_RECORD); const DBI_HASH_RECORD* hr = (const DBI_HASH_RECORD*)(hdr + 1); - unsigned* bitmap = (unsigned*)((char*)(hdr + 1) + hdr->size_hash_records); - unsigned* buckets = (unsigned*)((char*)(hdr + 1) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE); - unsigned index, last_index = (size - (sizeof(DBI_HASH_HEADER) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE)) / sizeof(unsigned); + unsigned* bitmap = (unsigned*)((char*)(hdr + 1) + hdr->hash_records_size); + unsigned* buckets = (unsigned*)((char*)(hdr + 1) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE); + unsigned index, last_index = (size - (sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE)) / sizeof(unsigned); /* Yes, offsets for accessiong hr[] are stored as multiple of 12; and not * as multiple of sizeof(*hr) = 8 as one might expect. @@ -279,10 +279,10 @@ static void dump_dbi_hash_table(const BYTE* root, unsigned size, const char* nam printf("%s\t[%u] <<empty>>\n", pfx, i); } /* shouldn't happen */ - if (sizeof(DBI_HASH_HEADER) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE + index * sizeof(unsigned) > size) + if (sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE + index * sizeof(unsigned) > size) { printf("%s-- left over %u bytes\n", pfx, - size - (unsigned)(sizeof(DBI_HASH_HEADER) + hdr->size_hash_records + DBI_BITMAP_HASH_SIZE + index * sizeof(unsigned))); + size - (unsigned)(sizeof(DBI_HASH_HEADER) + hdr->hash_records_size + DBI_BITMAP_HASH_SIZE + index * sizeof(unsigned))); } } } @@ -727,10 +727,10 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type printf("Types (%s) hash:\n", strmname); strmsize = pdb_get_file_size(reader, types->hash_file); - if (types->hash_offset + types->hash_len > strmsize || - (types->last_index - types->first_index) * types->hash_size != types->hash_len || - types->search_offset + types->search_len > strmsize || - types->type_remap_offset + types->type_remap_len > strmsize) + if (types->hash_offset + types->hash_size > strmsize || + (types->last_index - types->first_index) * types->hash_value_size != types->hash_size || + types->search_offset + types->search_size > strmsize || + types->type_remap_offset + types->type_remap_size > strmsize) { printf("\nIncoherent sizes... skipping\n"); return; @@ -739,7 +739,7 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type for (i = types->first_index; i < types->last_index; i++) { printf("\t\t%08x => ", i); - pdb_dump_hash_value((const BYTE*)hash + types->hash_offset + (i - types->first_index) * types->hash_size, types->hash_size); + pdb_dump_hash_value((const BYTE*)hash + types->hash_offset + (i - types->first_index) * types->hash_value_size, types->hash_value_size); printf("\n"); } /* print collisions in hash table (if any) */ @@ -749,7 +749,7 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type unsigned head_printed = 0; collision_arg.hash = (const BYTE*)hash + types->hash_offset; - collision_arg.hash_size = types->hash_size; + collision_arg.hash_size = types->hash_value_size; for (i = 0; i < types->last_index - types->first_index; i++) collision[i] = i; qsort(collision, types->last_index - types->first_index, sizeof(unsigned), collision_compar); @@ -757,9 +757,9 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type { unsigned j; for (j = i + 1; j < types->last_index - types->first_index; j++) - if (memcmp((const BYTE*)hash + types->hash_offset + collision[i] * types->hash_size, - (const BYTE*)hash + types->hash_offset + collision[j] * types->hash_size, - types->hash_size)) + if (memcmp((const BYTE*)hash + types->hash_offset + collision[i] * types->hash_value_size, + (const BYTE*)hash + types->hash_offset + collision[j] * types->hash_value_size, + types->hash_value_size)) break; if (j > i + 1) { @@ -770,7 +770,7 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type head_printed = 1; } printf("\t\t\tHash "); - pdb_dump_hash_value((const BYTE*)hash + types->hash_offset + collision[i] * types->hash_size, types->hash_size); + pdb_dump_hash_value((const BYTE*)hash + types->hash_offset + collision[i] * types->hash_value_size, types->hash_value_size); printf(":"); for (k = i; k < j; k++) printf(" %x", types->first_index + collision[k]); @@ -782,11 +782,11 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type } printf("\n\tIndexes => offsets:\n"); table = (const unsigned*)((const BYTE*)hash + types->search_offset); - for (i = 0; i < types->search_len / (2 * sizeof(unsigned)); i += 2) + for (i = 0; i < types->search_size / (2 * sizeof(unsigned)); i += 2) { printf("\t\t%08x => %08x\n", table[2 * i + 0], table[2 * i + 1]); } - if (types->type_remap_len && (strbase = read_string_table(reader))) + if (types->type_remap_size && (strbase = read_string_table(reader))) { unsigned num, capa, count_present, count_deleted; const unsigned* present_bitset; @@ -823,8 +823,8 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type if (is_bit_set(present_bitset, count_present, i)) { printf(" %s => ", pdb_get_string_table_entry(strbase, *table++)); - pdb_dump_hash_value((const BYTE*)table, types->hash_size); - table = (const unsigned*)((const BYTE*)table + types->hash_size); + pdb_dump_hash_value((const BYTE*)table, types->hash_value_size); + table = (const unsigned*)((const BYTE*)table + types->hash_value_size); } printf("\n"); } @@ -875,14 +875,14 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch "\ttype_size: %x\n" "\thash_file: %x\n" "\tpad: %x\n" - "\thash_size: %x\n" + "\thash_value_size: %x\n" "\thash_buckets %x\n" "\thash_offset: %x\n" - "\thash_len: %x\n" + "\thash_size: %x\n" "\tsearch_offset: %x\n" - "\tsearch_len: %x\n" + "\tsearch_size: %x\n" "\ttype_remap_offset: %x\n" - "\ttype_remap_len: %x\n", + "\ttype_remap_size: %x\n", strmname, types->version, types->type_offset, @@ -891,14 +891,14 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch types->type_size, types->hash_file, types->pad, - types->hash_size, + types->hash_value_size, types->hash_num_buckets, types->hash_offset, - types->hash_len, + types->hash_size, types->search_offset, - types->search_len, + types->search_size, types->type_remap_offset, - types->type_remap_len); + types->type_remap_size); codeview_dump_types_from_block((const char*)types + types->type_offset, types->type_size); pdb_dump_types_hash(reader, types, strmname); free(types); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2079
From: Eric Pouech <eric.pouech(a)gmail.com> Try to apply consistent naming: - file refers to (PDB) file - stream refers to a stream/file inside the PDB stream at MSF level (we were also using file for the later, which isn't very simple to follow). Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- dlls/dbghelp/msc.c | 142 ++++++++++++------------- include/wine/mscvpdb.h | 69 ++++++------- tools/winedump/pdb.c | 230 ++++++++++++++++++++--------------------- 3 files changed, 220 insertions(+), 221 deletions(-) diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 66b88e3de07..1ecb01024d1 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2874,8 +2874,8 @@ static void pdb_location_compute(struct process* pcs, loc->reg = loc_err_internal; } -static void* pdb_read_file(const struct pdb_file_info* pdb_file, DWORD file_nr); -static unsigned pdb_get_file_size(const struct pdb_file_info* pdb_file, DWORD file_nr); +static void* pdb_read_stream(const struct pdb_file_info* pdb_file, DWORD stream_nr); +static unsigned pdb_get_stream_size(const struct pdb_file_info* pdb_file, DWORD stream_nr); static BOOL codeview_snarf_sym_hashtable(const struct msc_debug_info* msc_dbg, const BYTE* symroot, DWORD symsize, const BYTE* hashroot, DWORD hashsize, @@ -3067,58 +3067,58 @@ static void* pdb_ds_read(const struct PDB_DS_HEADER* pdb, const UINT *block_list return buffer; } -static void* pdb_read_jg_file(const struct PDB_JG_HEADER* pdb, - const struct PDB_JG_TOC* toc, DWORD file_nr) +static void* pdb_read_jg_stream(const struct PDB_JG_HEADER* pdb, + const struct PDB_JG_TOC* toc, DWORD stream_nr) { const WORD* block_list; DWORD i; - if (!toc || file_nr >= toc->num_files) return NULL; + if (!toc || stream_nr >= toc->num_streams) return NULL; - block_list = (const WORD*) &toc->file[toc->num_files]; - for (i = 0; i < file_nr; i++) - block_list += (toc->file[i].size + pdb->block_size - 1) / pdb->block_size; + block_list = (const WORD*) &toc->streams[toc->num_streams]; + for (i = 0; i < stream_nr; i++) + block_list += (toc->streams[i].size + pdb->block_size - 1) / pdb->block_size; - return pdb_jg_read(pdb, block_list, toc->file[file_nr].size); + return pdb_jg_read(pdb, block_list, toc->streams[stream_nr].size); } -static void* pdb_read_ds_file(const struct PDB_DS_HEADER* pdb, - const struct PDB_DS_TOC* toc, DWORD file_nr) +static void* pdb_read_ds_stream(const struct PDB_DS_HEADER* pdb, + const struct PDB_DS_TOC* toc, DWORD stream_nr) { const UINT *block_list; DWORD i; - if (!toc || file_nr >= toc->num_files) return NULL; - if (toc->file_size[file_nr] == 0 || toc->file_size[file_nr] == 0xFFFFFFFF) return NULL; + if (!toc || stream_nr >= toc->num_streams) return NULL; + if (toc->stream_size[stream_nr] == 0 || toc->stream_size[stream_nr] == 0xFFFFFFFF) return NULL; - block_list = &toc->file_size[toc->num_files]; - for (i = 0; i < file_nr; i++) - block_list += (toc->file_size[i] + pdb->block_size - 1) / pdb->block_size; + block_list = &toc->stream_size[toc->num_streams]; + for (i = 0; i < stream_nr; i++) + block_list += (toc->stream_size[i] + pdb->block_size - 1) / pdb->block_size; - return pdb_ds_read(pdb, block_list, toc->file_size[file_nr]); + return pdb_ds_read(pdb, block_list, toc->stream_size[stream_nr]); } -static void* pdb_read_file(const struct pdb_file_info* pdb_file, - DWORD file_nr) +static void* pdb_read_stream(const struct pdb_file_info* pdb_file, + DWORD stream_nr) { switch (pdb_file->kind) { case PDB_JG: - return pdb_read_jg_file((const struct PDB_JG_HEADER*)pdb_file->image, - pdb_file->u.jg.toc, file_nr); + return pdb_read_jg_stream((const struct PDB_JG_HEADER*)pdb_file->image, + pdb_file->u.jg.toc, stream_nr); case PDB_DS: - return pdb_read_ds_file((const struct PDB_DS_HEADER*)pdb_file->image, - pdb_file->u.ds.toc, file_nr); + return pdb_read_ds_stream((const struct PDB_DS_HEADER*)pdb_file->image, + pdb_file->u.ds.toc, stream_nr); } return NULL; } -static unsigned pdb_get_file_size(const struct pdb_file_info* pdb_file, DWORD file_nr) +static unsigned pdb_get_stream_size(const struct pdb_file_info* pdb_file, DWORD stream_nr) { switch (pdb_file->kind) { - case PDB_JG: return pdb_file->u.jg.toc->file[file_nr].size; - case PDB_DS: return pdb_file->u.ds.toc->file_size[file_nr]; + case PDB_JG: return pdb_file->u.jg.toc->streams[stream_nr].size; + case PDB_DS: return pdb_file->u.ds.toc->stream_size[stream_nr]; } return 0; } @@ -3205,9 +3205,9 @@ static PDB_STRING_TABLE* pdb_read_strings(const struct pdb_file_info* pdb_file) idx = pdb_get_stream_by_name(pdb_file, "/names"); if (idx != -1) { - ret = pdb_read_file( pdb_file, idx ); + ret = pdb_read_stream( pdb_file, idx ); if (ret && ret->magic == 0xeffeeffe && - sizeof(*ret) + ret->length <= pdb_get_file_size(pdb_file, idx)) return ret; + sizeof(*ret) + ret->length <= pdb_get_stream_size(pdb_file, idx)) return ret; pdb_free( ret ); } WARN("string table not found\n"); @@ -3248,7 +3248,7 @@ static BOOL pdb_convert_types_header(PDB_TYPES* types, const BYTE* image) types->type_size = old->type_size; types->first_index = old->first_index; types->last_index = old->last_index; - types->hash_file = old->hash_file; + types->hash_stream = old->hash_stream; } else { @@ -3268,15 +3268,15 @@ static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols, { /* Old version of the symbols record header */ const PDB_SYMBOLS_OLD* old = (const PDB_SYMBOLS_OLD*)image; - symbols->version = 0; - symbols->module_size = old->module_size; - symbols->offset_size = old->offset_size; - symbols->hash_size = old->hash_size; - symbols->srcmodule_size = old->srcmodule_size; - symbols->pdbimport_size = 0; - symbols->global_hash_file= old->global_hash_file; - symbols->public_file = old->public_file; - symbols->gsym_file = old->gsym_file; + symbols->version = 0; + symbols->module_size = old->module_size; + symbols->offset_size = old->offset_size; + symbols->hash_size = old->hash_size; + symbols->srcmodule_size = old->srcmodule_size; + symbols->pdbimport_size = 0; + symbols->global_hash_stream = old->global_hash_stream; + symbols->public_stream = old->public_stream; + symbols->gsym_stream = old->gsym_stream; *header_size = sizeof(PDB_SYMBOLS_OLD); } @@ -3288,8 +3288,8 @@ static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols, } } -static void pdb_convert_symbol_file(const PDB_SYMBOLS* symbols, - PDB_SYMBOL_FILE_EX* sfile, +static void pdb_convert_symbol_file(const PDB_SYMBOLS* symbols, + PDB_SYMBOL_FILE_EX* sfile, unsigned* size, const void* image) { @@ -3297,10 +3297,10 @@ static void pdb_convert_symbol_file(const PDB_SYMBOLS* symbols, { const PDB_SYMBOL_FILE *sym_file = image; memset(sfile, 0, sizeof(*sfile)); - sfile->file = sym_file->file; - sfile->range.index = sym_file->range.index; - sfile->symbol_size = sym_file->symbol_size; - sfile->lineno_size = sym_file->lineno_size; + sfile->stream = sym_file->stream; + sfile->range.index = sym_file->range.index; + sfile->symbol_size = sym_file->symbol_size; + sfile->lineno_size = sym_file->lineno_size; sfile->lineno2_size = sym_file->lineno2_size; *size = sizeof(PDB_SYMBOL_FILE) - 1; } @@ -3392,7 +3392,7 @@ static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg, ERR("-Unsupported hash of size %u\n", ctp->header.hash_value_size); return FALSE; } - ctp->hash_stream = pdb_read_file(pdb_file, ctp->header.hash_file); + ctp->hash_stream = pdb_read_stream(pdb_file, ctp->header.hash_stream); /* FIXME always present? if not reconstruct ?*/ if (!ctp->hash_stream) { @@ -3402,7 +3402,7 @@ static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg, ctp->module = msc_dbg->module; /* Reconstruct the types offset table - * Note: the hash subfile of the PDB_TYPES only contains a partial table + * Note: the hash stream of the PDB_TYPES only contains a partial table * (not all the indexes are present, so it requires first a binary search in partial table, * followed by a linear search...) */ @@ -3472,7 +3472,7 @@ static void pdb_process_types(const struct msc_debug_info* msc_dbg, const struct pdb_file_info* pdb_file) { struct codeview_type_parse ctp; - BYTE* types_image = pdb_read_file(pdb_file, 2); + BYTE* types_image = pdb_read_stream(pdb_file, 2); if (types_image) { @@ -3513,7 +3513,7 @@ static BOOL pdb_init(const struct pdb_lookup* pdb_lookup, struct pdb_file_info* struct PDB_JG_ROOT* root; pdb_file->u.jg.toc = pdb_jg_read(pdb, pdb->toc_block, pdb->toc.size); - root = pdb_read_jg_file(pdb, pdb_file->u.jg.toc, 1); + root = pdb_read_jg_stream(pdb, pdb_file->u.jg.toc, 1); if (!root) { ERR("-Unable to get root from .PDB in %s\n", pdb_lookup->filename); @@ -3557,7 +3557,7 @@ static BOOL pdb_init(const struct pdb_lookup* pdb_lookup, struct pdb_file_info* pdb_file->u.ds.toc = pdb_ds_read(pdb, (const UINT*)((const char*)pdb + pdb->toc_block * pdb->block_size), pdb->toc_size); - root = pdb_read_ds_file(pdb, pdb_file->u.ds.toc, 1); + root = pdb_read_ds_stream(pdb, pdb_file->u.ds.toc, 1); if (!root) { ERR("-Unable to get root from .PDB in %s\n", pdb_lookup->filename); @@ -3589,20 +3589,20 @@ static BOOL pdb_init(const struct pdb_lookup* pdb_lookup, struct pdb_file_info* if (0) /* some tool to dump the internal files from a PDB file */ { - int i, num_files; - + int i, num_streams; + switch (pdb_file->kind) { - case PDB_JG: num_files = pdb_file->u.jg.toc->num_files; break; - case PDB_DS: num_files = pdb_file->u.ds.toc->num_files; break; + case PDB_JG: num_streams = pdb_file->u.jg.toc->num_streams; break; + case PDB_DS: num_streams = pdb_file->u.ds.toc->num_streams; break; } - for (i = 1; i < num_files; i++) + for (i = 1; i < num_streams; i++) { - unsigned char* x = pdb_read_file(pdb_file, i); + unsigned char* x = pdb_read_stream(pdb_file, i); FIXME("********************** [%u]: size=%08x\n", - i, pdb_get_file_size(pdb_file, i)); - dump(x, pdb_get_file_size(pdb_file, i)); + i, pdb_get_stream_size(pdb_file, i)); + dump(x, pdb_get_stream_size(pdb_file, i)); pdb_free(x); } } @@ -3711,7 +3711,7 @@ static BOOL pdb_process_internal(const struct process* pcs, pdb_file->hMap = hMap; pdb_file->image = image; - symbols_image = pdb_read_file(pdb_file, 3); + symbols_image = pdb_read_stream(pdb_file, 3); if (symbols_image) { PDB_SYMBOLS symbols; @@ -3761,23 +3761,23 @@ static BOOL pdb_process_internal(const struct process* pcs, pdb_lookup, pdb_module_info, module_index); pdb_process_types(msc_dbg, pdb_file); - ipi_image = pdb_read_file(pdb_file, 4); + ipi_image = pdb_read_stream(pdb_file, 4); ipi_ok = pdb_init_type_parse(msc_dbg, pdb_file, &ipi_ctp, ipi_image); /* Read global types first, so that lookup by name in module (=compilation unit) * streams' loading can succeed them. */ - globalimage = pdb_read_file(pdb_file, symbols.gsym_file); + globalimage = pdb_read_stream(pdb_file, symbols.gsym_stream); if (globalimage) { const BYTE* data; - unsigned global_size = pdb_get_file_size(pdb_file, symbols.gsym_file); + unsigned global_size = pdb_get_stream_size(pdb_file, symbols.gsym_stream); - data = pdb_read_file(pdb_file, symbols.global_hash_file); + data = pdb_read_stream(pdb_file, symbols.global_hash_stream); if (data) { codeview_snarf_sym_hashtable(msc_dbg, globalimage, global_size, - data, pdb_get_file_size(pdb_file, symbols.global_hash_file), + data, pdb_get_stream_size(pdb_file, symbols.global_hash_stream), pdb_global_feed_types); pdb_free((void*)data); } @@ -3794,7 +3794,7 @@ static BOOL pdb_process_internal(const struct process* pcs, HeapValidate(GetProcessHeap(), 0, NULL); pdb_convert_symbol_file(&symbols, &sfile, &size, file); - modimage = pdb_read_file(pdb_file, sfile.file); + modimage = pdb_read_stream(pdb_file, sfile.stream); file_name = (const char*)file + size; if (modimage) { @@ -3820,20 +3820,20 @@ static BOOL pdb_process_internal(const struct process* pcs, if (globalimage) { const BYTE* data; - unsigned global_size = pdb_get_file_size(pdb_file, symbols.gsym_file); + unsigned global_size = pdb_get_stream_size(pdb_file, symbols.gsym_stream); - data = pdb_read_file(pdb_file, symbols.global_hash_file); + data = pdb_read_stream(pdb_file, symbols.global_hash_stream); if (data) { codeview_snarf_sym_hashtable(msc_dbg, globalimage, global_size, - data, pdb_get_file_size(pdb_file, symbols.global_hash_file), + data, pdb_get_stream_size(pdb_file, symbols.global_hash_stream), pdb_global_feed_variables); pdb_free((void*)data); } - if (!(dbghelp_options & SYMOPT_NO_PUBLICS) && (data = pdb_read_file(pdb_file, symbols.public_file))) + if (!(dbghelp_options & SYMOPT_NO_PUBLICS) && (data = pdb_read_stream(pdb_file, symbols.public_stream))) { const DBI_PUBLIC_HEADER* pubhdr = (const DBI_PUBLIC_HEADER*)data; - codeview_snarf_sym_hashtable(msc_dbg, globalimage, pdb_get_file_size(pdb_file, symbols.gsym_file), + codeview_snarf_sym_hashtable(msc_dbg, globalimage, pdb_get_stream_size(pdb_file, symbols.gsym_stream), (const BYTE*)(pubhdr + 1), pubhdr->hash_size, pdb_global_feed_public); pdb_free((void*)data); } @@ -4209,8 +4209,8 @@ BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, strbase = pdb_read_strings(&pdb_info->pdb_files[0]); if (!strbase) return FALSE; - fpoext = pdb_read_file(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream); - size = pdb_get_file_size(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream); + fpoext = pdb_read_stream(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream); + size = pdb_get_stream_size(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream); if (fpoext && (size % sizeof(*fpoext)) == 0) { size /= sizeof(*fpoext); diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 85b115876c6..7aff95c3e76 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -43,30 +43,29 @@ * * Regarding PDB files: * ------------------- - * They are implemented as a set of internal files (as a small file - * system). The file is split into blocks, an internal file is made - * of a set of blocks. Internal files are accessed through - * numbers. For example, - * 1/ is the ROOT (basic information on the file) - * 2/ is the Symbol information (global symbols, local variables...) - * 3/ is the Type internal file (each the symbols can have type + * They are implemented as a set of internal streams (as a small file + * system). The file is split into blocks, an internal stream is made of a set + * of blocks, that can be non continuous. The table of contents gives the set of + * blocks for a given stream. + * Some internal streams are accessed through numbers. For example, + * #1 is the ROOT (basic information on the file) + * #2 is the Symbol information (global symbols, local variables...) + * #3 is the Type internal stream (each the symbols can have type * information associated with it). * * Over the years, three formats existed for the PDB: - * - ?? was rather linked to 16 bit code (our support shall be rather - * bad) - * - JG: it's the signature embedded in the file header. This format - * has been used in MSVC 2.0 => 5.0. - * - DS: it's the signature embedded in the file header. It's the - * current format supported my MS. + * - ?? was rather linked to 16 bit code (our support shall be rather bad) + * - JG: it's the signature embedded in the file header. This format has been + * used in MSVC 2.0 => 5.0. + * - DS: it's the signature embedded in the file header. It's the current format + * supported my MS. * - * Types internal stream + * Types internal stream (aka TPI) * --------------------- - * Types (from the Type internal file) have existed in three flavors - * (note that those flavors came as historical evolution, but there - * isn't a one to one link between types evolution and PDB formats' - * evolutions: - * - the first flavor (suffixed by V1 in this file), where the types + * Types (from the Type internal stream) have existed in three flavors (note + * that those flavors came as historical evolution, but there isn't a one to one + * link between types evolution and PDB formats' evolutions: + * - the first flavor (suffixed by V1 in mscvpdb.h), where the types * and subtypes are 16 bit entities; and where strings are in Pascal * format (first char is their length and are not 0 terminated) * - the second flavor (suffixed by V2) differs from first flavor with @@ -2376,7 +2375,7 @@ struct startend * ======================================== */ -struct PDB_FILE +struct PDB_JG_STREAM { unsigned int size; unsigned int unknown; @@ -2389,7 +2388,7 @@ struct PDB_JG_HEADER unsigned int block_size; unsigned short free_list_block; unsigned short total_alloc; - struct PDB_FILE toc; + struct PDB_JG_STREAM toc; unsigned short toc_block[1]; }; @@ -2406,14 +2405,14 @@ struct PDB_DS_HEADER struct PDB_JG_TOC { - unsigned int num_files; - struct PDB_FILE file[1]; + unsigned int num_streams; + struct PDB_JG_STREAM streams[1]; }; struct PDB_DS_TOC { - unsigned int num_files; - unsigned int file_size[1]; + unsigned int num_streams; + unsigned int stream_size[1]; }; struct PDB_JG_ROOT @@ -2441,7 +2440,7 @@ typedef struct _PDB_TYPES_OLD unsigned short first_index; unsigned short last_index; unsigned int type_size; - unsigned short hash_file; + unsigned short hash_stream; unsigned short pad; } PDB_TYPES_OLD, *PPDB_TYPES_OLD; @@ -2452,7 +2451,7 @@ typedef struct _PDB_TYPES unsigned int first_index; unsigned int last_index; unsigned int type_size; - unsigned short hash_file; + unsigned short hash_stream; unsigned short pad; unsigned int hash_value_size; unsigned int hash_num_buckets; @@ -2493,7 +2492,7 @@ typedef struct _PDB_SYMBOL_FILE unsigned int unknown1; PDB_SYMBOL_RANGE range; unsigned short flag; - unsigned short file; + unsigned short stream; unsigned int symbol_size; unsigned int lineno_size; unsigned int lineno2_size; @@ -2507,7 +2506,7 @@ typedef struct _PDB_SYMBOL_FILE_EX unsigned int unknown1; PDB_SYMBOL_RANGE_EX range; unsigned short flag; - unsigned short file; + unsigned short stream; unsigned int symbol_size; unsigned int lineno_size; unsigned int lineno2_size; @@ -2535,9 +2534,9 @@ typedef struct _PDB_SYMBOL_IMPORT typedef struct _PDB_SYMBOLS_OLD { - unsigned short global_hash_file; - unsigned short public_file; - unsigned short gsym_file; + unsigned short global_hash_stream; + unsigned short public_stream; + unsigned short gsym_stream; unsigned short pad; unsigned int module_size; unsigned int offset_size; @@ -2550,11 +2549,11 @@ typedef struct _PDB_SYMBOLS unsigned int signature; unsigned int version; unsigned int age; - unsigned short global_hash_file; + unsigned short global_hash_stream; unsigned short flags; - unsigned short public_file; + unsigned short public_stream; unsigned short bldVer; - unsigned short gsym_file; + unsigned short gsym_stream; unsigned short rbldVer; unsigned int module_size; unsigned int offset_size; diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 5687766fd1e..31f4fd3bc46 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -47,23 +47,23 @@ struct pdb_reader const struct PDB_DS_ROOT* root; } ds; } u; - void* (*read_file)(struct pdb_reader*, DWORD); - DWORD file_used[1024]; + void* (*read_stream)(struct pdb_reader*, DWORD); + DWORD stream_used[1024]; }; -static inline BOOL has_file_been_read(struct pdb_reader* reader, unsigned file_nr) +static inline BOOL has_stream_been_read(struct pdb_reader* reader, unsigned stream_nr) { - return reader->file_used[file_nr / 32] & (1 << (file_nr % 32)); + return reader->stream_used[stream_nr / 32] & (1 << (stream_nr % 32)); } -static inline void mark_file_been_read(struct pdb_reader* reader, unsigned file_nr) +static inline void mark_stream_been_read(struct pdb_reader* reader, unsigned stream_nr) { - reader->file_used[file_nr / 32] |= 1 << (file_nr % 32); + reader->stream_used[stream_nr / 32] |= 1 << (stream_nr % 32); } -static inline void clear_file_been_read(struct pdb_reader* reader, unsigned file_nr) +static inline void clear_stream_been_read(struct pdb_reader* reader, unsigned stream_nr) { - reader->file_used[file_nr / 32] &= ~(1 << (file_nr % 32)); + reader->stream_used[stream_nr / 32] &= ~(1 << (stream_nr % 32)); } static void* pdb_jg_read(const struct PDB_JG_HEADER* pdb, const WORD* block_list, int size) @@ -83,72 +83,72 @@ static void* pdb_jg_read(const struct PDB_JG_HEADER* pdb, const WORD* block_list return buffer; } -static void* pdb_jg_read_file(struct pdb_reader* reader, DWORD file_nr) +static void* pdb_jg_read_stream(struct pdb_reader* reader, DWORD stream_nr) { const WORD* block_list; DWORD i; - if (!reader->u.jg.toc || file_nr >= reader->u.jg.toc->num_files) return NULL; + if (!reader->u.jg.toc || stream_nr >= reader->u.jg.toc->num_streams) return NULL; - mark_file_been_read(reader, file_nr); - if (reader->u.jg.toc->file[file_nr].size == 0 || - reader->u.jg.toc->file[file_nr].size == 0xFFFFFFFF) + mark_stream_been_read(reader, stream_nr); + if (reader->u.jg.toc->streams[stream_nr].size == 0 || + reader->u.jg.toc->streams[stream_nr].size == 0xFFFFFFFF) return NULL; - block_list = (const WORD*) &reader->u.jg.toc->file[reader->u.jg.toc->num_files]; - for (i = 0; i < file_nr; i++) - block_list += (reader->u.jg.toc->file[i].size + + block_list = (const WORD*) &reader->u.jg.toc->streams[reader->u.jg.toc->num_streams]; + for (i = 0; i < stream_nr; i++) + block_list += (reader->u.jg.toc->streams[i].size + reader->u.jg.header->block_size - 1) / reader->u.jg.header->block_size; return pdb_jg_read(reader->u.jg.header, block_list, - reader->u.jg.toc->file[file_nr].size); + reader->u.jg.toc->streams[stream_nr].size); } static void pdb_jg_init(struct pdb_reader* reader) { reader->u.jg.header = PRD(0, sizeof(struct PDB_JG_HEADER)); - reader->read_file = pdb_jg_read_file; - reader->u.jg.toc = pdb_jg_read(reader->u.jg.header, + reader->read_stream = pdb_jg_read_stream; + reader->u.jg.toc = pdb_jg_read(reader->u.jg.header, reader->u.jg.header->toc_block, reader->u.jg.header->toc.size); - memset(reader->file_used, 0, sizeof(reader->file_used)); + memset(reader->stream_used, 0, sizeof(reader->stream_used)); } -static DWORD pdb_get_num_files(const struct pdb_reader* reader) +static DWORD pdb_get_num_streams(const struct pdb_reader* reader) { - if (reader->read_file == pdb_jg_read_file) - return reader->u.jg.toc->num_files; + if (reader->read_stream == pdb_jg_read_stream) + return reader->u.jg.toc->num_streams; else - return reader->u.ds.toc->num_files; + return reader->u.ds.toc->num_streams; } -static DWORD pdb_get_file_size(const struct pdb_reader* reader, unsigned idx) +static DWORD pdb_get_stream_size(const struct pdb_reader* reader, unsigned idx) { - if (reader->read_file == pdb_jg_read_file) - return reader->u.jg.toc->file[idx].size; + if (reader->read_stream == pdb_jg_read_stream) + return reader->u.jg.toc->streams[idx].size; else - return reader->u.ds.toc->file_size[idx]; + return reader->u.ds.toc->stream_size[idx]; } static void pdb_exit(struct pdb_reader* reader) { unsigned i, size; - unsigned char* file; + unsigned char* stream; - for (i = 0; i < pdb_get_num_files(reader); i++) + for (i = 0; i < pdb_get_num_streams(reader); i++) { - if (has_file_been_read(reader, i)) continue; + if (has_stream_been_read(reader, i)) continue; - file = reader->read_file(reader, i); - if (!file) continue; + stream = reader->read_stream(reader, i); + if (!stream) continue; - size = pdb_get_file_size(reader, i); + size = pdb_get_stream_size(reader, i); - printf("File --unused-- #%d (%x)\n", i, size); - dump_data(file, size, " "); - free(file); + printf("Stream --unused-- #%d (%x)\n", i, size); + dump_data(stream, size, " "); + free(stream); } - if (reader->read_file == pdb_jg_read_file) + if (reader->read_stream == pdb_jg_read_stream) { free((char*)reader->u.jg.root); free((char*)reader->u.jg.toc); @@ -169,7 +169,7 @@ static unsigned get_stream_by_name(struct pdb_reader* reader, const char* name) unsigned i; const char* str; - if (reader->read_file == pdb_jg_read_file) + if (reader->read_stream == pdb_jg_read_stream) { str = reader->u.jg.root->names; cbstr = reader->u.jg.root->cbNames; @@ -213,9 +213,9 @@ static PDB_STRING_TABLE* read_string_table(struct pdb_reader* reader) stream_idx = get_stream_by_name(reader, "/names"); if (stream_idx == -1) return NULL; - ret = reader->read_file(reader, stream_idx); + ret = reader->read_stream(reader, stream_idx); if (!ret) return NULL; - stream_size = pdb_get_file_size(reader, stream_idx); + stream_size = pdb_get_stream_size(reader, stream_idx); if (ret->magic == 0xeffeeffe && sizeof(*ret) + ret->length < stream_size) return ret; printf("Improper string table header (magic=%x)\n", ret->magic); dump_data((const unsigned char*)ret, stream_size, " "); @@ -290,29 +290,29 @@ static void dump_dbi_hash_table(const BYTE* root, unsigned size, const char* nam printf("%sNo header in symbols hash\n", pfx); } -static void dump_global_symbol(struct pdb_reader* reader, unsigned file) +static void dump_global_symbol(struct pdb_reader* reader, unsigned stream) { void* global = NULL; DWORD size; - global = reader->read_file(reader, file); + global = reader->read_stream(reader, stream); if (!global) return; - size = pdb_get_file_size(reader, file); + size = pdb_get_stream_size(reader, stream); dump_dbi_hash_table(global, size, "Global", ""); free(global); } -static void dump_public_symbol(struct pdb_reader* reader, unsigned file) +static void dump_public_symbol(struct pdb_reader* reader, unsigned stream) { unsigned size; DBI_PUBLIC_HEADER* hdr; - hdr = reader->read_file(reader, file); + hdr = reader->read_stream(reader, stream); if (!hdr) return; - size = pdb_get_file_size(reader, file); + size = pdb_get_stream_size(reader, stream); printf("Public symbols table: (%u)\n", size); @@ -339,7 +339,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx sidx->FPO = sidx->unk0 = sidx->unk1 = sidx->unk2 = sidx->unk3 = sidx->segments = sidx->unk4 = sidx->unk5 = sidx->unk6 = sidx->FPO_EXT = sidx->unk7 = -1; - symbols = reader->read_file(reader, 3); + symbols = reader->read_stream(reader, 3); if (!symbols) return; switch (symbols->version) @@ -357,34 +357,34 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx else sprintf(tcver, "old-%x", symbols->flags); printf("Symbols:\n" - "\tsignature: %08x\n" - "\tversion: %u\n" - "\tage: %08x\n" - "\tglobal_hash_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" - "\tsrc_module_size: %08x\n" - "\tpdbimport_size: %08x\n" - "\tresvd0: %08x\n" - "\tstream_idx_size: %08x\n" - "\tunknown2_size: %08x\n" - "\tresvd3: %04x\n" - "\tmachine: %s\n" - "\tresvd4 %08x\n", + "\tsignature: %08x\n" + "\tversion: %u\n" + "\tage: %08x\n" + "\tglobal_hash_stream: %u\n" + "\tbuilder: %s\n" + "\tpublic_stream: %u\n" + "\tbldVer: %u\n" + "\tgsym_stream: %u\n" + "\trbldVer: %u\n" + "\tmodule_size: %08x\n" + "\toffset_size: %08x\n" + "\thash_size: %08x\n" + "\tsrc_module_size: %08x\n" + "\tpdbimport_size: %08x\n" + "\tresvd0: %08x\n" + "\tstream_idx_size: %08x\n" + "\tunknown2_size: %08x\n" + "\tresvd3: %04x\n" + "\tmachine: %s\n" + "\tresvd4 %08x\n", symbols->signature, symbols->version, symbols->age, - symbols->global_hash_file, + symbols->global_hash_stream, tcver, /* from symbols->flags */ - symbols->public_file, + symbols->public_stream, symbols->bldVer, - symbols->gsym_file, + symbols->gsym_stream, symbols->rbldVer, symbols->module_size, symbols->offset_size, @@ -541,11 +541,11 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx } /* Read global symbol table */ - modimage = reader->read_file(reader, symbols->gsym_file); + modimage = reader->read_stream(reader, symbols->gsym_stream); if (modimage) { printf("\t------------globals-------------\n"); - codeview_dump_symbols(modimage, 0, pdb_get_file_size(reader, symbols->gsym_file)); + codeview_dump_symbols(modimage, 0, pdb_get_stream_size(reader, symbols->gsym_stream)); free(modimage); } @@ -553,14 +553,14 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx file = (const char*)symbols + sizeof(PDB_SYMBOLS); while (file - (const char*)symbols < sizeof(PDB_SYMBOLS) + symbols->module_size) { - int file_nr, symbol_size, lineno_size, lineno2_size; + int stream_nr, symbol_size, lineno_size, lineno2_size; const char* file_name; const char* lib_name; if (symbols->version < 19970000) { const PDB_SYMBOL_FILE* sym_file = (const PDB_SYMBOL_FILE*) file; - file_nr = sym_file->file; + stream_nr = sym_file->stream; file_name = sym_file->filename; lib_name = file_name + strlen(file_name) + 1; symbol_size = sym_file->symbol_size; @@ -579,10 +579,10 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\t\tindex: %04x\n" "\t\t\tpad2: %04x\n" "\t\tflag: %04x\n" - "\t\tfile: %04x\n" + "\t\tstream: %04x\n" "\t\tsymb size: %08x\n" "\t\tline size: %08x\n" - "\t\tline2 size: %08x\n" + "\t\tline2 size: %08x\n" "\t\tnSrcFiles: %08x\n" "\t\tattribute: %08x\n", sym_file->unknown1, @@ -594,7 +594,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx sym_file->range.index, sym_file->range.pad2, sym_file->flag, - sym_file->file, + sym_file->stream, sym_file->symbol_size, sym_file->lineno_size, sym_file->lineno2_size, @@ -605,7 +605,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx { const PDB_SYMBOL_FILE_EX* sym_file = (const PDB_SYMBOL_FILE_EX*) file; - file_nr = sym_file->file; + stream_nr = sym_file->stream; file_name = sym_file->filename; lib_name = file_name + strlen(file_name) + 1; symbol_size = sym_file->symbol_size; @@ -626,7 +626,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx "\t\t\ttimestamp: %08x\n" "\t\t\tunknown: %08x\n" "\t\tflag: %04x\n" - "\t\tfile: %04x\n" + "\t\tstream: %04x\n" "\t\tsymb size: %08x\n" "\t\tline size: %08x\n" "\t\tline2 size: %08x\n" @@ -645,7 +645,7 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx sym_file->range.timestamp, sym_file->range.unknown, sym_file->flag, - sym_file->file, + sym_file->stream, sym_file->symbol_size, sym_file->lineno_size, sym_file->lineno2_size, @@ -654,10 +654,10 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx sym_file->reserved[0], sym_file->reserved[1]); } - modimage = reader->read_file(reader, file_nr); + modimage = reader->read_stream(reader, stream_nr); if (modimage) { - int total_size = pdb_get_file_size(reader, file_nr); + int total_size = pdb_get_stream_size(reader, stream_nr); if (symbol_size) codeview_dump_symbols((const char*)modimage, sizeof(DWORD), symbol_size); @@ -677,8 +677,8 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx file = (char*)((DWORD_PTR)(lib_name + strlen(lib_name) + 1 + 3) & ~3); } - dump_global_symbol(reader, symbols->global_hash_file); - dump_public_symbol(reader, symbols->public_file); + dump_global_symbol(reader, symbols->global_hash_stream); + dump_public_symbol(reader, symbols->public_stream); free(symbols); free(filesimage); @@ -722,11 +722,11 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type const unsigned* table; PDB_STRING_TABLE* strbase; unsigned *collision; - hash = reader->read_file(reader, types->hash_file); + hash = reader->read_stream(reader, types->hash_stream); if (!hash) return; printf("Types (%s) hash:\n", strmname); - strmsize = pdb_get_file_size(reader, types->hash_file); + strmsize = pdb_get_stream_size(reader, types->hash_stream); if (types->hash_offset + types->hash_size > strmsize || (types->last_index - types->first_index) * types->hash_value_size != types->hash_size || types->search_offset + types->search_size > strmsize || @@ -838,15 +838,15 @@ static void pdb_dump_types_hash(struct pdb_reader* reader, const PDB_TYPES* type static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const char* strmname) { PDB_TYPES* types = NULL; - BOOL used = has_file_been_read(reader, strmidx); + BOOL used = has_stream_been_read(reader, strmidx); - if (pdb_get_file_size(reader, strmidx) < sizeof(*types)) + if (pdb_get_stream_size(reader, strmidx) < sizeof(*types)) { if (strmidx == 2) printf("-Too small type header\n"); return; } - types = reader->read_file(reader, strmidx); + types = reader->read_stream(reader, strmidx); if (!types) return; switch (types->version) @@ -862,7 +862,7 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch if (strmidx == 2) printf("-Unknown type info version %d\n", types->version); free(types); - if (used) clear_file_been_read(reader, strmidx); + if (used) clear_stream_been_read(reader, strmidx); return; } @@ -873,7 +873,7 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch "\tfirst_index: %x\n" "\tlast_index: %x\n" "\ttype_size: %x\n" - "\thash_file: %x\n" + "\thash_stream: %x\n" "\tpad: %x\n" "\thash_value_size: %x\n" "\thash_buckets %x\n" @@ -889,7 +889,7 @@ static void pdb_dump_types(struct pdb_reader* reader, unsigned strmidx, const ch types->first_index, types->last_index, types->type_size, - types->hash_file, + types->hash_stream, types->pad, types->hash_value_size, types->hash_num_buckets, @@ -911,8 +911,8 @@ static void pdb_dump_fpo(struct pdb_reader* reader, unsigned stream_idx) const char* frame_type[4] = {"Fpo", "Trap", "Tss", "NonFpo"}; if (stream_idx == (WORD)-1) return; - fpo = reader->read_file(reader, stream_idx); - size = pdb_get_file_size(reader, stream_idx); + fpo = reader->read_stream(reader, stream_idx); + size = pdb_get_stream_size(reader, stream_idx); if (fpo && (size % sizeof(*fpo)) == 0) { size /= sizeof(*fpo); @@ -938,8 +938,8 @@ static void pdb_dump_fpo_ext(struct pdb_reader* reader, unsigned stream_idx) strbase = read_string_table(reader); if (!strbase) return; - fpoext = reader->read_file(reader, stream_idx); - size = pdb_get_file_size(reader, stream_idx); + fpoext = reader->read_stream(reader, stream_idx); + size = pdb_get_stream_size(reader, stream_idx); if (fpoext && (size % sizeof(*fpoext)) == 0) { size /= sizeof(*fpoext); @@ -964,11 +964,11 @@ static void pdb_dump_segments(struct pdb_reader* reader, unsigned stream_idx) const char* ptr; if (stream_idx == (WORD)-1) return; - segs = reader->read_file(reader, stream_idx); + segs = reader->read_stream(reader, stream_idx); if (segs) { - size = pdb_get_file_size(reader, stream_idx); + size = pdb_get_stream_size(reader, stream_idx); for (ptr = segs; ptr < segs + size; ) { printf("Segment %s\n", ptr); @@ -993,7 +993,7 @@ static void pdb_jg_dump(void) struct pdb_reader reader; /* - * Read in TOC and well-known files + * Read in TOC and well-known streams */ pdb_jg_init(&reader); printf("Header (JG):\n" @@ -1008,7 +1008,7 @@ static void pdb_jg_dump(void) reader.u.jg.header->free_list_block, reader.u.jg.header->total_alloc); - reader.u.jg.root = reader.read_file(&reader, 1); + reader.u.jg.root = reader.read_stream(&reader, 1); if (reader.u.jg.root) { UINT *pdw, *ok_bits; @@ -1095,34 +1095,34 @@ static void* pdb_ds_read(const struct PDB_DS_HEADER* header, const UINT *block_l return buffer; } -static void* pdb_ds_read_file(struct pdb_reader* reader, DWORD file_number) +static void* pdb_ds_read_stream(struct pdb_reader* reader, DWORD stream_number) { const UINT *block_list; UINT i; - if (!reader->u.ds.toc || file_number >= reader->u.ds.toc->num_files) return NULL; + if (!reader->u.ds.toc || stream_number >= reader->u.ds.toc->num_streams) return NULL; - mark_file_been_read(reader, file_number); - if (reader->u.ds.toc->file_size[file_number] == 0 || - reader->u.ds.toc->file_size[file_number] == 0xFFFFFFFF) + mark_stream_been_read(reader, stream_number); + if (reader->u.ds.toc->stream_size[stream_number] == 0 || + reader->u.ds.toc->stream_size[stream_number] == 0xFFFFFFFF) return NULL; - block_list = reader->u.ds.toc->file_size + reader->u.ds.toc->num_files; - for (i = 0; i < file_number; i++) - block_list += (reader->u.ds.toc->file_size[i] + reader->u.ds.header->block_size - 1) / + block_list = reader->u.ds.toc->stream_size + reader->u.ds.toc->num_streams; + for (i = 0; i < stream_number; i++) + block_list += (reader->u.ds.toc->stream_size[i] + reader->u.ds.header->block_size - 1) / reader->u.ds.header->block_size; - return pdb_ds_read(reader->u.ds.header, block_list, reader->u.ds.toc->file_size[file_number]); + return pdb_ds_read(reader->u.ds.header, block_list, reader->u.ds.toc->stream_size[stream_number]); } static BOOL pdb_ds_init(struct pdb_reader* reader) { reader->u.ds.header = PRD(0, sizeof(*reader->u.ds.header)); if (!reader->u.ds.header) return FALSE; - reader->read_file = pdb_ds_read_file; + reader->read_stream = pdb_ds_read_stream; reader->u.ds.toc = pdb_ds_read(reader->u.ds.header, (const UINT *)((const char*)reader->u.ds.header + reader->u.ds.header->toc_block * reader->u.ds.header->block_size), reader->u.ds.header->toc_size); - memset(reader->file_used, 0, sizeof(reader->file_used)); + memset(reader->stream_used, 0, sizeof(reader->stream_used)); return TRUE; } @@ -1149,7 +1149,7 @@ static void pdb_ds_dump(void) reader.u.ds.header->unknown2, reader.u.ds.header->toc_block); - /* files with static indexes: + /* streams with static indexes: * 0: JG says old toc blocks * 1: root structure * 2: types @@ -1164,8 +1164,8 @@ static void pdb_ds_dump(void) * - segments * - extended FPO data */ - mark_file_been_read(&reader, 0); /* mark stream #0 as read */ - reader.u.ds.root = reader.read_file(&reader, 1); + mark_stream_been_read(&reader, 0); /* mark stream #0 as read */ + reader.u.ds.root = reader.read_stream(&reader, 1); if (reader.u.ds.root) { UINT *pdw, *ok_bits; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2079
participants (2)
-
Eric Pouech -
eric pouech (@epo)