public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] fix PR-15501
@ 2013-08-13 10:03 Muhammad Waqas
  2013-08-13 17:37 ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Muhammad Waqas @ 2013-08-13 10:03 UTC (permalink / raw)
  To: gdb-patches

Hi

GDB enable/disable command does not work correctly as it should be.
http://sourceware.org/bugzilla/show_bug.cgi?id=15501

Addition to Pedro examples.
if we execute following commands these will be executed
without an error.
(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004004b8 in main at 13929.c:13
2       breakpoint     keep y   0x00000000004004b8 in main at 13929.c:13
(gdb) disable 1 fooo.1
(gdb) info break
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   <MULTIPLE>
1.1                         n     0x00000000004004b8 in main at 13929.c:13
2       breakpoint     keep y   0x00000000004004b8 in main at 13929.c:13

It should disable breakpoint 1 and error on fooo but what gdb did, it disable 1.1
surprisingly.

I am prposing patch for this bug.

Workaround:
Pars args and handle them one by one if it contain period or not and do what it
requires(disable/enable breakpoint or location).

gdb\Changlog

2013-08-13  Muhammad Waqas  <mwaqas@codesourcery.com>

	PR gdb/15501
	* breakpoint.c (enable_command): Handle multiple arguments properly.
	(disable_command): Handle multiple arguments properly.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.773
diff -u -p -r1.773 breakpoint.c
--- breakpoint.c	24 Jul 2013 19:50:32 -0000	1.773
+++ breakpoint.c	13 Aug 2013 07:55:49 -0000
@@ -14553,25 +14553,35 @@ disable_command (char *args, int from_tt
  	if (user_breakpoint_p (bpt))
  	  disable_breakpoint (bpt);
      }
-  else if (strchr (args, '.'))
+  else
      {
-      struct bp_location *loc = find_location_by_number (args);
-      if (loc)
+      char *num = extract_arg (&args);
+
+      while (num)
  	{
-	  if (loc->enabled)
+	  if (strchr (num, '.'))
  	    {
-	      loc->enabled = 0;
-	      mark_breakpoint_location_modified (loc);
+	      struct bp_location *loc = find_location_by_number (num);
+
+	      if (loc)
+		{
+		  if (loc->enabled)
+		    {
+		      loc->enabled = 0;
+		      mark_breakpoint_location_modified (loc);
+		    }
+		  if (target_supports_enable_disable_tracepoint ()
+		      && current_trace_status ()->running && loc->owner
+		      && is_tracepoint (loc->owner))
+		    target_disable_tracepoint (loc);
+		}
+	      update_global_location_list (0);
  	    }
-	  if (target_supports_enable_disable_tracepoint ()
-	      && current_trace_status ()->running && loc->owner
-	      && is_tracepoint (loc->owner))
-	    target_disable_tracepoint (loc);
+	  else
+	    map_breakpoint_numbers (num, do_map_disable_breakpoint, NULL);
+	  num = extract_arg (&args);
  	}
-      update_global_location_list (0);
      }
-  else
-    map_breakpoint_numbers (args, do_map_disable_breakpoint, NULL);
  }
  
  static void
@@ -14677,25 +14687,35 @@ enable_command (char *args, int from_tty
  	if (user_breakpoint_p (bpt))
  	  enable_breakpoint (bpt);
      }
-  else if (strchr (args, '.'))
+  else
      {
-      struct bp_location *loc = find_location_by_number (args);
-      if (loc)
+      char *num = extract_arg (&args);
+
+      while (num)
  	{
-	  if (!loc->enabled)
+	  if (strchr (num, '.'))
  	    {
-	      loc->enabled = 1;
-	      mark_breakpoint_location_modified (loc);
+	      struct bp_location *loc = find_location_by_number (num);
+
+	      if (loc)
+		{
+		  if (!loc->enabled)
+		    {
+		      loc->enabled = 1;
+		      mark_breakpoint_location_modified (loc);
+		    }
+		  if (target_supports_enable_disable_tracepoint ()
+		      && current_trace_status ()->running && loc->owner
+		      && is_tracepoint (loc->owner))
+		    target_enable_tracepoint (loc);
+		}
+	      update_global_location_list (1);
  	    }
-	  if (target_supports_enable_disable_tracepoint ()
-	      && current_trace_status ()->running && loc->owner
-	      && is_tracepoint (loc->owner))
-	    target_enable_tracepoint (loc);
+	  else
+	    map_breakpoint_numbers (num, do_map_enable_breakpoint, NULL);
+	  num = extract_arg (&args);
  	}
-      update_global_location_list (1);
      }
-  else
-    map_breakpoint_numbers (args, do_map_enable_breakpoint, NULL);
  }

  /* This struct packages up disposition data for application to multiple

testsuite\Changlog

2013-07-13  Muhammad Waqas  <mwaqas@codesourccery.com>

	PR gdb/15501
	* gdb.base/ena-dis-br.exp: Add test to verify
	enable\disable commands work correctly with arguments.

Index: ena-dis-br.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ena-dis-br.exp,v
retrieving revision 1.22
diff -u -p -r1.22 ena-dis-br.exp
--- ena-dis-br.exp	27 Jun 2013 18:50:30 -0000	1.22
+++ ena-dis-br.exp	13 Aug 2013 07:57:26 -0000
@@ -301,5 +301,35 @@ gdb_test_multiple "continue 2" "$test" {
      }
  }
  
+# Verify that GDB correctly handles the "enable/disable" command with arguments.
+#
+if ![runto_main] then { fail "enable/disable break tests suppressed" }
+
+set b1 0
+set b2 0
+
+gdb_test_multiple "break main" "bp 1" {
+    -re "(Breakpoint )(\[0-9\]+)( at.* file .*$srcfile, line.*)($gdb_prompt $)" {
+	set b1 $expect_out(2,string)
+    	pass "breakpoint main 1"
+    }
+}
+
+gdb_test_multiple "break main" "bp 2" {
+    -re "(Breakpoint )(\[0-9\]+)( at.* file .*$srcfile, line.*)($gdb_prompt $)" {
+	set b2 $expect_out(2,string)
+    	pass "breakpoint main 2"
+    }
+}
+
+gdb_test_no_output "disable $b1.1 $b2.1" "disable command"
+gdb_test "info break" \
+    "(${b1}.1)(\[^\n\r\]*)( n.*)(${b2}.1)(\[^\n\r\]*)( n.*)" \
+    "disable ${b1}.1 and ${b2}.1"
+
+gdb_test "disable $b1 fooo.1" \
+    "Bad breakpoint number 'fooo'" \
+    "handle multiple args"
+
  gdb_exit
  return 0

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-08-23  7:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13 10:03 [PATCH] fix PR-15501 Muhammad Waqas
2013-08-13 17:37 ` Pedro Alves
2013-08-15 10:32   ` Muhammad Waqas
2013-08-19 15:28     ` Pedro Alves
2013-08-20  6:45       ` Waqas, Muhammad
2013-08-21 22:17     ` Pedro Alves
2013-08-22  9:36       ` Waqas, Muhammad
2013-08-22 12:02         ` Pedro Alves
2013-08-22 13:13           ` Waqas, Muhammad
2013-08-22 13:41             ` Pedro Alves
2013-08-23  7:27               ` Muhammad Waqas

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).