You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
1.7 KiB
110 lines
1.7 KiB
#include <stdio.h> |
|
#include <string.h> |
|
#include <stdlib.h> |
|
#include <stdint.h> |
|
#include <signal.h> |
|
#include <syscall.h> |
|
|
|
#include <unistd.h> |
|
#include <errno.h> |
|
#include <assert.h> |
|
#include <fcntl.h> |
|
|
|
#include <sys/uio.h> |
|
#include <sys/types.h> |
|
#include <sys/user.h> |
|
#include <sys/ptrace.h> |
|
#include <sys/wait.h> |
|
#include <sys/stat.h> |
|
#include <sys/mman.h> |
|
#include <sys/personality.h> |
|
|
|
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)
|
|
|