Commit 43dffcd0 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Now storing module information in Unicode form.

parent 6efc0619
......@@ -4,7 +4,7 @@
* Copyright (C) 1995, Alexandre Julliard
* Copyright (C) 1996, Eric Youngdale.
* Copyright (C) 1999-2000, Ulrich Weigand.
* Copyright (C) 2004, Eric Pouech.
* Copyright (C) 2004-2007, Eric Pouech.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -28,6 +28,8 @@
#include "dbghelp.h"
#include "objbase.h"
#include "oaidl.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "cvconst.h"
......@@ -310,7 +312,7 @@ struct process;
struct module
{
IMAGEHLP_MODULE64 module;
IMAGEHLP_MODULEW64 module;
/* ANSI copy of module.ModuleName for efficiency */
char module_name[MAX_PATH];
struct module* next;
......@@ -428,15 +430,26 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th
extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
/* module.c */
extern const WCHAR S_ElfW[];
extern const WCHAR S_WineLoaderW[];
extern struct module*
module_find_by_addr(const struct process* pcs, unsigned long addr,
enum module_type type);
extern struct module*
module_find_by_name(const struct process* pcs,
const WCHAR* name, enum module_type type);
extern struct module*
module_find_by_nameA(const struct process* pcs,
const char* name, enum module_type type);
extern BOOL module_get_debug(struct module_pair*);
extern struct module*
module_new(struct process* pcs, const char* name,
module_new(struct process* pcs, const WCHAR* name,
enum module_type type, BOOL virtual,
unsigned long addr, unsigned long size,
unsigned long stamp, unsigned long checksum);
extern struct module*
module_newA(struct process* pcs, const char* name,
enum module_type type, BOOL virtual,
unsigned long addr, unsigned long size,
unsigned long stamp, unsigned long checksum);
......@@ -451,7 +464,7 @@ extern enum module_type
extern void module_reset_debug_info(struct module* module);
extern BOOL module_remove(struct process* pcs,
struct module* module);
extern void module_set_module(struct module* module, const char* name);
extern void module_set_module(struct module* module, const WCHAR* name);
/* msc.c */
extern BOOL pe_load_debug_directory(const struct process* pcs,
......
......@@ -2,7 +2,7 @@
* File elf.c - processing of ELF files
*
* Copyright (C) 1996, Eric Youngdale.
* 1999-2004 Eric Pouech
* 1999-2007 Eric Pouech
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -802,21 +802,23 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
* is the global debug file directory, and execdir has been turned
* into a relative path)." (from GDB manual)
*/
static char* elf_locate_debug_link(const char* filename, const char* loaded_file,
static char* elf_locate_debug_link(const char* filename, const WCHAR* loaded_file,
struct elf_file_map* fmap_link)
{
static const char globalDebugDir[] = "/usr/lib/debug/";
const size_t globalDebugDirLen = strlen(globalDebugDir);
size_t loaded_file_len;
char* p;
char* slash;
loaded_file_len = WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, NULL, 0, NULL, NULL);
p = HeapAlloc(GetProcessHeap(), 0,
globalDebugDirLen + strlen(loaded_file) + 1 + 6 + 1 + strlen(filename) + 1);
globalDebugDirLen + loaded_file_len + 6 + 1 + strlen(filename) + 1);
if (!p) return FALSE;
/* we prebuild the string with "execdir" */
strcpy(p, loaded_file);
WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, p, loaded_file_len, NULL, NULL);
slash = strrchr(p, '/');
if (slash == NULL) slash = p; else slash++;
......@@ -879,7 +881,9 @@ static BOOL elf_debuglink_parse (struct module* module,
ret = elf_load_debug_info_from_map(module, &fmap_link, pool,
ht_symtab);
if (ret)
strcpy(module->module.LoadedPdbName, link_file);
MultiByteToWideChar(CP_ACP, 0, link_file, -1,
module->module.LoadedPdbName,
sizeof(module->module.LoadedPdbName));
else
WARN("Couldn't load debug information from %s\n", link_file);
elf_unmap_file(&fmap_link);
......@@ -928,7 +932,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
if (fmap->with_crc && (fmap->crc != calc_crc32(fmap)))
{
ERR("Bad CRC for module %s (got %08x while expecting %08lx)\n",
module->module.LoadedImageName, calc_crc32(fmap), fmap->crc);
debugstr_w(module->module.LoadedImageName), calc_crc32(fmap), fmap->crc);
/* we don't tolerate mis-matched files */
return FALSE;
}
......@@ -1062,14 +1066,14 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
lret = elf_debuglink_parse (module, pool, ht_symtab, dbg_link);
if (!lret)
WARN("Couldn't load linked debug file for %s\n",
module->module.ModuleName);
debugstr_w(module->module.ModuleName));
ret = ret || lret;
}
elf_unmap_section(fmap, debuglink_sect);
}
}
if (strstr(module->module.ModuleName, "<elf>") ||
!strcmp(module->module.ModuleName, "<wine-loader>"))
if (strstrW(module->module.ModuleName, S_ElfW) ||
!strcmpW(module->module.ModuleName, S_WineLoaderW))
{
/* add the thunks for native libraries */
if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY))
......@@ -1095,7 +1099,7 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
if (module->type != DMT_ELF || !module->elf_info)
{
ERR("Bad elf module '%s'\n", module->module.LoadedImageName);
ERR("Bad elf module '%s'\n", debugstr_w(module->module.LoadedImageName));
return FALSE;
}
......@@ -1104,8 +1108,12 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
if (!fmap)
{
char LoadedImageName[MAX_PATH];
fmap = &my_fmap;
ret = elf_map_file(module->module.LoadedImageName, fmap);
WideCharToMultiByte(CP_ACP, 0, module->module.LoadedImageName, -1,
LoadedImageName, MAX_PATH, NULL, NULL);
ret = elf_map_file(LoadedImageName, fmap);
}
if (ret)
ret = elf_load_debug_info_from_map(module, fmap, &pool, &ht_symtab);
......@@ -1204,7 +1212,7 @@ static BOOL elf_load_file(struct process* pcs, const char* filename,
struct elf_module_info *elf_module_info =
HeapAlloc(GetProcessHeap(), 0, sizeof(struct elf_module_info));
if (!elf_module_info) goto leave;
elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE,
elf_info->module = module_newA(pcs, filename, DMT_ELF, FALSE,
(load_offset) ? load_offset : fmap.elf_start,
fmap.elf_size, 0, calc_crc32(&fmap));
if (!elf_info->module)
......@@ -1313,7 +1321,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const char* filename,
struct module* module;
if (filename == NULL || *filename == '\0') return FALSE;
if ((module = module_find_by_name(pcs, filename, DMT_ELF)))
if ((module = module_find_by_nameA(pcs, filename, DMT_ELF)))
{
elf_info->module = module;
module->elf_info->elf_mark = 1;
......@@ -1469,7 +1477,7 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs)
elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE;
if (!elf_search_loader(pcs, &elf_info)) return FALSE;
elf_info.module->elf_info->elf_loader = 1;
strcpy(elf_info.module->module.ModuleName, "<wine-loader>");
module_set_module(elf_info.module, S_WineLoaderW);
return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0;
}
......
......@@ -2248,7 +2248,9 @@ static BOOL pdb_process_file(const struct process* pcs,
else
msc_dbg->module->module.PdbSig70 = pdb_lookup->u.ds.guid;
msc_dbg->module->module.PdbAge = pdb_lookup->age;
strcpy(msc_dbg->module->module.LoadedPdbName, pdb_lookup->filename);
MultiByteToWideChar(CP_ACP, 0, pdb_lookup->filename, -1,
msc_dbg->module->module.LoadedPdbName,
sizeof(msc_dbg->module->module.LoadedPdbName) / sizeof(WCHAR));
/* FIXME: we could have a finer grain here */
msc_dbg->module->module.LineNumbers = TRUE;
msc_dbg->module->module.GlobalSymbols = TRUE;
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 1996, Eric Youngdale.
* Copyright (C) 1999-2000, Ulrich Weigand.
* Copyright (C) 2004, Eric Pouech.
* Copyright (C) 2004-2007, Eric Pouech.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -289,10 +289,10 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module)
void* mapping;
IMAGE_NT_HEADERS* nth;
hFile = CreateFileA(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ,
hFile = CreateFileW(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return ret;
if ((hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0)
if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0)
{
if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
{
......@@ -354,8 +354,8 @@ struct module* pe_load_module(struct process* pcs, const char* name,
else if (name) strcpy(loaded_name, name);
else if (dbghelp_options & SYMOPT_DEFERRED_LOADS)
FIXME("Trouble ahead (no module name passed in deferred mode)\n");
if (!(module = module_find_by_name(pcs, loaded_name, DMT_PE)) &&
(hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
if (!(module = module_find_by_nameA(pcs, loaded_name, DMT_PE)) &&
(hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
{
if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
{
......@@ -366,7 +366,7 @@ struct module* pe_load_module(struct process* pcs, const char* name,
if (!base) base = nth->OptionalHeader.ImageBase;
if (!size) size = nth->OptionalHeader.SizeOfImage;
module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
module = module_newA(pcs, loaded_name, DMT_PE, FALSE, base, size,
nth->FileHeader.TimeDateStamp,
nth->OptionalHeader.CheckSum);
if (module)
......@@ -411,7 +411,7 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name,
struct module* module;
const char* ptr;
if ((module = module_find_by_name(pcs, name, DMT_PE))) return module;
if ((module = module_find_by_nameA(pcs, name, DMT_PE))) return module;
if (mod_name) ptr = mod_name;
else
{
......@@ -424,7 +424,7 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name,
}
}
}
if (ptr && (module = module_find_by_name(pcs, ptr, DMT_PE))) return module;
if (ptr && (module = module_find_by_nameA(pcs, ptr, DMT_PE))) return module;
if (base)
{
if (pcs->dbg_hdr_addr)
......@@ -434,11 +434,13 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name,
if (pe_load_nt_header(pcs->handle, base, &nth))
{
if (!size) size = nth.OptionalHeader.SizeOfImage;
module = module_new(pcs, name, DMT_PE, FALSE, base, size,
nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum);
module = module_newA(pcs, name, DMT_PE, FALSE, base, size,
nth.FileHeader.TimeDateStamp,
nth.OptionalHeader.CheckSum);
}
} else if (size)
module = module_new(pcs, name, DMT_PE, FALSE, base, size, 0 /* FIXME */, 0 /* FIXME */);
module = module_newA(pcs, name, DMT_PE, FALSE, base, size,
0 /* FIXME */, 0 /* FIXME */);
}
return module;
}
......@@ -133,7 +133,7 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
{
if (Mask[0] == '!')
{
pair.requested = module_find_by_name(pair.pcs, Mask + 1, DMT_UNKNOWN);
pair.requested = module_find_by_nameA(pair.pcs, Mask + 1, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE;
}
else
......
......@@ -1174,7 +1174,7 @@ BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol)
assert(name - Name < sizeof(tmp));
memcpy(tmp, Name, name - Name);
tmp[name - Name] = '\0';
module = module_find_by_name(pcs, tmp, DMT_UNKNOWN);
module = module_find_by_nameA(pcs, tmp, DMT_UNKNOWN);
return find_name(pcs, module, name + 1, Symbol);
}
for (module = pcs->lmodules; module; module = module->next)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment