dbghelp: Implemented SymMatchString.

This commit is contained in:
Eric Pouech 2005-12-19 18:16:35 +01:00 committed by Alexandre Julliard
parent a80d93c5e9
commit 17d93f9855
3 changed files with 29 additions and 7 deletions

View File

@ -81,7 +81,7 @@
@ stdcall SymLoadModule(long long str str long long) @ stdcall SymLoadModule(long long str str long long)
@ stdcall SymLoadModuleEx(long long str str double long ptr long) @ stdcall SymLoadModuleEx(long long str str double long ptr long)
@ stdcall SymMatchFileName(str str ptr ptr) @ stdcall SymMatchFileName(str str ptr ptr)
@ stub SymMatchString @ stdcall SymMatchString(str str long)
@ stdcall SymRegisterCallback64(long ptr double) @ stdcall SymRegisterCallback64(long ptr double)
@ stdcall SymRegisterCallback(long ptr ptr) @ stdcall SymRegisterCallback(long ptr ptr)
@ stdcall SymRegisterFunctionEntryCallback64(ptr ptr double) @ stdcall SymRegisterFunctionEntryCallback64(ptr ptr double)

View File

@ -81,11 +81,12 @@ static inline void re_append(char** mask, unsigned* len, char ch)
* + 1 or more of preceding char * + 1 or more of preceding char
* escapes \ on #, ?, [, ], *, +. don't work on - * escapes \ on #, ?, [, ], *, +. don't work on -
*/ */
static void compile_regex(const char* str, int numchar, regex_t* re) static void compile_regex(const char* str, int numchar, regex_t* re, BOOL _case)
{ {
char* mask = HeapAlloc(GetProcessHeap(), 0, 1); char* mask = HeapAlloc(GetProcessHeap(), 0, 1);
unsigned len = 1; unsigned len = 1;
BOOL in_escape = FALSE; BOOL in_escape = FALSE;
unsigned flags = REG_NOSUB;
re_append(&mask, &len, '^'); re_append(&mask, &len, '^');
@ -118,7 +119,8 @@ static void compile_regex(const char* str, int numchar, regex_t* re)
} }
re_append(&mask, &len, '$'); re_append(&mask, &len, '$');
mask[len - 1] = '\0'; mask[len - 1] = '\0';
if (regcomp(re, mask, REG_NOSUB)) FIXME("Couldn't compile %s\n", mask); if (_case) flags |= REG_ICASE;
if (regcomp(re, mask, flags)) FIXME("Couldn't compile %s\n", mask);
HeapFree(GetProcessHeap(), 0, mask); HeapFree(GetProcessHeap(), 0, mask);
} }
@ -733,7 +735,7 @@ static BOOL symt_enum_locals(struct process* pcs, const char* mask,
BOOL ret; BOOL ret;
regex_t preg; regex_t preg;
compile_regex(mask ? mask : "*", -1, &preg); compile_regex(mask ? mask : "*", -1, &preg, FALSE);
ret = symt_enum_locals_helper(pcs, module, &preg, EnumSymbolsCallback, ret = symt_enum_locals_helper(pcs, module, &preg, EnumSymbolsCallback,
UserContext, sym_info, UserContext, sym_info,
&((struct symt_function*)sym)->vchildren); &((struct symt_function*)sym)->vchildren);
@ -780,8 +782,8 @@ BOOL WINAPI SymEnumSymbols(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR Mask,
if (bang == Mask) return FALSE; if (bang == Mask) return FALSE;
compile_regex(Mask, bang - Mask, &mod_regex); compile_regex(Mask, bang - Mask, &mod_regex, FALSE);
compile_regex(bang + 1, -1, &sym_regex); compile_regex(bang + 1, -1, &sym_regex, FALSE);
for (module = pcs->lmodules; module; module = module->next) for (module = pcs->lmodules; module; module = module->next)
{ {
@ -824,7 +826,7 @@ BOOL WINAPI SymEnumSymbols(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR Mask,
Mask = bang + 1; Mask = bang + 1;
} }
compile_regex(Mask ? Mask : "*", -1, &sym_regex); compile_regex(Mask ? Mask : "*", -1, &sym_regex, FALSE);
symt_enum_module(module, &sym_regex, EnumSymbolsCallback, UserContext); symt_enum_module(module, &sym_regex, EnumSymbolsCallback, UserContext);
regfree(&sym_regex); regfree(&sym_regex);
@ -1288,3 +1290,21 @@ DWORD WINAPI UnDecorateSymbolName(LPCSTR DecoratedName, LPSTR UnDecoratedName,
return 0; return 0;
return strlen(UnDecoratedName); return strlen(UnDecoratedName);
} }
/******************************************************************
* SymMatchString (DBGHELP.@)
*
*/
BOOL WINAPI SymMatchString(PCSTR string, PCSTR re, BOOL _case)
{
regex_t preg;
BOOL ret;
TRACE("%s %s %c\n", string, re, _case ? 'Y' : 'N');
compile_regex(re, -1, &preg, _case);
ret = regexec(&preg, string, 0, NULL, 0) == 0;
regfree(&preg);
return ret;
}

View File

@ -820,6 +820,8 @@ typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(HANDLE, ULONG, ULONG64, U
BOOL WINAPI SymRegisterCallback64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64, ULONG64); BOOL WINAPI SymRegisterCallback64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64, ULONG64);
BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL, PSTR, DWORD); BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL, PSTR, DWORD);
DWORD WINAPI UnDecorateSymbolName(LPCSTR, LPSTR, DWORD, DWORD); DWORD WINAPI UnDecorateSymbolName(LPCSTR, LPSTR, DWORD, DWORD);
BOOL WINAPI SymMatchString(PCSTR string, PCSTR re, BOOL _case);
BOOL WINAPI SymMatchStringW(PCWSTR string, PCWSTR re, BOOL _case);
/************************* /*************************
* Source Files * * Source Files *