Commit graph

926 commits

Author SHA1 Message Date
Eric Pouech 1d53204ebf winedbg: Print all pid and tid with 4 hex characters.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-01-17 10:59:15 +01:00
Eric Pouech edb38d15c5 winedbg: Make some internal data 'static const'.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-01-17 10:59:10 +01:00
Eric Pouech b12c1eaea6 winedbg: Wait for gdb to terminate before exiting (proxy mode).
This mainly allows Wine to reset the tty settings upon
termination and not let gdb do it (cf bug report).

Change: user is now required to explicitely terminate gdb
('quit' command) upon debuggee termination.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56032
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-01-04 12:19:01 +01:00
Eric Pouech 8cbf27659b winedbg: Fix main module detection in 'info share' command.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-12-22 21:50:55 +01:00
Bernhard Übelacker b0db6cfd4d winedbg: Retrieve module architecture before sorting.
This should avoid getting i386 when the process really is x86_64,
with just a single i386 module loaded.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56048
2023-12-19 21:41:02 +01:00
Eric Pouech 8a94049770 winedbg: Use dbghelp extended module info.
To pickup module's data model.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-11-24 16:47:19 +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
Alexandre Julliard 4e9f1a41b9 makefiles: Always use the global SOURCES variable for .man.in files. 2023-10-14 13:44:07 +02:00
Eric Pouech 44ab120661 winedbg: Correctly read LDT entries for wow64 debuggee.
This mostly matters for Mac as segment CS is handled as a real LDT
entry.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-10-13 18:04:36 +02:00
Eric Pouech 91ba80df26 winedbg: Set first LDT entry value as ntdll does.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-10-13 18:04:36 +02:00
Eric Pouech fdd1c1c776 winedbg: Detect debuggee termination before first exception.
When a crash in a program happens, and the debugger in launched in --auto
mode, in some cases the program terminates before the debugger has gotten
proper context on debuggee.
(Could be a watchdog in programs checking if it's debugged and terminating
itself if so).

Detect debuggee termination and still provide some information on debuggee
(threads, modules, system info). The backtrace will not be available as
no exception is gotten from debuggee.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55187
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-07-07 12:20:23 +02:00
Eric Pouech 7ada0e2239 winedbg: Add 'info system' command.
Letting the information displayed in '--auto' mode be available
as a command.
Simplify a bit the --auto mode handling.

Note:
- the WOW64 status of the debuggee used to be printed in system
  information, which is a bit ackward as system info shouldn't be
  tied to a given process.
- replaced it with supported guest machines (for the record, a
  64-bit only setup incorrectly returns i386 as supported guest;
  I guess we shouldn't care).
- now printing the wow64 status of a process when displaying an
  exception information instead.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-07-07 12:19:42 +02:00
Eric Pouech bde065746e winedbg: Cache wow64 status inside struct process.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-07-07 12:19:42 +02:00
Alexandre Julliard f20710d9b3 winedbg: Use nameless unions/structs. 2023-06-20 15:58:05 +02:00
Eric Pouech f01ce56a49 winedbg: Improve size management in watch command.
- support 8 byte targets
- default to CPU pointer size if size isn't present nor supported.
- detect unaligned requests

Signed-off-by: Eric Pouech <eric.pouech@codeweavers.com>
2023-04-18 18:18:19 +02:00
Eric Pouech adde76fabd winedbg: Simplify watch command implementation.
This also correctly initialize some lvalue.
Context of the bug has changed, but the underlying issue remained the same.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39495
Signed-off-by: Eric Pouech <eric.pouech@codeweavers.com>
2023-04-18 18:18:16 +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 fd87ddfae7 winedbg: Let 'break symbol : line' command work again.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2023-04-18 18:17:44 +02:00
Eric Pouech 24069aad30 winedbg: Don't crash when no search path has been set.
Note: it's anyway wrong to search source files inside modules' path
(a proper fix will require revisiting source file handling).
This fix will actually be sufficient when running wine from within
its build tree.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-04-05 15:24:41 +02:00
Alexandre Julliard 1774db388b winedbg: Use the Zydis library for disassembly. 2023-02-27 16:36:22 +01:00
Eric Pouech 234943344f winedbg: Don't expose module whose machine isn't the process' one to gdb.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00
Eric Pouech 71dbcbce26 winedbg: Handle multi-machine process in command 'info share'.
- filter out native machine on wow64 configuration.
- add option to info share to print all modules.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-02-06 22:34:44 +01:00
Eric Pouech 433bc12709 winedbg: Fix read access to variables with thread local storage.
No longer relying on loaded module info (getting index address out of
PE image, and caching it in struct dbg_module).

Co-authored-by: Evan Tang <etang@codeweavers.com>
2023-01-26 22:05:13 +01:00
Eric Pouech 224b33c2be winedbg: Track loaded modules.
Co-authored-by: Evan Tang <etang@codeweavers.com>
2023-01-26 22:05:13 +01:00
Eric Pouech 5fc54e3219 winedbg: Use debuggee's bitness for 'examine /a' command.
Also fixes stack dump in crash summary and 'info stack' command.
(We were using debugger's bitness instead).

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
Eric Pouech 3055653c1e winedbg: Pass loaded image's file handle to dbghelp.
In some cases (running from build tree, overriding load order...), the
path to the module from the load DLL debug event isn't the real path
to the loaded module. So pass the handle to loaded module's image from
winedbg to dbghelp (to avoid image lookup).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54250
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2023-01-24 18:24:13 +01:00
Eric Pouech a922577986 winedbg: Avoid passing a non allocated buffer to HeapFree.
Latest changes to heap management can lead to a crash in this situation.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-12-09 17:52:25 +01:00
Alexandre Julliard 57c58be77d winedbg: Fix printf format warnings on ARM platforms. 2022-12-08 18:11:23 +01:00
Eric Pouech 41221452c8 winedbg: Don't use invalid address mode in exception prolog.
Removes a GCC 12.2 warning about printing NULL string.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-11-14 13:13:02 +01:00
Eric Pouech 001665d735 winedbg: Enhance printing of variables or fields.
Prints 'int a[10]' (instead of 'int[10] a').
Ditto for variables/fields of type function pointer.

And for pure type printing, no longer prints --none-- for
arrays and function pointers.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-09-30 21:20:28 +02:00
Eric Pouech 16bcc3bc29 winedbg: Synthetize pointer to type when not available.
This ensures that we always have a type as pointer to a known <type>
(either because it exists in <type>'s module, or it's synthetized inside
debugger).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-07-29 18:55:32 +02:00
Eric Pouech dd977e4a85 winedbg: Store result of types_get_info(TI_GET_TYPE) in dbg_type.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-07-29 18:55:30 +02:00
Brendan Shanks 2dba29a653 winedbg: Prefer thread name from GetThreadDescription() in GDB proxy mode. 2022-07-27 23:07:06 +02:00
Brendan Shanks f89c8be852 winedbg: Prefer thread name from GetThreadDescription() in 'info thread' listing. 2022-07-27 23:07:06 +02:00
Brendan Shanks d3b72d0ff1 winedbg: Implement GDB qGetTIBAddr query. 2022-07-27 22:36:31 +02:00
Eric Pouech 890e3baaba winedbg: Use CRT allocation functions.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-07-25 11:22:18 +02:00
Eric Pouech 674ef559e0 winedbg: Do proper error management when reallocating memory.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-07-25 11:22:12 +02:00
Eric Pouech f8d3c2b203 winedbg: No longer hide current WineDbg process from 'info proc'.
We used to hide current WineDbg instance when displaying processes' list
(command 'info proc'). This can potentially generate some "dangling"
processes in the hierarchy (related to this WineDbg instance):
- conhost.exe
- start.exe (when launched from unix shell without full path
  to winedbg.exe)

Also, print a more comprehensive error message when trying to attach to
itself (now that debugger's PID is more easily available).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-29 23:23:41 +02:00
Jinoh Kang f815c2642e winedbg: Clarify options specific to GDB proxy mode.
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
2022-06-24 22:38:47 +02:00
Jinoh Kang beee5160a8 winedbg: Fix typos in manpage.
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
2022-06-20 10:37:59 +02:00
Eric Pouech 30313d23a3 winedbg: Remove FORCE_DEREF expressions.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:59 +02:00
Eric Pouech 5020371eab winedbg: Extend 'print' command to work with types.
'print struct foo' will show all fields of structure
'print enum bar' will show all definitions inside of enum (and their value)
'print /d <type>' will show the type size (in bytes)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:51 +02:00
Eric Pouech 73770ce573 winedbg: Do type / id discrimination when parsing.
- Get rid of struct type_expr_t
- Enable back typecasts (and rewrite the typecast to fit the type parsing scheme)

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:17 +02:00
Eric Pouech af0c59bcc8 winedbg: Use data model for basic type on input.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:14 +02:00
Eric Pouech 2d8b709021 winedbg: Redefine internal types with predefined sizes.
This will help mapping a name to a basic type.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:07 +02:00
Eric Pouech 685126e857 winedbg: Fix retrieving integral values.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
2022-05-24 20:09:04 +02:00