summaryrefslogblamecommitdiffstats
path: root/debugger.h
blob: 6a3fba7dc3801fbb864e593fe6206096b9aad96c (plain) (tree)
1
2
3
4
5
6
7
8
9

            

                   
                         

                 

                   
 
                          

                       
                             
             
             
 
                        
              
                










                        

                     


                     
                
               

              
                            

                        





                         

                        

                    
             
                
               

               
 
                     

  

                                                                                   
 
                                                        


                                             
                                          
 
                                       




                                           
 
                                                                          
#pragma once

#include <unistd.h>

#include "architecture.h"
#include "list.h"

struct breakpoint {
    LINKEDLIST;

    unsigned long address;
    unsigned long text;
    int installed;
    int previously_installed;
    int hits;
    int user;

    unsigned long stack;
    pid_t tid;
    int enabled;
};

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

struct state {
    LINKEDLIST;
    size_t regsize;
    user_regs_t regs;
    struct list maps;
};

struct process {
    LINKEDLIST;
    pid_t id;
    int child;
    struct list breakpoints;
    struct list threads;
    char status[128];
};

struct thread {
    LINKEDLIST;
    struct process *proc;

    struct list states;
    struct state *state;
    int clearstates;

    pid_t id;
    int stopped;
    int signal;
    int doing;
    int donext;

    char status[128];
};

extern struct breakpoint*add_breakpoint(struct process*proc,unsigned long address);
extern struct breakpoint*get_breakpoint(struct process*proc,unsigned long address);

extern struct process *dbg_attach(pid_t pid, int child);
extern void dbg_detach(struct process *proc);
extern int dbg_free(struct thread *th);

extern int dbg_sync(struct process *proc);

extern int dbg_intr(struct thread *th);
extern int dbg_cont(struct thread *th);
extern int dbg_syscall(struct thread *th);
extern int dbg_stepin(struct thread *th);
extern int dbg_stepover(struct thread *th);
extern int dbg_stepback(struct thread *th);

extern void *deref(struct thread *th, unsigned long address, size_t size);