Commit graph

1405 commits

Author SHA1 Message Date
Eric Pouech
5f9119447c dbghelp: Use nameless union/structs.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-07-06 20:54:30 +02:00
Jacek Caban
439a36e33a dbghelp: Use V_INT macro to access VARIANT value. 2023-07-06 20:54:30 +02:00
Alexandre Julliard
03ce134d6f dbghelp: Use nameless union/structs. 2023-07-05 17:03:30 +02:00
Eric Pouech
f93d7114c7 dbghelp/tests: Use indirect call for SymSetExtendedOption.
(sigh 1d281c62 was incomplete).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55128
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-30 17:35:48 +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
1d281c620d dbghelp/tests: Don't call SymSetExtendedOption() directly.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55128
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-26 20:20:27 +02:00
Eric Pouech
bbc2a9ab5b dbghelp: Implement SymSrvGetFileIndexInfo for PDB files.
Only done for DS format.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-26 16:49:45 +02:00
Eric Pouech
f4c1860480 dbghelp: Add tests for SymSrvGetFileIndexInfo() for PDB files.
Add infrastructure to generate fake .PDB files.

Only done in DS format.

I'm not sure we care about JG anymore, DS format has been introduced
by MS in early 2000 to supersede JG, and is still mainstream today).
For the record, LLVM in its PDB handling doesn't support JG format.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-26 16:49:45 +02:00
Eric Pouech
eb1f62bb31 dbghelp: Fix reading Wine loader's base address.
Note: the 32bit tests in new wow mode are still marked
todo as the ELF debug header is located above the 4G limit
and "default" module management in dbghelp compiled in 32bit
is (mostly) done with 32 bit addresses.
The correct fix should be to always consider ELF (and macho-O)
modules with 64bit addresses (which means likely to move all
modules handling to 64bit even in 32bit compilations).
But that goes far beyond this patch.

This limitation will only impact debuggers compiled in 32bit,
using 32bit builtin dbghelp on a 32bit debuggee.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55058
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55096
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-23 11:28:19 +02:00
Eric Pouech
1ed646ebf6 dbghelp/tests: Add explicit tests about loading ELF modules.
Perhaps next time ELF loader is modified, it'll be noticed if it breaks
things.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55058
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55096
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-23 11:28:08 +02:00
Eric Pouech
5efe29edc0 dbghelp: Implement SymSrvGetFileIndexInfo for PE modules.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-06-20 20:29:53 +02:00
Eric Pouech
4d32b2ee30 dbghelp/tests: Add tests for SymSrvGetInfoIndexes.
Tests related to debug directories.
Extending the PE image generator with debug directories.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-20 20:29:52 +02:00
Eric Pouech
954f302f70 dbghelp/tests: Add tests for SymSrvGetIndexesInfo.
Tests on PE image (header part, no debug directory).
Add infrastructure to generate PE image (derived from
kernel32/tests/loader.c).

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-20 20:29:49 +02:00
Eric Pouech
1f437ed89a dbghelp: Create implementation basis for SymSrvGetFileIndex*().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-06-20 20:29:48 +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
79bae0ed37 dbghelp/tests: Add more tests for module imagename handling.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-06-02 20:47:25 +02:00
Eric Pouech
ed532a36b3 dbghelp/tests: Review old-wow64 expected values.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-06-02 20:47:01 +02:00
Eric Pouech
76d922983d dbghelp/tests: Fix process kind detection on old Windows machines.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-06-02 20:35:53 +02:00
Michael Stefaniuc
cf3815dc59 dbghelp: Remove superfluous casts to self. 2023-06-01 22:00:19 +02:00
Eric Pouech
542ccaaf84 dbghelp: Better handle very long C++ qualified identifiers in dwarf.
This fixes some crashes especially when dealing with very long C++ names
(like template classes).

Fortunately, dwarf internals don't require type lookup by name (eg.
on forward declaration), so the impact of thrashing some names is limited.

It's very likely native doesn't store directly these very long names
(it could either store the qualified mangled name - which can be way shorter
for template classes - or use the names in lexical hierarchy: both boil down
to storing less information, and recompute it (unmangle or class hierarchy
walk) upon request).
But this would need a proper C++ support in dbghelp. Not for today.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-05-30 20:56:31 +02:00
Eric Pouech
812b4b1ca3 dbghelp: Use source file path as stored in debug info format.
Currently, dbghelp returns the source file either:
- in DOS format when native module option isn't enabled
- as stored in debug info format otherwise

This used to work for PE modules inside ELF shared libraries but is broken
since evolution to REAL modules. This generates several issues:
- winedbg does not always set the native module option when calling dbghelp
  for source file related functions, leading to heterogenous output to user
- some dbghelp function rely on matching source paths, hence leading to
  errors in winedbg when mixing the two formats for the same source file.

Introduce a new Wine only dbghelp option to return the source paths as they
are stored inside debug information format, and activate it unconditionaly
inside winedbg.

This fixes some failure cases of command 'break <NN>' in winedbg.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-04-18 18:17:44 +02:00
Eric Pouech
13afaa7c16 dbghelp/tests: Use msinfo32.exe instead of notepad.exe.
Under Windows 11, notepad.exe has been migrated into the UWP framework,
and can no longer be launched as a 32bit process:
- even if c:\windows\syswow64\notepad.exe is still a 32 bit PE file
- the process created from c:\windows\syswow64\notepad.exe is not a
  wow64 process.

So use msinfo32.exe instead. Like notepad.exe, it's a gui application,
present on Wine and all test-bot:ed windows platforms. But unlike
notepad.exe, it's not an UWP app on Windows 11.

(May not fully fix all the bugs below, but will get rid of a bunch
 of errors).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54535
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54536
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54537
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 18:08:23 +01:00
Eric Pouech
5477ee640b dbghelp: Fix vdso.so lookup.
- should have been fixed when libwine.so has been removed
- code was broken anyway
- enhanced protect against error when reading debuggee's memory

Introducing helper to correctly read pointer's from debuggee
(and other integral values).

vdso is now listed in ELF's module list (except if Wine's preloader
removes it from auxilary vector)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 17:49:00 +01: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
0f98972fe2 dbghelp/tests: Add tests for SymRefreshModuleList() on non-live target.
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
e1f41c0a17 dbghelp/tests: Preserve last error in process_get_kind().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 17:49:00 +01:00
Eric Pouech
2d3b6d03fe dbghelp/tests: Better use global variables.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-03-08 17:49:00 +01:00
Francois Gouget
ed6ab3222e dbghelp/tests: Let the tests run on Windows 7, 8 and 10 <= 1607.
Provide a fallback if IsWow64Process2() is not available.

Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54605
2023-03-07 17:25:08 +01:00
Eric Pouech
291daf542d dbghelp/tests: Fix tests for process count in wow64.
Introduce get_process_kind() to discriminate configurations.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-27 16:36:22 +01:00
Eric Pouech
8aea039507 dbghelp/tests: Introduce get_machine_bitness() helper.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-27 16:36:22 +01:00
Eric Pouech
160d961e32 dbghelp/tests: Only retrieve the system directories once.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-27 16:36:22 +01:00
Eric Pouech
91a644ae8a dbghelp/tests: Introduce ends_withW helper.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-27 16:36:22 +01:00
Eric Pouech
fbe23dafe1 dbghelp/tests: Adapt test_modules_overlap() for Windows 11.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54535
2023-02-27 16:36:22 +01:00
Eric Pouech
394361cdd0 dbghelp/tests: Add wrapper for EnumerateLoadedModulesW64().
Since this API sporadically fails with STATUS_INFO_LENGTH_MISMATCH
as GetLastError() (sic!) on Windows 11, retrying the call let us get
the relevant output.

No clear explanation of the cause of the failure, it's maybe generated
when modules are still loaded into child process and it detects
modification of the modules' list while enumerating all modules.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-27 16:36:22 +01:00
Eric Pouech
3bbb2caf08 dbghelp/tests: Fix failure on Win10 1607.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54534
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-22 18:04:39 +01:00
Eric Pouech
e138361f48 dbghelp/tests: Test that overlapped module is really unloaded.
(and not just modified in place).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-20 23:00:33 +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
c823f9b1a8 dbghelp/tests: Add some more tests about module handling.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:29 +01:00
Eric Pouech
db514b718a dbghelp/tests: Add test for loaded modules enumeration.
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
8be5c10ff8 dbghelp/tests: Add tests for 'module' name in EnumLoadedModules() callback.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:28 +01:00
Eric Pouech
82b26c5033 dbghelp/tests: Test return value of SymLoadModule.
It's supposed to be the base address of the module.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-17 18:59:28 +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
Francois Gouget
d9ccc8664c dbghelp: Fix a typo in a comment. 2023-02-14 09:58:03 +01:00
Eric Pouech
452041927f dbghelp: Fix failing test on Windows 7.
Using old versions of the module information structure.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54465
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-10 19:09:16 +01:00
Eric Pouech
a958b5aebf dbghelp: Identify a 32bit multi-arch wow64 debuggee as a live target.
Note: from now on, winedbg will 'see' the ELF 64 bit modules (not yet
the PE ones) in multi-arch wow64 use case.
Modules can be displayed in 'info wow share' command and their debug
information is loaded.
Stack manipulation and backtracking are not available.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:45 +01:00
Eric Pouech
aac4e9df0a dbghelp: Filter on machine when searching for Wine system PE modules.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00
Eric Pouech
4d2cbb4104 dbghelp: Allow loading modules for different machines.
SYMOPT_INCLUDE_32BIT_MODULES option applies when enumerating
loaded modules, but not when actually loading debug information for
a module.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00