1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

winedbg: Extend 'attach' command to load minidump files.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-03-05 10:15:49 +01:00 committed by Alexandre Julliard
parent 8a65cdd13d
commit 2e46d81c64
5 changed files with 37 additions and 23 deletions

View file

@ -141,10 +141,11 @@ command:
| tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); }
| tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE, NULL); dbg_printf("\n"); }
| tATTACH tNUM { dbg_attach_debuggee($2); dbg_active_wait_for_first_exception(); }
| tATTACH pathname { minidump_reload($2); }
| tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); }
| tTHREAD tNUM { dbg_set_curr_thread($2); }
| tKILL { dbg_curr_process->process_io->close_process(dbg_curr_process, TRUE); }
| tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL);}
| tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL); }
| tECHO tSTRING { dbg_printf("%s\n", $2); }
| tEXECFILE pathname { dbg_set_exec_file($2); }
| run_command

View file

@ -488,7 +488,8 @@ extern void fetch_module_name(void* name_addr, void* mod_addr, WCHAR
/* tgt_minidump.c */
extern void minidump_write(const char*, const EXCEPTION_RECORD*);
extern enum dbg_start minidump_reload(int argc, char* argv[]);
extern enum dbg_start minidump_reload(const char *);
extern enum dbg_start minidump_start(int argc, char* argv[]);
/* tgt_module.c */
extern enum dbg_start tgt_module_load(const char* name, BOOL keep);

View file

@ -307,7 +307,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
const char *str;
char tmp[128];
dbg_printf("WineDbg starting on minidump on pid %04lx\n", pid);
dbg_printf("WineDbg starting minidump on pid %04lx\n", pid);
switch (msi->ProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_UNKNOWN:
@ -564,23 +564,23 @@ static void cleanup(struct tgt_process_minidump_data* data)
static struct be_process_io be_process_minidump_io;
enum dbg_start minidump_reload(int argc, char* argv[])
enum dbg_start minidump_reload(const char* filename)
{
struct tgt_process_minidump_data* data;
enum dbg_start ret = start_error_parse;
/* try the form <myself> minidump-file */
if (argc != 1) return start_error_parse;
WINE_TRACE("Processing Minidump file %s\n", argv[0]);
if (dbg_curr_process)
{
dbg_printf("Already attached to a process. Use 'detach' or 'kill' before loading a minidump file'\n");
return start_error_init;
}
data = malloc(sizeof(struct tgt_process_minidump_data));
if (!data) return start_error_init;
data->mapping = NULL;
data->hMap = NULL;
data->hFile = INVALID_HANDLE_VALUE;
if ((data->hFile = CreateFileA(argv[0], GENERIC_READ, FILE_SHARE_READ, NULL,
if ((data->hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE &&
((data->hMap = CreateFileMappingA(data->hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
((data->mapping = MapViewOfFile(data->hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
@ -594,7 +594,7 @@ enum dbg_start minidump_reload(int argc, char* argv[])
}
__EXCEPT_PAGE_FAULT
{
dbg_printf("Unexpected fault while reading minidump %s\n", argv[0]);
dbg_printf("Unexpected fault while reading minidump %s\n", filename);
dbg_curr_pid = 0;
}
__ENDTRY;
@ -603,6 +603,16 @@ enum dbg_start minidump_reload(int argc, char* argv[])
return ret;
}
enum dbg_start minidump_start(int argc, char* argv[])
{
/* try the form <myself> minidump-file */
if (argc != 1) return start_error_parse;
WINE_TRACE("Processing Minidump file %s\n", argv[0]);
return minidump_reload(argv[0]);
}
static BOOL tgt_process_minidump_close_process(struct dbg_process* pcs, BOOL kill)
{
struct tgt_process_minidump_data* data = private_data(pcs);

View file

@ -786,7 +786,7 @@ int main(int argc, char** argv)
}
if (!argc) ds = start_ok;
else if ((ds = dbg_active_attach(argc, argv)) == start_error_parse &&
(ds = minidump_reload(argc, argv)) == start_error_parse)
(ds = minidump_start(argc, argv)) == start_error_parse)
ds = dbg_active_launch(argc, argv);
switch (ds)
{

View file

@ -138,18 +138,26 @@ Exits the debugger.
Attach to a Wine process (\fIN\fR is its Windows ID, numeric or hexadecimal).
IDs can be obtained using the \fBinfo\ process\fR command. Note the
\fBinfo\ process\fR command returns hexadecimal values
.IP
.IP \fBattach\ \fIfile.mdmp\fR
Reload the state of a debuggee from the minidump \fIfile.mdmp\fR.
See the \fBminidump\fR command to save such a file.
.IP \fBdetach\fR
Detach from a Wine-process.
.IP \fBthread\ \fIN\fR
Change the current thread to \fIN\fR (its Windows TID, numeric or hexadecimal).
.IP
Detach the current Wine-process. The process is no longer debugged by WineDbg,
but is still running (for a live target).
.IP \fBkill\fR
Kills the current Wine-process. The process is no longer debugged by WineDbg,
and is also terminated (for a live target).
.IP \fBminidump\fR\ \fIfile.mdmp\fR
Saves the debugging context of the debuggee into a minidump file called
\fIfile.mdmp\fR.
.IP \fBrun\fR
Re-run the same process with the same arguments.
Note: all breakpoints of precedent process are no longer available.
.IP \fBrun\ \fIarg1\ arg2...\fR
Re-run the same process with arguments \fIarg1\ arg2...\fR.
Note: all breakpoints of precedent process are no longer available.
.IP \fBthread\ \fIN\fR
Change the current thread to \fIN\fR (its Windows TID, numeric or hexadecimal).
.PP
\fIHelp commands\fR
.IP \fBhelp\fR
@ -355,12 +363,6 @@ When specifying an identifier, if several symbols with
this name exist, the debugger will prompt for the symbol you want to
use. Pick up the one you want from its number.
.PP
\fIMisc.\fR
.PP
.BI "minidump " file.mdmp
saves the debugging context of the debuggee into a minidump file called
\fIfile.mdmp\fR.
.PP
\fIInformation on Wine internals\fR
.IP \fBinfo\ class\fR
Lists all Windows classes registered in Wine