Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing a command to gdb when running a program

I am using gdb to debug a program, and I want to have the output of the command

$(perl -e 'print "A"x20') 

as my argument. How can I do that? This way the argument would be very flexible.

like image 927
wakandan Avatar asked Dec 30 '22 20:12

wakandan


2 Answers

You can use the run command and pass it any parameters afterwards which will be arguments.

If you want the above, try:

run `$(perl -e 'print "A"x20')`

as a command once you start gdb.

like image 161
samoz Avatar answered Jan 29 '23 01:01

samoz


The above is slightly off and wouldn't work for me either. If you use the set args command, the following will work (at least on my system):

set args "`perl -e 'print "A"x20;'`"

As usual, simply type 'run' after to start debugging, and the proper argument should be passed.

like image 24
gnometorule Avatar answered Jan 29 '23 01:01

gnometorule