WINEDBG(1)

πŸŽ€ NAME πŸŽ€

winedbg(1) from the Wine Developers Manual: winedbg is the Wine debugger, bestie. πŸ’–

✨ SYNOPSIS ✨

winedbg [ options ] [ program_name [ program_arguments ] | wpid ]

winedbg --gdb [ options ] [ program_name [ program_arguments ] | wpid ]

winedbg --auto wpid

winedbg --minidump [ file.mdmp ] wpid

winedbg file.mdmp

πŸ’œ DESCRIPTION πŸ’œ

Okay so winedbg is a debugger for Wine. It allows:

  • debugging native Win32 applications
  • debugging Winelib applications
  • being a drop-in replacement for Dr Watson

🌈 MODES 🌈

winedbg can be used in five modes. The first argument to the program determines the mode winedbg will run in. Five whole modes, bestie β€” the first argument is the vibe check. πŸ’…

  • default β€” No explicit mode? This is standard winedbg operating mode. winedbg will act as the front end for the user.
  • --gdb β€” winedbg will be used as a proxy for gdb. gdb will be the front end for command handling, and winedbg will proxy all debugging requests from gdb to the Win32 APIs.
  • --auto β€” This mode is used when winedbg is set up in AeDebug registry entry as the default debugger. winedbg will then display basic information about a crash. This is useful for users who don't want to debug a crash, but rather gather relevant information about the crash to be sent to developers.
  • --minidump β€” This mode is similar to the --auto one, except that instead of printing the information on the screen (as --auto does), it's saved into a minidump file. The name of the file is either passed on the command line, or generated by WineDbg when none is given. This file could later on be reloaded into winedbg for further examination.
  • file.mdmp β€” In this mode winedbg reloads the state of a debuggee which has been saved into a minidump file. See either the minidump command below, or the --minidump mode.

πŸ’… OPTIONS πŸ’…

When in default mode, the following options are available:

  • --command string β€” winedbg will execute the command string as if it was keyed on winedbg command line, and then will exit. This can be handy for getting the pid of running processes (winedbg --command "info proc").
  • --exec filename β€” Sets the executable name, without starting the executable.
  • --file filename β€” winedbg will execute the list of commands contained in file filename as if they were keyed on winedbg command line, and then will exit.

When in gdb proxy mode, the following options are available:

  • --no-start β€” Don't launch gdb directly; instead, print the target remote GDB command to execute and listen for connection from any GDB-compatible debugger. Normally, --gdb will start both the proxy debugging server and an instance of gdb for the front end. This option instructs winedbg to skip launching of gdb, and instead prints the GDB command that can be used to manually connect to the server. This command is in the form target remote localhost:<port> where <port> is the TCP port winedbg's proxy debugging server is bound to.

This option allows the user to replace gdb with some other debugger front end, such as ddd, kgdb, gdbgui, or Qt Creator. Regardless of whether --no-start is specified, winedbg will quit after the first connection is hung up (e.g. gdb detaches from the debuggee).

  • --port port β€” Start the GDB proxy debugging server on the given port. If this option is not specified, winedbg will let the operating system choose any available port. This option can be used in conjunction with --no-start to specify the port the server shall be bound to.
  • --with-xterm β€” This will run the gdb front end in a new xterm(1) window instead of using the current Unix terminal for its interface. This option is ignored if --no-start is specified.

In all modes, the rest of the command line, when passed, is used to identify which program, if any, is to be debugged:

  • program_name β€” This is the name of an executable to start for a debugging session. winedbg will actually create a process with this executable. If program_arguments are also given, they will be used as arguments for creating the process to be debugged.
  • wpid β€” winedbg will attach to the process whose Windows pid is wpid. Use the info proc command within winedbg to list running processes and their Windows pids.
  • default β€” If nothing is specified, you will enter the debugger without any run nor attached process. You'll have to do the job yourself. 🫢

πŸ’¬ COMMANDS

🌸 Default mode, and while reloading a minidump file

okay so first thing's first: most of the commands you already know from winedbg are literally the same vibes as the ones from gdb, so if you need the deep lore, please refer to the gdb documentations πŸ’–. also pls check out the gdb differences section later on to get the full list of where winedbg switches it up from gdb commands β€” iykyk.

✨ Misc. commands

  • abort β€” just straight up aborts the debugger. πŸ’€ no cap.
  • quit β€” exits the debugger. bye bestie 🫢

🧚 Process handling

  • attach N β€” attaches to a Wine process, where N is its Windows ID, and yes it can be numeric or hexadecimal. you can grab those IDs with the info process command. πŸ’… note: the info process command returns hexadecimal values!
  • attach file.mdmp β€” reloads the state of a debuggee from the minidump file.mdmp. peek the minidump command if you wanna save one of these bad boys.
  • detach β€” detaches the current Wine process. the process is no longer debugged by WineDbg, but it's still running (this is for a live target, obvi).
  • kill β€” kills the current Wine process. the process is no longer debugged by WineDbg, and it's also terminated (again, for a live target). πŸ”₯
  • minidump file.mdmp β€” saves the debugging context of the debuggee into a minidump file called file.mdmp ✨
  • run β€” re-runs the same process with the same arguments. ⚠️ note: all breakpoints of the precedent process are no longer available. rip to those breakpoints πŸͺ¦
  • run arg1 arg2... β€” re-runs the same process with the arguments arg1 arg2.... same warning bestie: all breakpoints of the precedent process are no longer available.
  • thread N β€” changes the current thread to N, which is its Windows TID, numeric or hexadecimal. 🧡

πŸŽ€ Help commands

  • help β€” prints some help on the commands.
  • help info β€” prints some help on info commands. so meta πŸ¦‹

⭐ Flow control commands

  • cont β€” continues execution until the next breakpoint or exception.
  • pass β€” passes the exception event up to the filter chain.
  • step β€” continues execution until the next C line of code (enters function call).
  • next β€” continues execution until the next C line of code (doesn't enter function call).
  • stepi β€” executes the next assembly instruction (enters function call).
  • nexti β€” executes the next assembly instruction (doesn't enter function call).
  • finish β€” executes until the return of the current function is reached.
bestie listen πŸ‘€ cont, step, next, stepi, nexti can be postfixed by a number (N), meaning the command must be executed N times before control is returned to you. literally so handy.

πŸ‘‘ Breakpoints, watchpoints

  • enable N β€” enables (break|watch)-point N.
  • disable N β€” disables (break|watch)-point N.
  • delete N β€” deletes (break|watch)-point N.
  • cond N β€” removes any existing condition to (break|watch)-point N.
  • cond N expr β€” adds the condition expr to (break|watch)-point N. expr will be evaluated each time the (break|watch)-point is hit. if the result is a zero value, the breakpoint isn't triggered. ✨
  • break * N β€” adds a breakpoint at address N.
  • break id β€” adds a breakpoint at the address of symbol id.
  • break id N β€” adds a breakpoint at line N inside symbol id.
  • break N β€” adds a breakpoint at line N of the current source file.
  • break β€” adds a breakpoint at the current $PC address. yes, with no args at all πŸ’…
  • watch * N β€” adds a watch command (on write) at address N (on 4 bytes).
  • watch id β€” adds a watch command (on write) at the address of symbol id. size depends on the size of id.
  • rwatch * N β€” adds a watch command (on read) at address N (on 4 bytes).
  • rwatch id β€” adds a watch command (on read) at the address of symbol id. size depends on the size of id.
  • info break β€” lists all (break|watch)-points (with their state).

you can use the symbol EntryPoint to stand for the entry point of the Dll 🫢

and here's a lil detail that's lowkey iconic: when you set a (break|watch)-point by id and the symbol can't be found (for example, the symbol is contained in a not yet loaded module), winedbg will recall the name of the symbol and will try to set the breakpoint each time a new module is loaded (until it succeeds). it literally remembers for you. main character energy fr.

πŸ¦‹ Stack manipulation

  • bt β€” prints the calling stack of the current thread.
  • bt N β€” prints the calling stack of the thread of ID N. note: this doesn't change the position of the current frame as manipulated by the up & dn commands. πŸ™ˆ
  • up β€” goes up one frame in the current thread's stack.
  • up N β€” goes up N frames in the current thread's stack.
  • dn β€” goes down one frame in the current thread's stack.
  • dn N β€” goes down N frames in the current thread's stack.
  • frame N β€” sets N as the current frame for the current thread's stack.
  • info locals β€” prints information on local variables for the current function frame.

🌈 Directory & source file manipulation

  • show dir β€” prints the list of dirs where source files are looked for.
  • dir pathname β€” adds pathname to the list of dirs where to look for source files.
  • dir β€” deletes the list of dirs where to look for source files. empty. gone. ✨
  • symbolfile pathname β€” loads external symbol definition file pathname.
  • symbolfile pathname N β€” loads external symbol definition file pathname (applying an offset of N to addresses).
  • list β€” lists 10 source lines forwards from the current position.
  • list - β€” lists 10 source lines backwards from the current position.
  • list N β€” lists 10 source lines from line N in the current file.
  • list pathname:N β€” lists 10 source lines from line N in file pathname.
  • list id β€” lists 10 source lines of function id.
  • list * N β€” lists 10 source lines from address N.

and here's the cute part: you can specify the end target (to change that 10 lines value) using the , separator. for example:

  • list 123, 234 β€” lists source lines from line 123 up to line 234 in the current file 🌸
  • list foo.c:1,56 β€” lists source lines from line 1 up to 56 in file foo.c

πŸ“ Displaying

quick definition bestie: a display is an expression that's evaluated and printed after the execution of any winedbg command. so it just... keeps showing up. obsessed.

  • display
  • info display β€” lists the active displays.
  • display expr β€” adds a display for the expression expr.
  • display /fmt expr β€” adds a display for the expression expr. printing the evaluated expr is done using the given format (see the print command for more on formats).
  • del display N
  • undisplay N β€” deletes display N. (both spellings, slay πŸ’…)

πŸ’œ Disassembly

  • disas β€” disassemble from the current position.
  • disas expr β€” disassemble from the address expr.
  • disas expr,expr β€” disassembles code between the addresses specified by the two expressions.

🧚 Memory (reading, writing, typing)

  • x expr β€” examines memory at address expr.
  • x /fmt expr β€” examines memory at address expr using format fmt.
  • print expr β€” prints the value of expr (possibly using its type).
  • print /fmt expr β€” prints the value of expr (possibly using its type).
  • set var = expr β€” writes the value of expr in the var variable.
  • whatis expr β€” prints the C type of the expression expr.

okay so fmt is either a letter or a count letter, where letter can be:

  • s β€” an ASCII string
  • u β€” a UTF16 Unicode string
  • i β€” instructions (disassemble)
  • x β€” 32-bit unsigned hexadecimal integer
  • d β€” 32-bit signed decimal integer
  • w β€” 16-bit unsigned hexadecimal integer
  • c β€” character (only printable 0x20-0x7f are actually printed)
  • b β€” 8-bit unsigned hexadecimal integer
  • g β€” Win32 GUID

πŸ”₯ Expressions

expressions in Wine Debugger are mostly written in a C form. cute, right? however, there are a few discrepancies you gotta know about:

  • Identifiers can take a ! in their names. this mainly lets you specify a module where to look the ID from, e.g. USER32!CreateWindowExA. πŸ’…
  • In a cast operation, when specifying a structure or a union, you must use the struct or union keyword (even if your program uses a typedef). no skipping, bestie.

also: when specifying an identifier, if several symbols with this name exist, the debugger will prompt for the symbol you want to use. just pick up the one you want from its number 🫢

🌟 Information on Wine internals

  • info class β€” lists all Windows classes registered in Wine.
  • info class id β€” prints information on Windows class id.
  • info share β€” lists all the dynamic libraries loaded in the debugged program (including .so files, NE and PE DLLs).
  • info share N β€” prints information on the module at address N.
  • info regs β€” prints the value of the CPU registers.
  • info all-regs β€” prints the value of the CPU and Floating Point registers.
  • info segment β€” lists all allocated segments (i386 only).
  • info segment N β€” prints information on segment N (i386 only).
  • info stack β€” prints the values on top of the stack.
  • info map β€” lists all virtual mappings used by the debugged program.
  • info map N β€” lists all virtual mappings used by the program of Windows pid N.
  • info wnd β€” displays the window hierarchy starting from the desktop window.
  • info wnd N β€” prints information of the Window of handle N.
  • info process β€” lists all w-processes in the Wine session.
  • info thread β€” lists all w-threads in the Wine session.
  • info frame β€” lists the exception frames (starting from the current stack frame). you can also pass, as an optional argument, a thread id (instead of the current thread) to examine its exception frames. 🧡

debug messages can be turned on and off as you're debugging using the set command β€” but only for channels initialized with the WINEDEBUG environment variable. that part matters, don't forget it ✨

  • set warn + win β€” turns on warn on the win channel.
  • set + win β€” turns on warn/fixme/err/trace on the win channel.
  • set - win β€” turns off warn/fixme/err/trace on the win channel.
  • set fixme - all β€” turns off the fixme class on all channels.

πŸŽ€ Gdb mode

see the gdb documentation for all the gdb commands, bestie β€” that's the whole reference.

however! a few Wine extensions are available, through the monitor command πŸ‘‘

  • monitor wnd β€” lists all windows in the Wine session.
  • monitor proc β€” lists all processes in the Wine session.
  • monitor mem β€” displays memory mapping of the debugged process.

πŸ¦‹ Auto and minidump modes

since no user input is possible, no commands are available. that's it. that's the whole section πŸ’€

🌸 ENVIRONMENT

  • WINE_GDB β€” when used in gdb proxy mode, WINE_GDB specifies the name (and the path) of the executable to be used for gdb. "gdb" is used by default. 🫢

πŸŽ€ AUTHORS

the first version was written by Eric Youngdale. πŸ‘‘

see the Wine developers list for the rest of the contributors πŸ’–

⭐ BUGS

bugs can be reported on the Wine bug tracker. go off, report them πŸ›

πŸ‘‘ AVAILABILITY

winedbg is part of the Wine distribution, which is available through WineHQ, the Wine development headquarters. 🌈

✨ SEE ALSO ✨

okay so when you're done vibing with winedbg and you wanna go read more, here's the reading list bestie 🫢

  • wine(1) β€” literally the whole reason we're here, go say hi to the main character πŸ‘‘
  • Wine documentation and support β€” the docs and the support situation, your safe space when things get messy 😭

and that's a wrap on WINEDBG(1), bestie!! πŸŽ€ you made it all the way to the bottom, I'm so proud of you fr fr πŸ’– go forth and debug slayfully ✨

this icon was brought to you by Wine 11.21, dated October 2005 β€” vintage, iconic, still serving πŸ’…πŸŒΈ