🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.objective-c
Article #418

Re: Debugging Objective C with gcc/gdb

#418
From: Paul F. Kunz
Date: Wed, 27 Jul 1994 04:59
64 lines
2861 bytes
>>>>> On Tue, 26 Jul 1994 18:58:52 GMT, tisu@quads.uchicago.edu (Seth Tisue) said:
In article <1994Jul26.185852.14238@midway.uchicago.edu> tisu@quads.uchicago.edu (Seth Tisue) writes:


> I'm using gcc 2.5.8 and gdb 4.1.2 on a Solaris 2.3 machine.

> I'd like to debug Objective C programs.  Right now I'm using a few
> hacks, like this one:

>   break objc_msg_lookup command <#> silent finish end

> (So that when I step through my program, I don't wind up in the
> bowels of libobjc.a.)

   I guess you missed the algorithm between method names and the
implementation functions as seen by the debugger and linker.   For
example, if class MyObject has method

	- doThis:anObject forThat:(int) anInt

then to set breakpoint one types

	break _i_MyObject__doThis_forThat_

Each ":" in the method name becomes a "_" in the symbol name for gdb
and the linker.   If methods are defined in a category, i.e.

	@implementation MyObject(MyCategory)
	- foo:anObject withBar:anotherObject
	{...}

then the breakpoint is set with

	break _i_MyObject_MyCategory_foo_withBar_

If you want to break at a Class method (i.e. factory method) then
change the "_i_" to "_c_".


> Is there a more official way of doing this?  Or does anyone have
> their own hacks they'd like to share?  Also, how can I see the
> contents of an instance variable of an arbitrary id?  i.e. if my
> code looks like:

>   MyClass* myvar;

> I can type "p myvar->data" and get an answer.  But if my code looks
> like:

>   id myvar;

> and I happen to know at runtime that myvar is a MyClass object, how
> do I access the instance variable?  

   Best to use the stronger type declaration (MyClass *myvar) or you
can try

	p (MyClass *)myvar

and hope for the best.
--
Paul F. Kunz	Paul_Kunz@slac.stanford.edu (NeXT mail ok)
Stanford Linear Accelerator Center, Stanford University
Voice: (415) 926-2884   (NeXT) Fax: (415) 926-3587
Technical Details
Message-ID: <PFKEB.94Jul26215915@kaon.SLAC.Stanford.EDU>
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!lll-winken.llnl.gov!unixhub!kaon.SLAC.Stanford.EDU!pfkeb
References: <1994Jul26.185852.14238@midway.uchicago.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,2f8d99d540d413bb
X-Google-Attributes: gid11318c,public
X-Google-Thread: 1111a3,2f8d99d540d413bb
X-Google-Attributes: gid1111a3,public
X-Google-ArrivalTime: 1994-07-26 22:15:58 PST
Newsgroups: comp.lang.objective-c,gnu.gcc.help
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!lll-winken.llnl.gov!unixhub!kaon.SLAC.Stanford.EDU!pfkeb
From: pfkeb@kaon.SLAC.Stanford.EDU (Paul F. Kunz)
Subject: Re: Debugging Objective C with gcc/gdb
In-Reply-To: tisu@quads.uchicago.edu's message of Tue, 26 Jul 1994 18:58:52 GMT
Message-ID: <PFKEB.94Jul26215915@kaon.SLAC.Stanford.EDU>
Sender: news@unixhub.SLAC.Stanford.EDU
Reply-To: Paul_Kunz@slac.stanford.edu
Organization: Stanford Linear Accelerator Center
References: <1994Jul26.185852.14238@midway.uchicago.edu>
Date: Wed, 27 Jul 1994 04:59:15 GMT
Lines: 64