Switching to python build script.
This commit is contained in:
@@ -46,12 +46,18 @@ void AttachConsole() {
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
}
|
||||
|
||||
} // namespace xe
|
||||
|
||||
// Used in console mode apps; automatically picked based on subsystem.
|
||||
int main(int argc, wchar_t* argv[]) {
|
||||
int Main() {
|
||||
auto entry_info = xe::GetEntryInfo();
|
||||
|
||||
// Convert command line to an argv-like format so we can share code/use
|
||||
// gflags.
|
||||
auto command_line = GetCommandLineW();
|
||||
int argc;
|
||||
wchar_t** argv = CommandLineToArgvW(command_line, &argc);
|
||||
if (!argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
google::SetUsageMessage(std::string("usage: ") +
|
||||
xe::to_string(entry_info.usage));
|
||||
google::SetVersionString("1.0");
|
||||
@@ -82,30 +88,23 @@ int main(int argc, wchar_t* argv[]) {
|
||||
int result = entry_info.entry_point(args);
|
||||
|
||||
google::ShutDownCommandLineFlags();
|
||||
LocalFree(argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace xe
|
||||
|
||||
// Used in console mode apps; automatically picked based on subsystem.
|
||||
int main(int argc_ignored, char** argv_ignored) { return xe::Main(); }
|
||||
|
||||
// Used in windowed apps; automatically picked based on subsystem.
|
||||
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR command_line, int) {
|
||||
// Attach a console so we can write output to stdout. If the user hasn't
|
||||
// redirected output themselves it'll pop up a window.
|
||||
xe::AttachConsole();
|
||||
|
||||
auto entry_info = xe::GetEntryInfo();
|
||||
|
||||
// Convert to an argv-like format so we can share code/use gflags.
|
||||
std::wstring buffer = entry_info.name + L" " + command_line;
|
||||
int argc;
|
||||
wchar_t** argv = CommandLineToArgvW(buffer.c_str(), &argc);
|
||||
if (!argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Run normal entry point.
|
||||
int result = main(argc, argv);
|
||||
|
||||
LocalFree(argv);
|
||||
return result;
|
||||
return xe::Main();
|
||||
}
|
||||
|
||||
#if defined _M_IX86
|
||||
|
||||
@@ -62,6 +62,57 @@ LPSYMGETSYMFROMADDR64 sym_get_sym_from_addr_64_ = nullptr;
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
||||
bool InitializeStackWalker() {
|
||||
if (sym_get_options_) {
|
||||
// Already initialized.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Attempt to load dbghelp.
|
||||
// NOTE: we never free it. That's fine.
|
||||
HMODULE module = LoadLibrary(TEXT("dbghelp.dll"));
|
||||
if (!module) {
|
||||
XELOGE("Unable to load dbghelp.dll - not found on path or invalid");
|
||||
return false;
|
||||
}
|
||||
sym_get_options_ = reinterpret_cast<LPSYMGETOPTIONS>(
|
||||
GetProcAddress(module, "SymGetOptions"));
|
||||
sym_set_options_ = reinterpret_cast<LPSYMSETOPTIONS>(
|
||||
GetProcAddress(module, "SymSetOptions"));
|
||||
sym_initialize_ = reinterpret_cast<LPSYMINITIALIZE>(
|
||||
GetProcAddress(module, "SymInitialize"));
|
||||
stack_walk_64_ =
|
||||
reinterpret_cast<LPSTACKWALK64>(GetProcAddress(module, "StackWalk64"));
|
||||
sym_function_table_access_64_ = reinterpret_cast<LPSYMFUNCTIONTABLEACCESS64>(
|
||||
GetProcAddress(module, "SymFunctionTableAccess64"));
|
||||
sym_get_module_base_64_ = reinterpret_cast<LPSYMGETMODULEBASE64>(
|
||||
GetProcAddress(module, "SymGetModuleBase64"));
|
||||
sym_get_sym_from_addr_64_ = reinterpret_cast<LPSYMGETSYMFROMADDR64>(
|
||||
GetProcAddress(module, "SymGetSymFromAddr64"));
|
||||
if (!sym_get_options_ || !sym_set_options_ || !sym_initialize_ ||
|
||||
!stack_walk_64_ || !sym_function_table_access_64_ ||
|
||||
!sym_get_module_base_64_ || !sym_get_sym_from_addr_64_) {
|
||||
XELOGE("Unable to get one or more symbols from dbghelp.dll");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize the symbol lookup services.
|
||||
DWORD options = sym_get_options_();
|
||||
if (FLAGS_debug_symbol_loader) {
|
||||
options |= SYMOPT_DEBUG;
|
||||
}
|
||||
options |= SYMOPT_DEFERRED_LOADS;
|
||||
options |= SYMOPT_LOAD_LINES;
|
||||
options |= SYMOPT_FAIL_CRITICAL_ERRORS;
|
||||
sym_set_options_(options);
|
||||
if (!sym_initialize_(GetCurrentProcess(), nullptr, TRUE)) {
|
||||
XELOGE("Unable to initialize symbol services");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class Win32StackWalker : public StackWalker {
|
||||
public:
|
||||
Win32StackWalker(backend::CodeCache* code_cache) {
|
||||
@@ -77,51 +128,7 @@ class Win32StackWalker : public StackWalker {
|
||||
|
||||
bool Initialize() {
|
||||
std::lock_guard<std::mutex> lock(dbghelp_mutex_);
|
||||
|
||||
// Attempt to load dbghelp.
|
||||
// NOTE: we never free it. That's fine.
|
||||
HMODULE module = LoadLibrary(TEXT("dbghelp.dll"));
|
||||
if (!module) {
|
||||
XELOGE("Unable to load dbghelp.dll - not found on path or invalid");
|
||||
return false;
|
||||
}
|
||||
sym_get_options_ = reinterpret_cast<LPSYMGETOPTIONS>(
|
||||
GetProcAddress(module, "SymGetOptions"));
|
||||
sym_set_options_ = reinterpret_cast<LPSYMSETOPTIONS>(
|
||||
GetProcAddress(module, "SymSetOptions"));
|
||||
sym_initialize_ = reinterpret_cast<LPSYMINITIALIZE>(
|
||||
GetProcAddress(module, "SymInitialize"));
|
||||
stack_walk_64_ =
|
||||
reinterpret_cast<LPSTACKWALK64>(GetProcAddress(module, "StackWalk64"));
|
||||
sym_function_table_access_64_ =
|
||||
reinterpret_cast<LPSYMFUNCTIONTABLEACCESS64>(
|
||||
GetProcAddress(module, "SymFunctionTableAccess64"));
|
||||
sym_get_module_base_64_ = reinterpret_cast<LPSYMGETMODULEBASE64>(
|
||||
GetProcAddress(module, "SymGetModuleBase64"));
|
||||
sym_get_sym_from_addr_64_ = reinterpret_cast<LPSYMGETSYMFROMADDR64>(
|
||||
GetProcAddress(module, "SymGetSymFromAddr64"));
|
||||
if (!sym_get_options_ || !sym_set_options_ || !sym_initialize_ ||
|
||||
!stack_walk_64_ || !sym_function_table_access_64_ ||
|
||||
!sym_get_module_base_64_ || !sym_get_sym_from_addr_64_) {
|
||||
XELOGE("Unable to get one or more symbols from dbghelp.dll");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize the symbol lookup services.
|
||||
DWORD options = sym_get_options_();
|
||||
if (FLAGS_debug_symbol_loader) {
|
||||
options |= SYMOPT_DEBUG;
|
||||
}
|
||||
options |= SYMOPT_DEFERRED_LOADS;
|
||||
options |= SYMOPT_LOAD_LINES;
|
||||
options |= SYMOPT_FAIL_CRITICAL_ERRORS;
|
||||
sym_set_options_(options);
|
||||
if (!sym_initialize_(GetCurrentProcess(), nullptr, TRUE)) {
|
||||
XELOGE("Unable to initialize symbol services");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return InitializeStackWalker();
|
||||
}
|
||||
|
||||
size_t CaptureStackTrace(uint64_t* frame_host_pcs, size_t frame_offset,
|
||||
|
||||
Reference in New Issue
Block a user