Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/dbghelp/symbol.c | 75 +++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 21 deletions(-)
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index f59e322fef..177c66480d 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1485,6 +1485,47 @@ BOOL symt_fill_func_line_info(const struct module* module, const struct symt_fun return FALSE; }
+/****************************************************************** + * sym_fill_func_line_info64W + * + * fills information about a file + */ +static BOOL symt_fill_func_line_info64W(const struct module* module, const struct symt_function* func, + DWORD64 addr, IMAGEHLP_LINEW64* line) +{ + struct line_info* dli = NULL; + BOOL found = FALSE; + int i; + + assert(func->symt.tag == SymTagFunction); + + for (i=vector_length(&func->vlines)-1; i>=0; i--) + { + dli = vector_at(&func->vlines, i); + if (!dli->is_source_file) + { + if (found || dli->u.pc_offset > addr) continue; + line->LineNumber = dli->line_number; + line->Address = dli->u.pc_offset; + line->Key = dli; + found = TRUE; + continue; + } + if (found) + { + char *filename = (char*)source_get(module, dli->u.source_file); + int len = lstrlenA(filename)+1; + + line->FileName = fetch_buffer(module->process, len * sizeof(WCHAR)); + + MultiByteToWideChar(CP_ACP, 0, filename, -1, line->FileName, len); + + return TRUE; + } + } + return FALSE; +} + /*********************************************************************** * SymGetSymNext64 (DBGHELP.@) */ @@ -1544,22 +1585,6 @@ static void copy_line_64_from_32(IMAGEHLP_LINE64* l64, const IMAGEHLP_LINE* l32) l64->Address = l32->Address; }
-/****************************************************************** - * copy_line_W64_from_32 (internal) - * - */ -static void copy_line_W64_from_64(struct process* pcs, IMAGEHLP_LINEW64* l64w, const IMAGEHLP_LINE64* l64) -{ - unsigned len; - - l64w->Key = l64->Key; - l64w->LineNumber = l64->LineNumber; - len = MultiByteToWideChar(CP_ACP, 0, l64->FileName, -1, NULL, 0); - if ((l64w->FileName = fetch_buffer(pcs, len * sizeof(WCHAR)))) - MultiByteToWideChar(CP_ACP, 0, l64->FileName, -1, l64w->FileName, len); - l64w->Address = l64->Address; -} - /****************************************************************** * copy_line_32_from_64 (internal) * @@ -1623,12 +1648,20 @@ BOOL WINAPI SymGetLineFromAddr64(HANDLE hProcess, DWORD64 dwAddr, BOOL WINAPI SymGetLineFromAddrW64(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINEW64 Line) { - IMAGEHLP_LINE64 il64; + struct module_pair pair; + struct symt_ht* symt; + + pair.pcs = process_find_by_handle(hProcess); + if (!pair.pcs) return FALSE; + pair.requested = module_find_by_addr(pair.pcs, dwAddr, DMT_UNKNOWN); + if (!module_get_debug(&pair)) return FALSE; + if ((symt = symt_find_nearest(pair.effective, dwAddr)) == NULL) return FALSE; + + if (symt->symt.tag != SymTagFunction) return FALSE; + if (!symt_fill_func_line_info64W(pair.effective, (struct symt_function*)symt, + dwAddr, Line)) return FALSE; + *pdwDisplacement = dwAddr - Line->Address;
- il64.SizeOfStruct = sizeof(il64); - if (!SymGetLineFromAddr64(hProcess, dwAddr, pdwDisplacement, &il64)) - return FALSE; - copy_line_W64_from_64(process_find_by_handle(hProcess), Line, &il64); return TRUE; }
Alistair Leslie-Hughes leslie_alistair@hotmail.com writes:
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com
dlls/dbghelp/symbol.c | 75 +++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 21 deletions(-)
Why is that better?
On 5/6/19 2:16 am, Alexandre Julliard wrote:
Alistair Leslie-Hughes leslie_alistair@hotmail.com writes:
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com
dlls/dbghelp/symbol.c | 75 +++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 21 deletions(-)
Why is that better?
Its not. The title should be something "Dont call SymGetLineFromAddr64 from SymGetLineFromAddrW64"
or the like.
My end goal is to fix
https://bugs.winehq.org/show_bug.cgi?id=34687
My first attempt, Huw suggested to "For SymGetLineFromAddr64() calls SymGetLineFromAddrW64()"
https://www.winehq.org/pipermail/wine-devel/2017-February/116170.html
My next attempt Zebediah pointed out that I would have a double conversion when using SymGetLineFromAddr.
These three patches address both concerns.
During my investigation, I found that dbghelp is using a flag value for working out if winedbg is the one actually
calling it. However, this value is actually now a valid option (may not of been at the time it was written).
So my current plan is
1. Have all SymGetLineFromAddr* call SymGetLineFromAddrW64
2. Implement/Stub functions SymSetExtendedOption/SymGetExtendedOption (available windows 10)
3. Add an internal value into SymSetExtendedOption for winedbg to use (which doesn't conflict with current values).
4. Update dbghelp/winedbg to use the internal value.
5. Return windows path when winedbg isn't in use.
Hope this makes things clearer.
Regards
Alistair.
Alistair Leslie-Hughes leslie_alistair@hotmail.com writes:
So my current plan is
Have all SymGetLineFromAddr* call SymGetLineFromAddrW64
Implement/Stub functions SymSetExtendedOption/SymGetExtendedOption
(available windows 10)
- Add an internal value into SymSetExtendedOption for winedbg to use
(which doesn't conflict with current values).
Update dbghelp/winedbg to use the internal value.
Return windows path when winedbg isn't in use.
I'd suggest instead to always return Windows paths, and fix winedbg to handle that.