dbghelp: Correctly setup the Unix regular expression for matching file names in SymEnumLines.
Plug a potential memory leak as well.
This commit is contained in:
parent
b5ffe31d22
commit
418a001e00
|
@ -154,6 +154,55 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void re_append(char** mask, unsigned* len, char ch)
|
||||||
|
{
|
||||||
|
*mask = HeapReAlloc(GetProcessHeap(), 0, *mask, ++(*len));
|
||||||
|
(*mask)[*len - 2] = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL compile_regex(regex_t* re, const char* srcfile)
|
||||||
|
{
|
||||||
|
char* mask;
|
||||||
|
unsigned len = 1;
|
||||||
|
|
||||||
|
mask = HeapAlloc(GetProcessHeap(), 0, 1);
|
||||||
|
re_append(&mask, &len, '^');
|
||||||
|
if (!srcfile || !*srcfile) re_append(&mask, &len, '*');
|
||||||
|
else while (*srcfile)
|
||||||
|
{
|
||||||
|
switch (*srcfile)
|
||||||
|
{
|
||||||
|
case '\\':
|
||||||
|
case '/':
|
||||||
|
re_append(&mask, &len, '[');
|
||||||
|
re_append(&mask, &len, '\\');
|
||||||
|
re_append(&mask, &len, '\\');
|
||||||
|
re_append(&mask, &len, '/');
|
||||||
|
re_append(&mask, &len, ']');
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
re_append(&mask, &len, '\\');
|
||||||
|
re_append(&mask, &len, '.');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
re_append(&mask, &len, *srcfile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
srcfile++;
|
||||||
|
}
|
||||||
|
re_append(&mask, &len, '$');
|
||||||
|
mask[len - 1] = '\0';
|
||||||
|
len = regcomp(re, mask, REG_NOSUB);
|
||||||
|
HeapFree(GetProcessHeap(), 0, mask);
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
FIXME("Couldn't compile %s\n", mask);
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* SymEnumLines (DBGHELP.@)
|
* SymEnumLines (DBGHELP.@)
|
||||||
*
|
*
|
||||||
|
@ -172,17 +221,13 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
|
||||||
|
|
||||||
if (!cb) return FALSE;
|
if (!cb) return FALSE;
|
||||||
if (!(dbghelp_options & SYMOPT_LOAD_LINES)) return TRUE;
|
if (!(dbghelp_options & SYMOPT_LOAD_LINES)) return TRUE;
|
||||||
if (regcomp(&re, srcfile, REG_NOSUB))
|
|
||||||
{
|
|
||||||
FIXME("Couldn't compile %s\n", srcfile);
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
pair.pcs = process_find_by_handle(hProcess);
|
pair.pcs = process_find_by_handle(hProcess);
|
||||||
if (!pair.pcs) return FALSE;
|
if (!pair.pcs) return FALSE;
|
||||||
if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland);
|
if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland);
|
||||||
pair.requested = module_find_by_addr(pair.pcs, base, DMT_UNKNOWN);
|
pair.requested = module_find_by_addr(pair.pcs, base, DMT_UNKNOWN);
|
||||||
if (!module_get_debug(&pair)) return FALSE;
|
if (!module_get_debug(&pair)) return FALSE;
|
||||||
|
if (!compile_regex(&re, srcfile)) return FALSE;
|
||||||
|
|
||||||
sci.SizeOfStruct = sizeof(sci);
|
sci.SizeOfStruct = sizeof(sci);
|
||||||
sci.ModBase = base;
|
sci.ModBase = base;
|
||||||
|
@ -215,6 +260,7 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
regfree(&re);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue