winedbg: Added a maintenance command to load a given module (for debug purposes).
This commit is contained in:
parent
2ffc90d670
commit
b2557f25d9
|
@ -25,6 +25,7 @@ C_SRCS = \
|
|||
stack.c \
|
||||
tgt_active.c \
|
||||
tgt_minidump.c \
|
||||
tgt_module.c \
|
||||
types.c \
|
||||
winedbg.c
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ static int dbg_error(const char*);
|
|||
%token tENABLE tDISABLE tBREAK tHBREAK tWATCH tDELETE tSET tPRINT tEXAM
|
||||
%token tABORT tECHO
|
||||
%token tCLASS tMAPS tSTACK tSEGMENTS tSYMBOL tREGS tALLREGS tWND tQUEUE tLOCAL tEXCEPTION
|
||||
%token tPROCESS tTHREAD tMODREF tEOL tEOF
|
||||
%token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
|
||||
%token tPROCESS tTHREAD tEOL tEOF
|
||||
%token tFRAME tSHARE tMODULE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
|
||||
%token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE
|
||||
%token <string> tPATH tIDENTIFIER tSTRING tDEBUGSTR tINTVAR
|
||||
%token <integer> tNUM tFORMAT
|
||||
|
@ -285,6 +285,8 @@ info_command:
|
|||
|
||||
maintenance_command:
|
||||
tMAINTENANCE tTYPE { print_types(); }
|
||||
| tMAINTENANCE tMODULE tSTRING { tgt_module_load($3, FALSE); }
|
||||
| tMAINTENANCE '*' tMODULE tSTRING { tgt_module_load($4, TRUE); }
|
||||
;
|
||||
|
||||
noprocess_state:
|
||||
|
|
|
@ -177,11 +177,12 @@ STRING \"[^\n"]+\"
|
|||
<INITIAL>whatis|whati|what { BEGIN(NOCMD); return tWHATIS; }
|
||||
<INITIAL,NOPROCESS>run|ru|r { BEGIN(ASTRING_EXPECTED); return tRUN;}
|
||||
<INITIAL>detach|detac|deta|det { BEGIN(NOCMD); return tDETACH; }
|
||||
<INITIAL>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; }
|
||||
<INITIAL,NOPROCESS>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; }
|
||||
<INITIAL>minidump|mdmp { BEGIN(PATH_EXPECTED); return tMINIDUMP; }
|
||||
<INITIAL>echo { BEGIN(ASTRING_EXPECTED); return tECHO; }
|
||||
<NOPROCESS>attach|attac|atta|att { BEGIN(NOCMD); return tATTACH; }
|
||||
<INFO_CMD>share|shar|sha { return tSHARE; }
|
||||
<MAINT_CMD>module|modul|mod { BEGIN(ASTRING_EXPECTED); return tMODULE; }
|
||||
<INFO_CMD>locals|local|loca|loc { return tLOCAL; }
|
||||
<INFO_CMD>class|clas|cla { return tCLASS; }
|
||||
<INFO_CMD>process|proces|proce|proc { return tPROCESS; }
|
||||
|
|
|
@ -393,6 +393,9 @@ extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe);
|
|||
extern void minidump_write(const char*, const EXCEPTION_RECORD*);
|
||||
extern enum dbg_start minidump_reload(int argc, char* argv[]);
|
||||
|
||||
/* tgt_module.c */
|
||||
extern enum dbg_start tgt_module_load(const char* name, BOOL keep);
|
||||
|
||||
/* types.c */
|
||||
extern void print_value(const struct dbg_lvalue* addr, char format, int level);
|
||||
extern int types_print_type(const struct dbg_type*, BOOL details);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Wine debugger - loading a module for debug purposes
|
||||
*
|
||||
* Copyright 2006 Eric Pouech
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "debugger.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
|
||||
|
||||
static struct be_process_io be_process_module_io;
|
||||
|
||||
static BOOL WINAPI tgt_process_module_read(HANDLE hProcess, const void* addr,
|
||||
void* buffer, SIZE_T len, SIZE_T* rlen)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL WINAPI tgt_process_module_write(HANDLE hProcess, void* addr,
|
||||
const void* buffer, SIZE_T len, SIZE_T* wlen)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
enum dbg_start tgt_module_load(const char* name, BOOL keep)
|
||||
{
|
||||
DWORD opts = SymGetOptions();
|
||||
HANDLE hDummy = (HANDLE)0x87654321;
|
||||
|
||||
SymSetOptions((opts & ~(SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS)) |
|
||||
SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | 0x40000000);
|
||||
SymInitialize(hDummy, NULL, FALSE);
|
||||
SymLoadModule(hDummy, NULL, name, NULL, 0, 0);
|
||||
|
||||
if (keep)
|
||||
{
|
||||
dbg_printf("Non supported mode... errors may occur\n"
|
||||
"Use at your own risks\n");
|
||||
SymSetOptions(SymGetOptions() | 0x40000000);
|
||||
dbg_curr_process = dbg_add_process(&be_process_module_io, 1, hDummy);
|
||||
dbg_curr_pid = 1;
|
||||
/* FIXME: missing thread creation, fetching frames, restoring dbghelp's options... */
|
||||
}
|
||||
else
|
||||
{
|
||||
SymCleanup(hDummy);
|
||||
SymSetOptions(opts);
|
||||
}
|
||||
|
||||
return start_ok;
|
||||
}
|
||||
|
||||
static BOOL tgt_process_module_close_process(struct dbg_process* pcs, BOOL kill)
|
||||
{
|
||||
SymCleanup(pcs->handle);
|
||||
dbg_del_process(pcs);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct be_process_io be_process_module_io =
|
||||
{
|
||||
tgt_process_module_close_process,
|
||||
tgt_process_module_read,
|
||||
tgt_process_module_write,
|
||||
};
|
Loading…
Reference in New Issue