I want to run an executable, redirect it's stdout to my program's via pipe, and LLDB debug my program. So, for example:
cat my_file | ./main
and then debug ./main.
I'm aware of process launch -i my_file
, but that's not exactly what I want to do - I want the output to come from cat's stdout (it could be any other executable which -i wouldn't achieve similar behaviour with).
I see no relevant options under help process launch
.
That isn't an option supported by lldb. You can get almost the same effect by running:
(lldb) process attach -w -n main
then go to the command line and run the cat | ./main
command.
lldb will attach to the process called main when it is created. lldb does this by polling the process table, so it won't stop at the very beginning of the program's life. However, it usually catches it very early on (often in the dyld loading phase) so this might not be an issue for you. If it is - and main is a program you can rebuild, one solution is to put something like this at the beginning of main:
int go_on = 1
while (go_on) { sleep(1); }
Then when you attach, do:
(lldb) expr go_on = 0
(lldb) continue
For those still looking to pass shell command outputs to lldb as arguments.
One solution that you can try, is creating an environment variable with the result of the command and then passing this as an argument to lldb. When lldb runs it sets the target.run-args option taken from the environment variable.
In your example you would do something along those lines.
ARG=`cat my_file`
(echo $ARG to validate the result is that you want)
lldb -- main $ARG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With