Commit graph

233 commits

Author SHA1 Message Date
Alex Henrie 04225e1109 dbghelp: Annotate allocation functions with __WINE_(ALLOC_SIZE|DEALLOC|MALLOC). 2022-12-06 17:04:50 +01:00
Eric Pouech c99bafb775 dbghelp: Implement SymAddrIncludeInlineTrace().
Replacing symt_get_inlinesite_depth() with SymAddrIncludeInlineTrace()
as they look very (very) similar.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-18 14:11:50 +01:00
Eric Pouech 1ed24f7ec6 dbghelp: Support loading modules from Wine's multi-arch build tree.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-09 21:23:48 +01:00
Eric Pouech e6fd3021ba dbghelp: Added missing DECLSPEC_HIDDEN attribute.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-09 21:23:48 +01:00
Eric Pouech c4f1f5b185 dbghelp: Get rid of symt_inlinesite by merging it inside symt_function.
Basically:
- extending symt_function to enable storage of multiple address ranges
- symt_function and sym_inlinesite now share the same fields, so
  get rid to the later.

Note that only the first range of a top level function is actually
stored and used (even if the structure allows for more).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-01 17:53:57 +01:00
Eric Pouech 790a2852aa dbghelp: Use addr_range for storing symt_function address and size.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-01 17:53:57 +01:00
Eric Pouech c576b0c73f dbghelp: Store address range as FAM in symt_inlinesite.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-01 17:53:57 +01:00
Eric Pouech a6f1f7be7e dbghelp: No longer pass inline site's address upon creation.
Instead use the first address of the first defined range of address.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-01 17:53:51 +01:00
Eric Pouech 363f1f49a8 dbghelp: Realloc array of buckets inside struct vector.
Instead of silently leaking no longer used chunks.
Be more robust to OOM conditions.
Introducing pool_realloc().

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-10-21 23:18:06 +02:00
Eric Pouech c5f4874e7b dbghelp: Use heap functions for allocation.
Create a dedicated heap for each module (as it was done for the
private home grown pools).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-10-21 23:18:06 +02:00
Francois Gouget 0eb40cdbd0 dbghelp: Fix the spelling of a couple of comments. 2022-10-20 20:58:06 +02:00
Eric Pouech 3dee69106a dbghelp: Allow symt_block to be defined over non contiguous chunks.
This improves correctness of functions like SymFromAddr()
when searching local variables.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-10-19 21:07:27 +02:00
Eric Pouech 1bcdb17455 dbghelp: Remove symt_close_func_block() stabs's only parameter.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-10-10 11:11:21 +02:00
Eric Pouech b990eaa8a6 dbghelp: Expose local static variables' address.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-09-30 21:20:19 +02:00
Eric Pouech 99eb63bd7a dbghelp: Remove address field from symt_compiland.
It's mostly always set at 0, and native dbghelp doesn't expose it anyway.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-09-30 21:20:09 +02:00
Eric Pouech 14462bbeab dbghelp: Let symt_basic be trans-module and nameless.
Rationale:
- native doesn't report names for SymTagBaseType objects
  => so remove typename for sym_basic
- since symt_basic becomes pretty simple, it's possible to share the object
  across all modules loaded in dbghelp (simplicity, memory usage reduction)
- removed dwarf basic types cache in dwarf.c as we now have a generic one

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Eric Pouech 99c7818097 dbghelp: Introduce symt_find_symbol_at().
To be used in place of symt_find_nearest().
symt_find_symbol_at() ensures that the address passed is within the
boundaries of the returned symbol (while find_nearest() doesn't).

This fixes erroneous backtraces in debugger like:
$ ./wine winedbg notepad
WineDbg starting on pid 0104
RtlDefaultNpAcl () at Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731
0x00000170054805 ntdll+0x54805 [Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731]: ret
1731    }
Wine-dbg>bt
Backtrace:
=>0 0x00000170054805 RtlDefaultNpAcl+0x2d5(pAcl=<internal error>) [Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731] in ntdll (0x000001700701a4)
  1 0x0000017002d6c4 __wine_pop_frame(pAcl=<internal error>) [Z:\home\eric\work\wine\include\wine\exception.h:273] in ntdll (0x000001700701a4)
  2 0x0000017002d6c4 process_breakpoint+0x84() [Z:\home\eric\work\wine\dlls\ntdll\loader.c:3912] in ntdll (0x000001700701a4)
  3 0x000001700354c9 LdrInitializeThunk+0x509(context=<register R13 not accessible in this frame>, unknown2=<internal error>, unknown3=<internal error>, unknown4=<internal error>) [Z:\home\eric\work\wine\dlls\ntdll\loader.c:4200] in ntdll (0x000001700701a4)

where RtlDefaultNpAcl() has nothing to do here (it's the symbol below RIP
and we don't have a symbol with debug information for that address).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 21:27:25 +02:00
Alexandre Julliard 53ab4c5385 include: Avoid Windows types in CodeView structure definitions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-22 16:01:54 +02:00
Eric Pouech d72e6ac772 dbghelp: Attach a struct cpu* to every module.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-08 21:00:57 +01:00
Eric Pouech 5f9bcb13b7 mscvpdb.h: Move parsing definitions to dbghelp.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-02 20:32:51 +01:00
Eric Pouech 0187675065 dbghelp: Rename line_info's pc_offset field into address.
It's actually an absolute address.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-29 21:27:23 +02:00
Eric Pouech eee701ad52 dbghelp: Implement SymFromInlineContext for inlined frames.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-28 18:25:16 +02:00
Eric Pouech 82bac5d080 dbghelp: Implement StackWalkEx for inlined frames.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-28 18:25:16 +02:00
Eric Pouech fb34c82ef8 dbghelp/dwarf: Store each subrange for an inlined function.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-28 18:25:16 +02:00
Eric Pouech 690c2e51bf dbghelp/dwarf: Generate proper inline functions.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-28 18:25:16 +02:00
Eric Pouech b9290c987a dbghelp: Introduce symt_inlinesite (SymTagInlineSite) to support inline sites.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-28 18:25:16 +02:00
Eric Pouech 066bb761cc dbghelp: Add local scope information in struct process.
- make SymSetContext() generate this information
- let SymEnumSymboli() (when dealing with local symbols) use this
  information instead of the stack frame

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-27 22:40:50 +02:00
Eric Pouech 219e4b6e75 dbghelp: Implement SymFromInlineContext() when context isn't in inline mode.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-27 22:40:50 +02:00
Eric Pouech d3a876f172 dbghelp: Use wide string literals.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-19 20:55:41 +02:00
Eric Pouech 099a8bbfd3 dbghelp: Add helper to initialize a module_pair.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-13 22:52:25 +02:00
Eric Pouech b6044788ea dbghelp: Added support for custom symbols.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-06 20:29:34 +02:00
Eric Pouech dbcc714cef dbghelp: SymTagFunctionArgType's lexical parent is module, not SymTagFunctionType.
(as any other type)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-06 20:29:34 +02:00
Eric Pouech 24a7de70a6 dbghelp: Manage parent/child relationship between SymTagExe and SymTagCompiland.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-06 20:29:34 +02:00
Eric Pouech dd67b78ed3 dbghelp/dwarf: Add support for local variables with constant values.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-28 21:48:59 +02:00
Eric Pouech d648dcd3a6 dbghelp/dwarf: Share compilation unit header information.
Store cu information for dwarf content
- in each compiland
- and queue the unique one's inside the module.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-09 22:31:54 +02:00
Eric Pouech cee52d5988 dbghelp: Get rid of useless symt_normalize_func().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-07 23:19:22 +02:00
Eric Pouech d459301de6 dbghelp: Make symt_fill_func_line_info() and symt_get_func_line_next() static functions inside symbol.c.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-07 23:19:22 +02:00
Eric Pouech ffc3efe775 dbghelp: Manage the new MachineType field in IMAGEHLP_MODULE(W)64.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-06 17:59:11 +02:00
Eric Pouech a4b206b384 dbghelp: Handle the case where loader isn't what WINELOADER reports.
use case, in a WoW setup:
	wine programs/winedbg/winedbg.exe.so notepad.exe
where both winedbg and notepad are 64bit exec:s

in this case, dbghelp (loaded from winedbg) reads '<...>/wine' from WINELOADER
windows env block inside notepad
(but the unix env block is correctly set to wine64 by the tweak in
ntdll/unix/loader.c)

as a consequence dbghelp doesn't get the ELF information (it tries to read 32bit
ELF entities, and fails); hence misses all the loaded ELF libraries
winedbg's command 'info share' only reports the PE modules

note: the 'dual' case
  wine64 programs/winedbg/winedbg.exe.so c:\\windows\\syswow64\\notepad.exe
  where winedbg is a 64bit exec and notepad a 32bit
  shows the same failures

workaround this in dbghelp by tweaking the value of WINELOADER whether
the debuggee is 32 or 64bit

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-03 13:51:04 +02:00
Eric Pouech c8fede5efb dbghelp: Check correctness of type (esp. in case of unknown ones).
Since with the unknown type entry, we can end up with types which don't
match the expected symt->tag, we need to check before the conversions.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-03 13:50:14 +02:00
Eric Pouech 35c45857ae dbghelp: Tidy up internals for array type.
Mainly remove hackish storage of information with negative value and
use a uniform min/count pair for all debug formats.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 21:21:49 +02:00
Eric Pouech 46c12b2971 dbghelp: Enums should be found by name (as UDTs are).
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-30 22:49:58 +02:00
Eric Pouech 2325962e74 dbghelp: Return the stored name for a compiland.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-30 22:49:58 +02:00
Eric Pouech 1fa1620086 dbghelp: Introduce internal type (symt_module) to match SymTagExe.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-30 22:49:58 +02:00
Eric Pouech 3ed209e0d9 dbghelp: Correctly store and report bitfield information.
Bitfield information must be stored relative to first byte
of underlying integral type. We were storing the information
always relative to the first containing byte.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-30 22:49:58 +02:00
Eric Pouech d268cb028a dbghelp: Fix NameLen usage in SYMBOL_INFO(W).
SYMBOL_INFO.NameLen should be the actual length of the symbol, not the
length of the (potentially truncated) string returned in
SYMBOL_INFO.Name. Add an helper (symbol_setname) to set those fields
properly.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-30 22:49:58 +02:00
Alexandre Julliard e2659819b8 include: Always define 32- and 64-bit versions of the TEB and PEB structures.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-05 15:53:19 +01:00
Jacek Caban 310019789f dbghelp: Use WINELOADER environment variable from debuggee process in get_wine_loader_name.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49838
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-12-08 22:25:59 +01:00
Jacek Caban 7b6f6257bc dbghelp: Use debuggee environment in search_unix_path.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-13 22:07:32 +02:00
Jacek Caban 2b0977fc71 dbghelp: Use debuggee environment variables in search_dll_path.
This fixes searching wow32 binaries, where debuggee search path is
different than debugger's.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-09 21:04:05 +02:00