[PATCH 01/11] dbghelp: use wide string literals
Eric Pouech
eric.pouech at gmail.com
Tue Oct 19 08:50:54 CDT 2021
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
dlls/dbghelp/dbghelp.c | 10 ++++------
dlls/dbghelp/dbghelp_private.h | 1 -
dlls/dbghelp/elf_module.c | 8 ++------
dlls/dbghelp/macho_module.c | 15 +++++----------
dlls/dbghelp/minidump.c | 3 +--
dlls/dbghelp/module.c | 34 +++++++++++-----------------------
dlls/dbghelp/path.c | 19 ++++++-------------
dlls/dbghelp/symbol.c | 8 +++-----
8 files changed, 32 insertions(+), 66 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c
index 9d99f0d646a..65a57ac90dc 100644
--- a/dlls/dbghelp/dbghelp.c
+++ b/dlls/dbghelp/dbghelp.c
@@ -430,28 +430,26 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
{
unsigned size;
unsigned len;
- static const WCHAR sym_path[] = {'_','N','T','_','S','Y','M','B','O','L','_','P','A','T','H',0};
- static const WCHAR alt_sym_path[] = {'_','N','T','_','A','L','T','E','R','N','A','T','E','_','S','Y','M','B','O','L','_','P','A','T','H',0};
pcs->search_path = HeapAlloc(GetProcessHeap(), 0, (len = MAX_PATH) * sizeof(WCHAR));
while ((size = GetCurrentDirectoryW(len, pcs->search_path)) >= len)
pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (len *= 2) * sizeof(WCHAR));
pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1) * sizeof(WCHAR));
- len = GetEnvironmentVariableW(sym_path, NULL, 0);
+ len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0);
if (len)
{
pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR));
pcs->search_path[size] = ';';
- GetEnvironmentVariableW(sym_path, pcs->search_path + size + 1, len);
+ GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", pcs->search_path + size + 1, len);
size += 1 + len;
}
- len = GetEnvironmentVariableW(alt_sym_path, NULL, 0);
+ len = GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", NULL, 0);
if (len)
{
pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR));
pcs->search_path[size] = ';';
- GetEnvironmentVariableW(alt_sym_path, pcs->search_path + size + 1, len);
+ GetEnvironmentVariableW(L"_NT_ALTERNATE_SYMBOL_PATH", pcs->search_path + size + 1, len);
}
}
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index fda6714c332..2ebe6699a1d 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -626,7 +626,6 @@ void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size
/* module.c */
extern const WCHAR S_ElfW[] DECLSPEC_HIDDEN;
extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN;
-extern const WCHAR S_SlashW[] DECLSPEC_HIDDEN;
extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN;
extern BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess,
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 553b212c526..dbae4db40d2 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -1429,7 +1429,6 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename,
{
BOOL ret = FALSE;
struct module* module;
- static const WCHAR S_libstdcPPW[] = {'l','i','b','s','t','d','c','+','+','\0'};
if (filename == NULL || *filename == '\0') return FALSE;
if ((module = module_is_already_loaded(pcs, filename)))
@@ -1439,7 +1438,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename,
return module->module.SymType;
}
- if (wcsstr(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */
+ if (wcsstr(filename, L"libstdc++")) return FALSE; /* We know we can't do it */
ret = elf_load_file(pcs, filename, load_offset, dyn_addr, elf_info);
/* if relative pathname, try some absolute base dirs */
if (!ret && filename == file_name(filename))
@@ -1563,10 +1562,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
ULONG_PTR ehdr_addr;
if (elf_search_auxv(pcs, ELF_AT_SYSINFO_EHDR, &ehdr_addr))
- {
- static const WCHAR vdsoW[] = {'[','v','d','s','o',']','.','s','o',0};
- cb(vdsoW, ehdr_addr, 0, TRUE, user);
- }
+ cb(L"[vdso].so", ehdr_addr, 0, TRUE, user);
}
return TRUE;
}
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 34bc4f2c4ea..c4a19b63de0 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -1232,9 +1232,7 @@ static BOOL try_dsym(struct process *pcs, const WCHAR* path, struct macho_file_m
return FALSE;
}
-static const WCHAR dsym_subpath[] = {'\\','C','o','n','t','e','n','t','s',
- '\\','R','e','s','o','u','r','c','e','s',
- '\\','D','W','A','R','F','\\',0};
+static const WCHAR dsym_subpath[] = L"'\\Contents\\Resources\\DWARF\\";
static WCHAR *query_dsym(const GUID *uuid, const WCHAR *filename)
{
@@ -1287,8 +1285,6 @@ static WCHAR *query_dsym(const GUID *uuid, const WCHAR *filename)
*/
static void find_and_map_dsym(struct process *pcs, struct module* module)
{
- static const WCHAR dot_dsym[] = {'.','d','S','Y','M',0};
- static const WCHAR dot_dwarf[] = {'.','d','w','a','r','f',0};
struct macho_file_map* fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho;
const WCHAR* p;
size_t len;
@@ -1300,19 +1296,19 @@ static void find_and_map_dsym(struct process *pcs, struct module* module)
return;
p = file_name(module->module.LoadedImageName);
- len = lstrlenW(module->module.LoadedImageName) + lstrlenW(dot_dsym) + lstrlenW(dsym_subpath) + lstrlenW(p) + 1;
+ len = lstrlenW(module->module.LoadedImageName) + lstrlenW(L".dSYM") + lstrlenW(dsym_subpath) + lstrlenW(p) + 1;
path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!path)
return;
lstrcpyW(path, module->module.LoadedImageName);
- lstrcatW(path, dot_dsym);
+ lstrcatW(path, L".dSYM");
lstrcatW(path, dsym_subpath);
lstrcatW(path, p);
if (try_dsym(pcs, path, fmap))
goto found;
- lstrcpyW(path + lstrlenW(module->module.LoadedImageName), dot_dwarf);
+ lstrcpyW(path + lstrlenW(module->module.LoadedImageName), L".dwarf");
if (try_dsym(pcs, path, fmap))
goto found;
@@ -1552,7 +1548,6 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam
{
BOOL ret = FALSE;
struct module* module;
- static const WCHAR S_libstdcPPW[] = {'l','i','b','s','t','d','c','+','+','\0'};
const WCHAR* p;
struct macho_load_params load_params;
@@ -1567,7 +1562,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam
return module->module.SymType;
}
- if (wcsstr(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */
+ if (wcsstr(filename, L"libstdc++")) return FALSE; /* We know we can't do it */
load_params.process = pcs;
load_params.load_addr = load_addr;
diff --git a/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c
index cae966b8e80..c2461413570 100644
--- a/dlls/dbghelp/minidump.c
+++ b/dlls/dbghelp/minidump.c
@@ -326,7 +326,6 @@ static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
{
DWORD handle;
DWORD sz;
- static const WCHAR backslashW[] = {'\\', '\0'};
memset(ffi, 0, sizeof(*ffi));
if ((sz = GetFileVersionInfoSizeW(filename, &handle)))
@@ -337,7 +336,7 @@ static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
VS_FIXEDFILEINFO* ptr;
UINT len;
- if (VerQueryValueW(info, backslashW, (void*)&ptr, &len))
+ if (VerQueryValueW(info, L"\\", (void*)&ptr, &len))
memcpy(ffi, ptr, min(len, sizeof(*ffi)));
}
HeapFree(GetProcessHeap(), 0, info);
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 488ed1a3bd6..b645e6dbf0f 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -35,18 +35,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
#define NOTE_GNU_BUILD_ID 3
-const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'};
-const WCHAR S_WineLoaderW[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'};
-static const WCHAR S_DotSoW[] = {'.','s','o','\0'};
-const WCHAR S_SlashW[] = {'/','\0'};
-
-static const WCHAR S_AcmW[] = {'.','a','c','m','\0'};
-static const WCHAR S_DllW[] = {'.','d','l','l','\0'};
-static const WCHAR S_DrvW[] = {'.','d','r','v','\0'};
-static const WCHAR S_ExeW[] = {'.','e','x','e','\0'};
-static const WCHAR S_OcxW[] = {'.','o','c','x','\0'};
-static const WCHAR S_VxdW[] = {'.','v','x','d','\0'};
-static const WCHAR * const ext[] = {S_AcmW, S_DllW, S_DrvW, S_ExeW, S_OcxW, S_VxdW, NULL};
+const WCHAR S_ElfW[] = L"<elf>";
+const WCHAR S_WineLoaderW[] = L"<wine-loader>";
+static const WCHAR * const ext[] = {L".acm", L".dll", L".drv", L".exe", L".ocx", L".vxd", NULL};
static int match_ext(const WCHAR* ptr, size_t len)
{
@@ -77,8 +68,6 @@ static const WCHAR* get_filename(const WCHAR* name, const WCHAR* endptr)
static BOOL is_wine_loader(const WCHAR *module)
{
- static const WCHAR wineW[] = {'w','i','n','e',0};
- static const WCHAR suffixW[] = {'6','4',0};
const WCHAR *filename = get_filename(module, NULL);
const char *ptr;
BOOL ret = FALSE;
@@ -94,14 +83,14 @@ static BOOL is_wine_loader(const WCHAR *module)
}
else
{
- buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
- lstrcpyW( buffer, wineW );
+ buffer = heap_alloc( sizeof(L"wine") + 2 * sizeof(WCHAR) );
+ lstrcpyW( buffer, L"wine" );
}
if (!wcscmp( filename, buffer ))
ret = TRUE;
- lstrcatW( buffer, suffixW );
+ lstrcatW( buffer, L"64" );
if (!wcscmp( filename, buffer ))
ret = TRUE;
@@ -124,9 +113,9 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size)
lstrcpynW(out, S_WineLoaderW, size);
else
{
- if (len > 3 && !wcsicmp(&out[len - 3], S_DotSoW) &&
+ if (len > 3 && !wcsicmp(&out[len - 3], L".so") &&
(l = match_ext(out, len - 3)))
- lstrcpyW(&out[len - l - 3], S_ElfW);
+ lstrcpyW(&out[len - l - 3], L"<elf>");
}
while ((*out = towlower(*out))) out++;
}
@@ -464,7 +453,7 @@ static BOOL module_is_container_loaded(const struct process* pcs,
{
modname = get_filename(module->module.LoadedImageName, NULL);
if (!wcsnicmp(modname, filename, len) &&
- !memcmp(modname + len, S_DotSoW, 3 * sizeof(WCHAR)))
+ !memcmp(modname + len, L".so", 3 * sizeof(WCHAR)))
{
return TRUE;
}
@@ -746,7 +735,6 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
{
static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
static const WCHAR buildidW[] = {'.','b','u','i','l','d','-','i','d','/'};
- static const WCHAR dotDebug0W[] = {'.','d','e','b','u','g',0};
struct image_file_map* fmap_link = NULL;
WCHAR* p;
WCHAR* z;
@@ -757,7 +745,7 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
p = HeapAlloc(GetProcessHeap(), 0,
sizeof(globalDebugDirW) + sizeof(buildidW) +
- (idlen * 2 + 1) * sizeof(WCHAR) + sizeof(dotDebug0W));
+ (idlen * 2 + 1) * sizeof(WCHAR) + sizeof(L".debug"));
z = p;
memcpy(z, globalDebugDirW, sizeof(globalDebugDirW));
z += ARRAY_SIZE(globalDebugDirW);
@@ -778,7 +766,7 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
*z++ = "0123456789abcdef"[*id & 0x0F];
id++;
}
- memcpy(z, dotDebug0W, sizeof(dotDebug0W));
+ memcpy(z, L".debug", sizeof(L".debug"));
TRACE("checking %s\n", wine_dbgstr_w(p));
if (image_check_debug_link_gnu_id(p, fmap_link, idend - idlen, idlen))
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c
index ba757a55b0c..f99129eac49 100644
--- a/dlls/dbghelp/path.c
+++ b/dlls/dbghelp/path.c
@@ -242,14 +242,11 @@ static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse,
WIN32_FIND_DATAW fd;
unsigned pos;
BOOL found = FALSE;
- static const WCHAR S_AllW[] = {'*','.','*','\0'};
- static const WCHAR S_DotW[] = {'.','\0'};
- static const WCHAR S_DotDotW[] = {'.','.','\0'};
pos = lstrlenW(buffer);
if (pos == 0) return FALSE;
if (buffer[pos - 1] != '\\') buffer[pos++] = '\\';
- lstrcpyW(buffer + pos, S_AllW);
+ lstrcpyW(buffer + pos, L"*.*");
if ((h = FindFirstFileW(buffer, &fd)) == INVALID_HANDLE_VALUE)
return FALSE;
/* doc doesn't specify how the tree is enumerated...
@@ -257,7 +254,7 @@ static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse,
*/
do
{
- if (!wcscmp(fd.cFileName, S_DotW) || !wcscmp(fd.cFileName, S_DotDotW)) continue;
+ if (!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L"..")) continue;
lstrcpyW(buffer + pos, fd.cFileName);
if (recurse && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
@@ -723,10 +720,6 @@ BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL (*ma
{
const WCHAR dllsW[] = { '\\','d','l','l','s','\\' };
const WCHAR programsW[] = { '\\','p','r','o','g','r','a','m','s','\\' };
- const WCHAR dot_dllW[] = {'.','d','l','l',0};
- const WCHAR dot_exeW[] = {'.','e','x','e',0};
- const WCHAR dot_soW[] = {'.','s','o',0};
-
len = lstrlenW(env);
if (!(buf = heap_alloc((len + 8 + 3 * lstrlenW(name)) * sizeof(WCHAR)))) return FALSE;
@@ -735,8 +728,8 @@ BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL (*ma
memcpy(end, dllsW, sizeof(dllsW));
lstrcpyW(end + ARRAY_SIZE(dllsW), name);
- if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0;
- if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_dllW)) *p = 0;
+ if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, L".so")) *p = 0;
+ if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, L".dll")) *p = 0;
p = end + lstrlenW(end);
*p++ = '\\';
lstrcpyW(p, name);
@@ -751,8 +744,8 @@ BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL (*ma
memcpy(end, programsW, sizeof(programsW));
end += ARRAY_SIZE(programsW);
lstrcpyW(end, name);
- if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0;
- if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_exeW)) *p = 0;
+ if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, L".so")) *p = 0;
+ if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, L".exe")) *p = 0;
p = end + lstrlenW(end);
*p++ = '\\';
lstrcpyW(p, name);
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index 1113bbc39cf..76c92414b89 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -37,8 +37,6 @@ WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
extern char * CDECL __unDName(char *buffer, const char *mangled, int len,
void * (CDECL *pfn_alloc)(size_t), void (CDECL *pfn_free)(void *), unsigned short flags);
-static const WCHAR starW[] = {'*','\0'};
-
static inline int cmp_addr(ULONG64 a1, ULONG64 a2)
{
if (a1 > a2) return 1;
@@ -1089,7 +1087,7 @@ static BOOL symt_enum_locals(struct process* pcs, const WCHAR* mask,
if (sym->symt.tag == SymTagFunction)
{
- return symt_enum_locals_helper(&pair, mask ? mask : starW, se, (struct symt_function*)sym,
+ return symt_enum_locals_helper(&pair, mask ? mask : L"*", se, (struct symt_function*)sym,
&((struct symt_function*)sym)->vchildren);
}
return FALSE;
@@ -1210,7 +1208,7 @@ static BOOL sym_enum(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR Mask,
Mask = bang + 1;
}
- symt_enum_module(&pair, Mask ? Mask : starW, se);
+ symt_enum_module(&pair, Mask ? Mask : L"*", se);
return TRUE;
}
@@ -2154,7 +2152,7 @@ static BOOL re_match_multi(const WCHAR** pstring, const WCHAR** pre, BOOL _case)
case WILDCHAR(']'): case WILDCHAR('+'): case WILDCHAR('#'): return FALSE;
case WILDCHAR('*'):
/* transform '*' into '?#' */
- {static const WCHAR qmW[] = {'?',0}; re_beg = qmW;}
+ re_beg = L"?";
goto closure;
case WILDCHAR('['):
do
More information about the wine-devel
mailing list