[PATCH] D119009: [Support] Ensure handlers are set up before printing the stacktrace

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 4 11:14:24 PST 2022


aganea added a comment.

I'm not sure it's a good idea to start loading DLLs when we get to this point.
I would rather suggest calling `sys::PrintStackTraceOnErrorSignal({});` in `SBDebugger::Initialize()`. "argv0" will be auto-detected if necessary, otherwise if you can, change the `SBDebugger::Initialize()` API to pass it? It's only there so that we can find `llvm-symbolizer` next to the running executable.
You can also add something along those lines to avoid the crash:

  static bool isDebugHelpInitialized(void) {
     return fStackWalk64 && fSymInitialize && fSymSetOptions && fMiniDumpWriteDump;
  }
  ...
  static void PrintStackTraceForThread(llvm::raw_ostream &OS, HANDLE hProcess,
                                       HANDLE hThread, STACKFRAME64 &StackFrame,
                                       CONTEXT *Context) {
    if (!isDebugHelpInitialized())
      return;
  
    // Initialize the symbol handler.
    fSymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES);


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119009/new/

https://reviews.llvm.org/D119009



More information about the llvm-commits mailing list