LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash + strace = ..... (https://www.linuxquestions.org/questions/programming-9/bash-strace-%3D-183006/)

gearoid 05-18-2004 04:26 PM

bash + strace = .....
 
hey,

this might sound bizarre but I am trying to do something and I need some help. I have downloaded the source code of both bash and strace and want to modify both to do a little playing around. I'd like to modify my bash shell so everytime a command is invoked from the command line, not only is the command executed, but it is also straced, and the result of which saved to a file...

So if I was to type
Code:

ls
it would be the equivalent of
Code:

strace -o outFileName ls
but all done automatically. As far as I can see this only requires two small (he says awaiting a backlash!!) changes to both the bash source and the strace source....

Trouble is, can anyone save me some time and tell me what / where I should be changing?? Both have multiple files, and Ks of lines of code, and I will know what to do once I am in the right place, but the trouble is finding the right place to start!! So can someone tell me what files even to be looking at???

Thanks,
Gearóid


some more info on changes I want to make (to begin with)!!....

bash - hardcode in that every command should be preceded by a call to strace also

strace - hardcode in that every invocation should have its output saved to some file

I can change the genericity of this later - but for now I'd just like to get it working!!

jlliagre 05-18-2004 05:26 PM

Some comments:
Builtin bash commands wouldn't be traced by such technique.
There is probably no need to patch the strace command itself, as if you can intercept all bash exec calls, you can also insert the options you want.
A simpler solution consist on launchin the shell itself under strace with the options "-o outFileName -ff", that will create a trace file for each subcommand you launch.

infamous41md 05-18-2004 05:27 PM

here's a hint, for bash just grep for exec* and find where it is making calls to exec functions. and then do the exact same for strace, and right before strace calls exec open up your file and dup2 the descriptor to stdout.

gearoid 05-19-2004 03:05 AM

cool, thanks for the suggestions.....


All times are GMT -5. The time now is 07:05 PM.