Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Carl Shapiro" <carl.shapiro@gmail.com>
To: gdb@sourceware.org
Subject: Problems with hook-stop
Date: Wed, 26 Sep 2007 16:06:00 -0000	[thread overview]
Message-ID: <4dcb5abd0709260133h10aede86wb60a22094c8d9884@mail.gmail.com> (raw)

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 <signal.h>
#include <stdio.h>

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


             reply	other threads:[~2007-09-26  8:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 16:06 Carl Shapiro [this message]
2007-09-27 12:06 ` Mark Kettenis
2007-09-28  1:23   ` Carl Shapiro
2007-09-29 21:44     ` Daniel Jacobowitz
2007-10-02  7:57       ` Carl Shapiro
2007-10-02 11:42         ` Daniel Jacobowitz
2007-09-27 12:35 ` Christian Thalinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dcb5abd0709260133h10aede86wb60a22094c8d9884@mail.gmail.com \
    --to=carl.shapiro@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox