New Fedora GDB testfile: rhbz1261564-aarch64-watchpoint.exp

- Backport gdb-7.11 stable branch PR gdb/19676 fix (Pedro Alves).
This commit is contained in:
Jan Kratochvil 2016-03-15 19:31:32 +01:00
parent 01264bee10
commit b84e3d603f
3 changed files with 253 additions and 3 deletions

View File

@ -0,0 +1,86 @@
Index: gdb-7.6.1/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.6.1/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.exp 2016-03-10 22:31:31.152094080 +0100
@@ -0,0 +1,43 @@
+# Copyright (C) 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if { [prepare_for_testing rhbz1261564-aarch64-watchpoint.exp "rhbz1261564-aarch64-watchpoint"] } {
+ return -1
+}
+
+if { ! [ runto main ] } then { return 0 }
+
+gdb_test "rwatch aligned.var4" "Hardware read watchpoint \[0-9\]+: aligned.var4"
+
+proc checkvar { address } {
+ global gdb_prompt
+
+ set test "p &aligned.var$address"
+ gdb_test_multiple $test $test {
+ -re " = \\(int \\*\\) 0x\[0-9a-f\]+$address <aligned(\\+\[0-9\]+)?>\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ untested "$test (unexpected ELF layout)"
+ return 0
+ }
+ }
+ return 1
+}
+if ![checkvar "0"] { return }
+if ![checkvar "4"] { return }
+if ![checkvar "8"] { return }
+
+gdb_continue_to_end
Index: gdb-7.6.1/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.6.1/gdb/testsuite/gdb.base/rhbz1261564-aarch64-watchpoint.c 2016-03-10 22:31:31.152094080 +0100
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+__attribute__((aligned(16))) struct
+{
+ int var0, var4, var8;
+} aligned;
+
+int
+main (void)
+{
+ aligned.var0 = 1;
+ aligned.var4 = 2;
+ aligned.var8 = 3;
+
+ aligned.var4 = aligned.var0;
+
+ return 0;
+}

155
gdb-upstream.patch Normal file
View File

@ -0,0 +1,155 @@
http://sourceware.org/ml/gdb-patches/2016-03/msg00013.html
Subject: [PATCH 1/2] Fix PR gdb/19676: Disable displaced stepping if /proc not mounted
On GNU/Linux archs that support displaced stepping, if /proc is not
mounted, GDB gets stuck not able to step past breakpoints:
(gdb) c
Continuing.
dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
2163 LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
Cannot find AT_ENTRY auxiliary vector entry.
(gdb) c
Continuing.
dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
2163 LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
Cannot find AT_ENTRY auxiliary vector entry.
(gdb)
That's because GDB can't figure out where the scratch pad is.
This is a regression introduced by the earlier changes to make the
Linux native target always work in non-stop mode.
This commit makes GDB detect the case and fallback to stepping over
breakpoints in-line.
gdb/ChangeLog:
2016-03-01 Pedro Alves <pedro@cascais.lan>
PR gdb/19676
* infrun.c (displaced_step_prepare): Also disable displaced
stepping on NOT_SUPPORTED_ERROR.
* linux-tdep.c (linux_displaced_step_location): If reading auxv
fails, throw NOT_SUPPORTED_ERROR instead of generic error.
---
gdb/infrun.c | 3 ++-
gdb/linux-tdep.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3e8c9e0..696105d 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1894,7 +1894,8 @@ displaced_step_prepare (ptid_t ptid)
{
struct displaced_step_inferior_state *displaced_state;
- if (ex.error != MEMORY_ERROR)
+ if (ex.error != MEMORY_ERROR
+ && ex.error != NOT_SUPPORTED_ERROR)
throw_exception (ex);
if (debug_infrun)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 555c302..f197aa7 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -2426,7 +2426,8 @@ linux_displaced_step_location (struct gdbarch *gdbarch)
location. The auxiliary vector gets us the PowerPC-side entry
point address instead. */
if (target_auxv_search (&current_target, AT_ENTRY, &addr) <= 0)
- error (_("Cannot find AT_ENTRY auxiliary vector entry."));
+ throw_error (NOT_SUPPORTED_ERROR,
+ _("Cannot find AT_ENTRY auxiliary vector entry."));
/* Make certain that the address points at real code, and not a
function descriptor. */
--
2.5.0
http://sourceware.org/ml/gdb-patches/2016-03/msg00014.html
Subject: [PATCH 2/2] Fix PR gdb/19676: Internal error in linux-thread.db.c if /proc not mounted
If /proc is not mounted, GDB fails an assertion in find_new_threads_once:
Continuing.
/home/pedro/gdb/mygit/src/gdb/linux-thread-db.c:1249: internal-error: find_new_threads_once: Assertion `!target_has_execution' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
That was supposed to catch misuses of td_ta_thr_iter, which is unsafe
for live debugging. However, if /proc is not mounted, we still
fallback to using it.
I didn't bother with a warning, because GDB already prints several
others related to failing to open /proc files.
gdb/ChangeLog:
2016-03-01 Pedro Alves <pedro@cascais.lan>
PR gdb/19676
* linux-thread-db.c (try_thread_db_load_1): Leave
info->td_ta_thr_iter_p NULL iff debugging a live process and we
have /proc access.
(find_new_threads_once): Assert that we have a non-NULL
info->td_ta_thr_iter_p instead of checking whether the target has
execution.
---
gdb/linux-thread-db.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 1eb457d..ce60beb 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -564,7 +564,6 @@ try_thread_db_load_1 (struct thread_db_info *info)
/* These are essential. */
CHK (TDB_VERBOSE_DLSYM (info, td_ta_map_lwp2thr));
- CHK (TDB_VERBOSE_DLSYM (info, td_ta_thr_iter));
CHK (TDB_VERBOSE_DLSYM (info, td_thr_validate));
CHK (TDB_VERBOSE_DLSYM (info, td_thr_get_info));
@@ -572,10 +571,6 @@ try_thread_db_load_1 (struct thread_db_info *info)
TDB_DLSYM (info, td_thr_tls_get_addr);
TDB_DLSYM (info, td_thr_tlsbase);
-#undef TDB_VERBOSE_DLSYM
-#undef TDB_DLSYM
-#undef CHK
-
/* It's best to avoid td_ta_thr_iter if possible. That walks data
structures in the inferior's address space that may be corrupted,
or, if the target is running, may change while we walk them. If
@@ -587,6 +582,15 @@ try_thread_db_load_1 (struct thread_db_info *info)
currently on core targets, as it uses ptrace directly. */
if (target_has_execution
&& linux_proc_task_list_dir_exists (ptid_get_pid (inferior_ptid)))
+ info->td_ta_thr_iter_p = NULL;
+ else
+ CHK (TDB_VERBOSE_DLSYM (info, td_ta_thr_iter));
+
+#undef TDB_VERBOSE_DLSYM
+#undef TDB_DLSYM
+#undef CHK
+
+ if (info->td_ta_thr_iter_p == NULL)
{
struct lwp_info *lp;
int pid = ptid_get_pid (inferior_ptid);
@@ -1246,7 +1250,7 @@ find_new_threads_once (struct thread_db_info *info, int iteration,
data.new_threads = 0;
/* See comment in thread_db_update_thread_list. */
- gdb_assert (!target_has_execution);
+ gdb_assert (info->td_ta_thr_iter_p != NULL);
TRY
{
--
2.5.0

View File

@ -27,7 +27,7 @@ Version: 7.11
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 59%{?dist}
Release: 60%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL
Group: Development/Debuggers
@ -245,7 +245,7 @@ Patch231: gdb-6.3-bz202689-exec-from-pthread-test.patch
# Backported fixups post the source tarball.
#Xdrop: Just backports.
#Patch232: gdb-upstream.patch
Patch232: gdb-upstream.patch
# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000).
#=fedoratest+ppc
@ -557,6 +557,10 @@ Patch1075: gdb-testsuite-readline63-sigint.patch
# Fix strict-aliasing rules compilation error (RH BZ 1315191).
Patch1107: gdb-bfd-aliasing.patch
# [aarch64] Fix hardware watchpoints (RH BZ 1261564).
#=fedoratest
Patch1113: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
# Patch642: gdb-readline62-ask-more-rh.patch
@ -752,7 +756,7 @@ find -name "*.info*"|xargs rm -f
# Match the Fedora's version info.
%patch2 -p1
#patch232 -p1
%patch232 -p1
%patch349 -p1
%patch1058 -p1
%patch1059 -p1
@ -871,6 +875,7 @@ find -name "*.info*"|xargs rm -f
%patch331 -p1
%patch1075 -p1
%patch1107 -p1
%patch1113 -p1
%if 0%{?rhel:1} && 0%{?rhel} <= 7
%patch1044 -p1
@ -1388,6 +1393,10 @@ then
fi
%changelog
* Tue Mar 15 2016 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.11-60.fc24
- New Fedora GDB testfile: rhbz1261564-aarch64-watchpoint.exp
- Backport gdb-7.11 stable branch PR gdb/19676 fix (Pedro Alves).
* Tue Mar 8 2016 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.11-59.fc24
- Fix strict-aliasing rules compilation error (RH BZ 1315191).