1 typedef struct Data Data; 2 typedef struct Page Page; 3 typedef struct Proc Proc; 4 typedef struct Seg Seg; 5 6 enum { 7 Psegment = 0, 8 Pfd, 9 Pfpregs, 10 Pkregs, 11 Pnoteid, 12 Pns, 13 Pproc, 14 Pregs, 15 Pstatus, 16 Npfile, 17 18 Pagesize = 1024, /* need not relate to kernel */ 19 }; 20 21 struct Data { 22 ulong len; 23 char data[1]; 24 }; 25 26 struct Seg { 27 char* name; 28 uvlong offset; 29 uvlong len; 30 Page** pg; 31 int npg; 32 }; 33 34 struct Page { 35 Page* link; 36 ulong len; 37 char* data; 38 39 /* when page is written, these hold the ptr to it */ 40 int written; 41 int type; 42 ulong pid; 43 uvlong offset; 44 }; 45 46 struct Proc { 47 Proc *link; 48 long pid; 49 Data* d[Npfile]; 50 Seg** seg; /* memory segments */ 51 int nseg; 52 Seg* text; /* text file */ 53 }; 54 55 extern char *pfile[Npfile]; 56 57 Proc* snap(long pid, int usetext); 58 void* emalloc(ulong); 59 void* erealloc(void*, ulong); 60 char* estrdup(char*); 61 void writesnap(Biobuf*, Proc*); 62 Page* datapage(char *p, long len); 63 Proc* readsnap(Biobuf *b); 64 Page* findpage(Proc *plist, long pid, int type, uvlong off); 65 66 int debug; 67