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

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