-
-
Notifications
You must be signed in to change notification settings - Fork 201
fix(win): make symbolication and modulefinder independent of the system ANSI code page. #1389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
2d91922
38f1fee
2f50d93
de40603
986d65c
202cf41
1404955
898fe24
727fe5b
1957d2a
e5dd801
b99127a
0c979d3
5f17b73
d67abba
d30e4cd
d67a769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| #include "sentry_boot.h" | ||
| #include "sentry_string.h" | ||
|
|
||
| #include "sentry_symbolizer.h" | ||
| #include "sentry_windows_dbghelp.h" | ||
|
|
||
| #include <dbghelp.h> | ||
| #include <malloc.h> | ||
|
|
||
| #define MAX_SYM 1024 | ||
|
|
||
| bool | ||
| sentry__symbolize( | ||
| void *addr, void (*func)(const sentry_frame_info_t *, void *), void *data) | ||
|
|
@@ -17,29 +16,41 @@ sentry__symbolize( | |
| (void)func; | ||
| (void)addr; | ||
| #else | ||
| if (!addr || !func) { | ||
| return false; | ||
| } | ||
| HANDLE proc = sentry__init_dbghelp(); | ||
| size_t symbol_info_size | ||
| = sizeof(SYMBOL_INFOW) + MAX_SYM_NAME * sizeof(WCHAR); | ||
| SYMBOL_INFOW *symbol_info = _alloca(symbol_info_size); | ||
| memset(symbol_info, 0, symbol_info_size); | ||
| symbol_info->MaxNameLen = MAX_SYM_NAME; | ||
| symbol_info->SizeOfStruct = sizeof(SYMBOL_INFOW); | ||
|
|
||
| if (!SymFromAddrW(proc, (uintptr_t)addr, NULL, symbol_info)) { | ||
| return false; | ||
| } | ||
|
|
||
| SYMBOL_INFO *sym = (SYMBOL_INFO *)_alloca(sizeof(SYMBOL_INFO) + MAX_SYM); | ||
| memset(sym, 0, sizeof(SYMBOL_INFO) + MAX_SYM); | ||
| sym->MaxNameLen = MAX_SYM; | ||
| sym->SizeOfStruct = sizeof(SYMBOL_INFO); | ||
|
|
||
| if (!SymFromAddr(proc, (DWORD64)addr, 0, sym)) { | ||
| WCHAR mod_path_w[MAX_PATH]; | ||
| const DWORD n = GetModuleFileNameW( | ||
| (HMODULE)(uintptr_t)symbol_info->ModBase, mod_path_w, MAX_PATH); | ||
| if (n == 0 || n >= MAX_PATH) { | ||
| return false; | ||
| } | ||
|
|
||
| char mod_name[MAX_PATH]; | ||
| GetModuleFileNameA( | ||
| (HMODULE)(size_t)sym->ModBase, mod_name, sizeof(mod_name)); | ||
| char *mod_path = sentry__string_from_wstr(mod_path_w); | ||
| char *symbol_name = sentry__string_from_wstr(symbol_info->Name); | ||
|
|
||
| sentry_frame_info_t frame_info; | ||
| memset(&frame_info, 0, sizeof(sentry_frame_info_t)); | ||
| frame_info.load_addr = (void *)(size_t)sym->ModBase; | ||
| sentry_frame_info_t frame_info = { 0 }; | ||
| frame_info.load_addr = (void *)(uintptr_t)symbol_info->ModBase; | ||
| frame_info.instruction_addr = addr; | ||
| frame_info.symbol_addr = (void *)(size_t)sym->Address; | ||
| frame_info.symbol = sym->Name; | ||
| frame_info.object_name = mod_name; | ||
| frame_info.symbol_addr = (void *)(uintptr_t)symbol_info->Address; | ||
| frame_info.symbol = symbol_name; | ||
| frame_info.object_name = mod_path; | ||
| func(&frame_info, data); | ||
|
|
||
| sentry_free(mod_path); | ||
| sentry_free(symbol_name); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: String Conversion and Memory Management IssuesThe
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a sensible warning, but intentional in the current code:
|
||
| #endif // SENTRY_PLATFORM_XBOX | ||
|
|
||
| return true; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.