This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix for gdb/1689 (gdb.base/ena-dis-br.exp)


Hi all,

This patch fixes the last test in gdb.base/ena-dis-br.exp, which was a FAIL in wince,
and a KFAIL on Cygwin (at least). The problem is that internal breakpoints have
negative numbering starting at -1, and bpstat_num returns -1 on a breakpoint
that has already been deleted. bpstat_num would sometimes return the internal
breakpoint -1 resulting in ambiguity.


Fixed by changing bpstat_num's interface, to remove the ambiguity.

OK?

Cheers,
Pedro Alves

2007-03-01  Pedro Alves  <pedro_alves@portugalmail.pt>

	* breakpoint.c (bpstat_num): Add int *num parameter.
	* breakpoint.h (bpstat_num): Likewise.
	* infcmd.c (continue_command): Adjust to new bpstat_num
	interface.
	(program_info): Likewise.

---

 gdb/breakpoint.c |   26 ++++++++++++++------------
 gdb/breakpoint.h |    9 ++++++---
 gdb/infcmd.c     |   41 +++++++++++++++++++++++------------------
 3 files changed, 43 insertions(+), 33 deletions(-)

Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2007-02-24 16:53:16.000000000 +0000
+++ src/gdb/breakpoint.c	2007-03-01 00:49:48.000000000 +0000
@@ -2054,28 +2054,30 @@ bpstat_find_step_resume_breakpoint (bpst
 }
 
 
-/* Return the breakpoint number of the first breakpoint we are stopped
+/* Put in *NUM the breakpoint number of the first breakpoint we are stopped
    at.  *BSP upon return is a bpstat which points to the remaining
    breakpoints stopped at (but which is not guaranteed to be good for
    anything but further calls to bpstat_num).
-   Return 0 if passed a bpstat which does not indicate any breakpoints.  */
+   Return 0 if passed a bpstat which does not indicate any breakpoints.
+   Return -1 if stopped at a breakpoint that has been deleted since
+   we set it.
+   Return 1 otherwise.  */
 
 int
-bpstat_num (bpstat *bsp)
+bpstat_num (bpstat *bsp, int *num)
 {
   struct breakpoint *b;
 
   if ((*bsp) == NULL)
     return 0;			/* No more breakpoint values */
-  else
-    {
-      b = (*bsp)->breakpoint_at;
-      *bsp = (*bsp)->next;
-      if (b == NULL)
-	return -1;		/* breakpoint that's been deleted since */
-      else
-	return b->number;	/* We have its number */
-    }
+
+  b = (*bsp)->breakpoint_at;
+  *bsp = (*bsp)->next;
+  if (b == NULL)
+    return -1;			/* breakpoint that's been deleted since */
+
+  *num = b->number;		/* We have its number */
+  return 1;
 }
 
 /* Modify BS so that the actions will not be performed.  */
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h	2007-02-24 16:53:16.000000000 +0000
+++ src/gdb/breakpoint.h	2007-03-01 00:49:24.000000000 +0000
@@ -562,12 +562,15 @@ extern int bpstat_have_active_hw_watchpo
    return means print the frame as well as the source line).  */
 extern enum print_stop_action bpstat_print (bpstat);
 
-/* Return the breakpoint number of the first breakpoint we are stopped
+/* Put in *NUM the breakpoint number of the first breakpoint we are stopped
    at.  *BSP upon return is a bpstat which points to the remaining
    breakpoints stopped at (but which is not guaranteed to be good for
    anything but further calls to bpstat_num).
-   Return 0 if passed a bpstat which does not indicate any breakpoints.  */
-extern int bpstat_num (bpstat *);
+   Return 0 if passed a bpstat which does not indicate any breakpoints.
+   Return -1 if stopped at a breakpoint that has been deleted since
+   we set it.
+   Return 1 otherwise.  */
+extern int bpstat_num (bpstat *, int *);
 
 /* Perform actions associated with having stopped at *BSP.  Actually, we just
    use this for breakpoint commands.  Perhaps other actions will go here
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2007-02-24 16:53:16.000000000 +0000
+++ src/gdb/infcmd.c	2007-03-01 00:48:32.000000000 +0000
@@ -622,23 +622,27 @@ continue_command (char *proc_count_exp, 
   if (proc_count_exp != NULL)
     {
       bpstat bs = stop_bpstat;
-      int num = bpstat_num (&bs);
-      if (num == 0 && from_tty)
+      int num, stat;
+      int stopped = 0;
+
+      while ((stat = bpstat_num (&bs, &num)) != 0)
+	if (stat > 0)
+	  {
+	    set_ignore_count (num,
+			      parse_and_eval_long (proc_count_exp) - 1,
+			      from_tty);
+	    /* set_ignore_count prints a message ending with a period.
+	       So print two spaces before "Continuing.".  */
+	    if (from_tty)
+	      printf_filtered ("  ");
+	    stopped = 1;
+	  }
+
+      if (!stopped && from_tty)
 	{
 	  printf_filtered
 	    ("Not stopped at any breakpoint; argument ignored.\n");
 	}
-      while (num != 0)
-	{
-	  set_ignore_count (num,
-			    parse_and_eval_long (proc_count_exp) - 1,
-			    from_tty);
-	  /* set_ignore_count prints a message ending with a period.
-	     So print two spaces before "Continuing.".  */
-	  if (from_tty)
-	    printf_filtered ("  ");
-	  num = bpstat_num (&bs);
-	}
     }
 
   if (from_tty)
@@ -1388,7 +1392,8 @@ static void
 program_info (char *args, int from_tty)
 {
   bpstat bs = stop_bpstat;
-  int num = bpstat_num (&bs);
+  int num;
+  int stat = bpstat_num (&bs, &num);
 
   if (!target_has_execution)
     {
@@ -1401,20 +1406,20 @@ program_info (char *args, int from_tty)
 		   hex_string ((unsigned long) stop_pc));
   if (stop_step)
     printf_filtered (_("It stopped after being stepped.\n"));
-  else if (num != 0)
+  else if (stat != 0)
     {
       /* There may be several breakpoints in the same place, so this
          isn't as strange as it seems.  */
-      while (num != 0)
+      while (stat != 0)
 	{
-	  if (num < 0)
+	  if (stat < 0)
 	    {
 	      printf_filtered (_("\
 It stopped at a breakpoint that has since been deleted.\n"));
 	    }
 	  else
 	    printf_filtered (_("It stopped at breakpoint %d.\n"), num);
-	  num = bpstat_num (&bs);
+	  stat = bpstat_num (&bs, &num);
 	}
     }
   else if (stop_signal != TARGET_SIGNAL_0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]