Closed Bug 336517 Opened 19 years ago Closed 17 years ago

stack walking code for Mac OS X

Categories

(Core :: XPCOM, enhancement)

PowerPC
macOS
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dbaron, Assigned: dbaron)

References

Details

Attachments

(1 file)

We have stack walking code in xpcom/base/nsStackFrame* and xpcom/base/nsTraceRefcntImpl.cpp that's useful for Linux and Windows, but we don't have any for Mac OS X. It seems like it may well be possible to do something like what the Linux code does, now that trunk supports only 10.3 and up. (Is that correct?) See the information on dladdr in http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html We'd might also need to back out bug 196115 if dladdr is in libdl, which is where I'd expect.
We can use dladdr in theory, but we'll need to move all of the trunk build machines to be using a 10.3 SDK first (they're on 10.2 now). Because 10.3 SDKs are half-braindead, we need to be mindful of bug 329579. We won't need to back out bug 196115. dladdr is in libSystem. libdl.dylib is just a symlink to libSystem, there's no need to bring it in explicitly.
Yeah, I enabled the stackwalker code on OS X to be able to use the refcount balancer. It works, but the stack dumps aren't always very accurate (print out the wrong function names sometimes).
Any chance you could attach the patch? It's probably worth getting in; maybe others could improve it once it does, or write a post-processor like fix-linux-stack.pl.
dbaron, does the patch in bug 305581 do the same thing you're asking for in this bug?
Looks like so. May be worth waiting until after bug 374689 and bug 374829 to merge to tip...
Bug 305581 is PowerPC only I think. I don't really have a useable patch for this bug, I just commented out some ifdef's in nsStackFrameUnix.cpp and nsTraceRefcntImpl.cpp so I use the linux code. But we really should add ifdef's to enable this on OS X on Intel.
We'll leave the other bug for the code Simon has there, if it eventually becomes usable. Here's a patch that enables the Linux code for Mac OS X. I've tested it only on PPC (which actually required a small change); I suspect it will work on x86 too, but somebody testing wouldn't be a bad idea. It only shows publicly-visible symbols. I'll try writing a perl script based on fix-linux-stack.pl to at least get correct function names based on otool -l, otool -tv, and c++filt, which should be pretty quick.
Assignee: nobody → dbaron
Status: NEW → ASSIGNED
Attachment #276568 - Flags: review?(peterv)
Actually, nm -an should give me a good bit more useful info for a perl script. It even shows the debugging information.
I checked in a perl script into mozilla/tools/rb/fix-macosx-stack.pl that will fix the stack traces generated by the above code. It works for me on PPC; it may need some tweaking for x86.
Jesse tested this on x86-Mac, and it works fine there too, as does fix-macosx-stack.pl, which is now at revision 1.5 (but that's not quite on LXR yet): http://mxr.mozilla.org/seamonkey/source/tools/rb/fix-macosx-stack.pl?raw=1
Blocks: 392118
Attachment #276568 - Flags: review?(benjamin) → review+
Attachment #276568 - Flags: approval1.9+
Fix checked in to trunk, 2007-08-15 17:03 -0700.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: