diff --git a/Kernel/CoreDump.cpp b/Kernel/CoreDump.cpp index b03f27da82..2f3007e863 100644 --- a/Kernel/CoreDump.cpp +++ b/Kernel/CoreDump.cpp @@ -240,7 +240,7 @@ ByteBuffer CoreDump::create_notes_threads_data() const { ByteBuffer threads_data; - m_process->for_each_thread([&](Thread& thread) { + for (auto& thread : m_process->threads_for_coredump({})) { ByteBuffer entry_buff; ELF::Core::ThreadInfo info {}; @@ -251,9 +251,7 @@ ByteBuffer CoreDump::create_notes_threads_data() const entry_buff.append((void*)&info, sizeof(info)); threads_data += entry_buff; - - return IterationDecision::Continue; - }); + } return threads_data; } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 09c494f25b..8e49cc4187 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -677,7 +677,7 @@ void Process::die() m_tty = nullptr; for_each_thread([&](auto& thread) { - m_threads_for_coredump.append(&thread); + m_threads_for_coredump.append(thread); return IterationDecision::Continue; }); diff --git a/Kernel/Process.h b/Kernel/Process.h index ae43f88aea..612bd6317d 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -206,6 +206,9 @@ public: template IterationDecision for_each_thread(Callback) const; + template + IterationDecision for_each_thread_in_coredump(Callback) const; + void die(); void finalize(); @@ -500,6 +503,8 @@ public: HashMap& coredump_metadata() { return m_coredump_metadata; } const HashMap& coredump_metadata() const { return m_coredump_metadata; } + const NonnullRefPtrVector& threads_for_coredump(Badge) const { return m_threads_for_coredump; } + PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; } private: @@ -662,7 +667,7 @@ private: HashMap m_coredump_metadata; - Vector> m_threads_for_coredump; + NonnullRefPtrVector m_threads_for_coredump; }; extern InlineLinkedList* g_processes; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 1cd6e182ba..f3f1bf9561 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -785,6 +785,7 @@ public: u32 stack_ptr() const { return m_tss.esp; } RegisterState& get_register_dump_from_stack(); + const RegisterState& get_register_dump_from_stack() const { return const_cast(this)->get_register_dump_from_stack(); } TSS32& tss() { return m_tss; } const TSS32& tss() const { return m_tss; }