keiths / rpms / gdb

Forked from rpms/gdb 12 days ago
Clone
a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-bz541866-rwatch-before-run.patch
f524ac5
f637971
;; Fix i386+x86_64 rwatch+awatch before run, regression against 6.8 (BZ 541866).
f637971
;; Fix i386 rwatch+awatch before run (BZ 688788, on top of BZ 541866).
f637971
;;=push+jan: It should be fixed properly instead.
f524ac5
f637971
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
f637971
--- a/gdb/breakpoint.c
f637971
+++ b/gdb/breakpoint.c
31f5b96
@@ -8777,7 +8777,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
f637971
 		     int enabled, int internal, unsigned flags,
f637971
 		     int display_canonical)
f637971
 {
f637971
-  int i;
f637971
+  int i ATTRIBUTE_UNUSED;
c874340
 
f637971
   if (type == bp_hardware_breakpoint)
f637971
     {
31f5b96
@@ -14335,7 +14335,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
Jan Kratochvil 5752ad0
 
f637971
   if (bpt->type == bp_hardware_breakpoint)
f637971
     {
f637971
-      int i;
f637971
+      int i ATTRIBUTE_UNUSED;
f637971
       i = hw_breakpoint_used_count ();
f637971
       target_resources_ok = 
f637971
 	target_can_use_hardware_watchpoint (bp_hardware_breakpoint, 
f637971
diff --git a/gdb/config/i386/nm-linux.h b/gdb/config/i386/nm-linux.h
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/config/i386/nm-linux.h
Jan Kratochvil 5752ad0
@@ -0,0 +1,28 @@
Jan Kratochvil 5752ad0
+/* Native support for GNU/Linux i386.
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+   Copyright 2010 Free Software Foundation, Inc.
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+   This file is part of GDB.
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 5752ad0
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 5752ad0
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 5752ad0
+   (at your option) any later version.
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 5752ad0
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 5752ad0
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 5752ad0
+   GNU General Public License for more details.
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 5752ad0
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+#ifndef NM_LINUX_H
Jan Kratochvil 5752ad0
+#define NM_LINUX_H
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+#include "config/nm-linux.h"
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+/* Red Hat backward compatibility with gdb-6.8.  */
Jan Kratochvil 5752ad0
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
Jan Kratochvil 5752ad0
+
Jan Kratochvil 5752ad0
+#endif /* NM_LINUX64_H */
f637971
diff --git a/gdb/config/i386/nm-linux64.h b/gdb/config/i386/nm-linux64.h
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/config/i386/nm-linux64.h
c874340
@@ -0,0 +1,28 @@
c874340
+/* Native support for GNU/Linux amd64.
c874340
+
c874340
+   Copyright 2010 Free Software Foundation, Inc.
c874340
+
c874340
+   This file is part of GDB.
c874340
+
c874340
+   This program is free software; you can redistribute it and/or modify
c874340
+   it under the terms of the GNU General Public License as published by
c874340
+   the Free Software Foundation; either version 3 of the License, or
c874340
+   (at your option) any later version.
c874340
+
c874340
+   This program is distributed in the hope that it will be useful,
c874340
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
c874340
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c874340
+   GNU General Public License for more details.
c874340
+
c874340
+   You should have received a copy of the GNU General Public License
c874340
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
c874340
+
c874340
+#ifndef NM_LINUX64_H
c874340
+#define NM_LINUX64_H
c874340
+
c874340
+#include "config/nm-linux.h"
c874340
+
c874340
+/* Red Hat backward compatibility with gdb-6.8.  */
c874340
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
c874340
+
c874340
+#endif /* NM_LINUX64_H */
f637971
diff --git a/gdb/configure.nat b/gdb/configure.nat
f637971
--- a/gdb/configure.nat
f637971
+++ b/gdb/configure.nat
31f5b96
@@ -244,6 +244,7 @@ case ${gdb_host} in
f637971
 		;;
f637971
 	    i386)
f637971
 		# Host: Intel 386 running GNU/Linux.
f637971
+		NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux.h"
31f5b96
 		NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
31f5b96
 		i386-linux-nat.o x86-linux-nat.o nat/linux-btrace.o \
31f5b96
 		nat/x86-linux.o nat/x86-linux-dregs.o"
31f5b96
@@ -300,6 +301,7 @@ case ${gdb_host} in
f637971
 	case ${gdb_host_cpu} in
f637971
 	    i386)
f637971
 		# Host: GNU/Linux x86-64
f637971
+		NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux64.h"
31f5b96
 		NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
31f5b96
 		amd64-nat.o amd64-linux-nat.o x86-linux-nat.o \
31f5b96
 		nat/linux-btrace.o \
f637971
diff --git a/gdb/target.h b/gdb/target.h
f637971
--- a/gdb/target.h
f637971
+++ b/gdb/target.h
31f5b96
@@ -1972,9 +1972,11 @@ extern struct thread_info *target_thread_handle_to_thread_info
Jan Kratochvil 7306e88
    one.  OTHERTYPE is the number of watchpoints of other types than
Jan Kratochvil 7306e88
    this one used so far.  */
c874340
 
c874340
+#ifndef target_can_use_hardware_watchpoint
c874340
 #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
399e220
  (current_top_target ()->can_use_hw_breakpoint) ( \
Jan Kratochvil 32f92b2
 					     TYPE, CNT, OTHERTYPE)
c874340
+#endif
c874340
 
Jan Kratochvil b0e03f5
 /* Returns the number of debug registers needed to watch the given
Jan Kratochvil b0e03f5
    memory region, or zero if not supported.  */
f637971
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
c874340
@@ -0,0 +1,40 @@
c874340
+# Copyright 2009, 2010 Free Software Foundation, Inc.
c874340
+
c874340
+# This program is free software; you can redistribute it and/or modify
c874340
+# it under the terms of the GNU General Public License as published by
c874340
+# the Free Software Foundation; either version 3 of the License, or
c874340
+# (at your option) any later version.
c874340
+#
c874340
+# This program is distributed in the hope that it will be useful,
c874340
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c874340
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c874340
+# GNU General Public License for more details.
c874340
+#
c874340
+# You should have received a copy of the GNU General Public License
c874340
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
c874340
+
c874340
+# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set.
c874340
+if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]
c874340
+     && ![istarget "ia64-*-*"])
c874340
+    || [target_info exists gdb,no_hardware_watchpoints]} then {
c874340
+    verbose "Skipping watchpoint-hw-before-run test."
c874340
+    return
c874340
+}
c874340
+
c874340
+set test watchpoint-hw-before-run
c874340
+set srcfile watchpoint-hw-hit-once.c
c874340
+if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } {
c874340
+    return -1
c874340
+}
c874340
+
c874340
+gdb_test "rwatch watchee" "ardware read watchpoint 1: watchee"
c874340
+
c874340
+# `runto_main' or `runto main' would delete the watchpoint created above.
c874340
+
c874340
+if { [gdb_start_cmd] < 0 } {
c874340
+    untested start
c874340
+    return -1
c874340
+}
c874340
+gdb_test "" "main .* at .*" "start"
c874340
+
Jan Kratochvil c16b445
+gdb_test "continue" "Continuing.\r\n\r\nHardware read watchpoint \[0-9\]+: watchee\r\n\r\nValue = 0\r\n.*"