discuss-gnustep
[Top][All Lists]
Advanced

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

How exactly do I debug Objective-C with gdb?


From: Michael Baehr
Subject: How exactly do I debug Objective-C with gdb?
Date: Tue, 25 May 2004 18:28:27 -0500

I just rebuilt Ludovic's GNUMail.app and Pantomime Framework from CVS
and I'm trying to track down a segfault in some message-threading
code.  GDB's backtrace is helpful enough in that I know what method
it's in ([Container childAtIndex:]).  For informational purposes, here
is childAtIndex:

- (Container *) childAtIndex: (unsigned int) theIndex
{
  Container *aChild;
  unsigned int i;

  aChild = child;

  for (i = 0; i < theIndex; i++)
    {
      aChild = aChild->next;
    }

  return aChild;
}

The segfault occurs in the for loop, so it is obviously going past the
end of the linked list of children.

It would be very helpful to know the values of the iterator, theIndex,
etc., but I get this crap from gdb:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 22395)]
0x40073213 in -[Container childAtIndex:] () from
/opt/GNUstep/Local/Library/Libraries/libPantomime.so.1
(gdb) bt
#0  0x40073213 in -[Container childAtIndex:] () from
/opt/GNUstep/Local/Library/Libraries/libPantomime.so.1
#1  0x40065f26 in -[Folder thread] () from
/opt/GNUstep/Local/Library/Libraries/libPantomime.so.1
#2  0x0808171e in -[GNUMail threadOrUnthreadMessages:] ()
#3  0x40594e07 in L10 () from
/opt/GNUstep/System/Library/Libraries/libgnustep-base.so.1
#4  0x081f1a58 in ?? ()
#5  0x08115268 in _OBJC_SELECTOR_TABLE ()
#6  0x08506b90 in ?? ()
#7  0x00000100 in ?? ()
(gdb)

Looks right so far, doesn't it?

(gdb)info scope childAtIndex:
[0] cancel
[1] all
> 1

That doesn't look right :|  Then I try to print out some variables
that are in the scope:

(gdb) p theIndex
No symbol "theIndex" in current context.
(gdb) p i
No symbol "i" in current context.
(gdb) p aChild
No symbol "aChild" in current context.

@#*()$&ELJKDLFIUR_(T*W#RJ$

These symbols are obviously in scope and in the current context.  I
mean, I'm looking at the code in emacs while I'm doing this.  What,
precisely, am I doing wrong here?

Is gdb just broken when it comes to debugging Objective-C?

-- Michael Baehr




reply via email to

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