From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23933 invoked by alias); 24 Jan 2011 19:47:30 -0000 Received: (qmail 23715 invoked by uid 22791); 24 Jan 2011 19:47:26 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_50,TW_EG,T_FRT_STOCK2,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail3.caviumnetworks.com (HELO mail3.caviumnetworks.com) (12.108.191.235) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Jan 2011 19:47:15 +0000 Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,7,2,8378) id ; Mon, 24 Jan 2011 11:48:02 -0800 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 24 Jan 2011 11:47:13 -0800 Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 24 Jan 2011 11:47:13 -0800 Message-ID: <4D3DD73C.9060201@caviumnetworks.com> Date: Mon, 24 Jan 2011 20:20:00 -0000 From: David Daney User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Nathan Froyd Subject: [Patch v2] Add mips*-linux* catch syscall support. Content-Type: multipart/mixed; boundary="------------080302090101020104080708" X-IsSubscribed: yes 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 X-SW-Source: 2011-01/txt/msg00466.txt.bz2 This is a multi-part message in MIME format. --------------080302090101020104080708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1659 Change in v2: Simplify memory allocation in mips_linux_get_syscall_number() as suggested by Nathen Froyd. From the original posting: This patch adds catch syscall support for all three MIPS Linux ABIs (o32, n32 and n64). For the most part this works as expected, except for one small detail. The MIPS Linux syscall ABI passes the syscall number in register v0 when making a syscall, but it also uses the same register to return information back from the syscall. This clobbering of the syscall number is currently not well handled by GDB. We PASS all the tests for '(call to syscall ???)', but FAIL those for (returned from syscall ???), because GDB expects to be able to obtain the syscall number on syscall exit. For MIPS Linux it will never be available. I think the real fix for this is to improve the core 'catch syscall' support so that it can either remember the syscall number, or not try to print out bogus information, but that would be something for a different patch. Tested on mips-linux, and mips64-linux. OK to commit? 2011-01-24 David Daney * mips-linux-tdep.c: Include xml-syscall.h. (mips_linux_get_syscall_number): New function. (mips_linux_init_abi): Add calls to mips_linux_get_syscall_number() and set_xml_syscall_file_name(). * data-directory/Makefile.in (SYSCALLS_FILES): Add mips-o32-linux.xml, mips-n32-linux.xml and mips-n64-linux.xml * syscalls/mips-n32-linux.xml: New file. * syscalls/mips-n64-linux.xml: New file. * syscalls/mips-o32-linux.xml: New file. 2011-01-24 David Daney * gdb.base/catch-syscall.exp: Enable for mips*-linux*. --------------080302090101020104080708 Content-Type: text/plain; name="gdb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb.patch" Content-length: 48501 Index: gdb/mips-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v retrieving revision 1.86 diff -u -p -r1.86 mips-linux-tdep.c --- gdb/mips-linux-tdep.c 9 Jan 2011 03:20:33 -0000 1.86 +++ gdb/mips-linux-tdep.c 24 Jan 2011 19:39:52 -0000 @@ -40,6 +40,7 @@ #include "mips-linux-tdep.h" #include "glibc-tdep.h" #include "linux-tdep.h" +#include "xml-syscall.h" static struct target_so_ops mips_svr4_so_ops; @@ -1206,6 +1207,36 @@ mips_linux_syscall_next_pc (struct frame return pc + 4; } +/* Return the current system call's number present in the + v0 register. When the function fails, it returns -1. */ +static LONGEST +mips_linux_get_syscall_number (struct gdbarch *gdbarch, + ptid_t ptid) +{ + struct regcache *regcache = get_thread_regcache (ptid); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + int regsize = register_size (gdbarch, MIPS_V0_REGNUM); + /* The content of a register */ + gdb_byte buf[8]; + /* The result */ + LONGEST ret; + + /* Make sure we're in a known ABI */ + gdb_assert (tdep->mips_abi == MIPS_ABI_O32 + || tdep->mips_abi == MIPS_ABI_N32 + || tdep->mips_abi == MIPS_ABI_N64); + + gdb_assert (regsize <= sizeof (buf)); + + /* Getting the system call number from the register. + syscall number is in v0 or $2. */ + regcache_cooked_read (regcache, MIPS_V0_REGNUM, buf); + + ret = extract_signed_integer (buf, regsize, byte_order); + + return ret; +} /* Initialize one of the GNU/Linux OS ABIs. */ @@ -1219,6 +1250,9 @@ mips_linux_init_abi (struct gdbarch_info linux_init_abi (info, gdbarch); + /* Get the syscall number from the arch's register. */ + set_gdbarch_get_syscall_number (gdbarch, mips_linux_get_syscall_number); + switch (abi) { case MIPS_ABI_O32: @@ -1228,6 +1262,7 @@ mips_linux_init_abi (struct gdbarch_info (gdbarch, svr4_ilp32_fetch_link_map_offsets); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe); + set_xml_syscall_file_name ("syscalls/mips-o32-linux.xml"); break; case MIPS_ABI_N32: set_gdbarch_get_longjmp_target (gdbarch, @@ -1241,6 +1276,7 @@ mips_linux_init_abi (struct gdbarch_info does not distinguish between quiet and signalling NaNs). */ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe); + set_xml_syscall_file_name ("syscalls/mips-n32-linux.xml"); break; case MIPS_ABI_N64: set_gdbarch_get_longjmp_target (gdbarch, @@ -1254,6 +1290,7 @@ mips_linux_init_abi (struct gdbarch_info does not distinguish between quiet and signalling NaNs). */ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe); + set_xml_syscall_file_name ("syscalls/mips-n64-linux.xml"); break; default: break; Index: gdb/data-directory/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/data-directory/Makefile.in,v retrieving revision 1.7 diff -u -p -r1.7 Makefile.in --- gdb/data-directory/Makefile.in 1 Jan 2011 15:33:22 -0000 1.7 +++ gdb/data-directory/Makefile.in 24 Jan 2011 19:39:52 -0000 @@ -46,7 +46,8 @@ SYSCALLS_FILES = \ gdb-syscalls.dtd \ ppc-linux.xml ppc64-linux.xml \ i386-linux.xml amd64-linux.xml \ - sparc-linux.xml sparc64-linux.xml + sparc-linux.xml sparc64-linux.xml \ + mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) Index: gdb/syscalls/mips-n32-linux.xml =================================================================== RCS file: gdb/syscalls/mips-n32-linux.xml diff -N gdb/syscalls/mips-n32-linux.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/syscalls/mips-n32-linux.xml 24 Jan 2011 19:39:52 -0000 @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: gdb/syscalls/mips-n64-linux.xml =================================================================== RCS file: gdb/syscalls/mips-n64-linux.xml diff -N gdb/syscalls/mips-n64-linux.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/syscalls/mips-n64-linux.xml 24 Jan 2011 19:39:52 -0000 @@ -0,0 +1,312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: gdb/syscalls/mips-o32-linux.xml =================================================================== RCS file: gdb/syscalls/mips-o32-linux.xml diff -N gdb/syscalls/mips-o32-linux.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/syscalls/mips-o32-linux.xml 24 Jan 2011 19:39:52 -0000 @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: gdb/testsuite/gdb.base/catch-syscall.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/catch-syscall.exp,v retrieving revision 1.11 diff -u -p -r1.11 catch-syscall.exp --- gdb/testsuite/gdb.base/catch-syscall.exp 1 Jan 2011 15:33:41 -0000 1.11 +++ gdb/testsuite/gdb.base/catch-syscall.exp 24 Jan 2011 19:39:52 -0000 @@ -54,7 +54,8 @@ if {![istarget "hppa*-hp-hpux*"] && ![is #if { ![istarget "i\[34567\]86-*-linux*"] if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"] && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] - && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } { + && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] + && ![istarget "mips*-linux*"] } { continue } --------------080302090101020104080708--