Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Amker.Cheng" <amker.cheng@gmail.com>
To: gdb@sourceware.org
Subject: What happened in gdb between handle_sigint and async_request_quit?
Date: Thu, 05 Feb 2009 12:31:00 -0000	[thread overview]
Message-ID: <e8b251c80902050431j3efaec3dy27aafdd5c16968de@mail.gmail.com> (raw)

HI All:
It's my first message in this list. Please be generous if I break any
rules unintentionally.

I am studying gdb internals by debugging with native gdb-6.8 under
winxp_Sp2+cygwin-5.1,
and trying to find out how gdb handles signals, for example, hitting
Ctrol+c during debugging.


In my view, gdb registers "handle_sigint" to SIGINT in function
"async_init_signals" at first,
then creates async_signal_handler with "proc=async_request_quit" for
"sigint_token", here comes the codes:

void
async_init_signals (void)
{
  signal (SIGINT, handle_sigint);
  sigint_token =
    create_async_signal_handler (async_request_quit, NULL);
	
  /*other codes*/
}

void
handle_sigint (int sig)
{
  signal (sig, handle_sigint);

  /* We could be running in a loop reading in symfiles or something so
     it may be quite a while before we get back to the event loop.  So
     set quit_flag to 1 here. Then if QUIT is called before we get to
     the event loop, we will unwind as expected.  */

  quit_flag = 1;

  /* If immediate_quit is set, we go ahead and process the SIGINT right
     away, even if we usually would defer this to the event loop. The
     assumption here is that it is safe to process ^C immediately if
     immediate_quit is set. If we didn't, SIGINT would be really
     processed only the next time through the event loop.  To get to
     that point, though, the command that we want to interrupt needs to
     finish first, which is unacceptable. */
  if (immediate_quit)
    async_request_quit (0);
  else
    /* If immediate quit is not set, we process SIGINT the next time
       through the loop, which is fine. */
    mark_async_signal_handler_wrapper (sigint_token);
}
---------------cut here---------------

It's clear that in "handle_sigint" it just marks the corresponding
async_signal_handler of SIGINT,
result in the true SIGNAL HANDLER "async_request_quit" will be called
during next event loop.

I think gdb must stops the debuggee between calling to "handle_sigint"
and "async_request_quit",
the question is I cannot locate the codes doing this work.

Also, "handle_sigint" set "quit_flag" to 1, but I traced gdb and found
that it was set back to 0
before "async_request_quit" invoked. Who did this and when?

It seems to me that the asynchronous event loop is hard to trace, does
anybody have any tips?

Thanks in advance.
Best Regards.


             reply	other threads:[~2009-02-05 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05 12:31 Amker.Cheng [this message]
2009-02-05 16:13 ` teawater
2009-02-05 16:25   ` paawan oza
2009-02-06  9:14     ` Amker.Cheng
2009-02-06 15:14       ` Amker.Cheng
2009-02-06 16:43         ` Joel Brobecker
2009-02-07 10:08           ` Amker.Cheng

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=e8b251c80902050431j3efaec3dy27aafdd5c16968de@mail.gmail.com \
    --to=amker.cheng@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