With OSX 10.6, the callStackSymbols call gives a nicely formatted stack
trace, whereas the GTM one is a bit hard to read because of not handling
the length of 64 bit frame addresses, and using the full paths to
executables, and some formatting issues. I therefore altered the formatting
to match what callStackSymbols gives as follows:
static NSString *GTMStackTraceFromAddressDescriptors(struct
GTMAddressDescriptor descs[],
NSUInteger count) {
NSMutableString *trace = [NSMutableString string];
for (NSUInteger i = 0; i < count; i++) {
// Newline between all the lines
if (i) {
[trace appendString:@"\n"];
}
if (descs[i].class_name) {
[trace appendFormat:@"%-2u %-35s %#016lx %s[%s %s]",
i,
(descs[i].filename ? [[[NSString stringWithCString:descs[i].filename
encoding:NSUTF8StringEncoding] lastPathComponent]
cStringUsingEncoding:NSUTF8StringEncoding] : "??"),
descs[i].address,
(descs[i].is_class_method ? "+" : "-"),
descs[i].class_name,
(descs[i].symbol ? descs[i].symbol : "??")];
} else {
[trace appendFormat:@"%-2u %-35s %#016lx %s()",
i,
(descs[i].filename ? [[[NSString stringWithCString:descs[i].filename
encoding:NSUTF8StringEncoding] lastPathComponent]
cStringUsingEncoding:NSUTF8StringEncoding] : "??"),
descs[i].address,
(descs[i].symbol ? descs[i].symbol : "??")];
}
}
return trace;
}
I hope this is of some use to improve the source.
Original issue reported on code.google.com by gideonyo...@novamind.com on 16 Feb 2010 at 3:40
Original issue reported on code.google.com by
gideonyo...@novamind.com
on 16 Feb 2010 at 3:40