From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18971 invoked by alias); 21 Mar 2007 18:51:48 -0000 Received: (qmail 18955 invoked by uid 22791); 21 Mar 2007 18:51:46 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.palmsource.com (HELO mx2.palmsource.com) (12.7.175.14) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 21 Mar 2007 18:51:38 +0000 Received: from localhost (localhost [127.0.0.1]) by localhost.domain.tld (Postfix) with ESMTP id E258E1341F0; Wed, 21 Mar 2007 11:51:36 -0700 (PDT) Received: from mx2.palmsource.com ([127.0.0.1]) by localhost (mx2.palmsource.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26170-03-11; Wed, 21 Mar 2007 10:51:35 -0800 (PST) Received: from ussunex02.palmsource.com (unknown [192.168.101.10]) by mx2.palmsource.com (Postfix) with ESMTP id 8DFE0133C83; Wed, 21 Mar 2007 11:51:35 -0700 (PDT) Received: from 192.168.92.92 ([192.168.92.92]) by ussunex02.palmsource.com ([192.168.101.10]) via Exchange Front-End Server owa.palmsource.com ([10.0.20.17]) with Microsoft Exchange Server HTTP-DAV ; Wed, 21 Mar 2007 18:51:35 +0000 Received: from svmsnyderlnx by owa.palmsource.com; 21 Mar 2007 11:51:33 -0700 Subject: Re: debugging a program that uses SIGTRAP From: Michael Snyder To: Michael FIG Cc: gdb@sourceware.org In-Reply-To: <7qtzwfuxxk.fsf@babe.fig.org> References: <7qy7lruz89.fsf@babe.fig.org> <20070321021809.GA2523@caradoc.them.org> <7qtzwfuxxk.fsf@babe.fig.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 21 Mar 2007 18:51:00 -0000 Message-Id: <1174503093.30660.31.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-03/txt/msg00258.txt.bz2 On Tue, 2007-03-20 at 20:34 -0600, Michael FIG wrote: > Thanks for the swift reply! > > Daniel Jacobowitz writes: > > > I don't see any good way to solve this. You've got two sets of > > breakpoints and they're both going to stop GDB - it doesn't know which > > ones you want and which you don't. > > Okay. I thought somehow GDB would pass SIGTRAP iff it knows it has > not set a breakpoint on the current instruction pointer by scanning > its list of breakpoints. > > > Even if you get past that point, your handler will now get called > > every time GDB hits a breakpoint or single steps - single stepping > > will probably be broken. > > Would the above suggestion be reasonable? I think it would behave > nicer than what I have now, especially for my circumstance, since > there isn't any overlap between the code I'm trying to debug and the > code _it's_ trying to debug. > > If it does seem reasonable, I can look into creating a patch. I > haven't gotten my hands dirty in GDB before. :) Michael, rather than telling gdb to always pass SIGTRAP (handle SIGTRAP pass), or modifying gdb, you might be able to debug at least a simple case (say, where there are only a few non-breakpoint traps) by explicitly telling gdb to pass the SIGTRAP on a case by case basis: Program received signal SIGTRAP, Trace/breakpoint trap. (gdb) signal SIGTRAP Continuing with signal SIGTRAP. If you expect a lot of events, there is a little-known feature called a hook. You can put a hook on the "stop" event, and have it do something to recognize your events. Perhaps you can maintain your own list of locations. (gdb) define hook-stop > if in-my-list > signal SIGTRAP > end > end