Skip to content

Commit da0fb95

Browse files
author
jeffreytan81
committed
Fix stackTrace perf issue in lldb-dap
1 parent 6e84ab9 commit da0fb95

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ DAP::DAP()
3636
focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false),
3737
enable_auto_variable_summaries(false),
3838
enable_synthetic_child_debugging(false),
39+
enable_display_extended_backtrace(false),
3940
restarting_process_id(LLDB_INVALID_PROCESS_ID),
4041
configuration_done_sent(false), waiting_for_run_in_terminal(false),
4142
progress_event_reporter(

lldb/tools/lldb-dap/DAP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ struct DAP {
177177
bool is_attach;
178178
bool enable_auto_variable_summaries;
179179
bool enable_synthetic_child_debugging;
180+
bool enable_display_extended_backtrace;
180181
// The process event thread normally responds to process exited events by
181182
// shutting down the entire adapter. When we're restarting, we keep the id of
182183
// the old process here so we can detect this case and keep running.

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ void request_attach(const llvm::json::Object &request) {
701701
GetBoolean(arguments, "enableAutoVariableSummaries", false);
702702
g_dap.enable_synthetic_child_debugging =
703703
GetBoolean(arguments, "enableSyntheticChildDebugging", false);
704+
g_dap.enable_display_extended_backtrace =
705+
GetBoolean(arguments, "enableDisplayExtendedBacktrace", false);
704706
g_dap.command_escape_prefix =
705707
GetString(arguments, "commandEscapePrefix", "`");
706708
g_dap.SetFrameFormat(GetString(arguments, "customFrameFormat"));
@@ -3091,17 +3093,20 @@ void request_stackTrace(const llvm::json::Object &request) {
30913093
// This will always return an invalid thread when
30923094
// libBacktraceRecording.dylib is not loaded or if there is no extended
30933095
// backtrace.
3094-
lldb::SBThread queue_backtrace_thread =
3095-
thread.GetExtendedBacktraceThread("libdispatch");
3096+
lldb::SBThread queue_backtrace_thread;
3097+
if (g_dap.enable_display_extended_backtrace)
3098+
queue_backtrace_thread = thread.GetExtendedBacktraceThread("libdispatch");
30963099
if (queue_backtrace_thread.IsValid()) {
30973100
// One extra frame as a label to mark the enqueued thread.
30983101
totalFrames += queue_backtrace_thread.GetNumFrames() + 1;
30993102
}
31003103

31013104
// This will always return an invalid thread when there is no exception in
31023105
// the current thread.
3103-
lldb::SBThread exception_backtrace_thread =
3104-
thread.GetCurrentExceptionBacktrace();
3106+
lldb::SBThread exception_backtrace_thread;
3107+
if (g_dap.enable_display_extended_backtrace)
3108+
exception_backtrace_thread = thread.GetCurrentExceptionBacktrace();
3109+
31053110
if (exception_backtrace_thread.IsValid()) {
31063111
// One extra frame as a label to mark the exception thread.
31073112
totalFrames += exception_backtrace_thread.GetNumFrames() + 1;

0 commit comments

Comments
 (0)