Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: Nick Roberts <nickrob@snap.net.nz>
Cc: gdb@sources.redhat.com
Subject: Re: internal-error: insert_step_resume_breakpoint_at_sal
Date: Sun, 06 Feb 2005 07:26:00 -0000	[thread overview]
Message-ID: <4202BABF.3090605@gnu.org> (raw)
Message-ID: <20050206072600.BbXEJ3hAsqiZ_ixMUQuWEPfMAFwzuBgfStSaiApfJug@z> (raw)
In-Reply-To: <16888.15318.746005.711735@farnswood.snap.net.nz>

[chug chug chug]

This is what I've noticed ...

(gdb) n
infrun: proceed (addr=0xffffffff, signal=144, step=1)

GDB tries to single step off the breakpoint @0x80a05f6, (when doing this 
all breakpoints are removed).  GDB is expecting to get a SIGTRAP back ...

infrun: resume (step=1, signal=0)
target_terminal_inferior ()
child:target_xfer_partial (2, (null), 0xbffff18a,  0x0,  0x80a05f6, 2) = 
2, bytes = 8b 45
target_resume (2896, step, 0)
infrun: wait_for_inferior

... but instead the inferior executes _no_ instructions and instead 
returns a [pending] SIGIO (still @0x80a05f6) ...

target_wait (-1, status) = 2896,   status->kind = stopped, signal = SIGIO
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
target_fetch_registers (eip) = f6050a08 0x80a05f6 134874614
infrun: stop_pc = 0x80a05f6
infrun: random signal 23

... so GDB again tries to step the inferior, this time passing in the 
SIGNAL, and expecting back a SIGTRAP when the inferior reaches the 
signal handlers first instruction ...

[wonder if, for this case GDB can insert all breakpoints and do a continue]

infrun: resume (step=1, signal=23)
target_terminal_inferior ()
child:target_xfer_partial (2, (null), 0xbfffeffa,  0x0,  0x80a05f6, 2) = 
2, bytes = 8b 45
target_resume (2896, step, SIGIO)
infrun: prepare_to_wait

... but instead GDB gets back another pending SIGIO with the PC still 
back at the original BP instruction!

=> that's a known kernel bug.  Instead of single-stepping into the 
signal handler, the kernel runs the signal handler to completion.  Fixed 
in very recent 2.6 kernels.

... so gdb tries again to step into the signal handler again (remember, 
GDB's expecting the inferior to return a sigtrap from the process 
reaching the signal handler's first instruction) ...

target_wait (-1, status) = 2896,   status->kind = stopped, signal = SIGIO
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
target_fetch_registers (eip) = f6050a08 0x80a05f6 134874614
infrun: stop_pc = 0x80a05f6
infrun: random signal 23
infrun: resume (step=1, signal=23)
target_terminal_inferior ()
child:target_xfer_partial (2, (null), 0xbfffeffa,  0x0,  0x80a05f6, 2) = 
2, bytes = 8b 45
target_resume (2896, step, SIGIO)
infrun: prepare_to_wait

... but instead the signal handler runs, returns, and then executes 
_one_ instruction before trapping!

=> that's part of the same kernel bug

target_wait (-1, status) = 2896,   status->kind = stopped, signal = SIGTRAP
target_fetch_registers (eip) = f9050a08 0x80a05f9 134874617
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80a05f9
infrun: trap expected
infrun: step-resume breakpoint

... so I think we've now got gdb thinking that the inferior got a 
sigtrap  [tick] indicating that the process reached the handler [cross] 
and hence the the inferior should continue until the signal handler 
returns ...

child:target_xfer_partial (2, (null), 0x84ff020,  0x0,  0x810bdc0, 1) = 
1, bytes =
  83
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x810bdc0, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x810bdc0, xxx) = 0
child:target_xfer_partial (2, (null), 0x85004c8,  0x0,  0x80e74c1, 1) = 
1, bytes = 68
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x80e74c1, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x80e74c1, xxx) = 0
child:target_xfer_partial (2, (null), 0x874d058,  0x0,  0x80a05f6, 1) = 
1, bytes = 8b
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x80a05f6, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x80a05f6, xxx) = 0
child:target_xfer_partial (2, (null), 0x874d348,  0x0,  0x40009bd0, 1) = 
1, bytes = c3
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x40009bd0, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x40009bd0, xxx) = 0
child:target_xfer_partial (2, (null), 0x8aacb20,  0x0,  0x4000c2e0, 1) = 
1, bytes =
  55
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x4000c2e0, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x4000c2e0, xxx) = 0
child:target_xfer_partial (2, (null), 0x87f2118,  0x0,  0x4032e860, 1) = 
1, bytes = 55
child:target_xfer_partial (2, (null), 0x0,  0x8271b10,  0x4032e860, 1) = 
1, bytes =
  cc
target_insert_breakpoint (0x4032e860, xxx) = 0
infrun: resume (step=0, signal=0)

... consequently GDB inserts breakpoints, including the step-resume 
breakpoint at expected signal return address, and continues the target. 
  The inferior is ment to next run the handler, return, and hit the 
step-resume breakpoint.  Funny enough this doesn't work (it's well past 
that step resume breakpoint).

First thing I'd do is run the sig*.exp tests to see which are failing - 
if the kernel's working correctly they all pass.

The next thing we can consider is, for the case of GDB wanting to "next" 
over a signal optimizing things so that instead it does a 
"continue/signal".  That might help a little, but then it might not.

Andrew


  reply	other threads:[~2005-02-06  7:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-24  4:02 Nick Roberts
2005-01-16 10:54 ` Nick Roberts
2005-01-18 18:59   ` Andrew Cagney
2005-01-18 21:53     ` Nick Roberts
2005-01-19 15:55       ` Andrew Cagney
2005-01-20  0:59         ` Nick Roberts
2005-01-20 10:23           ` Dave Korn
2005-01-20 10:58             ` Nick Roberts
2005-01-20 17:07           ` Andrew Cagney
2005-01-21  2:47             ` Nick Roberts
2005-01-24 21:59               ` Andrew Cagney
2005-01-26 10:19                 ` Nick Roberts
2005-01-26 16:26                   ` Andrew Cagney
2005-01-26 20:48                     ` Nick Roberts
2005-01-26 21:39                       ` Andrew Cagney
2005-01-27  1:02                         ` Nick Roberts
2005-02-06  7:16                           ` Andrew Cagney [this message]
2005-02-06  7:26                             ` Andrew Cagney
2005-02-06 20:11                             ` Nick Roberts
2005-02-08 16:57                               ` Andrew Cagney

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=4202BABF.3090605@gnu.org \
    --to=cagney@gnu.org \
    --cc=gdb@sources.redhat.com \
    --cc=nickrob@snap.net.nz \
    /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