summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-28 08:41:18 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-28 08:41:18 +0100
commit5ff355c0cdf48796bc16335e1af7f34c41dcf576 (patch)
tree995867bab502755061db1cedd1f8e771390a540b
parentb72f067f0daac88ebe66e3f714e517b995b48e7b (diff)
downloadserenity-5ff355c0cdf48796bc16335e1af7f34c41dcf576.zip
Kernel: Generate coredump backtraces from "threads for coredump" list
This broke with the change that gave each process a list of its own threads. Since threads are removed slightly earlier from that list during process teardown, we're not able to use it for generating coredump backtraces. Fortunately we have the "threads for coredump" list for just this purpose. :^)
-rw-r--r--Kernel/CoreDump.cpp6
-rw-r--r--Kernel/Process.cpp2
-rw-r--r--Kernel/Process.h7
-rw-r--r--Kernel/Thread.h1
4 files changed, 10 insertions, 6 deletions
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<typename Callback>
IterationDecision for_each_thread(Callback) const;
+ template<typename Callback>
+ IterationDecision for_each_thread_in_coredump(Callback) const;
+
void die();
void finalize();
@@ -500,6 +503,8 @@ public:
HashMap<String, String>& coredump_metadata() { return m_coredump_metadata; }
const HashMap<String, String>& coredump_metadata() const { return m_coredump_metadata; }
+ const NonnullRefPtrVector<Thread>& threads_for_coredump(Badge<CoreDump>) const { return m_threads_for_coredump; }
+
PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; }
private:
@@ -662,7 +667,7 @@ private:
HashMap<String, String> m_coredump_metadata;
- Vector<RefPtr<Thread>> m_threads_for_coredump;
+ NonnullRefPtrVector<Thread> m_threads_for_coredump;
};
extern InlineLinkedList<Process>* 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<Thread*>(this)->get_register_dump_from_stack(); }
TSS32& tss() { return m_tss; }
const TSS32& tss() const { return m_tss; }