I'm running atos
to symbolicate addresses using -arch arm64 -o MyApp -s <slide> -f <symbol file>
. However, it prints lines like type metadata accessor for GradientView (in MyApp) (<compiler-generated>:0)
. I'd like it to print the mangled name instead, e.g. _$s22FeatureImpl12LanguageCellC19GradientViewSo012GradientI0CvpACTk
. I need this for various reasons, including to pass to an order file for the linker. Is there any way to do this with atos
?
I've found a workaround without atos
. I can use the private CoreSymbolication framework directly:
#import <Foundation/Foundation.h>
#include <stdint.h>
#include <mach/machine.h>
#include <mach-o/arch.h>
#include <architecture/byte_order.h>
struct sCSTypeRef {
void* csCppData; // typically retrieved using CSCppSymbol...::data(csData & 0xFFFFFFF8)
void* csCppObj; // a pointer to the actual CSCppObject
};
typedef struct sCSTypeRef CSTypeRef;
typedef CSTypeRef CSSymbolicatorRef;
typedef CSTypeRef CSSourceInfoRef;
typedef CSTypeRef CSSymbolOwnerRef;
typedef CSTypeRef CSSectionRef;
typedef CSTypeRef CSSegmentRef;
typedef CSTypeRef CSSymbolRef;
typedef CSTypeRef CSRegionRef;
typedef CSTypeRef CSUUIDRef;
CSSymbolicatorRef CSSymbolicatorCreateWithURLAndArchitecture(CFURLRef url, cpu_type_t type);
CSSymbolRef CSSymbolicatorGetSymbolWithAddressAtTime(CSSymbolicatorRef cs, vm_address_t addr, uint64_t time);
const char* CSSymbolGetMangledName(CSSymbolRef sym);
int main(int argc, const char * argv[]) {
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSTR("/path/to/dSYM/binary"), kCFURLPOSIXPathStyle, false);
CSSymbolicatorRef cs = CSSymbolicatorCreateWithURLAndArchitecture(url, 16777228 /* arm64 cputype */);
int slide = ...;
ptrdiff_t addr = ...;
CSSymbolRef sym = CSSymbolicatorGetSymbolWithAddressAtTime(cs, addr - slide, 0);
const char *name = CSSymbolGetMangledName(sym);
printf("%s\n", name);
return 0;
}
https://github.com/mountainstorm/CoreSymbolication/blob/master/CoreSymbolication/CoreSymbolication.h provided the prototypes