Module: wine Branch: master Commit: d05b7c8e193d4a7e73a391bd4bc812d33dd1989a URL: https://gitlab.winehq.org/wine/wine/-/commit/d05b7c8e193d4a7e73a391bd4bc812d...
Author: Eric Pouech epouech@codeweavers.com Date: Sun Feb 25 10:36:55 2024 +0100
dbghelp: Search subdirectories in element path.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/dbghelp/path.c | 46 ++++++++++++++++++++++++++++------------------ dlls/dbghelp/tests/path.c | 4 ---- 2 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c index 0565442bb8b..db0873f133c 100644 --- a/dlls/dbghelp/path.c +++ b/dlls/dbghelp/path.c @@ -510,7 +510,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul SYMSRV_INDEX_INFOW *info, BOOL* is_unmatched) { struct module_find mf; - WCHAR *ptr; + WCHAR *ptr, *ext; const WCHAR* filename; WCHAR *searchPath = pcs->search_path; WCHAR buffer[MAX_PATH]; @@ -539,22 +539,9 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul
/* FIXME: Use Environment-Variables (see MS docs) _NT_SYMBOL_PATH and _NT_ALT_SYMBOL_PATH - FIXME: Implement "Standard Path Elements" (Path) ... (see MS docs) - do a search for (every?) path-element like this ... - <path> - <path>\dll - <path>\symbols\dll - (dll may be exe, or sys depending on the file extension) */ - - /* 2. check module-path */ - file_pathW(module->module.LoadedImageName, buffer); - if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; - if (module->real_path) - { - file_pathW(module->real_path, buffer); - if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; - } + */
+ ext = wcsrchr(module->module.LoadedImageName, L'.'); while (searchPath) { size_t len; @@ -562,17 +549,40 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul ptr = wcschr(searchPath, ';'); len = (ptr) ? ptr - searchPath : wcslen(searchPath);
- if (len < ARRAY_SIZE(buffer)) + if (len + 1 < ARRAY_SIZE(buffer)) { memcpy(buffer, searchPath, len * sizeof(WCHAR)); - buffer[len] = '\0'; + buffer[len] = L'\0'; /* return first fully matched file */ if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + len = wcslen(buffer); /* do_searchW removes the trailing \ in buffer when present */ + /* check once max size for \symbols<ext>\ */ + if (ext && len + 9 /* \symbols\ */ + wcslen(ext + 1) + 1 + 1 <= ARRAY_SIZE(buffer)) + { + buffer[len++] = L'\'; + wcscpy(buffer + len, ext + 1); + wcscat(buffer + len, L"\"); + if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + wcscpy(buffer + len, L"symbols\"); + wcscat(buffer + len, ext + 1); + wcscat(buffer + len, L"\"); + if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + } } else ERR("Too long search element %ls\n", searchPath); searchPath = ptr ? ptr + 1 : NULL; } + + /* check module-path */ + if (module->real_path) + { + file_pathW(module->real_path, buffer); + if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + } + file_pathW(module->module.LoadedImageName, buffer); + if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE; + /* if no fully matching file is found, return the best matching file if any */ if ((dbghelp_options & SYMOPT_LOAD_ANYTHING) && mf.matched) { diff --git a/dlls/dbghelp/tests/path.c b/dlls/dbghelp/tests/path.c index f45cfd29b58..45b71ed4718 100644 --- a/dlls/dbghelp/tests/path.c +++ b/dlls/dbghelp/tests/path.c @@ -1581,16 +1581,12 @@ static void test_load_modules_path(void) } else { - todo_wine_if(i == 4 || i == 5 || i == 7 || i == 8 || i == 11) ok(im.SymType == SymPdb, "Unexpected symtype %x\n", im.SymType); make_path(filename, topdir, NULL, test_files[test->found_file].module_path); - todo_wine_if(i == 2 || i == 4 || i == 5 || i == 7 || i == 8 || i == 11 || i == 21) ok(!wcscmp(im.LoadedPdbName, filename), "Expected %ls as loaded pdb file, got '%ls' instead\n", test_files[test->found_file].module_path, im.LoadedPdbName); - todo_wine_if(i == 11 || i == 21) ok(im.PdbAge == test_files[test->found_file].age_or_timestamp, "Expected %lx as pdb-age, got %lx instead\n", test_files[test->found_file].age_or_timestamp, im.PdbAge); - todo_wine_if(i == 11) ok(im.PdbUnmatched == !(test_files[test->found_file].age_or_timestamp == 0x0030cafe), "Expecting matched PDB\n"); } ok(IsEqualGUID(&im.PdbSig70, &guid1), "Unexpected PDB GUID\n");