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 internal-error on permanent breakpoint on top of permanent breakpoint.


GDB currently hits an internal error if we set a breakpoint over the
same hardcoded permanent trap location more than once.

Currently:

 >./gdb ./testsuite/gdb.arch/i386-permbkpt
 (gdb) b main
 Breakpoint 1 at 0x400488: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) b main
 Note: breakpoint 1 (permanent) also set at pc 0x400488.
 Breakpoint 2 at 0x400488: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 ../../src/gdb/breakpoint.c:3974: internal-error: another breakpoint was inserted on top of a permanent breakpoint
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n)    

The check that asserts doesn't make much sense for this case.  In fact, there isn't
any benefit in marking permanent breakpoints as duplicates of other permanent
breakpoints, since, permanent breakpoints are always inserted.

After patch:

 >./gdb ./testsuite/gdb.arch/i386-permbkpt
 (gdb) b main
 Breakpoint 1 at 0x400488: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) b main
 Note: breakpoint 1 (permanent) also set at pc 0x400488.
 Breakpoint 2 at 0x400488: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.

Tested on x86_64-linux, and checked in.  I also ran the new test on cygwin, to be
sure the _ bits are correct.

-- 
Pedro Alves

gdb/
2009-03-05  Pedro Alves  <pedro@codesourcery.com>

	* breakpoint.c (check_duplicates_for): Skip permanent breakpoints
	duplicates of permanent breakpoints.

gdb/testsuite/
2009-03-05  Pedro Alves  <pedro@codesourcery.com>

	* gdb.arch/i386-permbkpt.S, gdb.arch/i386-permbkpt.exp: New.

---
 gdb/breakpoint.c                         |    7 ++--
 gdb/testsuite/gdb.arch/i386-permbkpt.S   |   30 +++++++++++++++++
 gdb/testsuite/gdb.arch/i386-permbkpt.exp |   52 +++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 3 deletions(-)

Index: src/gdb/testsuite/gdb.arch/i386-permbkpt.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.arch/i386-permbkpt.S	2009-03-05 22:27:56.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+   This file is part of the gdb testsuite.  */
+
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str)     CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str)     str
+#endif
+
+	.global SYMBOL(main)
+SYMBOL(main):
+	int3
+	ret
Index: src/gdb/testsuite/gdb.arch/i386-permbkpt.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.arch/i386-permbkpt.exp	2009-03-05 22:34:46.000000000 +0000
@@ -0,0 +1,52 @@
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# This file is part of the gdb testsuite.
+
+if $tracelevel {
+    strace $tracelevel
+}
+
+# Test inserting breakpoints over permanent breakpoints on i386 and amd64.
+
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
+    verbose "Skipping i386 test for multi break at permanent breakpoint location."
+    return
+}
+
+set testfile "i386-permbkpt"
+set srcfile ${testfile}.S
+set binfile ${objdir}/${subdir}/${testfile}
+
+# Some targets have leading underscores on assembly symbols.
+# TODO: detect this automatically
+set additional_flags ""
+if { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } then {
+    set additional_flags "additional_flags=-DSYMBOL_PREFIX=_"
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
+    untested i386-permbkpt.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+gdb_test "break main" "" "First permanent break"
+gdb_test "break main" "" "Second permanent break"
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2009-03-05 22:26:23.000000000 +0000
+++ src/gdb/breakpoint.c	2009-03-05 22:27:56.000000000 +0000
@@ -3948,8 +3948,8 @@ check_duplicates_for (CORE_ADDR address,
     }
 
   /* If we found a permanent breakpoint at this address, go over the
-     list again and declare all the other breakpoints there to be the
-     duplicates.  */
+     list again and declare all the other breakpoints there (except
+     other permanent breakpoints) to be the duplicates.  */
   if (perm_bp)
     {
       perm_bp->duplicate = 0;
@@ -3963,7 +3963,8 @@ check_duplicates_for (CORE_ADDR address,
       ALL_BP_LOCATIONS (b)
 	if (b != perm_bp)
 	  {
-	    if (b->owner->enable_state != bp_disabled
+	    if (b->owner->enable_state != bp_permanent
+		&& b->owner->enable_state != bp_disabled
 		&& b->owner->enable_state != bp_call_disabled
 		&& b->enabled && !b->shlib_disabled		
 		&& b->address == address	/* address / overlay match */


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