Re: [DEBIGGING] Infinite Loops

From: d. hall (dhall@OOI.NET)
Date: 10/19/98

+// thus on Mon, 19 Oct 1998 16:42:49 -0500, Joshua wrote:

Most of the citation has been kept to keep the explanation somewhat sane.

>>>> My mud is getting caugth into endless loops, and i dont know how to
>>>> track them down!  Does anyone have any ideas?

>>> If you're on linux/unix, start the mud under GDB and hit control-C when
>>> you're in your endless loop. Then use the "backtrace" command to see
>>> where you are. (You can also use GDB to break into an existing mud
>>> process, "gdb bin/circle <process id number>").

>> Good, i'm running GDB under linux, but what does 'break into an existing
>> mud process' mean ?  Does the mud create child processes? and how do i
>> see their id's, the top command and ps don't show them...

ps auxww | grep circle will normally show the process ID.

> PID is process id, maybe someone else can expand upon gdb since i'm not a
> gnu guru, but i take it that he means to specify the pid such as

If the mud's already running, and you didn't start the mud via gdb, you can
use the 'attach' command within gdb.  The attaching can also be done via
giving the process ID at the command line as shown above and below.

If the mud is running with say process number 25666 (use the ps command
listed above to find out).

Start gdb, and type

(gdb) attach 25666

> % gdb bin/circle 25666

Or else you can call gdb as above, this is normally the best way since then
all the symbol tables should be aligned correctly, but I believe it's best
to be in the directory with the source code.

(this may not work if you have a file called 25666, but that's a strange
file name =)

> assuming that my circle process was 25666, now you're debugging a running
> process

Then you might want to hit Control-C to 'stop the mud', and type

(gdb) bt

for a backtrace, this will list a trace of the functions last called, a
good starting point to figure out where you mud is hanging.

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST