Question

I have a source file testcc.c which just print a "Hello, World", I compile it with cc as below

cc -g -o testcc testcc.c

it works fine when I run it. now I want to debug it with gdb with the following command.

gdb testcc

I can see the output from gdb.

GDB is free software and you are welcome to 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. GDB 4.16 (sparc-sun-solaris2.6), Copyright 1996 Free Software Foundation, Inc...

But, When I try to set a breakpoint at line 5, I got the following message

(gdb) break 5
Breakpoint 1 at 0x10814: file /home/users/xxx/C, line 5.
(gdb)

The problem is /home/users/xxx/C is my current working directory, not the source file!

Then, I try to use the file:line-number options

(gdb) break testcc.c:5
No source file named testcc.c.

So, I include the full path for the file name as below

(gdb) break /home/users/xxx/testcc.c:5
No source file named /home/users/xxx/testcc.c.

I am confused, the file is there, why gdb can not find it? I also try to specify the directory to search for source files when starting gdb

gdb -d /home/users/xxx/C testcc

it still not work, what's the problem?

Was it helpful?

Solution

After struggle for a whole day, I finally find that we should use dbx to debug program compiled by Sun cc compiler. here is the link said this.

http://www.cs.cmu.edu/~gilpin/tutorial/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top