From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16563 invoked by alias); 19 May 2006 23:13:01 -0000 Received: (qmail 16548 invoked by uid 22791); 19 May 2006 23:12:59 -0000 X-Spam-Check-By: sourceware.org Received: from e33.co.us.ibm.com (HELO e33.co.us.ibm.com) (32.97.110.151) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 19 May 2006 23:12:57 +0000 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e33.co.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k4JNCt33002648 for ; Fri, 19 May 2006 19:12:55 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k4JNCtR5146584 for ; Fri, 19 May 2006 17:12:55 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id k4JNCsnF022663 for ; Fri, 19 May 2006 17:12:55 -0600 Received: from dufur.beaverton.ibm.com (dufur.beaverton.ibm.com [9.47.22.20]) by d03av02.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id k4JNCskD022628; Fri, 19 May 2006 17:12:54 -0600 Subject: Re: Break on syscall? From: PAUL GILLIAM Reply-To: pgilliam@us.ibm.com To: Daniel Jacobowitz Cc: Mark Kettenis , kernel-hacker@bennee.com, gdb@sources.redhat.com In-Reply-To: <20060519220521.GA16297@nevyn.them.org> References: <1148033730.30951.15.camel@okra.transitives.com> <20060519124834.GA750@nevyn.them.org> <200605192116.k4JLGFkw025170@elgar.sibelius.xs4all.nl> <20060519220521.GA16297@nevyn.them.org> Content-Type: text/plain; charset=utf-8 Date: Sat, 20 May 2006 03:00:00 -0000 Message-Id: <1148076571.315.16.camel@dufur.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 (2.2.2-5) Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00324.txt.bz2 On Fri, 2006-05-19 at 18:05 -0400, Daniel Jacobowitz wrote: > On Fri, May 19, 2006 at 11:16:15PM +0200, Mark Kettenis wrote: > > > Date: Fri, 19 May 2006 08:48:35 -0400 > > > From: Daniel Jacobowitz > > > > > > On Fri, May 19, 2006 at 11:15:30AM +0100, Alex Bennee wrote: > > > > Is it possible to get gdb to break on entering/exiting a syscall (rather > > > > than breaking on entering libc or some such)? > > > > > > This is not supported. > > > > But I think it would be nice if we would support something like "catch > > syscall", just like we support "catch fork". > > Yes, probably. I think I even started work on this once. It's just a > bit trickier. Not only do you want to be able to decode arguments, but > there are other problems... for example, I think procfs allows it, but > traditionally ptrace has no way to request a single step and stop if > entering a syscall, so you'd need an arch hook to detect it to handle > that case. > > A nice project for some rainy month :-) > >From the ptrace(2) man page on Linux: PTRACE_SYSCALL, PTRACE_SINGLESTEP Restarts the stopped child as for PTRACE_CONT, but arranges for the child to be stopped at the next entry to or exit from a sys- tem call, or after execution of a single instruction, respec- tively. (The child will also, as usual, be stopped upon receipt of a signal.) From the parent’s perspective, the child will appear to have been stopped by receipt of a SIGTRAP. So, for PTRACE_SYSCALL, for example, the idea is to inspect the argu- ments to the system call at the first stop, then do another PTRACE_SYSCALL and inspect the return value of the system call at the second stop. (addr is ignored.) The 'ltrace' utility uses this to trace system calls. It uses a sleazy table (/etc/ltrace.cfg) to find out about their arguments... GDB should be able to do a much better job, although matching syscall numbers to their associated library routines would be a challenge (at least for me 8-) -=# Paul #=- PS: Here in Oregon, rainy months are the norm 8-)