mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 18:56:48 +00:00
[WINESYNC] dbghelp: Factor out query_dsym.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id c3c2cda9d2792f8c9c612b5bd6e9fd4d08cbb073 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
e2e7cce46f
commit
329ea60f7c
2 changed files with 41 additions and 36 deletions
|
@ -1241,6 +1241,44 @@ static BOOL try_dsym(struct process *pcs, const WCHAR* path, struct macho_file_m
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const WCHAR dsym_subpath[] = {'/','C','o','n','t','e','n','t','s',
|
||||||
|
'/','R','e','s','o','u','r','c','e','s',
|
||||||
|
'/','D','W','A','R','F','/',0};
|
||||||
|
|
||||||
|
static WCHAR *query_dsym(const UINT8 *uuid, const WCHAR *filename)
|
||||||
|
{
|
||||||
|
char uuid_string[UUID_STRING_LEN];
|
||||||
|
CFStringRef uuid_cfstring;
|
||||||
|
CFStringRef query_string;
|
||||||
|
MDQueryRef query = NULL;
|
||||||
|
WCHAR *path = NULL;
|
||||||
|
|
||||||
|
format_uuid(uuid, uuid_string);
|
||||||
|
uuid_cfstring = CFStringCreateWithCString(NULL, uuid_string, kCFStringEncodingASCII);
|
||||||
|
query_string = CFStringCreateWithFormat(NULL, NULL, CFSTR("com_apple_xcode_dsym_uuids == \"%@\""), uuid_cfstring);
|
||||||
|
CFRelease(uuid_cfstring);
|
||||||
|
query = MDQueryCreate(NULL, query_string, NULL, NULL);
|
||||||
|
CFRelease(query_string);
|
||||||
|
MDQuerySetMaxCount(query, 1);
|
||||||
|
if (MDQueryExecute(query, kMDQuerySynchronous) && MDQueryGetResultCount(query) >= 1)
|
||||||
|
{
|
||||||
|
MDItemRef item = (MDItemRef)MDQueryGetResultAtIndex(query, 0);
|
||||||
|
CFStringRef item_path = MDItemCopyAttribute(item, kMDItemPath);
|
||||||
|
if (item_path)
|
||||||
|
{
|
||||||
|
CFIndex item_path_len = CFStringGetLength(item_path);
|
||||||
|
size_t len = item_path_len + strlenW(dsym_subpath) + strlenW(filename) + 1;
|
||||||
|
path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||||
|
CFStringGetCharacters(item_path, CFRangeMake(0, item_path_len), (UniChar*)path);
|
||||||
|
strcpyW(path + item_path_len, dsym_subpath);
|
||||||
|
strcatW(path, filename);
|
||||||
|
CFRelease(item_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CFRelease(query);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* find_and_map_dsym
|
* find_and_map_dsym
|
||||||
*
|
*
|
||||||
|
@ -1255,16 +1293,11 @@ static BOOL try_dsym(struct process *pcs, const WCHAR* path, struct macho_file_m
|
||||||
static void find_and_map_dsym(struct process *pcs, struct module* module)
|
static void find_and_map_dsym(struct process *pcs, struct module* module)
|
||||||
{
|
{
|
||||||
static const WCHAR dot_dsym[] = {'.','d','S','Y','M',0};
|
static const WCHAR dot_dsym[] = {'.','d','S','Y','M',0};
|
||||||
static const WCHAR dsym_subpath[] = {'/','C','o','n','t','e','n','t','s','/','R','e','s','o','u','r','c','e','s','/','D','W','A','R','F','/',0};
|
|
||||||
static const WCHAR dot_dwarf[] = {'.','d','w','a','r','f',0};
|
static const WCHAR dot_dwarf[] = {'.','d','w','a','r','f',0};
|
||||||
struct macho_file_map* fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho;
|
struct macho_file_map* fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho;
|
||||||
const WCHAR* p;
|
const WCHAR* p;
|
||||||
size_t len;
|
size_t len;
|
||||||
WCHAR* path = NULL;
|
WCHAR* path = NULL;
|
||||||
char uuid_string[UUID_STRING_LEN];
|
|
||||||
CFStringRef uuid_cfstring;
|
|
||||||
CFStringRef query_string;
|
|
||||||
MDQueryRef query = NULL;
|
|
||||||
|
|
||||||
/* Without a UUID, we can't verify that any debug info file we find corresponds
|
/* Without a UUID, we can't verify that any debug info file we find corresponds
|
||||||
to this file. Better to have no debug info than incorrect debug info. */
|
to this file. Better to have no debug info than incorrect debug info. */
|
||||||
|
@ -1289,39 +1322,11 @@ static void find_and_map_dsym(struct process *pcs, struct module* module)
|
||||||
if (try_dsym(pcs, path, fmap))
|
if (try_dsym(pcs, path, fmap))
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
format_uuid(fmap->uuid->uuid, uuid_string);
|
HeapFree(GetProcessHeap(), 0, path);
|
||||||
uuid_cfstring = CFStringCreateWithCString(NULL, uuid_string, kCFStringEncodingASCII);
|
if ((path = query_dsym(fmap->uuid->uuid, p))) try_dsym(pcs, path, fmap);
|
||||||
query_string = CFStringCreateWithFormat(NULL, NULL, CFSTR("com_apple_xcode_dsym_uuids == \"%@\""), uuid_cfstring);
|
|
||||||
CFRelease(uuid_cfstring);
|
|
||||||
query = MDQueryCreate(NULL, query_string, NULL, NULL);
|
|
||||||
CFRelease(query_string);
|
|
||||||
MDQuerySetMaxCount(query, 1);
|
|
||||||
if (MDQueryExecute(query, kMDQuerySynchronous) && MDQueryGetResultCount(query) >= 1)
|
|
||||||
{
|
|
||||||
MDItemRef item = (MDItemRef)MDQueryGetResultAtIndex(query, 0);
|
|
||||||
CFStringRef item_path = MDItemCopyAttribute(item, kMDItemPath);
|
|
||||||
if (item_path)
|
|
||||||
{
|
|
||||||
CFIndex item_path_len = CFStringGetLength(item_path);
|
|
||||||
if (item_path_len + strlenW(dsym_subpath) + strlenW(p) >= len)
|
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, path);
|
|
||||||
len = item_path_len + strlenW(dsym_subpath) + strlenW(p) + 1;
|
|
||||||
path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
||||||
}
|
|
||||||
CFStringGetCharacters(item_path, CFRangeMake(0, item_path_len), (UniChar*)path);
|
|
||||||
strcpyW(path + item_path_len, dsym_subpath);
|
|
||||||
strcatW(path, p);
|
|
||||||
CFRelease(item_path);
|
|
||||||
|
|
||||||
if (try_dsym(pcs, path, fmap))
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
found:
|
found:
|
||||||
HeapFree(GetProcessHeap(), 0, path);
|
HeapFree(GetProcessHeap(), 0, path);
|
||||||
if (query) CFRelease(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
|
|
@ -4,4 +4,4 @@ files:
|
||||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||||
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
||||||
tags:
|
tags:
|
||||||
wine: 3047385437c7ef36996d0418ac378677f3e9d67c
|
wine: c3c2cda9d2792f8c9c612b5bd6e9fd4d08cbb073
|
||||||
|
|
Loading…
Reference in a new issue