delayed break in debugger
eric pouech
eric.pouech at wanadoo.fr
Mon May 21 03:34:43 CDT 2001
to set a breakpoint on a function in the debugger, the module
containing this function had to be already loaded
this patch lets, when a lookup for a function fails when setting a
breakpoint,
to remember the name, and try to set the breakpoint for every newly
loaded
module
A+
--
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: dbg_delaybk
ChangeLog: add the notion of delayed breakpoint (when a function is not loaded yet, the name will be tried again for each new loaded module)
GenDate: 2001/05/21 08:06:26 UTC
ModifiedFiles: debugger/break.c debugger/debugger.h debugger/info.c debugger/stabs.c debugger/winedbg.c
AddedFiles:
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/debugger/break.c,v
retrieving revision 1.26
diff -u -u -r1.26 break.c
--- debugger/break.c 2001/05/03 18:32:47 1.26
+++ debugger/break.c 2001/05/05 14:05:10
@@ -372,12 +372,26 @@
*/
void DEBUG_AddBreakpointFromId(const char *name, int lineno)
{
- DBG_VALUE value;
-
- if (DEBUG_GetSymbolValue(name, lineno, &value, TRUE))
+ DBG_VALUE value;
+ int i;
+
+ if (DEBUG_GetSymbolValue(name, lineno, &value, TRUE)) {
DEBUG_AddBreakpoint(&value, NULL);
- else
- DEBUG_Printf(DBG_CHN_MESG, "Unable to add breakpoint\n");
+ return;
+ }
+
+ DEBUG_Printf(DBG_CHN_MESG, "Unable to add breakpoint, will check again when a new DLL is loaded\n");
+ for (i = 0; i < DEBUG_CurrProcess->num_delayed_bp; i++) {
+ if (!strcmp(name, DEBUG_CurrProcess->delayed_bp[i].name) &&
+ lineno == DEBUG_CurrProcess->delayed_bp[i].lineno) {
+ return;
+ }
+ }
+ DEBUG_CurrProcess->delayed_bp = DBG_realloc(DEBUG_CurrProcess->delayed_bp,
+ sizeof(DBG_DELAYED_BP) * ++DEBUG_CurrProcess->num_delayed_bp);
+
+ DEBUG_CurrProcess->delayed_bp[DEBUG_CurrProcess->num_delayed_bp - 1].name = strcpy(DBG_alloc(strlen(name) + 1), name);
+ DEBUG_CurrProcess->delayed_bp[DEBUG_CurrProcess->num_delayed_bp - 1].lineno = lineno;
}
/***********************************************************************
@@ -396,7 +410,7 @@
DEBUG_FindNearestSymbol(&value.addr, TRUE, &nh, 0, NULL);
if (nh == NULL) {
- DEBUG_Printf(DBG_CHN_MESG,"Unable to add breakpoint\n");
+ DEBUG_Printf(DBG_CHN_MESG, "Unable to add breakpoint\n");
return;
}
DEBUG_GetLineNumberAddr(nh, lineno, &value.addr, TRUE);
@@ -405,6 +419,27 @@
value.type = NULL;
value.cookie = DV_TARGET;
DEBUG_AddBreakpoint( &value, NULL );
+}
+
+/***********************************************************************
+ * DEBUG_CheckDelayedBP
+ *
+ * Check is a registered delayed BP is now available.
+ */
+void DEBUG_CheckDelayedBP(void)
+{
+ DBG_VALUE value;
+ int i = 0;
+ DBG_DELAYED_BP* dbp = DEBUG_CurrProcess->delayed_bp;
+
+ while (i < DEBUG_CurrProcess->num_delayed_bp) {
+ if (DEBUG_GetSymbolValue(dbp[i].name, dbp[i].lineno, &value, TRUE)) {
+ DEBUG_AddBreakpoint(&value, NULL);
+ memmove(&dbp[i], &dbp[i+1], (--DEBUG_CurrProcess->num_delayed_bp - i) * sizeof(*dbp));
+ } else {
+ i++;
+ }
+ }
}
/***********************************************************************
Index: debugger/debugger.h
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/debugger/debugger.h,v
retrieving revision 1.21
diff -u -u -r1.21 debugger.h
--- debugger/debugger.h 2001/05/03 18:32:47 1.21
+++ debugger/debugger.h 2001/05/05 13:46:46
@@ -183,6 +183,11 @@
struct tagDBG_THREAD* prev;
} DBG_THREAD;
+typedef struct tagDBG_DELAYED_BP {
+ int lineno;
+ char* name;
+} DBG_DELAYED_BP;
+
typedef struct tagDBG_PROCESS {
HANDLE handle;
DWORD pid;
@@ -192,6 +197,8 @@
struct tagDBG_MODULE** modules;
int num_modules;
unsigned long dbg_hdr_addr;
+ DBG_DELAYED_BP* delayed_bp;
+ int num_delayed_bp;
/*
* This is an index we use to keep track of the debug information
* when we have multiple sources. We use the same database to also
@@ -257,6 +264,7 @@
extern void DEBUG_AddBreakpointFromLineno( int lineno );
extern void DEBUG_AddWatchpoint( const DBG_VALUE *addr, int is_write );
extern void DEBUG_AddWatchpointFromId( const char *name );
+extern void DEBUG_CheckDelayedBP( void );
extern void DEBUG_DelBreakpoint( int num );
extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
extern void DEBUG_InfoBreakpoints(void);
Index: debugger/info.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/debugger/info.c,v
retrieving revision 1.17
diff -u -u -r1.17 info.c
--- debugger/info.c 2000/12/29 05:38:00 1.17
+++ debugger/info.c 2001/04/20 18:29:49
@@ -69,7 +69,7 @@
if (strstr(default_format, "%S") == NULL)
{
DEBUG_nchar += DEBUG_Printf( DBG_CHN_MESG, default_format, res );
- }
+ }
else
{
char* ptr;
Index: debugger/stabs.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/debugger/stabs.c,v
retrieving revision 1.39
diff -u -u -r1.39 stabs.c
--- debugger/stabs.c 2001/01/22 02:17:46 1.39
+++ debugger/stabs.c 2001/05/05 13:48:37
@@ -1308,6 +1308,7 @@
switch (dbg_hdr.r_state) {
case RT_CONSISTENT:
DEBUG_WalkList(&dbg_hdr);
+ DEBUG_CheckDelayedBP();
break;
case RT_ADD:
break;
Index: debugger/winedbg.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/debugger/winedbg.c,v
retrieving revision 1.33
diff -u -u -r1.33 winedbg.c
--- debugger/winedbg.c 2001/05/05 00:44:48 1.33
+++ debugger/winedbg.c 2001/05/05 13:47:38
@@ -150,6 +150,8 @@
p->num_modules = 0;
p->next_index = 0;
p->dbg_hdr_addr = 0;
+ p->delayed_bp = NULL;
+ p->num_delayed_bp = 0;
p->next = DEBUG_ProcessList;
p->prev = NULL;
@@ -162,10 +164,16 @@
static void DEBUG_DelProcess(DBG_PROCESS* p)
{
+ int i;
+
if (p->threads != NULL) {
DEBUG_Printf(DBG_CHN_ERR, "Shouldn't happen\n");
while (p->threads) DEBUG_DelThread(p->threads);
}
+ for (i = 0; i < p->num_delayed_bp; i++) {
+ DBG_free(p->delayed_bp[i].name);
+ }
+ DBG_free(p->delayed_bp);
if (p->prev) p->prev->next = p->next;
if (p->next) p->next->prev = p->prev;
if (p == DEBUG_ProcessList) DEBUG_ProcessList = p->next;
@@ -730,6 +738,7 @@
de->u.LoadDll.nDebugInfoSize);
_strupr(buffer);
DEBUG_LoadModule32(buffer, de->u.LoadDll.hFile, (DWORD)de->u.LoadDll.lpBaseOfDll);
+ DEBUG_CheckDelayedBP();
if (DBG_IVAR(BreakOnDllLoad)) {
DEBUG_Printf(DBG_CHN_MESG, "Stopping on DLL %s loading at %08lx\n",
buffer, (unsigned long)de->u.LoadDll.lpBaseOfDll);
More information about the wine-patches
mailing list