From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30765 invoked by alias); 26 Sep 2007 08:33:17 -0000 Received: (qmail 30753 invoked by uid 22791); 26 Sep 2007 08:33:16 -0000 X-Spam-Check-By: sourceware.org Received: from mu-out-0910.google.com (HELO mu-out-0910.google.com) (209.85.134.187) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 26 Sep 2007 08:33:14 +0000 Received: by mu-out-0910.google.com with SMTP id g7so2732204muf for ; Wed, 26 Sep 2007 01:33:11 -0700 (PDT) Received: by 10.82.172.10 with SMTP id u10mr788661bue.1190795591271; Wed, 26 Sep 2007 01:33:11 -0700 (PDT) Received: by 10.82.108.11 with HTTP; Wed, 26 Sep 2007 01:33:11 -0700 (PDT) Message-ID: <4dcb5abd0709260133h10aede86wb60a22094c8d9884@mail.gmail.com> Date: Wed, 26 Sep 2007 16:06:00 -0000 From: "Carl Shapiro" To: gdb@sourceware.org Subject: Problems with hook-stop MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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-09/txt/msg00214.txt.bz2 Hi, I am trying to write a user-defined command hook that automatically passes a SIGTRAP to my program. Here is the definition I am working with: define hook-stop if (((* (char *) ($pc - 1)) & 0xff) == 0xcc) signal SIGTRAP end end My target architecture is x86. This command fires the first time I hit an "int3" instruction. The next time I hit an int3, hook-stop is not executed and I must manually pass a SIGTRAP by evaluating "signal SIGTRAP". It seems that every other time gdb is stopped with a SIGTRAP the stop hook is not executed. Here's a program that can be used to demonstrate this: #include #include void handler(int signum) { fprintf(stderr, "handler(signum=%d)\n", signum); } int main(int argc, char *argv[]) { struct sigaction sa; int i; sa.sa_handler = handler; for (i = 0;; ++i) { fprintf(stderr, "i=%d\n", i); asm("int3"); } return 0; } If I remove the "signal SIGTRAP" statement from hook-stop, it fires every time around the loop. Does anyone know where am I going wrong wrong? Thanks, Carl