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

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