mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 12:47:41 +00:00
LibDebug: Assert that we can read the executable of the debugee
This commit is contained in:
parent
3b422564f3
commit
b5f6a1a9e8
2 changed files with 13 additions and 4 deletions
|
@ -30,12 +30,19 @@
|
||||||
|
|
||||||
DebugSession::DebugSession(int pid)
|
DebugSession::DebugSession(int pid)
|
||||||
: m_debugee_pid(pid)
|
: m_debugee_pid(pid)
|
||||||
, m_executable(String::format("/proc/%d/exe", pid))
|
, m_executable(initialize_executable_mapped_file(pid))
|
||||||
, m_elf(ELF::Loader::create(reinterpret_cast<u8*>(m_executable.data()), m_executable.size()))
|
, m_elf(ELF::Loader::create(reinterpret_cast<const u8*>(m_executable->data()), m_executable->size()))
|
||||||
, m_debug_info(m_elf)
|
, m_debug_info(m_elf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NonnullOwnPtr<const MappedFile> DebugSession::initialize_executable_mapped_file(int pid)
|
||||||
|
{
|
||||||
|
auto executable = adopt_own(*new MappedFile(String::format("/proc/%d/exe", pid)));
|
||||||
|
ASSERT(executable->is_valid());
|
||||||
|
return executable;
|
||||||
|
}
|
||||||
|
|
||||||
DebugSession::~DebugSession()
|
DebugSession::~DebugSession()
|
||||||
{
|
{
|
||||||
for (const auto& bp : m_breakpoints) {
|
for (const auto& bp : m_breakpoints) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ public:
|
||||||
|
|
||||||
const ELF::Loader& elf() const { return *m_elf; }
|
const ELF::Loader& elf() const { return *m_elf; }
|
||||||
NonnullRefPtr<const ELF::Loader> elf_ref() const { return m_elf; }
|
NonnullRefPtr<const ELF::Loader> elf_ref() const { return m_elf; }
|
||||||
const MappedFile& executable() const { return m_executable; }
|
const MappedFile& executable() const { return *m_executable; }
|
||||||
const DebugInfo& debug_info() const { return m_debug_info; }
|
const DebugInfo& debug_info() const { return m_debug_info; }
|
||||||
|
|
||||||
enum DebugDecision {
|
enum DebugDecision {
|
||||||
|
@ -119,10 +119,12 @@ private:
|
||||||
// x86 breakpoint instruction "int3"
|
// x86 breakpoint instruction "int3"
|
||||||
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
||||||
|
|
||||||
|
static NonnullOwnPtr<const MappedFile> initialize_executable_mapped_file(int pid);
|
||||||
|
|
||||||
int m_debugee_pid { -1 };
|
int m_debugee_pid { -1 };
|
||||||
bool m_is_debugee_dead { false };
|
bool m_is_debugee_dead { false };
|
||||||
|
|
||||||
MappedFile m_executable;
|
NonnullOwnPtr<const MappedFile> m_executable;
|
||||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||||
DebugInfo m_debug_info;
|
DebugInfo m_debug_info;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue