Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to trace ObjC messages

31 views
Skip to first unread message

Bruce Montegani

unread,
Jun 11, 1996, 3:00:00 AM6/11/96
to

Does anyone know how to trace all messages that are executed when an
application is running including API kit messages.

i think this would be very helpful in determining the message sequencing of
an application especially with the NeXT kits.

Thanks

Bruce Montegani

Steve Dekorte

unread,
Jun 12, 1996, 3:00:00 AM6/12/96
to

When you compile, there's a debug option you can use and you can mark which
classes you want to see message invocations in. Check out the gdb docs.

--
Steve Dekorte "C++/Java, the COBOL of the 90s"
NeXTstep consultant - Anaheim, CA
mailto:dek...@suite.com (NeXTmail,MIME)
http://www.batech.com/~dekorte/dekorte/index.html

Steve Besler

unread,
Jun 14, 1996, 3:00:00 AM6/14/96
to

In article p...@news.mr.net, bm...@rconnect.com (Bruce Montegani) writes:
>Does anyone know how to trace all messages that are executed when an
>application is running including API kit messages.

Try linking your application with /usr/lib/libPeep.a (using "-lPeep")
Then, run your app, and look at it with AppInspector with the Peep
option turned on.

Unfortunately, I don't know how to link libPeep into an existing
application...

Cheers,

Steve

--
Steven Besler, Coop Student "I do not speak for Motorola."
Motorola Wireless Data Group bes...@mdd.comm.mot.com

Matt Watson

unread,
Jun 15, 1996, 3:00:00 AM6/15/96
to

In article <4pkmc3$p...@news.mr.net> bm...@rconnect.com (Bruce Montegani)
writes:
> Does anyone know how to trace all messages that are executed when an
> application is running including API kit messages.
>

(gdb) b objc_msgSend
Breakpoint 1 at 0x60044f0
(gdb) comm 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>silent
>p *(char **)($sp+8)
>up
>cont
>end
(gdb) r

(Getting this to work on HP-PA is left as an exercise to the reader...)

matt.
--
Matt Watson
Thaumaturgist
NeXT Software, Inc.

Eric Noyau

unread,
Jun 16, 1996, 3:00:00 AM6/16/96
to

In article <4pteds$n...@news.next.com> Matt_...@NeXT.com (Matt Watson)
writes:
Matt, you are giving away corporate secrets !

I have another solution to the same problem:

(enoyau@pelane) gdb test
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (NEXTSTEP 4.0 --target i386), Copyright 1995 Free Software
Foundation, Inc...

(gdb) b main
Reading in symbols for test_main.m...done.
Breakpoint 1 at 0x3b47: test_main.m:9.
(gdb) r
[...]
Breakpoint 1, main (argc=1, argv=0xbffff6f8) at test_main.m:9
test_main.m:9: No such file or directory.
(gdb) b objc_msgSend
Breakpoint 2 at 0x5002230
(gdb) comm 2


Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>silent

>printf "%c[%s %s]\n", (((*((**(int ***)($sp+4)) + 4)) & 2) ? '+' : '-'),
(char *)(*((**(int ***)($sp+4)) + 2)), (char *)sel_getName(*(int
*)($sp+8))
>cont
>end
(gdb)cont
Continuing.
+[NSAutoreleasePool alloc]
+[NSAutoreleasePool initialize]
+[NSAutoreleasePool allocWithZone:]
+[NSThread allocWithZone:]
+[NSThread initialize]
-[NSThread init]
-[NSAutoreleasePool init]
+[NSUserDefaults standardUserDefaults]
+[NSUserDefaults initialize]
+[NSAutoreleasePool allocWithZone:]
-[NSAutoreleasePool init]
-[NSConstantString getCString:maxLength:]
-[NSConstantString length]
-[NSConstantString getCString:maxLength:range:remainingRange:]
[... etc...]

(Getting this to work on HP-PA is still left as an exercise to the
reader... ;^) )

-- Eric

Gregory H. Anderson

unread,
Jun 16, 1996, 3:00:00 AM6/16/96
to

Eric Noyau writes

> I have another solution to the same problem:

Wait, Eric, you forgot something:

----------------------- BEGIN GEEK CODE BLOCK -----------------------


> printf "%c[%s %s]\n",(((*((**(int***)($sp+4))+4))&2)?'+':'-'),
> (char*)(*((**(int ***)($sp+4))+2)),(char*)sel_getName(*(int*)($sp+8))

------------------------ END GEEK CODE BLOCK ------------------------

There. Now it is properly formatted for USENET. Man, I loves dem
triple '*'s...

--
Gregory H. Anderson | "I wander'd off by myself, In the
Crystal Ball/Star Gazer | mystical moist night-air, and from
Anderson Financial Systems | time to time, Look'd up in perfect
gr...@afs.com (NeXTmail OK) | silence at the stars." Walt Whitman

Art Isbell

unread,
Jun 16, 1996, 3:00:00 AM6/16/96
to

Eric_...@next.com (Eric Noyau) wrote:
> >printf "%c[%s %s]\n", (((*((**(int ***)($sp+4)) + 4)) & 2) ? '+' : '-'),
> (char *)(*((**(int ***)($sp+4)) + 2)), (char *)sel_getName(*(int
> *)($sp+8))

Oh my gawd!!
--
Art Isbell NeXT/MIME Mail: ais...@cubicsol.com
Trego Systems Voice/Fax: +1 408 335 2515
CaseServ: NEXTSTEP/OpenStep Voice Mail: +1 408 335 1154
managed care solutions US Mail: Felton, CA 95018-9442

David Stes

unread,
Jun 16, 1996, 3:00:00 AM6/16/96
to

> Does anyone know how to trace all messages that are executed when an
> application is running including API kit messages.

On the NeXT 2.1, I found libPeep.a & AppInspector.app very useful for this
(but is this still working ? I haven't been able to use this app since 3.0
for anything else than "inspecting" the objects in the application - not
for actually tracing messages. Maybe I'm missing something here...)

If you have a Solaris or WindowsNT machine at hand, you could also try
using the Stepstone objcc which has an excellent feature for tracing
messages. You can turn it on or off from within your program or from
within the debugger by the "msgFlag" boolean.

(The Stepstone compiler comes with runtime source... here's the relevant
code at the start of the C messenger)

IMP _imp(Object *recvr, SEL sel)
{
SHR shr;
REGISTER int index;

#if defined(NO_TRACEBACK)
if (msgFlag)_prnFrame(msgIOD, recvr, sel, NO);
#else
if (msgFlag)_prnFrame(msgIOD, GETFRAME(recvr), ARGPTR(recvr), NO);
#endif

if (recvr == (Object *)nil)
return (IMP)_nilHandler;

if ((shr=recvr->isa) == Nil)
return (IMP)_freedHandler;


0 new messages