Reputation: 5407
I have c++ program which I run by passing string with it.
g++ -o a main.cpp -lpthread
and execute it with ./a "Good nice"
But how I debug it with gdb? main.cpp calling functions from other files which are included in it.
gdb ./a "Good nice"
takes "--" as files and says no such file!
I want to debug line by line!
Upvotes: 5
Views: 425
Reputation: 40614
Use the --args
option of gdb:
gdb --args ./a "Good nice"
Also add the -g
option to your compiler call, because otherwise gdb won't be able to connect your executable with your source code:
g++ -g -o a main.cpp -lpthread
Upvotes: 6
Reputation: 45410
Anther choice is provide argument after run
$gdb ./a
run "Good nice"
Upvotes: 3