gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to use gdb with inputfile


From: Charles Manning
Subject: Re: how to use gdb with inputfile
Date: Mon, 19 Apr 2010 11:17:11 +1200
User-agent: KMail/1.9.10

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

[Prev in Thread] Current Thread [Next in Thread]