2

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.

4
  • Just a guess: there is layout asm and layout src. Do you want: layout src at the outset? Commented May 8, 2022 at 16:48
  • Tried this, it says 'No source Available'. Commented May 8, 2022 at 16:53
  • 1
    I've never used layout before. When I want to see the C source, I've always used list Commented May 8, 2022 at 16:59
  • Thanks, at least I can debug my code now. :) Commented May 8, 2022 at 17:15

1 Answer 1

1

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.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.