From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4734 invoked by alias); 22 Jan 2014 16:24:59 -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 4723 invoked by uid 89); 22 Jan 2014 16:24:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 22 Jan 2014 16:24:55 +0000 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Jan 2014 16:24:51 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 22 Jan 2014 16:24:50 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id F37991B08066 for ; Wed, 22 Jan 2014 16:24:10 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s0MGOXLu62718050 for ; Wed, 22 Jan 2014 16:24:33 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s0MGOhJF013940 for ; Wed, 22 Jan 2014 09:24:44 -0700 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-219.boeblingen.de.ibm.com [9.152.212.219]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s0MGOgZK013927; Wed, 22 Jan 2014 09:24:43 -0700 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Andreas Krebbel , Ulrich Weigand Subject: [PATCH] S390: Add support for 'catch syscall' command. Date: Wed, 22 Jan 2014 16:24:00 -0000 Message-ID: <87r4800yt0.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14012216-2966-0000-0000-00000A03883A X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00868.txt.bz2 gdb/ChangeLog: * syscalls/s390x-linux.xml: New file. * syscalls/s390-linux.xml: New file. * s390-linux-tdep.c (XML_SYSCALL_FILENAME_S390): New macro. (XML_SYSCALL_FILENAME_S390X): Likewise. (op_svc): New enum value for SVC opcode. (s390_sigtramp_frame_sniffer): Replace literal by 'op_svc'. (s390_linux_get_syscall_number): New function. (s390_gdbarch_init): Register '*get_syscall_number' and the syscall xml file name. * data-directory/Makefile.in (SYSCALLS_FILES): Add "s390-linux.xml" and "s390x-linux.xml". * NEWS: Announce new feature. gdb/testsuite/ChangeLog: * gdb.base/catch-syscall.exp: Activate test on s390*-linux. --- gdb/NEWS | 2 + gdb/data-directory/Makefile.in | 3 +- gdb/s390-linux-tdep.c | 44 +++- gdb/syscalls/s390-linux.xml | 331 +++++++++++++++++++++++++++++++ gdb/syscalls/s390x-linux.xml | 298 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/catch-syscall.exp | 3 +- 6 files changed, 678 insertions(+), 3 deletions(-) create mode 100644 gdb/syscalls/s390-linux.xml create mode 100644 gdb/syscalls/s390x-linux.xml diff --git a/gdb/NEWS b/gdb/NEWS index 44189d5..5a44a67 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -26,6 +26,8 @@ The target does not record data and therefore does not allow reading memory or registers. +* The "catch syscall" command now works on s390*-linux* targets. + * New remote packets qXfer:btrace:read's annex diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index e535316..29a48e4 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -49,7 +49,8 @@ SYSCALLS_FILES = \ ppc-linux.xml ppc64-linux.xml \ i386-linux.xml amd64-linux.xml \ sparc-linux.xml sparc64-linux.xml \ - mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml + mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml \ + s390-linux.xml s390x-linux.xml PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 8b71e78..3084b32 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -45,6 +45,7 @@ #include "linux-tdep.h" #include "s390-linux-tdep.h" #include "auxv.h" +#include "xml-syscall.h" #include "stap-probe.h" #include "ax.h" @@ -66,6 +67,9 @@ #include "features/s390x-linux64v2.c" #include "features/s390x-te-linux64.c" +#define XML_SYSCALL_FILENAME_S390 "syscalls/s390-linux.xml" +#define XML_SYSCALL_FILENAME_S390X "syscalls/s390x-linux.xml" + /* The tdep structure. */ struct gdbarch_tdep @@ -905,6 +909,7 @@ enum op1_brxhg= 0xec, op2_brxhg= 0x44, op_brxle = 0x85, op1_brxlg= 0xec, op2_brxlg= 0x45, + op_svc = 0x0a, }; @@ -2328,7 +2333,7 @@ s390_sigtramp_frame_sniffer (const struct frame_unwind *self, if (target_read_memory (pc, sigreturn, 2)) return 0; - if (sigreturn[0] != 0x0a /* svc */) + if (sigreturn[0] != op_svc) return 0; if (sigreturn[1] != 119 /* sigreturn */ @@ -2347,6 +2352,36 @@ static const struct frame_unwind s390_sigtramp_frame_unwind = { s390_sigtramp_frame_sniffer }; +/* Retrieve the syscall number at a ptrace syscall-stop. Return -1 + upon error. */ + +static LONGEST +s390_linux_get_syscall_number (struct gdbarch *gdbarch, + ptid_t ptid) +{ + struct regcache *regs = get_thread_regcache (ptid); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + ULONGEST pc; + ULONGEST svc_number = -1; + unsigned opcode; + + /* Assume that the PC points after the 2-byte SVC instruction. We + don't currently support SVC via EXECUTE. */ + regcache_cooked_read_unsigned (regs, tdep->pc_regnum, &pc); + pc -= 2; + opcode = read_memory_unsigned_integer ((CORE_ADDR) pc, 1, byte_order); + if (opcode != op_svc) + return -1; + + svc_number = read_memory_unsigned_integer ((CORE_ADDR) pc + 1, 1, + byte_order); + if (svc_number == 0) + regcache_cooked_read_unsigned (regs, S390_R1_REGNUM, &svc_number); + + return svc_number; +} + /* Frame base handling. */ @@ -3265,6 +3300,9 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_frame_align (gdbarch, s390_frame_align); set_gdbarch_return_value (gdbarch, s390_return_value); + /* Syscall handling. */ + set_gdbarch_get_syscall_number (gdbarch, s390_linux_get_syscall_number); + /* Frame handling. */ dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg); dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum); @@ -3303,6 +3341,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); + set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390); + if (have_upper) { if (have_linux_v2) @@ -3347,6 +3387,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_address_class_name_to_type_flags (gdbarch, s390_address_class_name_to_type_flags); + set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390); + if (have_linux_v2) set_gdbarch_core_regset_sections (gdbarch, s390x_linux64v2_regset_sections); diff --git a/gdb/syscalls/s390-linux.xml b/gdb/syscalls/s390-linux.xml new file mode 100644 index 0000000..5a755ad --- /dev/null +++ b/gdb/syscalls/s390-linux.xml @@ -0,0 +1,331 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/s390x-linux.xml b/gdb/syscalls/s390x-linux.xml new file mode 100644 index 0000000..9f2b60f --- /dev/null +++ b/gdb/syscalls/s390x-linux.xml @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index 8ff4220..da838f7 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -34,7 +34,8 @@ if { ![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"] } { if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"] && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] - && ![istarget "mips*-linux*"] && ![istarget "arm*-linux*"] } { + && ![istarget "mips*-linux*"] && ![istarget "arm*-linux*"] + && ![istarget "s390*-linux*"] } { continue } -- 1.8.3.1