Blame SOURCES/gdb-bz541866-rwatch-before-run.patch

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