From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13119 invoked by alias); 29 Jan 2014 15:03:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 13109 invoked by uid 89); 29 Jan 2014 15:03:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 29 Jan 2014 15:03:39 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s0TF3b6k026963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jan 2014 15:03:37 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s0TF3asf029518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 29 Jan 2014 15:03:37 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s0TF3aNp029503 for ; Wed, 29 Jan 2014 15:03:36 GMT Received: from termi.oracle.com (/10.175.38.99) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Jan 2014 07:03:35 -0800 From: jose.marchesi@oracle.com (Jose E. Marchesi) To: gdb-patches@sourceware.org Subject: [PATCH][SPARC] Fix single-stepping in syscalls other than sigreturn Date: Wed, 29 Jan 2014 15:03:00 -0000 Message-ID: <87y51yu8sr.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg01037.txt.bz2 [Continuing http://sourceware.org/ml/gdb-patches/2013-09/msg00817.html] Improved patch including a testcase and also some minor changes in the changelog entry. 2014-01-29 Jose E. Marchesi * sparc64-linux-tdep.c (sparc64_linux_step_trap): Get PC from the sigreturn register save area only if the syscall is sigreturn. 2014-01-29 Jose E. Marchesi * gdb.arch/sparc-sysstep.exp: New file. * gdb.arch/sparc-sysstep.c: Likewise. * gdb.arch/Makefile.in (EXECUTABLES): Add sparc-sysstep. diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index ea83c28..a381d2a 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -111,7 +111,9 @@ sparc64_linux_sigframe_init (const struct tramp_frame *self, static CORE_ADDR sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn) { - if (insn == 0x91d0206d) + /* __NR_rt_sigreturn is 101 */ + if ((insn == 0x91d0206d) + && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101)) { struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); diff --git a/gdb/testsuite/gdb.arch/Makefile.in b/gdb/testsuite/gdb.arch/Makefile.in index e5f8934..658c7ad 100644 --- a/gdb/testsuite/gdb.arch/Makefile.in +++ b/gdb/testsuite/gdb.arch/Makefile.in @@ -3,7 +3,7 @@ srcdir = @srcdir@ EXECUTABLES = altivec-abi altivec-regs amd64-byte amd64-disp-step amd64-dword \ amd64-entry-value amd64-i386-address amd64-word i386-bp_permanent \ - i386-permbkpt i386-avx i386-signal i386-sse + i386-permbkpt i386-avx i386-signal i386-sse sparc-sysstep all info install-info dvi install uninstall installcheck check: @echo "Nothing to be done for $@..." diff --git a/gdb/testsuite/gdb.arch/sparc-sysstep.c b/gdb/testsuite/gdb.arch/sparc-sysstep.c new file mode 100644 index 0000000..911fcbd --- /dev/null +++ b/gdb/testsuite/gdb.arch/sparc-sysstep.c @@ -0,0 +1,35 @@ +/* Test single-stepping system call instructions in sparc. + + Copyright 2014 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +#include + +int global; + +static void +handler (int sig) +{ +} + +int +main () +{ + signal (SIGALRM, handler); + kill (getpid (), SIGALRM); + return 0; /* sparc-sysstep.exp: last */ +} diff --git a/gdb/testsuite/gdb.arch/sparc-sysstep.exp b/gdb/testsuite/gdb.arch/sparc-sysstep.exp new file mode 100644 index 0000000..ac840f5 --- /dev/null +++ b/gdb/testsuite/gdb.arch/sparc-sysstep.exp @@ -0,0 +1,48 @@ +# Copyright 2014 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 . +# +# This file is part of the gdb testsuite. + +# Test single-stepping system call instructions (ta 0x6d) in the two +# cases distinguished by the implementation: sigreturn and all others. +# The sigreturn syscall requires a special analysis since the return +# PC must be extracted from the sigreturn register save area in the +# stack. + +if ![istarget "sparc*-*-linux*"] then { + return 0 +} + +set testfile sparc-sysstep +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if {[prepare_for_testing ${testfile}.exp ${binfile} $srcfile {additional_flags=-g}]} { + return -1 +} + +if ![runto_main] { + return -1 +} + +# Watching the global variable will guarantee that gdb will +# single-step through the whole program. + +set lno [gdb_get_line_number "sparc-sysstep.exp: last" $srcfile] + +gdb_test "break $srcfile:$lno" "Breakpoint \[0-9\] at .*" +gdb_test_no_output "set can-use-hw-watchpoints 0" "" +gdb_test "watch global" "Watchpoint .*: global" +gdb_test "continue" "Continuing.*${srcfile}:${lno}.*"