public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Hui Zhu <teawater@gmail.com>
Cc: insight <insight@sourceware.org>
Subject: Re: [BUG] build trunk error
Date: Fri, 13 May 2011 00:37:00 -0000	[thread overview]
Message-ID: <4DCC7D3A.5060206@redhat.com> (raw)
In-Reply-To: <BANLkTimo3Lb28=mT5FTy-mP1G80Q2mTjWw@mail.gmail.com>

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

On 05/08/2011 09:05 PM, Hui Zhu wrote:
> ../../src/gdb/gdbtk/generic/gdbtk-hooks.c: In function 'gdbtk_add_hooks':
> ../../src/gdb/gdbtk/generic/gdbtk-hooks.c:126: error: passing argument
> 1 of 'observer_attach_breakpoint_created' from incompatible pointer
> type

[snip]

I've committed the attached patch to address this. IMO this patch should 
have been necessary years ago! [Better late than never, gdb! :-)]

Thank you for notifying me.

Keith

ChangeLog
2011-05-12  Keith Seitz  <keiths@redhat.com>

	* generic/gdbtk-hooks.c (gdbtk_create_breakpoint): Change
	parameter from `int' to `struct breakpoint *'.
	(gdbtk_delete_breakpoint): Likewise.
	(gdbtk_modify_breakpoint): Likewise.
	* generic/gdbtk-bp.c (ALL_BREAKPOINTS): Define.
	(breakpoint_list): Remove.
	(breakpoint_list_size): Remove.
	(Gdbtk_Breakpoint_Init): Remove initialization of breakpoint_list.
	(gdb_find_bp_at_addr): Rewrite using ALL_BREAKPOINTS.
	(gdb_find_bp_at_line): Likewise.
	(gdb_get_breakpoint_info): Likewise.
	(gdb_get_breakpoint_list): Likewise.
	(gdbtk_create_breakpoint): Change parameter from `int' to
	`struct breakpoint *' and update function.
	(gdbtk_delete_breakpoint): Likewise.
	(gdbtk_modify_breakpoint): Likewise.	
	(breakpoint_notify): Rewrite using ALL_BREAKPOINTS.

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

Index: generic/gdbtk-bp.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-bp.c,v
retrieving revision 1.40
diff -u -p -r1.40 gdbtk-bp.c
--- generic/gdbtk-bp.c	12 Apr 2011 05:11:08 -0000	1.40
+++ generic/gdbtk-bp.c	13 May 2011 00:33:04 -0000
@@ -42,6 +42,8 @@ static int gdbtk_obj_array_ptr;
 /* From breakpoint.c */
 extern struct breakpoint *breakpoint_chain;
 
+#define ALL_BREAKPOINTS(B)  for (B = breakpoint_chain; B; B = B->next)
+
 /* From gdbtk-hooks.c */
 extern void report_error (void);
 
@@ -78,13 +80,6 @@ char *bpdisp[] =
  || (bp)->type == bp_read_watchpoint					      \
  || (bp)->type == bp_access_watchpoint)
 
-/* Breakpoint/Tracepoint lists. Unfortunately, gdb forces us to
-   keep a list of breakpoints, too. Why couldn't it be done like
-   treacepoints? */
-#define DEFAULT_LIST_SIZE 32
-static struct breakpoint **breakpoint_list;
-static int breakpoint_list_size = DEFAULT_LIST_SIZE;
-
 /*
  * Forward declarations
  */
@@ -119,9 +114,9 @@ static int tracepoint_exists (char *args
 
 /* Breakpoint/tracepoint events and related functions */
 
-void gdbtk_create_breakpoint (int);
-void gdbtk_delete_breakpoint (int);
-void gdbtk_modify_breakpoint (int);
+void gdbtk_create_breakpoint (struct breakpoint *);
+void gdbtk_delete_breakpoint (struct breakpoint *);
+void gdbtk_modify_breakpoint (struct breakpoint *);
 void gdbtk_create_tracepoint (int);
 void gdbtk_delete_tracepoint (int);
 void gdbtk_modify_tracepoint (int);
@@ -156,10 +151,6 @@ Gdbtk_Breakpoint_Init (Tcl_Interp *inter
   Tcl_CreateObjCommand (interp, "gdb_tracepoint_exists",
 			gdbtk_call_wrapper, gdb_tracepoint_exists_command, NULL);
 
-  /* Initialize our tables of BPs. */
-  breakpoint_list = (struct breakpoint **) xmalloc (breakpoint_list_size * sizeof (struct breakpoint *));
-  memset (breakpoint_list, 0, breakpoint_list_size * sizeof (struct breakpoint *));
-
   return TCL_OK;
 }
 
@@ -209,9 +200,9 @@ static int
 gdb_find_bp_at_addr (ClientData clientData, Tcl_Interp *interp,
 		     int objc, Tcl_Obj *CONST objv[])
 {
-  int i;
   CORE_ADDR addr;
   Tcl_WideInt waddr;
+  struct breakpoint *b;
 
   if (objc != 2)
     {
@@ -224,12 +215,11 @@ gdb_find_bp_at_addr (ClientData clientDa
   addr = waddr;
 
   Tcl_SetListObj (result_ptr->obj_ptr, 0, NULL);
-  for (i = 0; i < breakpoint_list_size; i++)
+  ALL_BREAKPOINTS (b)
     {
-      if (breakpoint_list[i] != NULL && breakpoint_list[i]->loc != NULL
-	  && breakpoint_list[i]->loc->address == addr)
+      if (b->loc != NULL && b->loc->address == addr)
 	Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
-				  Tcl_NewIntObj (i));
+				  Tcl_NewIntObj (b->number));
     }
 
   return TCL_OK;
@@ -249,7 +239,8 @@ gdb_find_bp_at_line (ClientData clientDa
 
 {
   struct symtab *s;
-  int i, line;
+  int line;
+  struct breakpoint *b;
 
   if (objc != 3)
     {
@@ -268,12 +259,14 @@ gdb_find_bp_at_line (ClientData clientDa
     }
 
   Tcl_SetListObj (result_ptr->obj_ptr, 0, NULL);
-  for (i = 0; i < breakpoint_list_size; i++)
-    if (breakpoint_list[i] != NULL
-	&& breakpoint_list[i]->line_number == line
-	&& !strcmp (breakpoint_list[i]->source_file, s->filename))
-      Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
-				Tcl_NewIntObj (i));
+  ALL_BREAKPOINTS (b)
+  {
+    if (b->line_number == line && !strcmp (b->source_file, s->filename))
+      {
+	Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
+				  Tcl_NewIntObj (b->number));
+      }
+  }
 
   return TCL_OK;
 }
@@ -311,7 +304,11 @@ gdb_get_breakpoint_info (ClientData clie
       return TCL_ERROR;
     }
 
-  b = (bpnum <= breakpoint_list_size ? breakpoint_list[bpnum] : NULL);
+  ALL_BREAKPOINTS (b)
+  {
+    if (b->number == bpnum)
+      break;
+  }
   if (!b || b->type != bp_breakpoint)
     {
       gdbtk_set_result (interp, "Breakpoint #%d does not exist.", bpnum);
@@ -466,8 +463,8 @@ static int
 gdb_get_breakpoint_list (ClientData clientData, Tcl_Interp *interp,
 			 int objc, Tcl_Obj *CONST objv[])
 {
-  int i;
   Tcl_Obj *new_obj;
+  struct breakpoint *b;
 
   if (objc != 1)
     {
@@ -475,15 +472,14 @@ gdb_get_breakpoint_list (ClientData clie
       return TCL_ERROR;
     }
 
-  for (i = 0; i < breakpoint_list_size; i++)
-    {
-      if (breakpoint_list[i] != NULL
-	  && breakpoint_list[i]->type == bp_breakpoint)
-	{
-	  new_obj = Tcl_NewIntObj (i);
-	  Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, new_obj);
-	}
-    }
+  ALL_BREAKPOINTS (b)
+  {
+    if (b->type == bp_breakpoint)
+      {
+	new_obj = Tcl_NewIntObj (b->number);
+	Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, new_obj);
+      }
+  }
 
   return TCL_OK;
 }
@@ -575,49 +571,25 @@ gdb_set_bp (ClientData clientData, Tcl_I
  */
 
 void
-gdbtk_create_breakpoint (int num)
+gdbtk_create_breakpoint (struct breakpoint *b)
 {
-  struct breakpoint *b;
-  for (b = breakpoint_chain; b != NULL; b = b->next)
-    {
-      if (b->number == num)
-	break;
-    }
-
   if (b == NULL || !BREAKPOINT_IS_INTERESTING (b))
     return;
 
-  /* Check if there is room to store it */
-  if (num >= breakpoint_list_size)
-    {
-      int oldsize = breakpoint_list_size;
-      while (num >= breakpoint_list_size)
-	breakpoint_list_size += DEFAULT_LIST_SIZE;
-      breakpoint_list = (struct breakpoint **) xrealloc (breakpoint_list, breakpoint_list_size * sizeof (struct breakpoint *));
-      memset (&(breakpoint_list[oldsize]), 0, (breakpoint_list_size - oldsize) * sizeof (struct breakpoint *));
-    }
-
-  breakpoint_list[num] = b;
-  breakpoint_notify (num, "create");
+  breakpoint_notify (b->number, "create");
 }
 
 void
-gdbtk_delete_breakpoint (int num)
+gdbtk_delete_breakpoint (struct breakpoint *b)
 {
-  if (num >= 0
-      && num <= breakpoint_list_size
-      && breakpoint_list[num] != NULL)
-    {
-      breakpoint_notify (num, "delete");
-      breakpoint_list[num] = NULL;
-    }
+  breakpoint_notify (b->number, "delete");
 }
 
 void
-gdbtk_modify_breakpoint (int num)
+gdbtk_modify_breakpoint (struct breakpoint *b)
 {
-  if (num >= 0)
-    breakpoint_notify (num, "modify");
+  if (b->number >= 0)
+    breakpoint_notify (b->number, "modify");
 }
 
 /* This is the generic function for handling changes in
@@ -630,21 +602,26 @@ static void
 breakpoint_notify (int num, const char *action)
 {
   char *buf;
+  struct breakpoint *b;
 
-  if (num > breakpoint_list_size
-      || num < 0
-      || breakpoint_list[num] == NULL
+  ALL_BREAKPOINTS (b)
+  {
+    if (num == b->number)
+      break;
+  }
+
+  if (b->number < 0
       /* FIXME: should not be so restrictive... */
-      || breakpoint_list[num]->type != bp_breakpoint)
+      || b->type != bp_breakpoint)
     return;
 
   /* We ensure that ACTION contains no special Tcl characters, so we
      can do this.  */
-  buf = xstrprintf ("gdbtk_tcl_breakpoint %s %d", action, num);
+  buf = xstrprintf ("gdbtk_tcl_breakpoint %s %d", action, b->number);
 
   if (Tcl_Eval (gdbtk_interp, buf) != TCL_OK)
     report_error ();
-  free(buf); 
+  xfree(buf); 
 }
 \f
 /*
Index: generic/gdbtk-hooks.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v
retrieving revision 1.51
diff -u -p -r1.51 gdbtk-hooks.c
--- generic/gdbtk-hooks.c	2 Dec 2010 06:48:00 -0000	1.51
+++ generic/gdbtk-hooks.c	13 May 2011 00:33:05 -0000
@@ -1,7 +1,7 @@
 /* Startup code for Insight.
 
    Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 200, 2002, 2003, 2004,
-   2008, 2010 Free Software Foundation, Inc.
+   2008, 2010, 2011 Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
 
@@ -68,9 +68,9 @@ volatile int in_fputs = 0;
 int gdbtk_force_detach = 0;
 
 /* From gdbtk-bp.c */
-extern void gdbtk_create_breakpoint (int);
-extern void gdbtk_delete_breakpoint (int);
-extern void gdbtk_modify_breakpoint (int);
+extern void gdbtk_create_breakpoint (struct breakpoint *);
+extern void gdbtk_delete_breakpoint (struct breakpoint *);
+extern void gdbtk_modify_breakpoint (struct breakpoint *);
 extern void gdbtk_create_tracepoint (int);
 extern void gdbtk_delete_tracepoint (int);
 extern void gdbtk_modify_tracepoint (int);

  reply	other threads:[~2011-05-13  0:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-09  4:06 Hui Zhu
2011-05-13  0:37 ` Keith Seitz [this message]
2011-05-14  3:42   ` Hui Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DCC7D3A.5060206@redhat.com \
    --to=keiths@redhat.com \
    --cc=insight@sourceware.org \
    --cc=teawater@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).