dbghelp: Use . instead of concrete path for search path.

Signed-off-by: Thomas Faber <thomas.faber@reactos.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Thomas Faber 2021-11-12 18:17:53 -05:00 committed by Alexandre Julliard
parent 6bedd7cce6
commit bb2802984d
2 changed files with 24 additions and 21 deletions

View File

@ -178,29 +178,36 @@ struct cpu* cpu_find(DWORD machine)
static WCHAR* make_default_search_path(void)
{
WCHAR* search_path;
unsigned size;
unsigned len;
WCHAR* p;
unsigned sym_path_len;
unsigned alt_sym_path_len;
search_path = HeapAlloc(GetProcessHeap(), 0, (len = MAX_PATH) * sizeof(WCHAR));
while ((size = GetCurrentDirectoryW(len, search_path)) >= len)
search_path = HeapReAlloc(GetProcessHeap(), 0, search_path, (len *= 2) * sizeof(WCHAR));
search_path = HeapReAlloc(GetProcessHeap(), 0, search_path, (size + 1) * sizeof(WCHAR));
sym_path_len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0);
alt_sym_path_len = GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", NULL, 0);
len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0);
if (len)
/* The default symbol path is ".[;%_NT_SYMBOL_PATH%][;%_NT_ALTERNATE_SYMBOL_PATH%]".
* If the variables exist, the lengths include a null-terminator. We use that
* space for the semicolons, and only add the initial dot and the final null. */
search_path = HeapAlloc(GetProcessHeap(), 0,
(1 + sym_path_len + alt_sym_path_len + 1) * sizeof(WCHAR));
if (!search_path) return NULL;
p = search_path;
*p++ = L'.';
if (sym_path_len)
{
search_path = HeapReAlloc(GetProcessHeap(), 0, search_path, (size + 1 + len + 1) * sizeof(WCHAR));
search_path[size] = ';';
GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", search_path + size + 1, len);
size += 1 + len;
*p++ = L';';
GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", p, sym_path_len);
p += sym_path_len - 1;
}
len = GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", NULL, 0);
if (len)
if (alt_sym_path_len)
{
search_path = HeapReAlloc(GetProcessHeap(), 0, search_path, (size + 1 + len + 1) * sizeof(WCHAR));
search_path[size] = ';';
GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", search_path + size + 1, len);
*p++ = L';';
GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", p, alt_sym_path_len);
p += alt_sym_path_len - 1;
}
*p = L'\0';
return search_path;
}

View File

@ -141,7 +141,6 @@ static void test_search_path(void)
* We unset both variables earlier so should simply get "." */
ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path));
ok(ret == TRUE, "ret = %d\n", ret);
todo_wine
ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path);
/* Set an arbitrary search path */
@ -156,7 +155,6 @@ static void test_search_path(void)
ok(ret == TRUE, "ret = %d\n", ret);
ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path));
ok(ret == TRUE, "ret = %d\n", ret);
todo_wine
ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path);
/* With _NT_SYMBOL_PATH */
@ -165,7 +163,6 @@ static void test_search_path(void)
ok(ret == TRUE, "ret = %d\n", ret);
ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path));
ok(ret == TRUE, "ret = %d\n", ret);
todo_wine
ok(!strcmp(search_path, ".;X:\\"), "Got search path '%s', expected '.;X:\\'\n", search_path);
/* With both _NT_SYMBOL_PATH and _NT_ALT_SYMBOL_PATH */
@ -192,7 +189,6 @@ static void test_search_path(void)
ok(ret == TRUE, "ret = %d\n", ret);
ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path));
ok(ret == TRUE, "ret = %d\n", ret);
todo_wine
ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path);
}