[Lldb-commits] [lldb] [lldb] Rework how we pass the execution context to the statusline (PR #159887)

via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 22 14:52:52 PDT 2025


================
@@ -2109,28 +2122,33 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 
   if (StatuslineSupported()) {
     std::lock_guard<std::mutex> guard(m_statusline_mutex);
-    if (!m_statusline)
+    if (!m_statusline) {
       m_statusline.emplace(*this);
+      m_statusline->Enable(GetSelectedExecutionContextRef());
+    }
   }
 
   bool done = false;
   while (!done) {
     EventSP event_sp;
     if (listener_sp->GetEvent(event_sp, std::nullopt)) {
+      std::optional<ExecutionContextRef> exe_ctx_ref = std::nullopt;
       if (event_sp) {
         Broadcaster *broadcaster = event_sp->GetBroadcaster();
         if (broadcaster) {
           uint32_t event_type = event_sp->GetType();
           ConstString broadcaster_class(broadcaster->GetBroadcasterClass());
           if (broadcaster_class == broadcaster_class_process) {
-            HandleProcessEvent(event_sp);
+            if (ProcessSP process_sp = HandleProcessEvent(event_sp))
+              exe_ctx_ref = ExecutionContext(process_sp);
----------------
jimingham wrote:

You're being a little inconsistent here.  

ExecutionContext(lldb::ProcessSP &) returns an ExecutionContext with only the target & process shared pointers set.  In other places where you use GetSelectedExecutionContextRef, you're passing in all the selected entities.  That makes status line code that might want to show thread info have to guess whether this means it shouldn't because the caller on purpose didn't have a particular thread, or if it should get that process' selected thread.

I think it would be easier on the status line formatting code if we always put as much detail as we know.  Since this is a process event, then we should provide the selected Thread & Frame.  For Thread events below, we should fill in the selected frame for the thread.  And if were to be a frame event (we don't have those yet) that would determine everything above it.

That way when you're in the status line code you always know what the caller means.

https://github.com/llvm/llvm-project/pull/159887


More information about the lldb-commits mailing list