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

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