public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Update breakpoint methods
@ 2009-11-09 19:43 Keith Seitz
  0 siblings, 0 replies; only message in thread
From: Keith Seitz @ 2009-11-09 19:43 UTC (permalink / raw)
  To: insight

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi,

Recent snapshot users have probably noticed that breakpoints have been 
broken for a couple of weeks. This is a direct result of some ancient 
code in insight which has been using some private gdb code to do its work.

I've rewritten these routines to follow the same methodology as the MI 
code. This should help insulate insight from some gdb churn.

If there are any problems with this, please let me know ASAP. I am 
gearing up for the release candidate (that I promised a week or two ago).

Keith

ChangeLog
   2009-11-09  Keith Seitz  <keiths@redhat.com>

	* library/srctextwin.itb (lookup_line): Update parameters
	to gdb_set_bp.
	* generic/gdbtk-bp.c: Remove extern declarations for symbols
	in breakpoint.c.
	(gdb_set_bp_addr): Remove.
	(Gdbtk_Breakpoint_Init): Remove Tcl command "gdb_set_bp_addr".
	(gdb_set_bp): Remove file and line arguments; add "addr" argument.
	Rewrite to use "public" APIs from gdb.

[-- Attachment #2: bp.patch --]
[-- Type: text/plain, Size: 7811 bytes --]

Index: library/srctextwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
retrieving revision 1.45
diff -u -p -r1.45 srctextwin.itb
--- library/srctextwin.itb	9 Oct 2009 02:51:47 -0000	1.45
+++ library/srctextwin.itb	9 Nov 2009 19:34:29 -0000
@@ -1756,10 +1756,10 @@ itcl::body SrcTextWin::lookup_line {win 
 
   switch $type {
     asm {
-      set set_cmd [list gdb_set_bp_addr $addr]
+      set set_cmd [list gdb_set_bp "*$addr"]
     }
     src {
-      set set_cmd [list gdb_set_bp $current(filename) $addr]
+      set set_cmd [list gdb_set_bp "$current(filename):$addr"]
     }
   }
 
Index: generic/gdbtk-bp.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-bp.c,v
retrieving revision 1.31
diff -u -p -r1.31 gdbtk-bp.c
--- generic/gdbtk-bp.c	7 Jul 2009 12:38:56 -0000	1.31
+++ generic/gdbtk-bp.c	9 Nov 2009 19:34:29 -0000
@@ -1,5 +1,5 @@
 /* Tcl/Tk command definitions for Insight - Breakpoints.
-   Copyright (C) 2001, 2002, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,6 +31,7 @@
 #include "gdbtk-cmds.h"
 #include "observer.h"
 #include "arch-utils.h"
+#include "exceptions.h"
 
 /* From breakpoint.c */
 extern struct breakpoint *breakpoint_chain;
@@ -71,17 +72,6 @@ char *bpdisp[] =
  || (bp)->type == bp_read_watchpoint					      \
  || (bp)->type == bp_access_watchpoint)
 
-/*
- * These are routines we need from breakpoint.c.
- * at some point make these static in breakpoint.c and move GUI code there
- */
-
-extern struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
-					      struct symtab_and_line,
-					      enum bptype);
-extern void set_breakpoint_count (int);
-extern int breakpoint_count;
-
 /* Breakpoint/Tracepoint lists. Unfortunately, gdb forces us to
    keep a list of breakpoints, too. Why couldn't it be done like
    treacepoints? */
@@ -103,8 +93,6 @@ static int gdb_get_breakpoint_info (Clie
 static int gdb_get_breakpoint_list (ClientData, Tcl_Interp *, int,
 				    Tcl_Obj * CONST[]);
 static int gdb_set_bp (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST objv[]);
-static int gdb_set_bp_addr (ClientData, Tcl_Interp *, int,
-			    Tcl_Obj * CONST objv[]);
 
 /* Tracepoint-related functions */
 static int gdb_actions_command (ClientData, Tcl_Interp *, int,
@@ -147,8 +135,6 @@ Gdbtk_Breakpoint_Init (Tcl_Interp *inter
   Tcl_CreateObjCommand (interp, "gdb_get_breakpoint_list", gdbtk_call_wrapper,
 			gdb_get_breakpoint_list, NULL);
   Tcl_CreateObjCommand (interp, "gdb_set_bp", gdbtk_call_wrapper, gdb_set_bp, NULL);
-  Tcl_CreateObjCommand (interp, "gdb_set_bp_addr", gdbtk_call_wrapper,
-			gdb_set_bp_addr, NULL);
 
   /* Tracepoint commands */
   Tcl_CreateObjCommand (interp, "gdb_actions",
@@ -489,8 +475,7 @@ gdb_get_breakpoint_list (ClientData clie
  * It sets breakpoints, and notifies the GUI.
  *
  * Tcl Arguments:
- *    filename: the file in which to set the breakpoint
- *    line:     the line number for the breakpoint
+ *    addr:     the "address" for the breakpoint (either *ADDR or file:line)
  *    type:     the type of the breakpoint
  *    thread:   optional thread number
  * Tcl Result:
@@ -500,135 +485,59 @@ static int
 gdb_set_bp (ClientData clientData, Tcl_Interp *interp,
 	    int objc, Tcl_Obj *CONST objv[])
 {
-  struct symtab_and_line sal;
-  int line, thread = -1;
-  struct breakpoint *b;
-  char *buf, *typestr;
-  enum bpdisp disp;
+  int temp, ignore_count, thread, pending, enabled;
+  char *address, *typestr, *condition;
+  struct gdb_exception e;
+
+  /* Insight does not use all of these (yet?).  */
+  ignore_count = 0;
+  condition = NULL;
+  pending = 0;
+  enabled = 1;
 
-  if (objc != 4 && objc != 5)
+  if (objc != 3 && objc != 4)
     {
-      Tcl_WrongNumArgs (interp, 1, objv, "filename line type ?thread?");
+      Tcl_WrongNumArgs (interp, 1, objv, "addr type ?thread?");
       return TCL_ERROR;
     }
 
-  sal.symtab = lookup_symtab (Tcl_GetStringFromObj (objv[1], NULL));
-  if (sal.symtab == NULL)
-    return TCL_ERROR;
-
-  if (Tcl_GetIntFromObj (interp, objv[2], &line) == TCL_ERROR)
+  address = Tcl_GetStringFromObj (objv[1], NULL);
+  if (address == NULL)
     {
       result_ptr->flags = GDBTK_IN_TCL_RESULT;
       return TCL_ERROR;
     }
 
-  typestr = Tcl_GetStringFromObj (objv[3], NULL);
+  typestr = Tcl_GetStringFromObj (objv[2], NULL);
   if (strncmp (typestr, "temp", 4) == 0)
-    disp = disp_del;
+    temp = 1;
   else if (strncmp (typestr, "normal", 6) == 0)
-    disp = disp_donttouch;
+    temp = 0;
   else
     {
       gdbtk_set_result (interp, "type must be \"temp\" or \"normal\"");
       return TCL_ERROR;
     }
 
-  if (objc == 5)
+  if (objc == 4)
     {
-      if (Tcl_GetIntFromObj (interp, objv[4], &thread) == TCL_ERROR)
+      if (Tcl_GetIntFromObj (interp, objv[3], &thread) == TCL_ERROR)
 	{
 	  result_ptr->flags = GDBTK_IN_TCL_RESULT;
 	  return TCL_ERROR;
 	}
     }
 
-  sal.line = line;
-  if (!find_line_pc (sal.symtab, sal.line, &sal.pc))
-    return TCL_ERROR;
-
-  sal.section = find_pc_overlay (sal.pc);
-  b = set_raw_breakpoint (get_current_arch (), sal, bp_breakpoint);
-  set_breakpoint_count (breakpoint_count + 1);
-  b->number = breakpoint_count;
-  b->disposition = disp;
-  b->thread = thread;
-
-  /* FIXME: this won't work for duplicate basenames! */
-  buf = xstrprintf ("%s:%d", lbasename (Tcl_GetStringFromObj (objv[1], NULL)),
-	     line);
-  b->addr_string = xstrdup (buf);
-  free(buf);
-
-  /* now send notification command back to GUI */
-  observer_notify_breakpoint_created (b->number);
-  return TCL_OK;
-}
-
-/* This implements the tcl command "gdb_set_bp_addr"
- * It sets breakpoints, and notifies the GUI.
- *
- * Tcl Arguments:
- *    addr:     the CORE_ADDR at which to set the breakpoint
- *    type:     the type of the breakpoint
- *    thread:   optional thread number
- * Tcl Result:
- *    The return value of the call to gdbtk_tcl_breakpoint.
- */
-static int
-gdb_set_bp_addr (ClientData clientData, Tcl_Interp *interp, int objc,
-		 Tcl_Obj *CONST objv[])
-     
-{
-  struct symtab_and_line sal;
-  int thread = -1;
-  CORE_ADDR addr;
-  Tcl_WideInt waddr;
-  struct breakpoint *b;
-  char *saddr, *typestr;
-  enum bpdisp disp;
-
-  if (objc != 3 && objc != 4)
+  TRY_CATCH (e, RETURN_MASK_ALL)
     {
-      Tcl_WrongNumArgs (interp, 1, objv, "address type ?thread?");
-      return TCL_ERROR;
+      set_breakpoint (get_current_arch (), address, condition,
+		      0 /* hardwareflag */, temp, thread, ignore_count,
+		      pending, enabled);
     }
 
-  if (Tcl_GetWideIntFromObj (interp, objv[1], &waddr) != TCL_OK)
+  if (e.reason < 0)
     return TCL_ERROR;
-  addr = waddr;
-  saddr = Tcl_GetStringFromObj (objv[1], NULL);
-
-  typestr = Tcl_GetStringFromObj (objv[2], NULL);
-  if (strncmp (typestr, "temp", 4) == 0)
-    disp = disp_del;
-  else if (strncmp (typestr, "normal", 6) == 0)
-    disp = disp_donttouch;
-  else
-    {
-      gdbtk_set_result (interp, "type must be \"temp\" or \"normal\"");
-      return TCL_ERROR;
-    }
-
-  if (objc == 4)
-    {
-      if (Tcl_GetIntFromObj (interp, objv[3], &thread) == TCL_ERROR)
-	{
-	  result_ptr->flags = GDBTK_IN_TCL_RESULT;
-	  return TCL_ERROR;
-	}
-    }
-
-  sal = find_pc_line (addr, 0);
-  sal.pc = addr;
-  b = set_raw_breakpoint (get_current_arch (), sal, bp_breakpoint);
-  set_breakpoint_count (breakpoint_count + 1);
-  b->number = breakpoint_count;
-  b->disposition = disp;
-  b->thread = thread;
-  b->addr_string = xstrdup (saddr);
 
-  /* now send notification command back to GUI */
-  observer_notify_breakpoint_created (b->number);
   return TCL_OK;
 }
 \f

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-09 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09 19:43 [PATCH] Update breakpoint methods Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).