Sharath
Sharath

Reputation: 33

passing the output of one .py script to another in GDB

How to pass the output of one .py script which I executed in GDB using below command:

(gdb)source myfilename.py 

to another .py script myfilename2.py

E.g: On running myfile myfilename.py in GDB I get the below results

(gdb)source myfilename.py
(gdb)print $function("input")
(gdb)$1 = someoutput`

If I want to pass $1 as input to another .py script how do I do it.

Thanks for the help.

Upvotes: 1

Views: 1102

Answers (2)

PSN
PSN

Reputation: 2516

I'm not sure if you can run other python programs output to another in gdb, but of course you can pass output of a command like this.

   (gdb) run "`python -c 'print "\xff\xff\xff\xff"'`"

May be you can try passing the second .py file instead of the command for its output to be passed into first .py.

Upvotes: 1

Doctor Strange
Doctor Strange

Reputation: 18

You cannot use contents of GDB variable $1 for your program input, since program launch is performed by shell, not by gdb.

You can store your script output in file, launch gdb for your executable and use command

(gdb)run <outputfile

Or use a named pipe, as suggested in this answer.

Upvotes: 0

Related Questions