Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by Dave Griffiths
Fri, 31 Jul 1992 23:59
Tracing method calls in gdb
Author: Dave Griffiths
Date: Fri, 31 Jul 1992 23:59
Date: Fri, 31 Jul 1992 23:59
8 lines
646 bytes
646 bytes
I find that quite often I would like to trace the methods that are being called during execution of a program. Has anybody got a gdb script that will do this? Presumably it's possible to put a break into something like objc_msgSend() that will print the object name and method and then continue? Thanks for any help, Dave Griffiths
Re: Tracing method calls in gdb (SUMMARY)
Author: Dave Griffiths
Date: Wed, 05 Aug 1992 18:10
Date: Wed, 05 Aug 1992 18:10
67 lines
2403 bytes
2403 bytes
In article <1992Jul31.235937.450@prim> prim!dave@germany.eu.net (Dave Griffiths) writes: >I find that quite often I would like to trace the methods that are being >called during execution of a program. Has anybody got a gdb script that >will do this? Presumably it's possible to put a break into something like >objc_msgSend() that will print the object name and method and then continue? > The only replies I got were from other people also expressing an interest in how to do it, so I figured it out myself (see below). This is for version 2.0 of the OS. You have to disassemble objc_msgSend() and objc_msgSendSuper() to find the calls to "jmp (a0)" if you're running some other version and it doesn't work. However, the results weren't as useful as I'd hoped. For one thing, it runs soooooo SLOWLY! Mainly I suppose because you're switching back and forth between the two processes. Conditional breaks don't help for the same reason. Secondly, the simplest of operations results in trillions of method calls! Ploughing through them is quite a chore. It would be nice to have some way of showing the stack depth and then you could indent the output accordingly to make it more readable. Couldn't think of an easy way to do it though. (You could increment a convenience variable on input, set a break at the return address and decrement it on return, but how to remove the return break without messing up recursion?). Anyway if anyone wants to play, here it is: break *(&objc_msgSend + 46) commands 1 silent x/i $a0 cont end break *(&objc_msgSend + 104) commands 2 silent x/i $a0 cont end break *(&objc_msgSend + 180) commands 3 silent x/i $a0 cont end break *(&objc_msgSendSuper + 50) commands 4 silent x/i $a0 cont end break *(&objc_msgSendSuper + 102) commands 5 silent x/i $a0 cont end break *(&objc_msgSendSuper + 166) commands 6 silent x/i $a0 cont end This assumes that these are the first breakpoints you have set (I put the script into .gdbinit). Dave Griffiths
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads