ugdb icon indicating copy to clipboard operation
ugdb copied to clipboard

Add convienient way for passing data to stdin

Open gizlu opened this issue 4 years ago • 2 comments

Let's say i have prog which reads data from stdin I run it using my shell's input redirection:

$ ./some-exec --foo --bar < redirected_file.txt
$ printf "some-string\ndupa\n" | ./some-exec --foo --bar

It would be nice if ugdb took stdin and passed it to debugged program so we could use it that way:

$ ugdb -- ./some-exec --foo --bar < redirected_file.txt
$ printf "some-string\ndupa\n" | ugdb -- ./some-exec --foo --bar

gizlu avatar Sep 16 '21 15:09 gizlu

Sorry for taking so long to respond. I've been quite busy with work lately.

In general I like the idea and see how it would be useful to something to stdin via a script or something. I wonder about the best way to that, though. Consider that you might want to restart the debugging session after you've stepped over a critical function. When restarting the execution the program would possibly miss some part of the data passed via stdin.

What do you think about passing a script via commandline argument that would be executed to the program whenever it is started? Something like this

$ ugdb --stdin-script script.sh ./some-exec

where script.sh contains cat redirected_file.txt or printf "some-string\ndupa\n"?

ftilde avatar Oct 26 '21 19:10 ftilde

Also sorry for taking so long to respond. I've had misconfigured github notfications.

Sorry for taking so long to respond. I've been quite busy with work lately. In general I like the idea and see how it would be useful to something to stdin via a script or something. I wonder about the best way to that, though. Consider that you might want to restart the debugging session after you've stepped over a critical function. When restarting the execution the program would possibly miss some part of the data passed via stdin.

Good point, I missed that.

What do you think about passing a script via commandline argument that would be executed to the program whenever it is started?

$ ugdb --stdin-script script.sh ./some-exec

where script.sh contains cat redirected_file.txt or printf "some-string\ndupa\n"?

Sounds good. If you pass stdin-script to shell (using something like popen() rather than fork/exec) it could be even used without writing separate script like that:

$ ugdb --stdin-script "curl something | tail"  ./some-exec

gizlu avatar Jan 07 '22 16:01 gizlu