Commit graph

1384 commits

Author SHA1 Message Date
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
Eric Pouech 75fd446272 dbghelp: Add tests about modules loading.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00
Eric Pouech 7de1284b59 dbghelp: Stop unwinding on potential 64bit frame for i386 cpu.
Transform potential error on 32 => 64 bit transition with
end of stack (needed in new wow64 for dbghelp's stackwalk tests).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00
Eric Pouech cda616d8ca winedump: Properly dump segment map information from PDB/DBI stream.
Changing field names to match better their content.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-02 10:58:21 +01:00
Eric Pouech cf71edaa4e winedump: Dump correctly ranges part of DBI stream.
The ranges describe for a PE image all the contributions
of each compilation unit towards the various sections.

Renaming offset_size into ranges_size which is closer to its actual content.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-02 10:58:07 +01:00
Eric Pouech 9a74d2b62f include: Use stream to denote MSF stream/file.
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@gmail.com>
2023-01-31 22:29:07 +01:00
Eric Pouech 26f89d84e2 include: Consistenly use _size to name the size of a sub-block.
We were using either _size or _len depending on which one.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-31 22:29:05 +01:00
Eric Pouech 71abef0906 include: Be consistent in naming regarding MSF's block.
No longer calling it sometimes 'page'.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-31 22:29:00 +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 ad21db2e1e dbghelp: Don't use dbghelp_current_cpu.
It's bound to debugger's CPU not debuggee's.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 20:14:52 +01:00
Eric Pouech 85fb74a672 dbghelp: In dwarf debug info, use the same name of anonymous UDT as pdb.
It's hard coded by msvc in PDB information, so adapt dwarf to advertize
the same.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 20:14:52 +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
Ake Rehnman 70b8461bef dbghelp: Store path to module image when passed through file handle.
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 18:25:54 +01:00
Eric Pouech 168c7a475d dbghelp: Don't search path when we have a file handle to loaded image.
When the handle to the loaded module is passed in SymLoadModule*(),
don't try to search for the module's image path and use only the file
handle.

Co-authored-by: Ake Rehnman <ake.rehnman@gmail.com>
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 18:24:09 +01:00
Alex Henrie 04225e1109 dbghelp: Annotate allocation functions with __WINE_(ALLOC_SIZE|DEALLOC|MALLOC). 2022-12-06 17:04:50 +01:00
Alex Henrie a6218a8145 include: Move wdbgexts.h from dbghelp to include.
This file is a public header in the Windows SDK.
2022-12-05 20:04:54 +01:00
Eric Pouech fbf2301177 dbghelp: Fix typos in codeview_is_type_forward().
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-22 21:51:26 +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 69108af654 dbghelp: Convert of couple more of string literals.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-21 18:03:53 +01:00
Eric Pouech b6205f57fa dbghelp: Add partial implementation of SymQueryInlineTrace.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-18 14:11: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