Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent gdb debugger help!!!

Status
Not open for further replies.

1Srini

IS-IT--Management
Oct 19, 2005
2
0
0
US
It's been while in touch with C program debugging. I wrote sample program and trying to debug with gdb. I am having problem to go step by step. The program works fine. when i say step, it is executing whole function. Also when i say print specific parameter value, it say's "No symbol "i" in current context". Here is the complile option that i have used to compile it and debug it. But 'i' is declared and assigned

Here are the complie options that i have tried.
gcc -g test.c -o test
gcc -g -Wall -o test test.c
gcc -Wall -O -g -o test test.c
gcc -Wall -O -g test.c

here is the code.
#include <stdio.h>

int bazz(int anint);
int f;
int main() {
int i;
i=5;
f=5;
printf("This is my program\n");
bazz(i);
return 0;
}

int bazz(int anint) {
printf("You gave me %d\n", anint);
return anint;
}


Am i doing any thing wrong?


Thanks in advance,
Srini.

 
Code:
/cygdrive/c/junk/c>gcc -ggdb junk1.c
/cygdrive/c/junk/c>gdb ./a.exe
GNU gdb 2003-03-03-cvs (cygwin-special)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) break main
Breakpoint 1 at 0x4010c2: file junk1.c, line 7.
(gdb) run
Starting program: /code/a.exe

Breakpoint 1, main () at junk1.c:7
7           i=5;
(gdb) step
8           f=5;
(gdb)
9           printf("This is my program\n");
(gdb)
This is my program
10          bazz(i);
(gdb)
bazz (anint=5) at junk1.c:15
15          printf("You gave me %d\n", anint);
(gdb)
You gave me 5
16          return anint;
(gdb)
17      }
(gdb)
main () at junk1.c:11
11          return 0;
(gdb)
12      }
(gdb)
0x61007408 in cygwin1!__assert () from /usr/bin/cygwin1.dll
(gdb)
Single stepping until exit from function cygwin1!__assert,
which has no line number information.
0x610c2060 in wmemset () from /usr/bin/cygwin1.dll
(gdb)
Single stepping until exit from function wmemset,
which has no line number information.
0x61005cf0 in cygwin1!__assert () from /usr/bin/cygwin1.dll
(gdb)
Single stepping until exit from function cygwin1!__assert,
which has no line number information.

Program exited normally.
(gdb)
 
Thank you Hammer.

I have used the same but i am getting different results. Am i doing any thing wrong?

$ gcc -ggdb test.c
$ gdb ./a.out
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "hppa2.0n-hp-hpux11.00"...
(gdb) break main
Breakpoint 1 at 0x2948
(gdb) run
Starting program: /home/syalavar/a.out

Breakpoint 1, 0x00002948 in main ()
(gdb) step
Single stepping until exit from function main,
which has no line number information.
This is my program
You gave me 5
0x77ee6478 in _start () from /usr/lib/libc.2
(gdb)
Single stepping until exit from function _start,
which has no line number information.

Program exited normally.
(gdb)


Any idea?

Thanks in advance.
 
I don't know what's causing the problem.
I'd suggest you start by upgrading to the latest version of gcc/gdb to see if it's a problem in that area.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top