Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save extremecoders-re/1f7fb28d44beefcb5caab585bc9f3228 to your computer and use it in GitHub Desktop.
Save extremecoders-re/1f7fb28d44beefcb5caab585bc9f3228 to your computer and use it in GitHub Desktop.
Debug a program in qemu with piped input

Debug a program in qemu with piped input

Within qemu

  1. Create named pipe
pi@raspberrypi ~ $ mkfifo thepipe
  1. Start a netcat listener which outputs to the pipe (redirected STDOUT)
pi@raspberrypi ~ $ nc -l -p 4444 >thepipe 
  1. Run the program in gdb with stdin redirected from pipe.
pi@raspberrypi ~ $ gdb -q ./program
r <thepipe

On host

  1. Connect to the listener (using netcat)
ubuntu@ubuntu $ nc 127.0.0.1 4444
  1. Whatever is sent to netcat as input becomes the input of the program. The output of the program will display in gdb and isn't redirected and can be done similarly if needed.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment