#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; #include "elf_dwarf.h" struct mi_buffer { u8 *data; u64 size; }; struct mi_sourcepoint { u64 pc; int line; int column; int file; }; struct mi_function { char *name; int comp_unit; u64 low_pc; u64 high_pc; }; struct mi_sourcefile { char *filename; char *dir; struct mi_buffer file; }; struct mi_compunit { u64 low_pc; u64 high_pc; struct mi_sourcepoint *sp_table; int sp_count; int source_file_count; struct mi_sourcefile *source_files; char **source_directories; int source_dirs_count; char *comp_dir; }; struct mi_debuginfo { struct mi_compunit compilation_units[16]; // TODO int cu_count; struct mi_function functions[64]; // TODO int func_count; }; struct mi_process { pid_t pid; u8 *elf; u64 elf_size; u64 base_address; u64 main_address; struct mi_debuginfo debug; }; struct mi_registers { u64 rbp; u64 rbx; u64 rax; u64 rcx; u64 rdx; u64 rsi; u64 rdi; u64 rip; u64 rsp; struct user_regs_struct _sys; }; #define NT_PRSTATUS 1 #define DIE(string) do { fprintf(stderr, string); exit(1); } while (0)