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.
|
|
|
#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;
|
|
|
|
u64 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mi_debuginfo {
|
|
|
|
struct mi_sourcepoint *sp_table;
|
|
|
|
int sp_count;
|
|
|
|
|
|
|
|
struct mi_function functions[64]; // TODO
|
|
|
|
int func_count;
|
|
|
|
|
|
|
|
char *comp_dir;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mi_process {
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
u8 *elf;
|
|
|
|
u64 elf_size;
|
|
|
|
|
|
|
|
u64 base_address;
|
|
|
|
u64 main_address;
|
|
|
|
|
|
|
|
struct mi_debuginfo debug;
|
|
|
|
|
|
|
|
char **source_file_names;
|
|
|
|
struct mi_buffer *source_files;
|
|
|
|
int source_file_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|