Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using GDB to debug a code compiled with Sun cc

807578Dec 30 2009 — edited Jan 3 2010
When using gdb to debug C code compiled with Sun's cc, the step-into doesn't work, i can only "step into" a function if i put a breakpoint on it. Also, sometimes if i set a breakpoint on a function name, like "break foo", gdb indeed breaks when foo is reached, but without showing the source code (this i could not reproduce with a small demo program).
I am using Sun Studio 12 on a SunOS 5.10 sun4u sparc machine.
My demo program is:

#include <stdio.h>
#include <strings.h>

void func1(str)
char str;
{
printf("This is the first line\n");
printf("STR: %s\n",str);
}

int main()
{
char str[10];

strcpy(str,"lalalal");
printf("Calling func1\n");
func1(str);
printf("Returned from func1\n");
}

The compilation command i run is:
cc -c -g step_into.c -o step_into.o
cc -g -o step_into step_into.o

When running the program with gdb, the "step" command does not step into func1, but runs it like "next".
I know there's the dbx debugger, but if there's a way to fix this with gdb - it is much preferable for us. Switching to dbx is not really feasible for us.

Regards,
Yael
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2010
Added on Dec 30 2009
7 comments
467 views