/ src / private-frameworks / DebugSymbols / DebugSymbols.c
DebugSymbols.c
 1  #include <DebugSymbols/DebugSymbols.h>
 2  
 3  const char* SYSTEM_DSYMS_DIR = "/System/Library/Caches/dsym/uuid";
 4  
 5  CFURLRef DBGCopyFullDSYMURLForUUID(CFUUIDRef uuid, CFURLRef exec_url)
 6  {
 7  	// Look up by UUID
 8  	if (uuid != NULL)
 9  	{
10  		CFStringRef uuidString = CFUUIDCreateString(NULL, uuid);
11  		CFStringRef dsymPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/%@.dSYM"), SYSTEM_DSYMS_DIR, uuidString);
12  
13  		CFRelease(uuidString);
14  
15  		if (access(CFStringGetCStringPtr(dsymPath, kCFStringEncodingUTF8), F_OK) == 0)
16  		{
17  			// printf("Found debug symbols: %s\n", CFStringGetCStringPtr(dsymPath, kCFStringEncodingUTF8));
18  			CFURLRef url = CFURLCreateWithFileSystemPath(NULL, dsymPath, kCFURLPOSIXPathStyle, false);
19  			CFRelease(dsymPath);
20  			return url;
21  		}
22  
23  		fprintf(stderr, "Didn't find debug symbols at %s based on UUID\n",CFStringGetCStringPtr(dsymPath, kCFStringEncodingUTF8));
24  		CFRelease(dsymPath);
25  	}
26  
27  
28  	// Try looking next to the executable
29  	if (exec_url != NULL)
30  	{
31  		CFStringRef exec_path = CFURLCopyFileSystemPath(exec_url, kCFURLPOSIXPathStyle);
32  		CFStringRef dsymPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.dSYM"), exec_path);
33  		CFRelease(exec_path);
34  
35  		if (access(CFStringGetCStringPtr(dsymPath, kCFStringEncodingUTF8), F_OK) == 0)
36  		{
37  			CFURLRef url = CFURLCreateWithFileSystemPath(NULL, dsymPath, kCFURLPOSIXPathStyle, false);
38  			CFRelease(dsymPath);
39  			return url;
40  		}
41  		fprintf(stderr, "Debug symbols not found at %s\n", CFStringGetCStringPtr(dsymPath, kCFStringEncodingUTF8));
42  
43  		CFRelease(dsymPath);
44  	}
45  
46  	return NULL;
47  }
48  
49  CFDictionaryRef DBGCopyDSYMPropertyLists(CFURLRef dsym_url)
50  {
51      return NULL;
52  }