Skip to content

Commit 170a8f1

Browse files
author
git apple-llvm automerger
committed
Merge commit '0207587a8c42' from swift/release/5.7 into stable/20211026
2 parents bb7d0c2 + 0207587 commit 170a8f1

File tree

6 files changed

+87
-40
lines changed

6 files changed

+87
-40
lines changed

lldb/bindings/interface/SBDebugger.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public:
141141
static SBError
142142
InitializeWithErrorHandling();
143143

144+
static void PrintStackTraceOnError();
145+
144146
static void
145147
Terminate();
146148

lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,46 +2880,47 @@ SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyO
28802880
#define SWIGTYPE_p_std__shared_ptrT_lldb_private__VariableList_t swig_types[187]
28812881
#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Variable_t swig_types[188]
28822882
#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Watchpoint_t swig_types[189]
2883-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t swig_types[190]
2884-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicLoader_t swig_types[191]
2885-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__File_t swig_types[192]
2886-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__JITLoaderList_t swig_types[193]
2887-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__MemoryRegionInfo_t swig_types[194]
2888-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__OperatingSystem_t swig_types[195]
2889-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedProcessInterface_t swig_types[196]
2890-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SectionList_t swig_types[197]
2891-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SourceManager_t swig_types[198]
2892-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StackFrameRecognizerManager_t swig_types[199]
2893-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StructuredDataImpl_t swig_types[200]
2894-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SymbolVendor_t swig_types[201]
2895-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SystemRuntime_t swig_types[202]
2896-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceCursor_t swig_types[203]
2897-
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceExporter_t swig_types[204]
2898-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BreakpointLocation_t swig_types[205]
2899-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Breakpoint_t swig_types[206]
2900-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BroadcasterManager_t swig_types[207]
2901-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Debugger_t swig_types[208]
2902-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Listener_t swig_types[209]
2903-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Module_t swig_types[210]
2904-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[211]
2905-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__OptionValue_t swig_types[212]
2906-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Process_t swig_types[213]
2907-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Queue_t swig_types[214]
2908-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Section_t swig_types[215]
2909-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StackFrame_t swig_types[216]
2910-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StructuredDataPlugin_t swig_types[217]
2911-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Target_t swig_types[218]
2912-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ThreadPlan_t swig_types[219]
2913-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Thread_t swig_types[220]
2914-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Type_t swig_types[221]
2915-
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__UnixSignals_t swig_types[222]
2916-
#define SWIGTYPE_p_unsigned_char swig_types[223]
2917-
#define SWIGTYPE_p_unsigned_int swig_types[224]
2918-
#define SWIGTYPE_p_unsigned_long_long swig_types[225]
2919-
#define SWIGTYPE_p_unsigned_short swig_types[226]
2920-
#define SWIGTYPE_p_void swig_types[227]
2921-
static swig_type_info *swig_types[229];
2922-
static swig_module_info swig_module = {swig_types, 228, 0, 0, 0, 0};
2883+
#define SWIGTYPE_p_std__shared_ptrT_lldb_private__WritableDataBuffer_t swig_types[190]
2884+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t swig_types[191]
2885+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicLoader_t swig_types[192]
2886+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__File_t swig_types[193]
2887+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__JITLoaderList_t swig_types[194]
2888+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__MemoryRegionInfo_t swig_types[195]
2889+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__OperatingSystem_t swig_types[196]
2890+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedProcessInterface_t swig_types[197]
2891+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SectionList_t swig_types[198]
2892+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SourceManager_t swig_types[199]
2893+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StackFrameRecognizerManager_t swig_types[200]
2894+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StructuredDataImpl_t swig_types[201]
2895+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SymbolVendor_t swig_types[202]
2896+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SystemRuntime_t swig_types[203]
2897+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceCursor_t swig_types[204]
2898+
#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceExporter_t swig_types[205]
2899+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BreakpointLocation_t swig_types[206]
2900+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Breakpoint_t swig_types[207]
2901+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BroadcasterManager_t swig_types[208]
2902+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Debugger_t swig_types[209]
2903+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Listener_t swig_types[210]
2904+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Module_t swig_types[211]
2905+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[212]
2906+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__OptionValue_t swig_types[213]
2907+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Process_t swig_types[214]
2908+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Queue_t swig_types[215]
2909+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Section_t swig_types[216]
2910+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StackFrame_t swig_types[217]
2911+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StructuredDataPlugin_t swig_types[218]
2912+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Target_t swig_types[219]
2913+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ThreadPlan_t swig_types[220]
2914+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Thread_t swig_types[221]
2915+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Type_t swig_types[222]
2916+
#define SWIGTYPE_p_std__weak_ptrT_lldb_private__UnixSignals_t swig_types[223]
2917+
#define SWIGTYPE_p_unsigned_char swig_types[224]
2918+
#define SWIGTYPE_p_unsigned_int swig_types[225]
2919+
#define SWIGTYPE_p_unsigned_long_long swig_types[226]
2920+
#define SWIGTYPE_p_unsigned_short swig_types[227]
2921+
#define SWIGTYPE_p_void swig_types[228]
2922+
static swig_type_info *swig_types[230];
2923+
static swig_module_info swig_module = {swig_types, 229, 0, 0, 0, 0};
29232924
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
29242925
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
29252926

@@ -21134,6 +21135,22 @@ SWIGINTERN PyObject *_wrap_SBDebugger_InitializeWithErrorHandling(PyObject *SWIG
2113421135
}
2113521136

2113621137

21138+
SWIGINTERN PyObject *_wrap_SBDebugger_PrintStackTraceOnError(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
21139+
PyObject *resultobj = 0;
21140+
21141+
if (!SWIG_Python_UnpackTuple(args, "SBDebugger_PrintStackTraceOnError", 0, 0, 0)) SWIG_fail;
21142+
{
21143+
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
21144+
lldb::SBDebugger::PrintStackTraceOnError();
21145+
SWIG_PYTHON_THREAD_END_ALLOW;
21146+
}
21147+
resultobj = SWIG_Py_Void();
21148+
return resultobj;
21149+
fail:
21150+
return NULL;
21151+
}
21152+
21153+
2113721154
SWIGINTERN PyObject *_wrap_SBDebugger_Terminate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
2113821155
PyObject *resultobj = 0;
2113921156

@@ -82275,6 +82292,7 @@ static PyMethodDef SwigMethods[] = {
8227582292
{ "SBDebugger_GetBroadcaster", _wrap_SBDebugger_GetBroadcaster, METH_O, "SBDebugger_GetBroadcaster(SBDebugger self) -> SBBroadcaster"},
8227682293
{ "SBDebugger_Initialize", _wrap_SBDebugger_Initialize, METH_NOARGS, "SBDebugger_Initialize()"},
8227782294
{ "SBDebugger_InitializeWithErrorHandling", _wrap_SBDebugger_InitializeWithErrorHandling, METH_NOARGS, "SBDebugger_InitializeWithErrorHandling() -> SBError"},
82295+
{ "SBDebugger_PrintStackTraceOnError", _wrap_SBDebugger_PrintStackTraceOnError, METH_NOARGS, "SBDebugger_PrintStackTraceOnError()"},
8227882296
{ "SBDebugger_Terminate", _wrap_SBDebugger_Terminate, METH_NOARGS, "SBDebugger_Terminate()"},
8227982297
{ "SBDebugger_Create", _wrap_SBDebugger_Create, METH_VARARGS, "\n"
8228082298
"SBDebugger_Create() -> SBDebugger\n"
@@ -86360,6 +86378,7 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Value_t = {"_p_st
8636086378
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__VariableList_t = {"_p_std__shared_ptrT_lldb_private__VariableList_t", "std::shared_ptr< lldb_private::VariableList > *|lldb::VariableListSP *", 0, 0, (void*)0, 0};
8636186379
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Variable_t = {"_p_std__shared_ptrT_lldb_private__Variable_t", "lldb::VariableSP *|std::shared_ptr< lldb_private::Variable > *", 0, 0, (void*)0, 0};
8636286380
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t = {"_p_std__shared_ptrT_lldb_private__Watchpoint_t", "lldb::WatchpointSP *|std::shared_ptr< lldb_private::Watchpoint > *", 0, 0, (void*)0, 0};
86381+
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t = {"_p_std__shared_ptrT_lldb_private__WritableDataBuffer_t", "std::shared_ptr< lldb_private::WritableDataBuffer > *|lldb::WritableDataBufferSP *", 0, 0, (void*)0, 0};
8636386382
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t = {"_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t", "lldb::DynamicCheckerFunctionsUP *|std::unique_ptr< lldb_private::DynamicCheckerFunctions > *", 0, 0, (void*)0, 0};
8636486383
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t = {"_p_std__unique_ptrT_lldb_private__DynamicLoader_t", "lldb::DynamicLoaderUP *|std::unique_ptr< lldb_private::DynamicLoader > *", 0, 0, (void*)0, 0};
8636586384
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__File_t = {"_p_std__unique_ptrT_lldb_private__File_t", "lldb::FileUP *|std::unique_ptr< lldb_private::File > *", 0, 0, (void*)0, 0};
@@ -86590,6 +86609,7 @@ static swig_type_info *swig_type_initial[] = {
8659086609
&_swigt__p_std__shared_ptrT_lldb_private__VariableList_t,
8659186610
&_swigt__p_std__shared_ptrT_lldb_private__Variable_t,
8659286611
&_swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t,
86612+
&_swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t,
8659386613
&_swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t,
8659486614
&_swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t,
8659586615
&_swigt__p_std__unique_ptrT_lldb_private__File_t,
@@ -86820,6 +86840,7 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Value_t[] = { {&
8682086840
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__VariableList_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__VariableList_t, 0, 0, 0},{0, 0, 0, 0}};
8682186841
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Variable_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Variable_t, 0, 0, 0},{0, 0, 0, 0}};
8682286842
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Watchpoint_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t, 0, 0, 0},{0, 0, 0, 0}};
86843+
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t, 0, 0, 0},{0, 0, 0, 0}};
8682386844
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t, 0, 0, 0},{0, 0, 0, 0}};
8682486845
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__DynamicLoader_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t, 0, 0, 0},{0, 0, 0, 0}};
8682586846
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__File_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__File_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -87050,6 +87071,7 @@ static swig_cast_info *swig_cast_initial[] = {
8705087071
_swigc__p_std__shared_ptrT_lldb_private__VariableList_t,
8705187072
_swigc__p_std__shared_ptrT_lldb_private__Variable_t,
8705287073
_swigc__p_std__shared_ptrT_lldb_private__Watchpoint_t,
87074+
_swigc__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t,
8705387075
_swigc__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t,
8705487076
_swigc__p_std__unique_ptrT_lldb_private__DynamicLoader_t,
8705587077
_swigc__p_std__unique_ptrT_lldb_private__File_t,

lldb/bindings/python/static-binding/lldb.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,11 @@ def InitializeWithErrorHandling():
41904190
r"""InitializeWithErrorHandling() -> SBError"""
41914191
return _lldb.SBDebugger_InitializeWithErrorHandling()
41924192

4193+
@staticmethod
4194+
def PrintStackTraceOnError():
4195+
r"""PrintStackTraceOnError()"""
4196+
return _lldb.SBDebugger_PrintStackTraceOnError()
4197+
41934198
@staticmethod
41944199
def Terminate():
41954200
r"""Terminate()"""
@@ -4697,6 +4702,10 @@ def SBDebugger_InitializeWithErrorHandling():
46974702
r"""SBDebugger_InitializeWithErrorHandling() -> SBError"""
46984703
return _lldb.SBDebugger_InitializeWithErrorHandling()
46994704

4705+
def SBDebugger_PrintStackTraceOnError():
4706+
r"""SBDebugger_PrintStackTraceOnError()"""
4707+
return _lldb.SBDebugger_PrintStackTraceOnError()
4708+
47004709
def SBDebugger_Terminate():
47014710
r"""SBDebugger_Terminate()"""
47024711
return _lldb.SBDebugger_Terminate()

lldb/include/lldb/API/SBDebugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class LLDB_API SBDebugger {
9292

9393
static lldb::SBError InitializeWithErrorHandling();
9494

95+
static void PrintStackTraceOnError();
96+
9597
static void Terminate();
9698

9799
// Deprecated, use the one that takes a source_init_files bool.

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ def run_suite():
883883

884884
import lldb
885885
lldb.SBDebugger.Initialize()
886+
lldb.SBDebugger.PrintStackTraceOnError()
886887

887888
# Use host platform by default.
888889
lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()

lldb/source/API/SBDebugger.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#include "llvm/ADT/StringRef.h"
5858
#include "llvm/Support/DynamicLibrary.h"
5959
#include "llvm/Support/ManagedStatic.h"
60+
#include "llvm/Support/PrettyStackTrace.h"
61+
#include "llvm/Support/Signals.h"
6062

6163
using namespace lldb;
6264
using namespace lldb_private;
@@ -206,6 +208,15 @@ lldb::SBError SBDebugger::InitializeWithErrorHandling() {
206208
return error;
207209
}
208210

211+
void SBDebugger::PrintStackTraceOnError() {
212+
LLDB_INSTRUMENT();
213+
214+
llvm::EnablePrettyStackTrace();
215+
static std::string executable =
216+
llvm::sys::fs::getMainExecutable(nullptr, nullptr);
217+
llvm::sys::PrintStackTraceOnErrorSignal(executable);
218+
}
219+
209220
void SBDebugger::Terminate() {
210221
LLDB_INSTRUMENT();
211222

0 commit comments

Comments
 (0)