mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous purpose was actually to load executables for the kernel, and that is now handled by the kernel itself. This patch includes some drive-by cleanup in LibDebug and CrashDaemon enabled by the fact that we no longer need to keep the ref-counted ELF::Loader around.
This commit is contained in:
parent
7551a66f73
commit
1e4c010643
24 changed files with 178 additions and 318 deletions
|
@ -35,9 +35,9 @@
|
|||
|
||||
namespace Debug {
|
||||
|
||||
DebugInfo::DebugInfo(NonnullRefPtr<const ELF::Loader> elf)
|
||||
: m_elf(elf)
|
||||
, m_dwarf_info(Dwarf::DwarfInfo::create(m_elf))
|
||||
DebugInfo::DebugInfo(NonnullOwnPtr<const ELF::Image> elf)
|
||||
: m_elf(move(elf))
|
||||
, m_dwarf_info(*m_elf)
|
||||
{
|
||||
prepare_variable_scopes();
|
||||
prepare_lines();
|
||||
|
@ -45,7 +45,7 @@ DebugInfo::DebugInfo(NonnullRefPtr<const ELF::Loader> elf)
|
|||
|
||||
void DebugInfo::prepare_variable_scopes()
|
||||
{
|
||||
m_dwarf_info->for_each_compilation_unit([&](const Dwarf::CompilationUnit& unit) {
|
||||
m_dwarf_info.for_each_compilation_unit([&](const Dwarf::CompilationUnit& unit) {
|
||||
auto root = unit.root_die();
|
||||
parse_scopes_impl(root);
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die)
|
|||
|
||||
void DebugInfo::prepare_lines()
|
||||
{
|
||||
auto section = m_elf->image().lookup_section(".debug_line");
|
||||
auto section = elf().lookup_section(".debug_line");
|
||||
if (section.is_undefined())
|
||||
return;
|
||||
|
||||
|
|
|
@ -33,14 +33,16 @@
|
|||
#include <LibDebug/Dwarf/DIE.h>
|
||||
#include <LibDebug/Dwarf/DwarfInfo.h>
|
||||
#include <LibDebug/Dwarf/LineProgram.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <LibELF/Image.h>
|
||||
#include <sys/arch/i386/regs.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
class DebugInfo {
|
||||
public:
|
||||
explicit DebugInfo(NonnullRefPtr<const ELF::Loader> elf);
|
||||
explicit DebugInfo(NonnullOwnPtr<const ELF::Image>);
|
||||
|
||||
const ELF::Image& elf() const { return *m_elf; }
|
||||
|
||||
struct SourcePosition {
|
||||
FlyString file_path;
|
||||
|
@ -117,8 +119,8 @@ private:
|
|||
void parse_scopes_impl(const Dwarf::DIE& die);
|
||||
OwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&) const;
|
||||
|
||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||
NonnullRefPtr<Dwarf::DwarfInfo> m_dwarf_info;
|
||||
NonnullOwnPtr<const ELF::Image> m_elf;
|
||||
Dwarf::DwarfInfo m_dwarf_info;
|
||||
|
||||
Vector<VariablesScope> m_scopes;
|
||||
Vector<Dwarf::LineProgram::LineInfo> m_sorted_lines;
|
||||
|
|
|
@ -33,8 +33,7 @@ namespace Debug {
|
|||
DebugSession::DebugSession(pid_t pid)
|
||||
: m_debuggee_pid(pid)
|
||||
, m_executable(map_executable_for_process(pid))
|
||||
, m_elf(ELF::Loader::create(reinterpret_cast<const u8*>(m_executable.data()), m_executable.size()))
|
||||
, m_debug_info(m_elf)
|
||||
, m_debug_info(make<ELF::Image>(reinterpret_cast<const u8*>(m_executable.data()), m_executable.size()))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibC/sys/arch/i386/regs.h>
|
||||
#include <LibDebug/DebugInfo.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ptrace.h>
|
||||
|
@ -99,8 +98,7 @@ public:
|
|||
template<typename Callback>
|
||||
void run(Callback callback);
|
||||
|
||||
const ELF::Loader& elf() const { return *m_elf; }
|
||||
NonnullRefPtr<const ELF::Loader> elf_ref() const { return m_elf; }
|
||||
const ELF::Image& elf() const { return m_debug_info.elf(); }
|
||||
const MappedFile& executable() const { return m_executable; }
|
||||
const DebugInfo& debug_info() const { return m_debug_info; }
|
||||
|
||||
|
@ -130,7 +128,6 @@ private:
|
|||
bool m_is_debuggee_dead { false };
|
||||
|
||||
MappedFile m_executable;
|
||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||
DebugInfo m_debug_info;
|
||||
|
||||
HashMap<void*, BreakPoint> m_breakpoints;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
DwarfInfo::DwarfInfo(NonnullRefPtr<const ELF::Loader> elf)
|
||||
DwarfInfo::DwarfInfo(const ELF::Image& elf)
|
||||
: m_elf(elf)
|
||||
{
|
||||
m_debug_info_data = section_data(".debug_info");
|
||||
|
@ -42,7 +42,7 @@ DwarfInfo::DwarfInfo(NonnullRefPtr<const ELF::Loader> elf)
|
|||
|
||||
ReadonlyBytes DwarfInfo::section_data(const String& section_name) const
|
||||
{
|
||||
auto section = m_elf->image().lookup_section(section_name);
|
||||
auto section = m_elf.lookup_section(section_name);
|
||||
if (section.is_undefined())
|
||||
return {};
|
||||
return section.bytes();
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <LibELF/Image.h>
|
||||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class DwarfInfo : public RefCounted<DwarfInfo> {
|
||||
class DwarfInfo {
|
||||
public:
|
||||
static NonnullRefPtr<DwarfInfo> create(NonnullRefPtr<const ELF::Loader> elf) { return adopt(*new DwarfInfo(move(elf))); }
|
||||
explicit DwarfInfo(const ELF::Image&);
|
||||
|
||||
ReadonlyBytes debug_info_data() const { return m_debug_info_data; }
|
||||
ReadonlyBytes abbreviation_data() const { return m_abbreviation_data; }
|
||||
|
@ -48,12 +48,11 @@ public:
|
|||
void for_each_compilation_unit(Callback) const;
|
||||
|
||||
private:
|
||||
explicit DwarfInfo(NonnullRefPtr<const ELF::Loader> elf);
|
||||
void populate_compilation_units();
|
||||
|
||||
ReadonlyBytes section_data(const String& section_name) const;
|
||||
|
||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||
const ELF::Image& m_elf;
|
||||
ReadonlyBytes m_debug_info_data;
|
||||
ReadonlyBytes m_abbreviation_data;
|
||||
ReadonlyBytes m_debug_strings_data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue