Skip to content

Commit ee8636f

Browse files
committed
Only recompute the symbol/execution context on process state change
1 parent d642bfd commit ee8636f

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

lldb/include/lldb/Core/Statusline.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef LLDB_CORE_STATUSLINE_H
1010
#define LLDB_CORE_STATUSLINE_H
1111

12+
#include "lldb/Symbol/SymbolContext.h"
13+
#include "lldb/Target/ExecutionContext.h"
1214
#include "lldb/lldb-forward.h"
1315
#include <cstdint>
1416
#include <string>
@@ -46,7 +48,8 @@ class Statusline {
4648
void UpdateScrollWindow(ScrollWindowMode mode);
4749

4850
Debugger &m_debugger;
49-
std::string m_last_str;
51+
ExecutionContext m_exe_ctx;
52+
SymbolContext m_symbol_ctx;
5053
uint64_t m_terminal_width = 0;
5154
uint64_t m_terminal_height = 0;
5255
};

lldb/source/Core/Debugger.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2149,13 +2149,16 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
21492149
while (!done) {
21502150
EventSP event_sp;
21512151
if (listener_sp->GetEvent(event_sp, std::nullopt)) {
2152+
bool update_statusline = false;
21522153
if (event_sp) {
21532154
Broadcaster *broadcaster = event_sp->GetBroadcaster();
21542155
if (broadcaster) {
21552156
uint32_t event_type = event_sp->GetType();
21562157
ConstString broadcaster_class(broadcaster->GetBroadcasterClass());
21572158
if (broadcaster_class == broadcaster_class_process) {
21582159
HandleProcessEvent(event_sp);
2160+
update_statusline =
2161+
(event_type & Process::eBroadcastBitStateChanged) != 0;
21592162
} else if (broadcaster_class == broadcaster_class_target) {
21602163
if (Breakpoint::BreakpointEventData::GetEventDataFromEvent(
21612164
event_sp.get())) {
@@ -2200,7 +2203,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
22002203
if (m_forward_listener_sp)
22012204
m_forward_listener_sp->AddEvent(event_sp);
22022205
}
2203-
RedrawStatusline();
2206+
RedrawStatusline(update_statusline);
22042207
}
22052208
}
22062209

lldb/source/Core/Statusline.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ void Statusline::Draw(std::string str) {
7070
if (!stream_sp)
7171
return;
7272

73-
m_last_str = str;
74-
7573
str = ansi::TrimAndPad(str, m_terminal_width);
7674

7775
LockedStreamFile locked_stream = stream_sp->Lock();
@@ -130,15 +128,16 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) {
130128

131129
void Statusline::Redraw(const ExecutionContext *exe_ctx,
132130
const SymbolContext *sym_ctx) {
133-
if (!exe_ctx && !sym_ctx) {
134-
Draw(m_last_str);
135-
return;
136-
}
131+
if (exe_ctx)
132+
m_exe_ctx = *exe_ctx;
133+
134+
if (sym_ctx)
135+
m_symbol_ctx = *sym_ctx;
137136

138137
StreamString stream;
139138
FormatEntity::Entry format = m_debugger.GetStatuslineFormat();
140-
FormatEntity::Format(format, stream, sym_ctx, exe_ctx, nullptr, nullptr,
141-
false, false);
139+
FormatEntity::Format(format, stream, &m_symbol_ctx, &m_exe_ctx, nullptr,
140+
nullptr, false, false);
142141

143142
Draw(stream.GetString().str());
144143
}

0 commit comments

Comments
 (0)