winedbg - ability to abort symbol lookup

Eric Pouech eric.pouech at wanadoo.fr
Sun Sep 15 08:31:55 CDT 2002


resent (with corrections as requested by Alexandre)

A+
-------------- next part --------------
Name:          wd_sym_abrt
ChangeLog:     added ability to abort on interactive symbol lookup
License:       X11
GenDate:       2002/09/15 13:29:11 UTC
ModifiedFiles: programs/winedbg/break.c programs/winedbg/dbg.y programs/winedbg/debugger.h programs/winedbg/expr.c programs/winedbg/hash.c programs/winedbg/info.c programs/winedbg/stabs.c
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/break.c,v
retrieving revision 1.1
diff -u -u -r1.1 break.c
--- programs/winedbg/break.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/break.c	10 Sep 2002 19:01:21 -0000
@@ -421,10 +421,15 @@
     DBG_VALUE 	value;
     int		i;
 
-    if (DEBUG_GetSymbolValue(name, lineno, &value, TRUE))
+    switch (DEBUG_GetSymbolValue(name, lineno, &value, TRUE))
     {
+    case gsv_found:
         DEBUG_AddBreakpoint(&value, NULL, TRUE);
         return;
+    case gsv_unknown:
+        break;
+    case gsv_aborted: /* user aborted symbol lookup */
+        return;
     }
 
     DEBUG_Printf(DBG_CHN_MESG, "Unable to add breakpoint, will check again when a new DLL is loaded\n");
@@ -487,11 +492,12 @@
     {
         if (dbp[i].is_symbol)
         {
-            if (!DEBUG_GetSymbolValue(dbp[i].u.symbol.name, dbp[i].u.symbol.lineno, &value, TRUE))
+            if (DEBUG_GetSymbolValue(dbp[i].u.symbol.name, dbp[i].u.symbol.lineno, &value, TRUE) != gsv_found)
                 continue;
         }
         else
             value = dbp[i].u.value;
         DEBUG_Printf(DBG_CHN_MESG, "trying to add delayed %s-bp\n", dbp[i].is_symbol ? "S" : "A");
         if (!dbp[i].is_symbol)
             DEBUG_Printf(DBG_CHN_MESG, "\t%04x %04lx:%08lx\n",
@@ -586,10 +593,17 @@
 {
    DBG_VALUE value;
 
-   if( DEBUG_GetSymbolValue(name, -1, &value, TRUE) )
+   switch (DEBUG_GetSymbolValue(name, -1, &value, TRUE))
+   {
+   case gsv_found:
       DEBUG_AddWatchpoint( &value, 1 );
-   else
+      break;
+   case gsv_unknown:
       DEBUG_Printf(DBG_CHN_MESG, "Unable to add watchpoint\n");
+      break;
+   case gsv_aborted: /* user aborted symbol lookup */
+       break;
+   }
 }
 
 /***********************************************************************
Index: programs/winedbg/dbg.y
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/dbg.y,v
retrieving revision 1.1
diff -u -u -r1.1 dbg.y
--- programs/winedbg/dbg.y	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/dbg.y	2 Sep 2002 19:44:42 -0000
@@ -405,6 +408,8 @@
    case DEBUG_STATUS_NO_FIELD:
       DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n");
       break;
+   case DEBUG_STATUS_ABORT:
+       break;
    default:
       DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode());
       DEBUG_ExternalDebugger();
Index: programs/winedbg/debugger.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debugger.h,v
retrieving revision 1.1
diff -u -u -r1.1 debugger.h
--- programs/winedbg/debugger.h	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/debugger.h	10 Sep 2002 18:40:17 -0000
@@ -291,6 +291,8 @@
 
 #define	OFFSET_OF(__c,__f)		((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
 
+enum get_sym_val {gsv_found, gsv_unknown, gsv_aborted};
+
   /* from winelib.so */
 extern void DEBUG_ExternalDebugger(void);
 
@@ -358,8 +360,7 @@
 					   const DBG_VALUE *addr,
 					   const char *sourcefile,
 					   int flags);
-extern int DEBUG_GetSymbolValue( const char * name, const int lineno,
-				 DBG_VALUE *addr, int );
+extern enum get_sym_val DEBUG_GetSymbolValue( const char * name, const int lineno, DBG_VALUE *addr, int );
 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
 					     struct name_hash ** rtn,
@@ -582,6 +583,7 @@
 #define	DEBUG_STATUS_DIV_BY_ZERO	(DEBUG_STATUS_OFFSET+2)
 #define	DEBUG_STATUS_BAD_TYPE		(DEBUG_STATUS_OFFSET+3)
 #define DEBUG_STATUS_NO_FIELD		(DEBUG_STATUS_OFFSET+4)
+#define DEBUG_STATUS_ABORT              (DEBUG_STATUS_OFFSET+5)
 
 extern DBG_INTVAR		DEBUG_IntVars[];
 
Index: programs/winedbg/expr.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/expr.c,v
retrieving revision 1.1
diff -u -u -r1.1 expr.c
--- programs/winedbg/expr.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/expr.c	10 Sep 2002 18:39:48 -0000
@@ -350,10 +356,16 @@
       rtn.addr.seg = 0;
       break;
     case EXPR_TYPE_SYMBOL:
-      if( !DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE) )
+      switch (DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE))
       {
-	  DEBUG_Printf(DBG_CHN_MESG, "%s\n", exp->un.symbol.name);
+      case gsv_found:
+          break;
+      case gsv_unknown:
 	  RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL);
+          /* should never be here */
+      case gsv_aborted:
+          RaiseException(DEBUG_STATUS_ABORT, 0, 0, NULL);
+          /* should never be here */
       }
       break;
     case EXPR_TYPE_PSTRUCT:
@@ -408,10 +420,17 @@
       /*
        * Now look up the address of the function itself.
        */
-      if( !DEBUG_GetSymbolValue(exp->un.call.funcname, -1, &rtn, FALSE ) )
-	{
+      switch (DEBUG_GetSymbolValue(exp->un.call.funcname, -1, &rtn, FALSE ))
+      {
+      case gsv_found:
+          break;
+      case gsv_unknown:
 	  RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL);
-	}
+          /* should never be here */
+      case gsv_aborted:
+          RaiseException(DEBUG_STATUS_ABORT, 0, 0, NULL);
+          /* should never be here */
+      }
 
 #if 0
       /* FIXME: NEWDBG NIY */
Index: programs/winedbg/hash.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/hash.c,v
retrieving revision 1.1
diff -u -u -r1.1 hash.c
--- programs/winedbg/hash.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/hash.c	10 Sep 2002 18:58:02 -0000
@@ -346,6 +346,11 @@
  *           DEBUG_GetSymbolValue
  *
  * Get the address of a named symbol.
+ * Return values:
+ *      gsv_found:   if the symbol is found
+ *      gsv_unknown: if the symbol isn't found
+ *      gsv_aborted: some error occured (likely, many symbols of same name exist, 
+ *          and user didn't pick one of them)
  */
 static int    DEBUG_GSV_Helper(const char* name, const int lineno,
 			       DBG_VALUE* value, int num, int bp_flag)
@@ -369,8 +374,9 @@
    return i;
 }
 
-BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
-			   DBG_VALUE *rtn, int bp_flag )
+enum get_sym_val DEBUG_GetSymbolValue( const char * name, 
+                                       const int lineno,
+                                       DBG_VALUE *rtn, int bp_flag )
 {
 #define NUMDBGV 10
    /* FIXME: NUMDBGV should be made variable */
@@ -398,7 +404,7 @@
    }
 
    if (num == 0) {
-      return FALSE;
+      return gsv_unknown;
    } else if (!DEBUG_InteractiveP || num == 1) {
       i = 0;
    } else {
@@ -429,6 +435,7 @@
 	  i = 0;
 	  if (DEBUG_ReadLine("=> ", buffer, sizeof(buffer)))
 	  {
+              if (buffer[0] == '\0') return gsv_aborted;
 	      i = atoi(buffer);
 	      if (i < 1 || i > num)
 		  DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i);
@@ -439,7 +446,7 @@
       i--;
    }
    *rtn = value[i];
-   return TRUE;
+   return gsv_found;
 }
 
 /***********************************************************************
Index: programs/winedbg/info.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/info.c,v
retrieving revision 1.1
diff -u -u -r1.1 info.c
--- programs/winedbg/info.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/info.c	10 Sep 2002 19:01:10 -0000
@@ -709,7 +709,7 @@
     BOOL                        bAll;
     void*                       addr;
 
-    if (!DEBUG_GetSymbolValue("first_dll", -1, &val, FALSE))
+    if (DEBUG_GetSymbolValue("first_dll", -1, &val, FALSE) != gsv_found)
     {
         DEBUG_Printf(DBG_CHN_MESG, "Can't get first_option symbol");
         return;
Index: programs/winedbg/stabs.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/stabs.c,v
retrieving revision 1.1
diff -u -u -r1.1 stabs.c
--- programs/winedbg/stabs.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/stabs.c	10 Sep 2002 19:01:18 -0000
@@ -1070,7 +1070,7 @@
        * we will have to keep the darned thing, because there can be
        * multiple local symbols by the same name.
        */
-      if(    (DEBUG_GetSymbolValue(symname, -1, &new_value, FALSE ) == TRUE)
+      if(    (DEBUG_GetSymbolValue(symname, -1, &new_value, FALSE ) == gsv_found)
 	  && (new_value.addr.off == (load_addr + symp->st_value)) )
 	  continue;
 


More information about the wine-patches mailing list