4

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.

wakandan
  • 1,099
  • 4
  • 19
  • 27
  • 1
    Are you reading the Hacking: The art of exploitation? I remember that he used perl to smash the stack. – Kasper Aug 25 '09 at 23:30

3 Answers3

5

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.

samoz
  • 56,849
  • 55
  • 141
  • 195
4

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.

gnometorule
  • 2,151
  • 2
  • 20
  • 29
1

It looks like you didn't start your program with gdb properly. Supposing your program is "a.out", in bash:

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

Hope this helps you.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
rui
  • 11
  • 1