Passing gdb command at program startup

I use gdb to debug the program and I want to get the output of the command

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

as my argument. How can i do this? Thus, the argument will be very flexible.

+3
source share
3 answers

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

If you want to do the above, try:

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

as a command after starting gdb.

+4
source

The above does not work a bit and will not work for me. If you use the set args command, the following will work (at least on my system):

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

, "run" .

+3

It looks like you did not run your program using gdb. Suppose your program is "a.out", in bash:

$gdb a.out
(gdb)run `$(perl -e 'print "A"x20')`

Hope this helps you.

+1
source

Source: https://habr.com/ru/post/1711681/


All Articles