C programming: how to use gdb with makefile and command line arguments?

To create an .out executable, I have to enter:

$: make
$: myprogram.out name.ged

My program includes a command line argument, thus, "name.ged".

Whenever I run gdb after receiving a segmentation error (the kernel is reset), I enter:

$: gdb a.out core
(gdb): bt

Then I use the back trace command, and gdb returns:

#0 0x4a145155 in ?? ()
#1 0x08a16ce0 in ?? ()

I even tried using the up t command to move up the stack, but still no luck. I can’t say which line in my program gives me a seg error. gdb works with my other programs that do not include Makefile arguments and commands, so I wonder if my commands are incorrect.

+5
source share
1 answer

( - :).

, gdb . -g . , . gdb backtrace.

make - (to) CFLAGS, .o.c.

CFLAGS= -g -Wall -Wextra

( , :). make ( ).

$ CFLAGS='-g -Wall -Wextra' make

bash.profile, .

CFLAGS='-Wall -Wextra'

, , make , :

CFLAGS+= -g
+7

All Articles