summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCoreDump
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibCoreDump')
-rw-r--r--Userland/Libraries/LibCoreDump/Backtrace.cpp30
-rw-r--r--Userland/Libraries/LibCoreDump/Backtrace.h7
-rw-r--r--Userland/Libraries/LibCoreDump/Reader.cpp6
-rw-r--r--Userland/Libraries/LibCoreDump/Reader.h3
4 files changed, 19 insertions, 27 deletions
diff --git a/Userland/Libraries/LibCoreDump/Backtrace.cpp b/Userland/Libraries/LibCoreDump/Backtrace.cpp
index afa6220447..1352fa9e72 100644
--- a/Userland/Libraries/LibCoreDump/Backtrace.cpp
+++ b/Userland/Libraries/LibCoreDump/Backtrace.cpp
@@ -68,29 +68,27 @@ static const ELFObjectInfo* object_info_for_region(const ELF::Core::MemoryRegion
return info_ptr;
}
-Backtrace::Backtrace(const Reader& coredump)
+Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread_info)
+ : m_thread_info(move(thread_info))
{
- coredump.for_each_thread_info([this, &coredump](const ELF::Core::ThreadInfo& thread_info) {
- uint32_t* ebp = (uint32_t*)thread_info.regs.ebp;
- uint32_t* eip = (uint32_t*)thread_info.regs.eip;
- while (ebp && eip) {
- add_backtrace_entry(coredump, (FlatPtr)eip);
- auto next_eip = coredump.peek_memory((FlatPtr)(ebp + 1));
- auto next_ebp = coredump.peek_memory((FlatPtr)(ebp));
- if (!next_eip.has_value() || !next_ebp.has_value())
- break;
- eip = (uint32_t*)next_eip.value();
- ebp = (uint32_t*)next_ebp.value();
- }
- return IterationDecision::Continue;
- });
+ uint32_t* ebp = (uint32_t*)m_thread_info.regs.ebp;
+ uint32_t* eip = (uint32_t*)m_thread_info.regs.eip;
+ while (ebp && eip) {
+ add_entry(coredump, (FlatPtr)eip);
+ auto next_eip = coredump.peek_memory((FlatPtr)(ebp + 1));
+ auto next_ebp = coredump.peek_memory((FlatPtr)(ebp));
+ if (!next_eip.has_value() || !next_ebp.has_value())
+ break;
+ eip = (uint32_t*)next_eip.value();
+ ebp = (uint32_t*)next_ebp.value();
+ }
}
Backtrace::~Backtrace()
{
}
-void Backtrace::add_backtrace_entry(const Reader& coredump, FlatPtr eip)
+void Backtrace::add_entry(const Reader& coredump, FlatPtr eip)
{
auto* region = coredump.region_containing((FlatPtr)eip);
if (!region) {
diff --git a/Userland/Libraries/LibCoreDump/Backtrace.h b/Userland/Libraries/LibCoreDump/Backtrace.h
index 6915b170c2..a0ca69d480 100644
--- a/Userland/Libraries/LibCoreDump/Backtrace.h
+++ b/Userland/Libraries/LibCoreDump/Backtrace.h
@@ -29,6 +29,7 @@
#include <AK/Types.h>
#include <LibCoreDump/Reader.h>
#include <LibDebug/DebugInfo.h>
+#include <LibELF/CoreDump.h>
namespace CoreDump {
@@ -54,14 +55,16 @@ public:
String to_string(bool color = false) const;
};
- Backtrace(const Reader&);
+ Backtrace(const Reader&, const ELF::Core::ThreadInfo&);
~Backtrace();
+ const ELF::Core::ThreadInfo thread_info() const { return m_thread_info; }
const Vector<Entry> entries() const { return m_entries; }
private:
- void add_backtrace_entry(const Reader&, FlatPtr eip);
+ void add_entry(const Reader&, FlatPtr eip);
+ ELF::Core::ThreadInfo m_thread_info;
Vector<Entry> m_entries;
};
diff --git a/Userland/Libraries/LibCoreDump/Reader.cpp b/Userland/Libraries/LibCoreDump/Reader.cpp
index d489520af5..843513e04c 100644
--- a/Userland/Libraries/LibCoreDump/Reader.cpp
+++ b/Userland/Libraries/LibCoreDump/Reader.cpp
@@ -26,7 +26,6 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
-#include <LibCoreDump/Backtrace.h>
#include <LibCoreDump/Reader.h>
#include <signal_numbers.h>
#include <string.h>
@@ -161,11 +160,6 @@ const ELF::Core::MemoryRegionInfo* Reader::region_containing(FlatPtr address) co
return ret;
}
-const Backtrace Reader::backtrace() const
-{
- return Backtrace(*this);
-}
-
int Reader::process_pid() const
{
auto process_info = this->process_info();
diff --git a/Userland/Libraries/LibCoreDump/Reader.h b/Userland/Libraries/LibCoreDump/Reader.h
index dbba53fa4d..15a7f38198 100644
--- a/Userland/Libraries/LibCoreDump/Reader.h
+++ b/Userland/Libraries/LibCoreDump/Reader.h
@@ -30,7 +30,6 @@
#include <AK/MappedFile.h>
#include <AK/Noncopyable.h>
#include <AK/OwnPtr.h>
-#include <LibCoreDump/Forward.h>
#include <LibELF/CoreDump.h>
#include <LibELF/Image.h>
@@ -63,8 +62,6 @@ public:
};
const LibraryData* library_containing(FlatPtr address) const;
- const Backtrace backtrace() const;
-
int process_pid() const;
u8 process_termination_signal() const;
String process_executable_path() const;