On Sunday 18 April 2010 03:33:59 Bob WM wrote:
> Hi there,
>
> How can I use gdb to debug   ./foo < foo.iniput?
>
> Thanks,
> Bob

Bob

I don't know how to do this directly but there is a brute force way to do this 
using gdb attach.

Change your main with

volatile int spinning=1;

main()
{
  while(spinning){}
...
}

Now you can launch

$ ./foo <foo_input

which will get stuck in the infinite loop

From a separate terminal
$ ps -ef
find the process number, say 12345

$gdb foo
(gdb) attach 12345
Set spinning to zero
(gdb) p spinning = 0

...



Reply via email to