ChangeSet ID: 21066 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/03 03:51:26
Modified files: include : dbghelp.h dlls/dbghelp : symbol.c source.c dbghelp_private.h dbghelp.spec
Log message: Eric Pouech eric.pouech@wanadoo.fr Implemented SymEnumLines.
Patch: http://cvs.winehq.org/patch.py?id=21066
Old revision New revision Changes Path 1.14 1.15 +13 -0 wine/include/dbghelp.h 1.17 1.18 +0 -13 wine/dlls/dbghelp/symbol.c 1.3 1.4 +66 -0 wine/dlls/dbghelp/source.c 1.16 1.17 +13 -0 wine/dlls/dbghelp/dbghelp_private.h 1.10 1.11 +1 -0 wine/dlls/dbghelp/dbghelp.spec
Index: wine/include/dbghelp.h diff -u -p wine/include/dbghelp.h:1.14 wine/include/dbghelp.h:1.15 --- wine/include/dbghelp.h:1.14 3 Nov 2005 9:51:26 -0000 +++ wine/include/dbghelp.h 3 Nov 2005 9:51:26 -0000 @@ -749,6 +749,19 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE, U BOOL WINAPI SymGetLineFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE); BOOL WINAPI SymGetLinePrev(HANDLE, PIMAGEHLP_LINE); BOOL WINAPI SymGetLineNext(HANDLE, PIMAGEHLP_LINE); +typedef struct _SRCCODEINFO +{ + DWORD SizeOfStruct; + PVOID Key; + DWORD64 ModBase; + char Obj[MAX_PATH+1]; + char FileName[MAX_PATH+1]; + DWORD LineNumber; + DWORD64 Address; +} SRCCODEINFO, *PSRCCODEINFO; + +typedef BOOL (CALLBACK* PSYM_ENUMLINES_CALLBACK)(PSRCCODEINFO, PVOID); +BOOL WINAPI SymEnumLines(HANDLE, ULONG64, PCSTR, PCSTR, PSYM_ENUMLINES_CALLBACK, PVOID);
/************************* * File & image handling * Index: wine/dlls/dbghelp/symbol.c diff -u -p wine/dlls/dbghelp/symbol.c:1.17 wine/dlls/dbghelp/symbol.c:1.18 --- wine/dlls/dbghelp/symbol.c:1.17 3 Nov 2005 9:51:26 -0000 +++ wine/dlls/dbghelp/symbol.c 3 Nov 2005 9:51:26 -0000 @@ -40,19 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
-struct line_info -{ - unsigned long is_first : 1, - is_last : 1, - is_source_file : 1, - line_number; - union - { - unsigned long pc_offset; /* if is_source_file isn't set */ - unsigned source_file; /* if is_source_file is set */ - } u; -}; - inline static int cmp_addr(ULONG64 a1, ULONG64 a2) { if (a1 > a2) return 1; Index: wine/dlls/dbghelp/source.c diff -u -p wine/dlls/dbghelp/source.c:1.3 wine/dlls/dbghelp/source.c:1.4 --- wine/dlls/dbghelp/source.c:1.3 3 Nov 2005 9:51:26 -0000 +++ wine/dlls/dbghelp/source.c 3 Nov 2005 9:51:26 -0000 @@ -26,6 +26,9 @@
#include "dbghelp_private.h" #include "wine/debug.h" +#ifdef HAVE_REGEX_H +# include <regex.h> +#endif
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
@@ -136,3 +139,66 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hP
return TRUE; } + +/****************************************************************** + * SymEnumLines (DBGHELP.@) + * + */ +BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland, + PCSTR srcfile, PSYM_ENUMLINES_CALLBACK cb, PVOID user) +{ + struct process* pcs; + struct module* module; + struct hash_table_iter hti; + struct symt_ht* sym; + regex_t re; + struct line_info* dli; + void* ptr; + SRCCODEINFO sci; + char* file; + + if (!cb) return FALSE; + pcs = process_find_by_handle(hProcess); + if (!pcs) return FALSE; + 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; + } + if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland); + module = module_find_by_addr(pcs, base, DMT_UNKNOWN); + if (!(module = module_get_debug(pcs, module))) return FALSE; + + sci.SizeOfStruct = sizeof(sci); + sci.ModBase = base; + + hash_table_iter_init(&module->ht_symbols, &hti, NULL); + while ((ptr = hash_table_iter_up(&hti))) + { + sym = GET_ENTRY(ptr, struct symt_ht, hash_elt); + if (sym->symt.tag != SymTagFunction) continue; + + dli = NULL; + sci.FileName[0] = '\0'; + while ((dli = vector_iter_up(&((struct symt_function*)sym)->vlines, dli))) + { + if (dli->is_source_file) + { + file = (char*)source_get(module, dli->u.source_file); + if (regexec(&re, file, 0, NULL, 0) != 0) file = ""; + strcpy(sci.FileName, file); + } + else if (sci.FileName[0]) + { + sci.Key = dli; + sci.Obj[0] = '\0'; /* FIXME */ + sci.LineNumber = dli->line_number; + sci.Address = dli->u.pc_offset; + if (!cb(&sci, user)) break; + } + } + } + return TRUE; +} Index: wine/dlls/dbghelp/dbghelp_private.h diff -u -p wine/dlls/dbghelp/dbghelp_private.h:1.16 wine/dlls/dbghelp/dbghelp_private.h:1.17 --- wine/dlls/dbghelp/dbghelp_private.h:1.16 3 Nov 2005 9:51:26 -0000 +++ wine/dlls/dbghelp/dbghelp_private.h 3 Nov 2005 9:51:26 -0000 @@ -289,6 +289,19 @@ struct process IMAGEHLP_STACK_FRAME ctx_frame; };
+struct line_info +{ + unsigned long is_first : 1, + is_last : 1, + is_source_file : 1, + line_number; + union + { + unsigned long pc_offset; /* if is_source_file isn't set */ + unsigned source_file; /* if is_source_file is set */ + } u; +}; + /* dbghelp.c */ extern struct process* process_find_by_handle(HANDLE hProcess); extern HANDLE hMsvcrt; Index: wine/dlls/dbghelp/dbghelp.spec diff -u -p wine/dlls/dbghelp/dbghelp.spec:1.10 wine/dlls/dbghelp/dbghelp.spec:1.11 --- wine/dlls/dbghelp/dbghelp.spec:1.10 3 Nov 2005 9:51:26 -0000 +++ wine/dlls/dbghelp/dbghelp.spec 3 Nov 2005 9:51:26 -0000 @@ -26,6 +26,7 @@ @ stub StackWalk64 @ stdcall StackWalk(long long long ptr ptr ptr ptr ptr ptr) @ stdcall SymCleanup(long) +@ stdcall SymEnumLines(ptr double str str ptr ptr) @ stdcall SymEnumSourceFiles(ptr double str ptr ptr) @ stub SymEnumSym @ stdcall SymEnumSymbols(ptr double str ptr ptr)