|
|
a1b30c |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
a1b30c |
From: Jeff Johnston <jjohnstn@redhat.com>
|
|
|
a1b30c |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
a1b30c |
Subject: gdb-6.3-threaded-watchpoints2-20050225.patch
|
|
|
a1b30c |
|
|
|
a1b30c |
;; Test sibling threads to set threaded watchpoints for x86 and x86-64
|
|
|
a1b30c |
;;=fedoratest
|
|
|
a1b30c |
|
|
|
a1b30c |
2005-02-28 Jeff Johnston <jjohnstn@redhat.com>
|
|
|
a1b30c |
|
|
|
a1b30c |
* config/i386/nm-linux.h: Change dr register routines to
|
|
|
a1b30c |
accept a ptid_t first argument. Change all calling macros
|
|
|
a1b30c |
to default the inferior_ptid for the first argument.
|
|
|
a1b30c |
(i386_linux_insert_watchpoint): New prototype.
|
|
|
a1b30c |
(i386_linux_remove_watchpoint, i386_linux_insert_hw_breakpoint): Ditto.
|
|
|
a1b30c |
(i386_linux_remove_hw_breakpoint): Ditto.
|
|
|
a1b30c |
(target_insert_watchpoint, target_remove_watchpoint): Undef and
|
|
|
a1b30c |
override.
|
|
|
a1b30c |
(target_insert_hw_breakpoint, target_remove_hw_breakpoint): Ditto.
|
|
|
a1b30c |
* config/i386/nm-linux64.h: Ditto except add amd64 versions of
|
|
|
a1b30c |
the watchpoint/hw-breakpoint insert/remove routines.
|
|
|
a1b30c |
* i386-nat.c: Include "inferior.h" to define inferior_ptid.
|
|
|
a1b30c |
* i386-linux-nat.c: Change all dr get/set routines to accept
|
|
|
a1b30c |
ptid_t as first argument and to use this argument to determine
|
|
|
a1b30c |
the tid for PTRACE.
|
|
|
a1b30c |
(i386_linux_set_debug_regs_for_thread): New function.
|
|
|
a1b30c |
(i386_linux_sync_debug_registers_callback): Ditto.
|
|
|
a1b30c |
(i386_linux_sync_debug_registers_across_threads): Ditto.
|
|
|
a1b30c |
(i386_linux_insert_watchpoint, i386_linux_remove_watchpoint): Ditto.
|
|
|
a1b30c |
(i386_linux_hw_breakpoint, i386_linux_remove_hw_breakpoint): Ditto.
|
|
|
a1b30c |
(i386_linux_new_thread): Ditto.
|
|
|
a1b30c |
(_initialize_i386_linux_nat): Ditto.
|
|
|
a1b30c |
* amd64-linux-nat.c: Change all dr get/set routines to accept
|
|
|
a1b30c |
ptid_t as first argument and to use this argument to determine
|
|
|
a1b30c |
the tid for PTRACE.
|
|
|
a1b30c |
(amd64_linux_set_debug_regs_for_thread): New function.
|
|
|
a1b30c |
(amd64_linux_sync_debug_registers_callback): Ditto.
|
|
|
a1b30c |
(amd64_linux_sync_debug_registers_across_threads): Ditto.
|
|
|
a1b30c |
(amd64_linux_insert_watchpoint, amd64_linux_remove_watchpoint): Ditto.
|
|
|
a1b30c |
(amd64_linux_hw_breakpoint, amd64_linux_remove_hw_breakpoint): Ditto.
|
|
|
a1b30c |
(amd64_linux_new_thread): Ditto.
|
|
|
a1b30c |
(_initialize_amd64_linux_nat): Register linux new thread observer.
|
|
|
a1b30c |
* testsuite/gdb.threads/watchthreads-threaded.c: New test case.
|
|
|
a1b30c |
* testsuite/gdb.threads/watchthreads-threaded.exp: Ditto.
|
|
|
a1b30c |
|
|
|
a1b30c |
[ With recent upstream GDB (6.8) reduced only to the testcase. ]
|
|
|
a1b30c |
|
|
|
a1b30c |
[ It was called watchthreads2.{exp,c} before but it conflicted with FSF GDB new
|
|
|
a1b30c |
testcase of the same name. ]
|
|
|
a1b30c |
|
|
|
a1b30c |
FIXME: The testcase does not expects multiple watchpoints hits per one stop.
|
|
|
a1b30c |
|
|
|
a1b30c |
diff --git a/gdb/testsuite/gdb.threads/watchthreads-threaded.c b/gdb/testsuite/gdb.threads/watchthreads-threaded.c
|
|
|
a1b30c |
new file mode 100644
|
|
|
a1b30c |
--- /dev/null
|
|
|
a1b30c |
+++ b/gdb/testsuite/gdb.threads/watchthreads-threaded.c
|
|
|
a1b30c |
@@ -0,0 +1,65 @@
|
|
|
a1b30c |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ This program is free software; you can redistribute it and/or modify
|
|
|
a1b30c |
+ it under the terms of the GNU General Public License as published by
|
|
|
a1b30c |
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
a1b30c |
+ (at your option) any later version.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ This program is distributed in the hope that it will be useful,
|
|
|
a1b30c |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a1b30c |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a1b30c |
+ GNU General Public License for more details.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ You should have received a copy of the GNU General Public License
|
|
|
a1b30c |
+ along with this program; if not, write to the Free Software
|
|
|
a1b30c |
+ Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
a1b30c |
+ Boston, MA 02111-1307, USA.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ This file is copied from schedlock.c. */
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+#include <stdio.h>
|
|
|
a1b30c |
+#include <unistd.h>
|
|
|
a1b30c |
+#include <stdlib.h>
|
|
|
a1b30c |
+#include <pthread.h>
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+void *thread_function(void *arg); /* Pointer to function executed by each thread */
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+#define NUM 5
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+unsigned int args[NUM+1];
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+int main() {
|
|
|
a1b30c |
+ int res;
|
|
|
a1b30c |
+ pthread_t threads[NUM];
|
|
|
a1b30c |
+ void *thread_result;
|
|
|
a1b30c |
+ long i;
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ for (i = 0; i < NUM; i++)
|
|
|
a1b30c |
+ {
|
|
|
a1b30c |
+ args[i] = 1; /* Init value. */
|
|
|
a1b30c |
+ res = pthread_create(&threads[i],
|
|
|
a1b30c |
+ NULL,
|
|
|
a1b30c |
+ thread_function,
|
|
|
a1b30c |
+ (void *) i);
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ args[i] = 1;
|
|
|
a1b30c |
+ thread_function ((void *) i);
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ exit(EXIT_SUCCESS);
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+void *thread_function(void *arg) {
|
|
|
a1b30c |
+ int my_number = (long) arg;
|
|
|
a1b30c |
+ int *myp = (int *) &args[my_number];
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ /* Don't run forever. Run just short of it :) */
|
|
|
a1b30c |
+ while (*myp > 0)
|
|
|
a1b30c |
+ {
|
|
|
a1b30c |
+ (*myp) ++; usleep (1); /* Loop increment. */
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+ pthread_exit(NULL);
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
diff --git a/gdb/testsuite/gdb.threads/watchthreads-threaded.exp b/gdb/testsuite/gdb.threads/watchthreads-threaded.exp
|
|
|
a1b30c |
new file mode 100644
|
|
|
a1b30c |
--- /dev/null
|
|
|
a1b30c |
+++ b/gdb/testsuite/gdb.threads/watchthreads-threaded.exp
|
|
|
a1b30c |
@@ -0,0 +1,126 @@
|
|
|
a1b30c |
+# This testcase is part of GDB, the GNU debugger.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Copyright 2005 Free Software Foundation, Inc.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# This program is free software; you can redistribute it and/or modify
|
|
|
a1b30c |
+# it under the terms of the GNU General Public License as published by
|
|
|
a1b30c |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
a1b30c |
+# (at your option) any later version.
|
|
|
a1b30c |
+#
|
|
|
a1b30c |
+# This program is distributed in the hope that it will be useful,
|
|
|
a1b30c |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a1b30c |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a1b30c |
+# GNU General Public License for more details.
|
|
|
a1b30c |
+#
|
|
|
a1b30c |
+# You should have received a copy of the GNU General Public License
|
|
|
a1b30c |
+# along with this program; if not, write to the Free Software
|
|
|
a1b30c |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Check that GDB can support multiple watchpoints across threads.
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# This test verifies that a watchpoint is detected in the proper thread
|
|
|
a1b30c |
+# so the test is only meaningful on a system with hardware watchpoints.
|
|
|
a1b30c |
+if [target_info exists gdb,no_hardware_watchpoints] {
|
|
|
a1b30c |
+ return 0;
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+set testfile "watchthreads-threaded"
|
|
|
a1b30c |
+set srcfile ${testfile}.c
|
|
|
a1b30c |
+set binfile [standard_output_file ${testfile}]
|
|
|
a1b30c |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
|
|
|
a1b30c |
+ return -1
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+gdb_exit
|
|
|
a1b30c |
+gdb_start
|
|
|
a1b30c |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
a1b30c |
+gdb_load ${binfile}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+gdb_test "set can-use-hw-watchpoints 1" "" ""
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+#
|
|
|
a1b30c |
+# Run to `main' where we begin our tests.
|
|
|
a1b30c |
+#
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+if ![runto_main] then {
|
|
|
a1b30c |
+ gdb_suppress_tests
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+set args_2 0
|
|
|
a1b30c |
+set args_3 0
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+gdb_breakpoint "thread_function"
|
|
|
a1b30c |
+gdb_continue_to_breakpoint "thread_function"
|
|
|
a1b30c |
+gdb_test "disable 2" ""
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+gdb_test_multiple "p args\[2\]" "get initial args2" {
|
|
|
a1b30c |
+ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" {
|
|
|
a1b30c |
+ set init_args_2 $expect_out(1,string)
|
|
|
a1b30c |
+ pass "get initial args2"
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+gdb_test_multiple "p args\[3\]" "get initial args3" {
|
|
|
a1b30c |
+ -re "\\\$\[0-9\]* = (.*)$gdb_prompt $" {
|
|
|
a1b30c |
+ set init_args_3 $expect_out(1,string)
|
|
|
a1b30c |
+ pass "get initial args3"
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+set args_2 $init_args_2
|
|
|
a1b30c |
+set args_3 $init_args_3
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Watch values that will be modified by distinct threads.
|
|
|
a1b30c |
+gdb_test "watch args\[2\]" "Hardware watchpoint 3: args\\\[2\\\]"
|
|
|
a1b30c |
+gdb_test "watch args\[3\]" "Hardware watchpoint 4: args\\\[3\\\]"
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+set init_line [expr [gdb_get_line_number "Init value"]+1]
|
|
|
a1b30c |
+set inc_line [gdb_get_line_number "Loop increment"]
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Loop and continue to allow both watchpoints to be triggered.
|
|
|
a1b30c |
+for {set i 0} {$i < 30} {incr i} {
|
|
|
a1b30c |
+ set test_flag 0
|
|
|
a1b30c |
+ gdb_test_multiple "continue" "threaded watch loop" {
|
|
|
a1b30c |
+ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads-threaded.c:$init_line.*$gdb_prompt $"
|
|
|
a1b30c |
+ { set args_2 1; set test_flag 1 }
|
|
|
a1b30c |
+ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads-threaded.c:$init_line.*$gdb_prompt $"
|
|
|
a1b30c |
+ { set args_3 1; set test_flag 1 }
|
|
|
a1b30c |
+ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = $args_2.*New value = [expr $args_2+1].*thread_function \\\(arg=0x2\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $"
|
|
|
a1b30c |
+ { set args_2 [expr $args_2+1]; set test_flag 1 }
|
|
|
a1b30c |
+ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = $args_3.*New value = [expr $args_3+1].*thread_function \\\(arg=0x3\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $"
|
|
|
a1b30c |
+ { set args_3 [expr $args_3+1]; set test_flag 1 }
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+ # If we fail above, don't bother continuing loop
|
|
|
a1b30c |
+ if { $test_flag == 0 } {
|
|
|
a1b30c |
+ set i 30;
|
|
|
a1b30c |
+ }
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Print success message if loop succeeded.
|
|
|
a1b30c |
+if { $test_flag == 1 } {
|
|
|
a1b30c |
+ pass "threaded watch loop"
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Verify that we hit first watchpoint in child thread.
|
|
|
a1b30c |
+set message "watchpoint on args\[2\] hit in thread"
|
|
|
a1b30c |
+if { $args_2 > 1 } {
|
|
|
a1b30c |
+ pass $message
|
|
|
a1b30c |
+} else {
|
|
|
a1b30c |
+ fail $message
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Verify that we hit second watchpoint in child thread.
|
|
|
a1b30c |
+set message "watchpoint on args\[3\] hit in thread"
|
|
|
a1b30c |
+if { $args_3 > 1 } {
|
|
|
a1b30c |
+ pass $message
|
|
|
a1b30c |
+} else {
|
|
|
a1b30c |
+ fail $message
|
|
|
a1b30c |
+}
|
|
|
a1b30c |
+
|
|
|
a1b30c |
+# Verify that all watchpoint hits are accounted for.
|
|
|
a1b30c |
+set message "combination of threaded watchpoints = 30 + initial values"
|
|
|
a1b30c |
+if { [expr $args_2+$args_3] == [expr [expr 30+$init_args_2]+$init_args_3] } {
|
|
|
a1b30c |
+ pass $message
|
|
|
a1b30c |
+} else {
|
|
|
a1b30c |
+ fail $message
|
|
|
a1b30c |
+}
|