[lldb] Add Python bindings to print stack traces on crashes.
As noticed in D87637, when LLDB crashes, we only print stack traces if LLDB is directly executed, not when used via Python bindings. Enabling this by default may be undesirable (libraries shouldn't be messing with signal handlers), so make this an explicit opt-in. I "commandeered" this patch from Jordan Rupprecht who put this up for review originally. Differential revision: https://reviews.llvm.org/D91835
This commit is contained in:
parent
50de659adc
commit
ee2d9b8723
|
@ -141,6 +141,8 @@ public:
|
|||
static SBError
|
||||
InitializeWithErrorHandling();
|
||||
|
||||
static void PrintStackTraceOnError();
|
||||
|
||||
static void
|
||||
Terminate();
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ public:
|
|||
|
||||
static lldb::SBError InitializeWithErrorHandling();
|
||||
|
||||
static void PrintStackTraceOnError();
|
||||
|
||||
static void Terminate();
|
||||
|
||||
// Deprecated, use the one that takes a source_init_files bool.
|
||||
|
|
|
@ -880,6 +880,7 @@ def run_suite():
|
|||
|
||||
import lldb
|
||||
lldb.SBDebugger.Initialize()
|
||||
lldb.SBDebugger.PrintStackTraceOnError()
|
||||
|
||||
checkLibcxxSupport()
|
||||
checkLibstdcxxSupport()
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
@ -206,6 +208,15 @@ lldb::SBError SBDebugger::InitializeWithErrorHandling() {
|
|||
return error;
|
||||
}
|
||||
|
||||
void SBDebugger::PrintStackTraceOnError() {
|
||||
LLDB_INSTRUMENT();
|
||||
|
||||
llvm::EnablePrettyStackTrace();
|
||||
// We don't have a meaningful argv[0] to use, so use "SBDebugger" as a
|
||||
// substitute.
|
||||
llvm::sys::PrintStackTraceOnErrorSignal("SBDebugger");
|
||||
}
|
||||
|
||||
void SBDebugger::Terminate() {
|
||||
LLDB_INSTRUMENT();
|
||||
|
||||
|
|
Loading…
Reference in a new issue