* signal 0 command
@ 2008-08-21 20:11 Seong-Kook Shin
2008-08-21 21:25 ` Andreas Schwab
0 siblings, 1 reply; 2+ messages in thread
From: Seong-Kook Shin @ 2008-08-21 20:11 UTC (permalink / raw)
To: gdb
Hi.
While reading the gdb info manual, I found the paragraph saying:
Alternatively, if SIGNAL is zero, continue execution without
giving a signal. This is useful when your program stopped on
account of a signal and would ordinary see the signal when resumed
with the `continue' command; `signal 0' causes it to resume
without a signal.
If I understand correctly, I can issue "signal 0" to ignore the current
signal GDB caught, right? So I made a simple program to raise SIGSEGV:
void
foo(const char *str)
{
char *p = 0; /* This should be "char *p = str" */
while (*p != '\0') {
/* do something */
p++;
}
}
After reading the manual, I thought that it is possible to
undo the generation of SIGSEGV after modifying the value `p'.
But when I set the value of `p' corrently, and execute "signal 0",
I can still see the SIGSEGV is generated.
$ gdb -q a.out
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /home/cinsk/pesticide/a.out
Program received signal SIGSEGV, Segmentation fault.
0x08048399 in foo (str=0x80484b8 "hello, world") at segv.c:8
8 while (*p != '\0') {
(gdb) p p
$1 = 0x0
(gdb) p p = str
$2 = 0x80484b8 "hello, world"
(gdb) signal 0
Continuing with no signal.
Program received signal SIGSEGV, Segmentation fault.
0x08048399 in foo (str=0x80484b8 "hello, world") at segv.c:8
8 while (*p != '\0') {
(gdb) _
Am I missing something? If I misunderstand the meaning of "signal 0" command,
please let me know. (A short example session would be great!!)
Thanks in advance.
--
C FAQs: http://www.eskimo.com/~scs/C-faq/top.html
Korean: http://pcrc.hongik.ac.kr/~cinsk/cfaqs/
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: signal 0 command
2008-08-21 20:11 signal 0 command Seong-Kook Shin
@ 2008-08-21 21:25 ` Andreas Schwab
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2008-08-21 21:25 UTC (permalink / raw)
To: Seong-Kook Shin; +Cc: gdb
"Seong-Kook Shin" <cinsky@gmail.com> writes:
> If I understand correctly, I can issue "signal 0" to ignore the current
> signal GDB caught, right? So I made a simple program to raise SIGSEGV:
>
> void
> foo(const char *str)
> {
> char *p = 0; /* This should be "char *p = str" */
>
> while (*p != '\0') {
> /* do something */
> p++;
> }
> }
>
> After reading the manual, I thought that it is possible to
> undo the generation of SIGSEGV after modifying the value `p'.
> But when I set the value of `p' corrently, and execute "signal 0",
> I can still see the SIGSEGV is generated.
Modifying the variable does not necessarily mean that the current
instruction can see the change. The value may be been loaded into a
register which is used instead by the insn. You may have to modify the
program counter to move back to where the variable's value is loaded.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-21 12:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 20:11 signal 0 command Seong-Kook Shin
2008-08-21 21:25 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox