Home > Back-end >  how to switch from assembly code to c code in gdb
how to switch from assembly code to c code in gdb

Time:05-13

I am trying to debug my c program using

gcc -g -lm -lpthread -std=c99 -w terminalproject.c

and then

gdb a.out

but when I type layout next, it shows me assembly code not c code.

How to switch to C code in layout?

EDIT: I am using Red Hat Linux 6, I tried to run it in Ubuntu, It is showing C code.

p.s my code has pthreads in it.

CodePudding user response:

This command:

gcc -g -lm -lpthread -std=c99 -w terminalproject.c

is wrong. Use this instead:

gcc -g -std=c99 -pthread terminalproject.c -lm

You should never use -w (suppress all warnings) flag, unless you desire painful debugging sessions.


layout src says No source Available.

This likely means that you are using updated GCC, but ancient GDB. Try building recent GDB release from source -- it's usually not hard.

  • Related