I’m trying to get a GDB backtrace output from GDB through PHP. I’d like to use system() to call “gdb /path/to/application /path/to/corefile”, but then I need to run “backtrace” within GDB.
Is there a way to execute a program through PHP and then run a command in that program while it’s running? I’m open to other ways to do this.
I’ve not tried it, but you could use tty functionality for this.
gdb has a -tty parameter that accepts input to standard input – so the tricky part is getting PHP to write. Someone in the PHP manual has contributed a function that may do what you need: http://www.php.net/manual/en/ref.readline.php#38022
Sorry if it’s not right, but given the absence of any other answers, this is what I’d be trying.
Edit: another thought. proc_open should do what you want: http://www.php.net/manual/en/function.proc-open.php