dbghelp: Add helper to initialize a module_pair.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
eded75f8d2
commit
099a8bbfd3
|
@ -629,6 +629,8 @@ extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN;
|
||||||
extern const WCHAR S_SlashW[] DECLSPEC_HIDDEN;
|
extern const WCHAR S_SlashW[] DECLSPEC_HIDDEN;
|
||||||
extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN;
|
extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
extern BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess,
|
||||||
|
DWORD64 addr) DECLSPEC_HIDDEN;
|
||||||
extern struct module*
|
extern struct module*
|
||||||
module_find_by_addr(const struct process* pcs, DWORD64 addr,
|
module_find_by_addr(const struct process* pcs, DWORD64 addr,
|
||||||
enum module_type type) DECLSPEC_HIDDEN;
|
enum module_type type) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -3652,10 +3652,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip,
|
||||||
struct module_pair pair;
|
struct module_pair pair;
|
||||||
struct frame_info info;
|
struct frame_info info;
|
||||||
|
|
||||||
if (!(pair.pcs = process_find_by_handle(csw->hProcess)) ||
|
if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE;
|
||||||
!(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) ||
|
|
||||||
!module_get_debug(&pair))
|
|
||||||
return FALSE;
|
|
||||||
if (!dwarf2_fetch_frame_info(pair.effective, csw->cpu, ip, &info)) return FALSE;
|
if (!dwarf2_fetch_frame_info(pair.effective, csw->cpu, ip, &info)) return FALSE;
|
||||||
|
|
||||||
/* if at very beginning of function, return and use default unwinder */
|
/* if at very beginning of function, return and use default unwinder */
|
||||||
|
|
|
@ -262,6 +262,13 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess, DWORD64 addr)
|
||||||
|
{
|
||||||
|
if (!(pair->pcs = process_find_by_handle(hProcess))) return FALSE;
|
||||||
|
pair->requested = module_find_by_addr(pair->pcs, addr, DMT_UNKNOWN);
|
||||||
|
return module_get_debug(pair);
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* module_find_by_nameW
|
* module_find_by_nameW
|
||||||
*
|
*
|
||||||
|
|
|
@ -3199,10 +3199,7 @@ BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip,
|
||||||
char* strbase;
|
char* strbase;
|
||||||
BOOL ret = TRUE;
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
if (!(pair.pcs = process_find_by_handle(csw->hProcess)) ||
|
if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE;
|
||||||
!(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) ||
|
|
||||||
!module_get_debug(&pair))
|
|
||||||
return FALSE;
|
|
||||||
if (!pair.effective->format_info[DFI_PDB]) return FALSE;
|
if (!pair.effective->format_info[DFI_PDB]) return FALSE;
|
||||||
pdb_info = pair.effective->format_info[DFI_PDB]->u.pdb_info;
|
pdb_info = pair.effective->format_info[DFI_PDB]->u.pdb_info;
|
||||||
TRACE("searching %lx => %lx\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage);
|
TRACE("searching %lx => %lx\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage);
|
||||||
|
|
|
@ -1363,10 +1363,7 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address,
|
||||||
struct module_pair pair;
|
struct module_pair pair;
|
||||||
struct symt_ht* sym;
|
struct symt_ht* sym;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, Address)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
|
if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
|
||||||
|
|
||||||
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol);
|
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol);
|
||||||
|
@ -1717,10 +1714,7 @@ static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr,
|
||||||
struct symt_ht* symt;
|
struct symt_ht* symt;
|
||||||
struct symt_function* func;
|
struct symt_function* func;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
if ((symt = symt_find_nearest(pair.effective, addr)) == NULL) return FALSE;
|
if ((symt = symt_find_nearest(pair.effective, addr)) == NULL) return FALSE;
|
||||||
|
|
||||||
if (symt->symt.tag != SymTagFunction) return FALSE;
|
if (symt->symt.tag != SymTagFunction) return FALSE;
|
||||||
|
@ -1862,10 +1856,7 @@ static BOOL symt_get_func_line_prev(HANDLE hProcess, struct internal_line_t* int
|
||||||
struct line_info* li;
|
struct line_info* li;
|
||||||
struct line_info* srcli;
|
struct line_info* srcli;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
|
|
||||||
if (key == NULL) return FALSE;
|
if (key == NULL) return FALSE;
|
||||||
|
|
||||||
|
@ -1944,10 +1935,7 @@ static BOOL symt_get_func_line_next(HANDLE hProcess, struct internal_line_t* int
|
||||||
struct line_info* srcli;
|
struct line_info* srcli;
|
||||||
|
|
||||||
if (key == NULL) return FALSE;
|
if (key == NULL) return FALSE;
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
|
|
||||||
/* search current source file */
|
/* search current source file */
|
||||||
for (srcli = key; !srcli->is_source_file; srcli--);
|
for (srcli = key; !srcli->is_source_file; srcli--);
|
||||||
|
@ -2344,10 +2332,7 @@ BOOL WINAPI SymAddSymbol(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR name,
|
||||||
|
|
||||||
TRACE("(%p %s %s %u)\n", hProcess, wine_dbgstr_a(name), wine_dbgstr_longlong(addr), size);
|
TRACE("(%p %s %s %u)\n", hProcess, wine_dbgstr_a(name), wine_dbgstr_longlong(addr), size);
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
|
|
||||||
return symt_new_custom(pair.effective, name, addr, size) != NULL;
|
return symt_new_custom(pair.effective, name, addr, size) != NULL;
|
||||||
}
|
}
|
||||||
|
@ -2400,11 +2385,8 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
|
||||||
if (!cb) return FALSE;
|
if (!cb) return FALSE;
|
||||||
if (!(dbghelp_options & SYMOPT_LOAD_LINES)) return TRUE;
|
if (!(dbghelp_options & SYMOPT_LOAD_LINES)) return TRUE;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, base)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland);
|
if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland);
|
||||||
pair.requested = module_find_by_addr(pair.pcs, base, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
if (!(srcmask = file_regex(srcfile))) return FALSE;
|
if (!(srcmask = file_regex(srcfile))) return FALSE;
|
||||||
|
|
||||||
sci.SizeOfStruct = sizeof(sci);
|
sci.SizeOfStruct = sizeof(sci);
|
||||||
|
|
|
@ -483,9 +483,7 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
|
||||||
hProcess, wine_dbgstr_longlong(BaseOfDll), EnumSymbolsCallback,
|
hProcess, wine_dbgstr_longlong(BaseOfDll), EnumSymbolsCallback,
|
||||||
UserContext);
|
UserContext);
|
||||||
|
|
||||||
if (!(pair.pcs = process_find_by_handle(hProcess))) return FALSE;
|
if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE;
|
||||||
pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
|
|
||||||
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
|
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
||||||
|
@ -1007,16 +1005,7 @@ BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase,
|
||||||
{
|
{
|
||||||
struct module_pair pair;
|
struct module_pair pair;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, ModBase)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, ModBase, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair))
|
|
||||||
{
|
|
||||||
FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return symt_get_info(pair.effective, symt_index2ptr(pair.effective, TypeId), GetType, pInfo);
|
return symt_get_info(pair.effective, symt_index2ptr(pair.effective, TypeId), GetType, pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,10 +1020,7 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll,
|
||||||
struct symt* type;
|
struct symt* type;
|
||||||
DWORD64 size;
|
DWORD64 size;
|
||||||
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE;
|
||||||
if (!pair.pcs) return FALSE;
|
|
||||||
pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN);
|
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
|
||||||
type = symt_find_type_by_name(pair.effective, SymTagNull, Name);
|
type = symt_find_type_by_name(pair.effective, SymTagNull, Name);
|
||||||
if (!type) return FALSE;
|
if (!type) return FALSE;
|
||||||
Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type);
|
Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type);
|
||||||
|
|
Loading…
Reference in New Issue