[Lldb-commits] [lldb] [lldb][Process/FreeBSDKernelCore] Add command for refreshing thread list (PR #188692)
Minsoo Choo via lldb-commits
lldb-commits at lists.llvm.org
Sun Mar 29 07:01:38 PDT 2026
================
@@ -60,20 +62,61 @@ static PluginProperties &GetGlobalPluginProperties() {
return g_settings;
}
+class CommandObjectProcessFreeBSDKernelCoreRefreshThreads
+ : public CommandObjectParsed {
+public:
+ CommandObjectProcessFreeBSDKernelCoreRefreshThreads(
+ CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "process plugin refresh-threads",
+ "Refresh the thread list from the FreeBSD kernel core dump. "
+ "This flushes the memory cache and re-reads the kernel's "
+ "allproc/zombie lists to rebuild the thread list from scratch.",
+ "process plugin refresh-threads") {}
+
+ ~CommandObjectProcessFreeBSDKernelCoreRefreshThreads() override = default;
+
+protected:
+ void DoExecute(Args &command, CommandReturnObject &result) override {
+ // TODO: Return early for elf-core based implementation.
+
+ auto *process = static_cast<ProcessFreeBSDKernelCore *>(
+ m_interpreter.GetExecutionContext().GetProcessPtr());
+ if (!process) {
+ result.AppendError("no process");
+ return;
+ }
+
+ // Clear the memory cache so DoUpdateThreadList() will re-read
+ // allproc, zombproc, and all thread/proc structures fresh from
+ // the core dump instead of getting stale cached values.
+ process->m_memory_cache.Clear();
+
+ // Explicitly clear the thread list after Flush() to guarantee that
+ // UpdateThreadListIfNeeded() sees size == 0 and enters the rebuild
+ // path regardless of stop-ID state.
+ process->GetThreadList().Clear();
+
+ // Rebuild the process thread list.
+ process->UpdateThreadListIfNeeded();
+
+ const uint32_t num_threads = process->GetThreadList().GetSize(false);
----------------
mchoo7 wrote:
Yup, it triggers `UpdateThreadListIfNeeded()`. I'm keeping the comment above.
https://github.com/llvm/llvm-project/pull/188692
More information about the lldb-commits
mailing list