1

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?

6
  • Is /home/users/xxx/C a real directory or have you mounted a Windows file system on your Solaris system ? Commented Nov 14, 2012 at 9:24
  • Do you see the message "Reading symbols from /path/to/your/cc/file...done." on startup? Also, GDB seems to be at version 7.4.1 on my Linux box, so 4.16 looks reeeaaally old to me... Finally, just to be sure, try gdb ./testcc (there might be another testcc in the path) Commented Nov 14, 2012 at 9:32
  • Try grabbing a more recent version of GDB from sunfreeware.com. I suspect your gdb, version 4.16 (sparc-sun-solaris2.6), is having trouble with the debugging information generated by your copy of gcc. Commented Nov 14, 2012 at 10:24
  • @Paul R, that's a real directory. Commented Nov 14, 2012 at 10:31
  • @Sjlver, I didn't see that message, I have tried gdb ./testcc, it doesn't work either. Commented Nov 14, 2012 at 10:32

1 Answer 1

2

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.