Module: wine
Branch: master
Commit: 29dd84443976005a8ec713dd1c75458e27346591
URL: https://source.winehq.org/git/wine.git/?a=commit;h=29dd84443976005a8ec713dd…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Wed Jun 22 16:28:09 2022 +0200
dbghelp: Use remap table from PDB hash stream.
The PDB hash stream from TPI header contains information to force a remap
to a given type record (whatever the order in the bucket hash list).
This is generated by the incremental linker in some occasions.
Use that information to remap the corresponding types.
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
---
dlls/dbghelp/msc.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 2e7336163bb..1c58b0e9cf6 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -3201,6 +3201,12 @@ static void pdb_dispose_type_parse(struct codeview_type_parse* ctp)
free((DWORD*)ctp->alloc_hash);
}
+static BOOL pdb_bitfield_is_bit_set(const unsigned* dw, unsigned len, unsigned i)
+{
+ if (i >= len * sizeof(unsigned) * 8) return FALSE;
+ return (dw[i >> 5] & (1u << (i & 31u))) != 0;
+}
+
static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg,
const struct pdb_file_info* pdb_file,
struct codeview_type_parse* ctp,
@@ -3268,6 +3274,42 @@ static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg,
ctp->alloc_hash[i - ctp->header.first_index].next = ctp->hash[hash_i];
ctp->hash[hash_i] = &ctp->alloc_hash[i - ctp->header.first_index];
}
+ /* 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)
+ {
+ const unsigned* remap = (const unsigned*)((const BYTE*)ctp->hash_stream + ctp->header.type_remap_offset);
+ unsigned i, capa, count_present;
+ const unsigned* present_bitset;
+ remap++; /* no need of num */
+ capa = *remap++;
+ count_present = *remap++;
+ present_bitset = remap;
+ remap += count_present;
+ remap += *remap + 1; /* skip deleted bit set */
+ for (i = 0; i < capa; ++i)
+ {
+ if (pdb_bitfield_is_bit_set(present_bitset, count_present, i))
+ {
+ unsigned hash_i;
+ struct hash_link** phl;
+ /* remap[0] is an offset for a string in /string stream, followed by type_id to force */
+ hash_i = pdb_read_hash_value(ctp, remap[1]);
+ for (phl = &ctp->hash[hash_i]; *phl; phl = &(*phl)->next)
+ if ((*phl)->id == remap[1])
+ {
+ struct hash_link* hl = *phl;
+ /* move hl node at first position of its hash bucket */
+ *phl = hl->next;
+ hl->next = ctp->hash[hash_i];
+ ctp->hash[hash_i] = hl;
+ break;
+ }
+ remap += 2;
+ }
+ }
+ }
return TRUE;
oom:
pdb_dispose_type_parse(ctp);
Module: wine
Branch: master
Commit: d12d5c7245635c9df26505c8b1aa3080404ca616
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d12d5c7245635c9df26505c8…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Wed Jun 22 16:28:09 2022 +0200
dbghelp: Preserve PDB's partial order for types of same name.
The PDB types can contain several times a type definition with an identical
name. It seems to appear when modifying a type in source (like adding new
fields to a struct):
- as the PDB file (generated from first compilation) is updated (and not
fully rewritten), the debug information for the old type is not flushed;
a new record (for the same struct name) is emitted, and inserted
before the old one in the hash table (bucket list).
Even if dbghelp's hash table is different from PDB's internal one (ie
number of buckets & bucket lists are different), we must maintain the order
of records of identical names (they end up in the same bucket) as a lookup
by name *must* return the first record in PDB's order.
Lookup by name is used:
- when resolving a forward definition (to get the full UDT definition
including for example a struct/class fields's list)
- when searching by type name from dbghelp APIs, like SymGetTypeFromName()
This patch implements the preservation of that order.
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
---
dlls/dbghelp/msc.c | 373 ++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 284 insertions(+), 89 deletions(-)
Diff: https://source.winehq.org/git/wine.git/?a=commitdiff;h=d12d5c7245635c9df265…
Module: wine
Branch: master
Commit: ddbd341bd0baa663338326246e2b05d8651743ff
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ddbd341bd0baa66333832624…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Wed Jun 22 16:28:09 2022 +0200
dbghelp: Clearly separate the type loading into two passes.
- create (contentless) UDT & enum in first pass
- fill UDT&enum content and load the rest of types in second pass.
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
---
dlls/dbghelp/msc.c | 491 +++++++++++++++++++++++++++--------------------------
1 file changed, 246 insertions(+), 245 deletions(-)
Diff: https://source.winehq.org/git/wine.git/?a=commitdiff;h=ddbd341bd0baa6633383…
Module: wine
Branch: master
Commit: b7c231c78f84402b47c79ba744884c32ca2a8323
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b7c231c78f84402b47c79ba7…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Wed Jun 22 16:28:08 2022 +0200
dbghelp: Rely on first/last type index from type header.
Code now follows these guidelines:
- define PDB & Codeview internals in cvconst.h and mscvinfo.h (instead
of having definitions in .c files, some of them being duplicate of .h
content, and their "duplicate" values eventually diverged over time)
- index of first type comes from PDB type header (instead of always being
hardcoded as FIRST_DEFINABLE_TYPE)
- use index of last typex from type header (instead of guessing the right
value while parsing types, which also allows a single allocation
instead of enlarging buffer while parsing).
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
---
dlls/dbghelp/msc.c | 108 ++++++++++++++++++++++---------------------------
include/wine/mscvpdb.h | 3 +-
2 files changed, 50 insertions(+), 61 deletions(-)
Diff: https://source.winehq.org/git/wine.git/?a=commitdiff;h=b7c231c78f84402b47c7…