1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-01 07:14:31 +00:00

dbghelp: Support SLMFLAG_NO_SYMBOLS in SymLoadModuleEx*().

Also correctly handling ImageName (the passed image name
in SymLoadModule) and LoadedImageName, which is only set when
debug info have been loaded (and is always an absolute path,
contrary to ImageName which can be relative).

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-01-17 14:29:36 +01:00 committed by Alexandre Julliard
parent 51a0aaeff4
commit 61f9f5a05f
6 changed files with 31 additions and 17 deletions

View File

@ -442,6 +442,7 @@ struct module
struct module* next;
enum dhext_module_type type : 16;
unsigned short is_virtual : 1,
dont_load_symbols : 1,
is_wine_builtin : 1,
has_file_image : 1;
struct cpu* cpu;

View File

@ -376,8 +376,12 @@ BOOL module_load_debug(struct module* module)
if (module->module.SymType == SymDeferred)
{
BOOL ret;
if (module->is_virtual) ret = FALSE;
if (module->is_virtual)
{
module->module.SymType = SymVirtual;
ret = TRUE;
}
else if (module->type == DMT_PE)
{
idslW64.SizeOfStruct = sizeof(idslW64);
@ -942,7 +946,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
if (!(pcs = process_find_by_handle(hProcess))) return 0;
if (Flags & ~(SLMFLAG_VIRTUAL))
if (Flags & ~(SLMFLAG_VIRTUAL | SLMFLAG_NO_SYMBOLS))
FIXME("Unsupported Flags %08lx for %s\n", Flags, debugstr_w(wImageName));
/* Trying to load a new module at the same address of an existing one,
@ -970,7 +974,6 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
if (!wImageName) wImageName = L"";
module = module_new(pcs, wImageName, DMT_PE, FALSE, TRUE, BaseOfDll, SizeOfDll, 0, 0, IMAGE_FILE_MACHINE_UNKNOWN);
if (!module) return 0;
module->module.SymType = SymVirtual;
}
else
{
@ -996,6 +999,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
return 0;
}
}
if (Flags & SLMFLAG_NO_SYMBOLS) module->dont_load_symbols = 1;
/* Store alternate name for module when provided. */
if (wModuleName)
@ -1531,6 +1535,11 @@ BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr,
if (dbghelp_opt_real_path && module->real_path)
lstrcpynW(miw64.LoadedImageName, module->real_path, ARRAY_SIZE(miw64.LoadedImageName));
else if (miw64.SymType == SymDeferred)
{
miw64.LoadedImageName[0] = '\0';
miw64.TimeDateStamp = 0;
}
/* update debug information from container if any */
if (module->module.SymType == SymNone)

View File

@ -3889,16 +3889,18 @@ static BOOL pdb_process_file(const struct process *pcs,
const struct msc_debug_info *msc_dbg,
const char *filename, const GUID *guid, DWORD timestamp, DWORD age)
{
BOOL ret;
struct module_format* modfmt;
struct pdb_module_info* pdb_module_info;
SYMSRV_INDEX_INFOW info;
BOOL unmatched;
if (path_find_symbol_file(pcs, msc_dbg->module, filename, TRUE, guid, timestamp, age, &info, &unmatched) &&
if (!msc_dbg->module->dont_load_symbols &&
path_find_symbol_file(pcs, msc_dbg->module, filename, TRUE, guid, timestamp, age, &info, &unmatched) &&
(modfmt = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct module_format) + sizeof(struct pdb_module_info))))
sizeof(struct module_format) + sizeof(struct pdb_module_info))))
{
BOOL ret;
pdb_module_info = (void*)(modfmt + 1);
msc_dbg->module->format_info[DFI_PDB] = modfmt;
modfmt->module = msc_dbg->module;
@ -3926,6 +3928,7 @@ static BOOL pdb_process_file(const struct process *pcs,
msc_dbg->module->module.TypeInfo = TRUE;
msc_dbg->module->module.SourceIndexed = TRUE;
msc_dbg->module->module.Publics = TRUE;
return TRUE;
}
msc_dbg->module->format_info[DFI_PDB] = NULL;
@ -3936,7 +3939,7 @@ static BOOL pdb_process_file(const struct process *pcs,
msc_dbg->module->module.PdbSig70 = *guid;
else
memset(&msc_dbg->module->module.PdbSig70, 0, sizeof(GUID));
msc_dbg->module->module.PdbSig = timestamp;
msc_dbg->module->module.PdbSig = 0;
msc_dbg->module->module.PdbAge = age;
return FALSE;
}

View File

@ -498,6 +498,7 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
mf->info->guid = info.guid;
mf->info->timestamp = info.timestamp;
mf->info->age = info.age;
mf->info->sig = info.sig;
}
/* yes, EnumDirTree/do_search and SymFindFileInPath callbacks use the opposite
* convention to stop/continue enumeration. sigh.

View File

@ -721,9 +721,12 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module)
if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY))
{
ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module);
ret = pe_load_stabs(pcs, module) || ret;
ret = pe_load_dwarf(module) || ret;
if (!module->dont_load_symbols)
{
ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module);
ret = pe_load_stabs(pcs, module) || ret;
ret = pe_load_dwarf(module) || ret;
}
ret = pe_load_msc_debug_info(pcs, module) || ret;
ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
/* if we still have no debug info (we could only get SymExport at this

View File

@ -1803,10 +1803,9 @@ static void test_load_modules_details(void)
}
else
loaded_img_name = test->in_image_name;
todo_wine_if(i == 3 || i == 5 || i == 7 || i == 9 || i == 11 || i == 13 || i == 15 || i == 17)
ok(!wcsicmp(im.LoadedImageName, (test->options & SYMOPT_DEFERRED_LOADS) ? L"" : loaded_img_name),
"Unexpected loaded image name '%ls' (%ls)\n", im.LoadedImageName, loaded_img_name);
todo_wine_if(i == 3 || i == 4 || i == 6 || i == 8 || i == 16)
todo_wine_if(i == 4 || i == 6 || i == 16)
ok(im.SymType == test->sym_type, "Unexpected module type %u\n", im.SymType);
if (test->mismatch_in)
{
@ -1842,7 +1841,6 @@ static void test_load_modules_details(void)
{
ok(val < ARRAY_SIZE(test_files), "Incorrect index\n");
if (test->flags & SLMFLAG_NO_SYMBOLS)
todo_wine_if(i == 8)
ok(!im.LoadedPdbName[0], "Unexpected value\n");
else
{
@ -1853,7 +1851,6 @@ static void test_load_modules_details(void)
ok(!im.DbgUnmatched, "Unexpected value\n");
ok(IsEqualGUID(&im.PdbSig70, test_files[val].guid), "Unexpected value %s %s\n",
wine_dbgstr_guid(&im.PdbSig70), wine_dbgstr_guid(test_files[val].guid));
todo_wine_if(i == 10)
ok(im.PdbSig == 0, "Unexpected value\n");
ok(im.PdbAge == test_files[val].age_or_timestamp, "Unexpected value\n");
}
@ -1868,7 +1865,7 @@ static void test_load_modules_details(void)
ok(im.PdbSig == 0, "Unexpected value\n");
ok(!im.PdbAge, "Unexpected value\n");
/* native returns either 0 or the actual timestamp depending on test case */
todo_wine_if(i == 4 || i == 5 || i == 7 || i == 9 || i == 11 || i == 13 || (i >= 15 && i <= 17))
todo_wine_if(i == 4 || i == 16)
ok(!im.TimeDateStamp || broken(im.TimeDateStamp == 12324), "Unexpected value\n");
}
ok(im.ImageSize == 0x6666, "Unexpected image size\n");
@ -1887,7 +1884,7 @@ static void test_load_modules_details(void)
SymFromNameW(dummy, L"foo", sym);
}
ret = SymAddSymbol(dummy, base, "winetest_symbol_virtual", base + 4242, 13, 0);
todo_wine_if(i >= 12 && i <= 15) { /* temp */
todo_wine_if(i == 8 || i == 9 || (i >= 12 && i <= 15)) { /* temp */
ok(ret, "Failed to add symbol\n");
memset(sym, 0, sizeof(*sym));
sym->SizeOfStruct = sizeof(*sym);