Commit graph

192 commits

Author SHA1 Message Date
Eric Pouech 6ab88cafaa dbghelp: Don't fail in SymAddSymbol for modules without debug information.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-03-07 22:56:12 +01:00
Eric Pouech 61f9f5a05f dbghelp: Support SLMFLAG_NO_SYMBOLS in SymLoadModuleEx*().
Also correctly handling ImageName (the passed image name
in SymLoadModule) and LoadedImageName, which is only set when
debug info have been loaded (and is always an absolute path,
contrary to ImageName which can be relative).

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-03-07 22:56:12 +01:00
Eric Pouech 83476e3d4a dbghelp: Fix some corner case of virtual module loading.
Seen when debugging some game, one can load a virtual module with
a NULL image name.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-03-06 22:05:51 +01:00
Eric Pouech 4f80a599b6 dbghelp: Mimic native behavior for module name.
Module names appear in three spots in dbghelp:
  A) SymGetModuleInfo() .ModuleName
  B) module enumeration (as parameter in callback)
  C) in symbol/type research in module!name form

Tests show that:
- A) and B) always use only the derivation of the image
  name, whatever the passed module name in SymLoadModule().
- C) can use either the form derived from image name
  {as A) and B)}, but also the passed module name in
  SymLoadModule().

Note: B) is limited to 64 characters, while A) is limited to 32
characters (not tested here).

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-03-06 22:05:49 +01:00
Eric Pouech d6d22677da dbghelp: Change order when trying to load modules.
Change from: dll.so   > PE image > ELF/Mach-O images
into         PE image > dll.so   > ELF/Mach-O images

Main goal is in SymLoadModule*(), to not resynchronize the system
modules list when requesting loading of a PE image.
This can gain quite some time in some situations.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-03-06 22:05:47 +01:00
Eric Pouech 7b0d974439 dbghelp: Fix some tests for SymLoadModule*().
On top of being closer to native behavior, this helps some
games where:
- they use dbghelp to gather information of where they generate exceptions,
- they generate exception in the game play,
- and refresh their list of loaded modules in dbghelp.

This can generate some delays (~2ms per module), which affects
game play (freeze, slugginess...).

Credit to Paul Gofman for triaging this.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-12-18 22:26:11 +01:00
Eric Pouech 60108ea1bc dbghelp: Pretend mach-o is present in case of failure.
On MacOs, starting with Big Sur 11.0.1, the system dynamic
libraries are no longer directly accessible on disk.
They are still available through dlopen and friends. For getting
access to the images (and their debug symbol), Apple provides,
in the developper kit, the tools to extract the files. Note that
this is handled as a database of all system libraries, where ASLR
is in place such that segments of a given library are no longer
contiguous in memory (dbghelp doesn't currently handle this).

Apart from not having image information nor debug information,
another side effect is that dbghelp tries every time it refreshes the
mach-o module list to reload any library for which it didn't have
an image file. This can be lengthy (esp when a typical process has
more than 300 modules loaded).

This patch forces the creation of the dbghelp module even if the
image file isn't found.

This patch cuts startup time of 'winedbg notepad' from 9.9 to 7.4s.
YMMV.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-11-16 20:56:07 +01:00
Eric Pouech 01c98c5eaf dbghelp: Expose PE native vs builtin information to winedbg.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-11-16 20:56:07 +01:00
Eric Pouech 8d75739b6a dbghelp: No longer decorate ELF/Mach-O module names.
Rely solely on extended module information.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-11-16 20:56:04 +01:00
Eric Pouech c50e02ec9c dbghelp: Expose some internal information about modules to winedbg.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-11-16 20:56:03 +01:00
Eric Pouech 43598133e6 dbghelp: Remove unneeded parameter to pe_map_file.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-10-18 11:01:56 +02:00
Eric Pouech d4104e8505 dbghelp: Simplified module_find_by_addr().
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-10-18 11:01:56 +02:00
Eric Pouech d6096057f5 dbghelp: Rename internal field (system -> host).
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-10-18 11:01:50 +02:00
Eric Pouech 776ba1304e dbghelp: Don't insert dwz file map into module's file maps' chain.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-09-15 21:15:28 +02:00
Alex Henrie 00df1bea9a dbghelp: Allocate real_path with the CRT and copy it to the module heap.
Fixes both a memory leak and an alloc/free mismatch, and the module heap
is the most appropriate place to hold the variable long-term.
2023-06-27 11:58:05 +02:00
Eric Pouech af7b97e780 dbghelp: Reimplement EnumerateLoadedModules().
- correctly taking into accoung SYMOPT_INCLUDE_32BIT_MODULES option
- converting, for 32bit modules requested from a 64bit module,
  the system32 paths into syswow64

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-06-02 20:47:28 +02:00
Eric Pouech 9877ba9732 dbghelp: Don't set ELF loader when wine's loader isn't accessible.
For dbghelp in 32-bit, when accessing a live debuggee in multi-arch
configuration, Wine's ELF loader is likely mapped above 4G, hence
not accessible with 32bit Windows APIs.
So don't try to expose the ELF libraries in that case.
Introducing a new loader operation class to support live targets, for
which system operations are not accessible, but pretending they are
successful.

Note:
- when Wine's loader ELF module isn't registered by dbghelp,
  any other ELF module will not be registered by dbghelp.
- further work may be needed for winedbg in auto mode (launched with
  AeDebug key on process exception) as in that mode winedbg
  doesn't relaunch itself in 64bit, so won't be able to access
  (64bit) ELF information (in multi-arch configuration).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 17:49:00 +01:00
Eric Pouech aabb4e12bc dbghelp: Use 'wine' as loader on multi-arch configuration.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 17:49:00 +01:00
Eric Pouech 32bc569520 dbghelp: Unload overlapping modules in SymLoadModule*().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:29 +01:00
Eric Pouech 5654af818a dbghelp: Add new module at end of the process' modules list.
This preserves order in which modules are loaded, and enumeration
is done according to this order.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:29 +01:00
Eric Pouech 45d01be56a dbghelp: Let EnumerateLoadedModules() expose image names.
Even is MSDN states that it enumerates modules' name, the first parameter
to the callback is the fullpath to the image.
So
- fix EnumerateLoadedModules() to pass the image name for the
  considered module
- fix all callbacks in Wine code to EnumerateLoadedModules to
  handle the image name instead of module name

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:29 +01:00
Eric Pouech 82e3e014be dbghelp: Use EnumProcessModulesEx().
In order to get 32bit modules for a wow64 process.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-15 21:48:33 +01:00
Alex Henrie 7a441eafb4 dbghelp: Handle memory allocation failure in image_locate_build_id_target (cppcheck). 2023-01-24 22:12:36 +01:00
Eric Pouech a89975f731 dbghelp: Expose the real path to the module in SymGetModuleInfo*().
Expose the real path of a loaded module (potentially read from
WINEDLLDIR or WINEBUILDDIR or overriden load order or ...).  This
improves gdb integration by passing the real path to the loaded
modules (instead of the paths in c:\windows\ system subdirectories).
Introduce new Wine only dbghelp's extended option to enable the
feature.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54250
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 18:25:58 +01:00
Eric Pouech 4119430e57 dbghelp: Locate alternate debug info files by their build id.
(including debuginfo client cache)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-21 18:03:53 +01:00
Eric Pouech b718fbc31f dbghelp: Search debug info files into local cache of debuginfod.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-21 18:03:53 +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 106a056c99 dbghelp: No longer use wine_dbgstr_longlong.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-10-10 11:11:15 +02:00
Eric Pouech 25108ba266 dbghelp: Fix local scope reset upon module unloading.
Change strategy for resetting local scope when unloading a module.
Old strategy was keeping the local scoped symbol alive on some code path when
unloading a module.
This caused some bad behavior as we kept a pointer to a deleted object.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-09-26 21:49:54 +02:00
Eric Pouech a64d157928 dbghelp: Enable compilation with long types.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-09 18:37:32 +01:00
Alistair Leslie-Hughes e19b18dd82 dbghelp: Fix use after free.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-13 18:02:58 +01:00
Eric Pouech 9f1766193e dbghelp: Simplify code for searching alternate debug info files.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Eric Pouech 789512beee dbghelp: Fix allocation error in image_load_debugaltlink.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Eric Pouech f10635ab08 dbghelp: In SymEnumerateLoadedModules, don't limit the number of modules.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Eric Pouech 4cc7a3ba90 dbghelp: Remove incorrect FIXME in SymEnumerateLoadedModules.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Eric Pouech 5e56bc3b21 dbghelp: Fix potential crash when loading a builtin PE module embedded in an ELF image.
Regression introduced by ced12a1a3a.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Eric Pouech b65ef71fc0 dbghelp: Improve collision handling in SymLoadModuleEx().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-16 22:14:54 +01:00
Eric Pouech 1465c7de2a dbghelp: Detect collision by looking at module's base address in SymLoadModuleEx().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-16 22:14:40 +01:00
Eric Pouech ced12a1a3a dbghelp: Move debug info loading out of image backends into SymLoadModuleEx().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-16 22:14:24 +01:00
Eric Pouech 1b7bce4bf8 dbghelp: Allow 32bit dbghelp to handle 64 addresses.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-16 22:14:05 +01:00
Eric Pouech e00f0d81fb dbghelp: Fix module name construction.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-16 22:13:45 +01:00
Eric Pouech 9f3e8a515f dbghelp: Use cpu from debuggee's modules rather than debugger's.
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 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 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 8f272e25af dbghelp: Factorize SymUnloadModule and SymUnloadModule64.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-19 20:59:07 +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 e5dbf5f74e dbghelp: Added support for locating a .dwz file (GNU extension) attached to a debug file.
A DWZ file contains additional Dwarf debug information, and can be shared
across several debug info files.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-16 22:22:44 +02:00
Eric Pouech fc380e0691 dbghelp: Separate alternate debug file lookup functions.
Split in two different (and disjoint) the functions for checking that
an alternate debug file matches the expected one
- the first based on crc
- the second based on GNU build-id

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-16 22:22:44 +02:00