snap.h 985 B

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