1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:27:35 +00:00

Debugger: Add source-level operations

- Print current source location, if available
- Add a breakpoint at a source location
- "sl" command - step to the next line in source
This commit is contained in:
Itamar 2020-04-19 23:33:06 +03:00 committed by Andreas Kling
parent 8a886e0e96
commit e35219b5ce
4 changed files with 72 additions and 14 deletions

View file

@ -29,10 +29,12 @@
#include <AK/Demangle.h>
#include <AK/HashMap.h>
#include <AK/MappedFile.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <AK/OwnPtr.h>
#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>
@ -85,8 +87,10 @@ public:
template<typename Callback>
void run(Callback callback);
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; }
const MappedFile& executable() const { return m_executable; }
const DebugInfo& debug_info() const { return m_debug_info; }
enum DebugDecision {
Continue,
@ -104,14 +108,14 @@ public:
private:
// x86 breakpoint instruction "int3"
static constexpr u8 BREAKPOINT_INSTRUCTION
= 0xcc;
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
int m_debugee_pid { -1 };
bool m_is_debugee_dead { false };
MappedFile m_executable;
ELF::Loader m_elf;
NonnullRefPtr<const ELF::Loader> m_elf;
DebugInfo m_debug_info;
HashMap<void*, BreakPoint> m_breakpoints;
};