Passing data to a shell'ed command

Shawn McCarney shawnmm@us.ibm.com
Tue Jul 3 14:58:00 GMT 2001


I need to create a user-defined command that reads some memory and then
passes it a formatting program.  I am assuming the formatting program would
be run via the 'shell' command'.  Is there any way to do this?

Below is a list of the things that I have thought of.  None of them seem to
be possible:

* Writing the command output to a file (this is my preferred approach)
* Passing output as stdin to a child process
* Setting an environment variable which contains the output
* Passing output as command line parameters to a child process

The data could be passed as command parameters if the 'shell' command
expanded convenience variables.  However, it doesn't seem to.

The only solution I have found so far is to require the user to run DDD and
then parse the ~/.ddd/log file.  However, this is a strange restriction on
the users.  It also might not work reliably due to buffered I/O.

Another possible solution would be to call C runtime I/O functions as part
an expression in a 'set' command.  However, these functions would be
running on the target, not the gdb host machine right?

Any other ideas?  Someone must have solved this already...

Shawn McCarney (shawnmm@us.ibm.com)



More information about the Gdb mailing list