mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibDebug: Move everything into the "Debug" namespace
This commit is contained in:
parent
b58ca7cf3d
commit
694b86a4bf
31 changed files with 115 additions and 85 deletions
|
@ -33,6 +33,8 @@
|
|||
|
||||
//#define DEBUG_SPAM
|
||||
|
||||
namespace Debug {
|
||||
|
||||
DebugInfo::DebugInfo(NonnullRefPtr<const ELF::Loader> elf)
|
||||
: m_elf(elf)
|
||||
, m_dwarf_info(Dwarf::DwarfInfo::create(m_elf))
|
||||
|
@ -107,9 +109,9 @@ void DebugInfo::prepare_lines()
|
|||
auto buffer = section.wrapping_byte_buffer();
|
||||
InputMemoryStream stream { buffer };
|
||||
|
||||
Vector<LineProgram::LineInfo> all_lines;
|
||||
Vector<Dwarf::LineProgram::LineInfo> all_lines;
|
||||
while (!stream.eof()) {
|
||||
LineProgram program(stream);
|
||||
Dwarf::LineProgram program(stream);
|
||||
all_lines.append(program.lines());
|
||||
}
|
||||
|
||||
|
@ -331,7 +333,9 @@ Vector<DebugInfo::SourcePosition> DebugInfo::source_lines_in_scope(const Variabl
|
|||
return source_lines;
|
||||
}
|
||||
|
||||
DebugInfo::SourcePosition DebugInfo::SourcePosition::from_line_info(const LineProgram::LineInfo& line)
|
||||
DebugInfo::SourcePosition DebugInfo::SourcePosition::from_line_info(const Dwarf::LineProgram::LineInfo& line)
|
||||
{
|
||||
return { line.file, line.line, line.address };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include <LibELF/Loader.h>
|
||||
#include <sys/arch/i386/regs.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
class DebugInfo {
|
||||
public:
|
||||
explicit DebugInfo(NonnullRefPtr<const ELF::Loader> elf);
|
||||
|
@ -48,7 +50,7 @@ public:
|
|||
bool operator==(const SourcePosition& other) const { return file_path == other.file_path && line_number == other.line_number; }
|
||||
bool operator!=(const SourcePosition& other) const { return !(*this == other); }
|
||||
|
||||
static SourcePosition from_line_info(const LineProgram::LineInfo&);
|
||||
static SourcePosition from_line_info(const Dwarf::LineProgram::LineInfo&);
|
||||
};
|
||||
|
||||
struct VariableInfo {
|
||||
|
@ -119,5 +121,7 @@ private:
|
|||
NonnullRefPtr<Dwarf::DwarfInfo> m_dwarf_info;
|
||||
|
||||
Vector<VariablesScope> m_scopes;
|
||||
Vector<LineProgram::LineInfo> m_sorted_lines;
|
||||
Vector<Dwarf::LineProgram::LineInfo> m_sorted_lines;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
DebugSession::DebugSession(int pid)
|
||||
: m_debugee_pid(pid)
|
||||
, m_executable(initialize_executable_mapped_file(pid))
|
||||
|
@ -263,3 +265,5 @@ void* DebugSession::single_step()
|
|||
set_registers(regs);
|
||||
return (void*)regs.eip;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace Debug {
|
||||
|
||||
class DebugSession {
|
||||
public:
|
||||
static OwnPtr<DebugSession> exec_and_attach(const String& command);
|
||||
|
@ -243,3 +245,5 @@ void DebugSession::run(Callback callback)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <AK/Stream.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
AbbreviationsMap::AbbreviationsMap(const DwarfInfo& dwarf_info, u32 offset)
|
||||
: m_dwarf_info(dwarf_info)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class DwarfInfo;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "CompilationUnit.h"
|
||||
#include "DIE.h"
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
CompilationUnit::CompilationUnit(const DwarfInfo& dwarf_info, u32 offset, const CompilationUnitHeader& header)
|
||||
: m_dwarf_info(dwarf_info)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "AbbreviationsMap.h"
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class DwarfInfo;
|
||||
class DIE;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Stream.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
DIE::DIE(const CompilationUnit& unit, u32 offset)
|
||||
: m_compilation_unit(unit)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class CompilationUnit;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <AK/Stream.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
DwarfInfo::DwarfInfo(NonnullRefPtr<const ELF::Loader> elf)
|
||||
: m_elf(elf)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibELF/Loader.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class DwarfInfo : public RefCounted<DwarfInfo> {
|
||||
public:
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Dwarf {
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
struct [[gnu::packed]] CompilationUnitHeader
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <sys/arch/i386/regs.h>
|
||||
|
||||
namespace Dwarf::Expression {
|
||||
namespace Debug::Dwarf::Expression {
|
||||
|
||||
Value evaluate(ReadonlyBytes bytes, const PtraceRegisters& regs)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
class PtraceRegisters;
|
||||
|
||||
namespace Dwarf::Expression {
|
||||
namespace Debug::Dwarf::Expression {
|
||||
|
||||
enum class Type {
|
||||
None,
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
//#define DWARF_DEBUG
|
||||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
LineProgram::LineProgram(InputMemoryStream& stream)
|
||||
: m_stream(stream)
|
||||
{
|
||||
|
@ -252,3 +254,5 @@ void LineProgram::run_program()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
class LineProgram {
|
||||
public:
|
||||
explicit LineProgram(InputMemoryStream& stream);
|
||||
|
@ -55,8 +57,7 @@ private:
|
|||
void handle_standard_opcode(u8 opcode);
|
||||
void handle_sepcial_opcode(u8 opcode);
|
||||
|
||||
struct [[gnu::packed]] UnitHeader32
|
||||
{
|
||||
struct [[gnu::packed]] UnitHeader32 {
|
||||
u32 length;
|
||||
u16 version;
|
||||
u32 header_length;
|
||||
|
@ -113,3 +114,5 @@ private:
|
|||
|
||||
Vector<LineInfo> m_lines;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
|
||||
#include "StackFrameUtils.h"
|
||||
|
||||
namespace StackFrameUtils {
|
||||
namespace Debug::StackFrameUtils {
|
||||
|
||||
Optional<StackFrameInfo> get_info(const DebugSession& session, FlatPtr current_ebp)
|
||||
{
|
||||
auto return_address = session.peek(reinterpret_cast<u32*>(current_ebp + sizeof(FlatPtr)));
|
||||
|
@ -37,4 +38,5 @@ Optional<StackFrameInfo> get_info(const DebugSession& session, FlatPtr current_e
|
|||
StackFrameInfo info = { return_address.value(), next_ebp.value() };
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
#include "LibDebug/DebugSession.h"
|
||||
|
||||
namespace StackFrameUtils {
|
||||
namespace Debug::StackFrameUtils {
|
||||
|
||||
struct StackFrameInfo {
|
||||
FlatPtr return_address;
|
||||
FlatPtr next_ebp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue