This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
signal 0 command
- From: "Seong-Kook Shin" <cinsky at gmail dot com>
- To: gdb at sourceware dot org
- Date: Thu, 21 Aug 2008 21:03:23 +0900
- Subject: signal 0 command
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/