This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Debugging the debugger
- From: Mansoor Ali Khan <mkhan at hdaar dot com>
- To: gdb at sources dot redhat dot com
- Date: Tue, 01 Mar 2005 16:16:31 +0500
- Subject: Debugging the debugger
- Organization: Haval Daar
- Reply-to: mkhan at hdaar dot com
GNU gdb 6.3
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34)
I want to get to the root of the problem. The problem is that when I run
my application through gdb, the program flow does not appear to be
'normal'. The same statement (line) keeps on repeating multiple times
until it finally gets executed. To elaborate further I am attaching the
piece of code that I am trying to debug, followed by the 'weird' actual
gdb output which is then followed by the output that I should be
expecting from gdb under normal circumstances. Note that DEBUG and
SAFE_FREE are macros. I am not using any threads etc. This might be a
simple configuration problem or may be some other trivial issue but I
have no idea how to go about it. Your help would be HIGHLY appreciated.
Thanks,
Mansoor.
The Program code:
int main()
{
//Instruct the debugger to use console for printing.
set_output_on_console(true);
struct cli_state *c;
struct in_addr ip;
DEBUG(0, ("Initializing cli_state ...\n")); //Its a macro
if (!(c=cli_initialise(NULL)))
{
DEBUG(0, ("unable to init cli_state. Exiting ...\n"));
return 1;
}
zero_ip(&ip);
ip = *(interpret_addr2("192.168.1.30"));
cli_connect(c, NULL, &ip);
SAFE_FREE(c); //Its a macro
return 0;
}
The ACTUAL gdb output:
(gdb) run
Starting program: /home/mkhan/libcifs/src/libcifs
Breakpoint 1, main () at main.c:11
11 set_output_on_console(true);
(gdb) next
17 DEBUG(0, ("Initializing cli_state ...\n"));
(gdb) next
0x08049224 22 return 1;
(gdb) next
Initializing cli_state ...
19 if (!(c=cli_initialise(NULL)))
(gdb) next
25 zero_ip(&ip);
(gdb) next
27 ip = *(interpret_addr2("192.168.1.30"));
(gdb) next
28 cli_connect(c, NULL, &ip);
(gdb) next
27 ip = *(interpret_addr2("192.168.1.30"));
(gdb) next
28 cli_connect(c, NULL, &ip);
(gdb) next
27 ip = *(interpret_addr2("192.168.1.30"));
(gdb) next
28 cli_connect(c, NULL, &ip);
(gdb) next
31 SAFE_FREE(c);
(gdb) next
33 return 0;
(gdb) next
34 }
(gdb) next
0xb74b1768 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) next
Single stepping until exit from function __libc_start_main,
which has no line number information.
Program exited normally.
(gdb)
The EXPECTED gdb output (which gdb should have given under normal
circumstances):
(gdb) run
Starting program: /home/mkhan/libcifs/src/libcifs
Breakpoint 1, main () at main.c:11
11 set_output_on_console(true);
(gdb) next
17 DEBUG(0, ("Initializing cli_state ...\n"));
(gdb) next
Initializing cli_state ...
19 if (!(c=cli_initialise(NULL)))
(gdb) next
25 zero_ip(&ip);
(gdb) next
27 ip = *(interpret_addr2("192.168.1.30"));
(gdb) next
28 cli_connect(c, NULL, &ip);
(gdb) next
31 SAFE_FREE(c);
(gdb) next
33 return 0;
(gdb) next
34 }
(gdb) next
0xb74b1768 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) next
Single stepping until exit from function __libc_start_main,
which has no line number information.
Program exited normally.
(gdb)