summaryrefslogblamecommitdiffstats
path: root/debugger.h
blob: 6305e964fcd5659cab65a64fbd72ae8c368d6dda (plain) (tree)






















































                                                                                  
#pragma once

#include <sys/user.h>
#include <unistd.h>

#include "console.h"
#include "list.h"

#define BREAKPOINT_INSN 0xcc

struct breakpoint {
    LINKEDLIST;
    unsigned long address;
    unsigned long stack;
    unsigned long orig;
    int enabled;
    int active;
};

struct map {
    LINKEDLIST;
    unsigned long start;
    unsigned long end;
    void *data;
};

struct state {
    LINKEDLIST;
    struct user_regs_struct regs;
    struct user_fpregs_struct fpregs;
    struct list maps;
};

struct tracee {
    struct list breaks;
    struct list states;
    struct state *state;
    pid_t id;
    int child;
    int stopped;
    int status;
    int signal;
    int cont;
    void *buff;
    size_t buffsize;
};

extern int dbg_process(struct tracee *dbg, pid_t pid);
extern int dbg_new_process(struct tracee *dbg, char **argv, struct console *cons);
extern int dbg_wait(struct tracee *dbg);
extern int dbg_stepin(struct tracee *dbg);
extern int dbg_stepover(struct tracee *dbg);
//extern int dbg_stepout(struct tracee *dbg);
extern int dbg_cont(struct tracee *dbg, int mode);
extern void *deref(struct tracee *dbg, unsigned long addr, size_t size);