dbghelp: .gnu_link support: rewrote helper functions for better later unicodification.
This commit is contained in:
parent
c75fb89a64
commit
6efc061992
@ -802,26 +802,49 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
|
|||||||
* is the global debug file directory, and execdir has been turned
|
* is the global debug file directory, and execdir has been turned
|
||||||
* into a relative path)." (from GDB manual)
|
* into a relative path)." (from GDB manual)
|
||||||
*/
|
*/
|
||||||
static char* elf_locate_debug_link (const char* filename, const char* moduleDir)
|
static char* elf_locate_debug_link(const char* filename, const char* loaded_file,
|
||||||
|
struct elf_file_map* fmap_link)
|
||||||
{
|
{
|
||||||
static const char globalDebugDir[] = "/usr/lib/debug";
|
static const char globalDebugDir[] = "/usr/lib/debug/";
|
||||||
const size_t moduleDirLen = strlen (moduleDir);
|
const size_t globalDebugDirLen = strlen(globalDebugDir);
|
||||||
const size_t globalDebugDirLen = strlen (globalDebugDir);
|
char* p;
|
||||||
struct stat statbuf;
|
char* slash;
|
||||||
|
|
||||||
char* p = HeapAlloc (GetProcessHeap(), 0,
|
p = HeapAlloc(GetProcessHeap(), 0,
|
||||||
moduleDirLen + 1 + max (6, globalDebugDirLen) + 1 + strlen (filename)+1);
|
globalDebugDirLen + strlen(loaded_file) + 1 + 6 + 1 + strlen(filename) + 1);
|
||||||
|
|
||||||
sprintf (p, "%s/%s", moduleDir, filename);
|
if (!p) return FALSE;
|
||||||
if (stat(p, &statbuf) != -1 && !S_ISDIR(statbuf.st_mode)) return p;
|
|
||||||
|
|
||||||
sprintf (p, "%s/.debug/%s", moduleDir, filename);
|
/* we prebuild the string with "execdir" */
|
||||||
if (stat(p, &statbuf) != -1 && !S_ISDIR(statbuf.st_mode)) return p;
|
strcpy(p, loaded_file);
|
||||||
|
slash = strrchr(p, '/');
|
||||||
|
if (slash == NULL) slash = p; else slash++;
|
||||||
|
|
||||||
sprintf (p, "%s/%s/%s", globalDebugDir, moduleDir, filename);
|
/* testing execdir/filename */
|
||||||
if (stat(p, &statbuf) != -1 && !S_ISDIR(statbuf.st_mode)) return p;
|
strcpy(slash, filename);
|
||||||
|
if (elf_map_file(p, fmap_link)) goto found;
|
||||||
|
|
||||||
strcpy (p, filename);
|
/* testing execdir/.debug/filename */
|
||||||
|
sprintf(slash, ".debug/%s", filename);
|
||||||
|
if (elf_map_file(p, fmap_link)) goto found;
|
||||||
|
|
||||||
|
/* testing globaldebugdir/execdir/filename */
|
||||||
|
memmove(p + globalDebugDirLen, p, slash - p);
|
||||||
|
memcpy(p, globalDebugDir, globalDebugDirLen);
|
||||||
|
slash += globalDebugDirLen;
|
||||||
|
strcpy(slash, filename);
|
||||||
|
if (elf_map_file(p, fmap_link)) goto found;
|
||||||
|
|
||||||
|
strcpy(p, filename);
|
||||||
|
if (elf_map_file(p, fmap_link)) goto found;
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, p);
|
||||||
|
|
||||||
|
WARN("Couldn't locate or map %s\n", filename);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
found:
|
||||||
|
TRACE("Located debug information file %s at %s\n", filename, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,19 +868,11 @@ static BOOL elf_debuglink_parse (struct module* module,
|
|||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
const char* dbg_link = (char*)debuglink;
|
const char* dbg_link = (char*)debuglink;
|
||||||
struct elf_file_map fmap_link;
|
struct elf_file_map fmap_link;
|
||||||
char* moduleDir;
|
|
||||||
char* link_file;
|
char* link_file;
|
||||||
char* slash;
|
|
||||||
|
|
||||||
moduleDir = HeapAlloc (GetProcessHeap(), 0, strlen (module->module.LoadedImageName) + 1);
|
link_file = elf_locate_debug_link(dbg_link, module->module.LoadedImageName, &fmap_link);
|
||||||
strcpy (moduleDir, module->module.LoadedImageName);
|
|
||||||
slash = strrchr (moduleDir, '/');
|
|
||||||
if (slash != 0) *slash = 0;
|
|
||||||
|
|
||||||
link_file = elf_locate_debug_link (dbg_link, moduleDir);
|
if (link_file)
|
||||||
TRACE("Located debug information file %s at %s\n", dbg_link, link_file);
|
|
||||||
|
|
||||||
if (elf_map_file(link_file, &fmap_link))
|
|
||||||
{
|
{
|
||||||
fmap_link.crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3));
|
fmap_link.crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3));
|
||||||
fmap_link.with_crc = 1;
|
fmap_link.with_crc = 1;
|
||||||
@ -868,12 +883,8 @@ static BOOL elf_debuglink_parse (struct module* module,
|
|||||||
else
|
else
|
||||||
WARN("Couldn't load debug information from %s\n", link_file);
|
WARN("Couldn't load debug information from %s\n", link_file);
|
||||||
elf_unmap_file(&fmap_link);
|
elf_unmap_file(&fmap_link);
|
||||||
|
HeapFree(GetProcessHeap(), 0, link_file);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
WARN("Couldn't map %s\n", dbg_link);
|
|
||||||
|
|
||||||
HeapFree (GetProcessHeap(), 0, link_file);
|
|
||||||
HeapFree (GetProcessHeap(), 0, moduleDir);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user