.gdbinit 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #
  2. # This is very much a work in progress to show how we can use macros to make the
  3. # GDB interface a lot more useable. For example the next / step commands only
  4. # work if the stepper doesn't leave the current scope. Beyond that you have a
  5. # single hardware breakpoint which can be used as an hb or a wa. You have to
  6. # remember to delete the previous one, so the br macro does this for you.
  7. #
  8. set confirm off
  9. set print null-stop
  10. define br
  11. d
  12. hb $arg0
  13. end
  14. set pagination off
  15. define prTV
  16. if $arg0
  17. set $type = $arg0.tt
  18. set $val = $arg0.value
  19. if $type == 0
  20. # NIL
  21. printf "Nil\n"
  22. end
  23. if $type == 1
  24. # Boolean
  25. printf "Boolean: %u\n", $val->n
  26. end
  27. if $type == 2
  28. # ROTable
  29. printf "ROTable: %p\n", $val->p
  30. end
  31. if $type == 3
  32. # Light Function
  33. printf "Light Func: %p\n",p $arg $val->p
  34. end
  35. if $type == 4
  36. # Light User Data
  37. printf "Light Udata: %p\n", $val->pend
  38. end
  39. if $type == 5
  40. # Number
  41. printf "Boolean: %u\n", $val->n
  42. end
  43. if $type == 6
  44. # TString
  45. set $o = &($val.gc->ts.tsv)
  46. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  47. printf "String: hash = 0x%08x, len = %u : %s\n", $o->hash, $o->len, (char *)($ts+1)
  48. end
  49. if $type == 7
  50. # Table
  51. __printComHdr $arg0
  52. set $ts = (TString *)$val->p
  53. end
  54. if $type == 8
  55. # Function
  56. set $o = &($val->gc.cl.c)
  57. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  58. if $o->isC == 0
  59. set $o = &($val->gc.cl.l)
  60. printf "LClosure: nupvalues = %u, gclist = %p, env = %p, p = %p\n", $o->nupvalues, $o->gclist, $o->env, $o->p
  61. else
  62. printf "CClosure: nupvalues = %u, gclist = %p, env = %p, f = %p\np", $o->nupvalues, $o->gclist, $o->env, $o->f
  63. end
  64. end
  65. if $type == 9
  66. # UserData
  67. end
  68. if $type == 10
  69. # Thread
  70. end
  71. end
  72. end
  73. define prL
  74. if L > 0
  75. printf " stack: %u\n", L->top-L->base
  76. printf " hooking: %u, %u, %u, %u, %p\n", L->hookmask, L->allowhook, L->basehookcount, L->hookcount, L->hook
  77. end
  78. end
  79. define dumpstrt
  80. set $st = $arg0
  81. set $i = 0
  82. while $i< $st->size
  83. set $o = &(((TString *)($st->hash[$i]))->tsv)
  84. while $o
  85. if $o->next
  86. printf "Slot: %5i %p %p %08x %02x %4u", $i, $o, $o->next, $o->hash, $o->marked, $o->len
  87. else
  88. printf "Slot: %5i %p %08x %02x %4u", $i, $o, $o->hash, $o->marked, $o->len
  89. end
  90. if $o->marked & 0x80
  91. printf "* %s\n", *(char **)($o+1)
  92. else
  93. printf " %s\n", (char *)($o+1)
  94. end
  95. set $o = &(((TString *)($o->next))->tsv)
  96. end
  97. set $i = $i + 1
  98. end
  99. end
  100. define dumpRAMstrt
  101. dumpstrt &(L->l_G->strt)
  102. end
  103. set history save on
  104. set history size 1000