gdb-extract-def 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # Invocation: gdb -x gdb-extract-def
  2. # extract-state /path/to/foo.bin /path/to/foo.fixture
  3. define extract-state
  4. file $arg0
  5. set $STACK_TOP=0x120000
  6. # Disables logging to stdout - only log to file
  7. set logging redirect on
  8. set logging file $arg1
  9. set logging overwrite on
  10. set logging on
  11. run
  12. printf "---BEGIN JSON---\n"
  13. printf "[\n"
  14. printf " %d,\n", $eax
  15. printf " %d,\n", $ecx
  16. printf " %d,\n", $edx
  17. printf " %d,\n", $ebx
  18. printf " %d,\n", $esp
  19. printf " %d,\n", $ebp
  20. printf " %d,\n", $esi
  21. printf " %d,\n", $edi
  22. printf " \n"
  23. printf " %d,\n", $mm0.v2_int32[0]
  24. printf " %d,\n", $mm0.v2_int32[1]
  25. printf " %d,\n", $mm1.v2_int32[0]
  26. printf " %d,\n", $mm1.v2_int32[1]
  27. printf " %d,\n", $mm2.v2_int32[0]
  28. printf " %d,\n", $mm2.v2_int32[1]
  29. printf " %d,\n", $mm3.v2_int32[0]
  30. printf " %d,\n", $mm3.v2_int32[1]
  31. printf " %d,\n", $mm4.v2_int32[0]
  32. printf " %d,\n", $mm4.v2_int32[1]
  33. printf " %d,\n", $mm5.v2_int32[0]
  34. printf " %d,\n", $mm5.v2_int32[1]
  35. printf " %d,\n", $mm6.v2_int32[0]
  36. printf " %d,\n", $mm6.v2_int32[1]
  37. printf " %d,\n", $mm7.v2_int32[0]
  38. printf " %d,\n", $mm7.v2_int32[1]
  39. printf " \n"
  40. printf " %d,\n", $xmm0.v4_int32[0]
  41. printf " %d,\n", $xmm0.v4_int32[1]
  42. printf " %d,\n", $xmm0.v4_int32[2]
  43. printf " %d,\n", $xmm0.v4_int32[3]
  44. printf " %d,\n", $xmm1.v4_int32[0]
  45. printf " %d,\n", $xmm1.v4_int32[1]
  46. printf " %d,\n", $xmm1.v4_int32[2]
  47. printf " %d,\n", $xmm1.v4_int32[3]
  48. printf " %d,\n", $xmm2.v4_int32[0]
  49. printf " %d,\n", $xmm2.v4_int32[1]
  50. printf " %d,\n", $xmm2.v4_int32[2]
  51. printf " %d,\n", $xmm2.v4_int32[3]
  52. printf " %d,\n", $xmm3.v4_int32[0]
  53. printf " %d,\n", $xmm3.v4_int32[1]
  54. printf " %d,\n", $xmm3.v4_int32[2]
  55. printf " %d,\n", $xmm3.v4_int32[3]
  56. printf " %d,\n", $xmm4.v4_int32[0]
  57. printf " %d,\n", $xmm4.v4_int32[1]
  58. printf " %d,\n", $xmm4.v4_int32[2]
  59. printf " %d,\n", $xmm4.v4_int32[3]
  60. printf " %d,\n", $xmm5.v4_int32[0]
  61. printf " %d,\n", $xmm5.v4_int32[1]
  62. printf " %d,\n", $xmm5.v4_int32[2]
  63. printf " %d,\n", $xmm5.v4_int32[3]
  64. printf " %d,\n", $xmm6.v4_int32[0]
  65. printf " %d,\n", $xmm6.v4_int32[1]
  66. printf " %d,\n", $xmm6.v4_int32[2]
  67. printf " %d,\n", $xmm6.v4_int32[3]
  68. printf " %d,\n", $xmm7.v4_int32[0]
  69. printf " %d,\n", $xmm7.v4_int32[1]
  70. printf " %d,\n", $xmm7.v4_int32[2]
  71. printf " %d,\n", $xmm7.v4_int32[3]
  72. printf " \n"
  73. printf " %d,\n", *(int*)($STACK_TOP-64)
  74. printf " %d,\n", *(int*)($STACK_TOP-60)
  75. printf " %d,\n", *(int*)($STACK_TOP-56)
  76. printf " %d,\n", *(int*)($STACK_TOP-52)
  77. printf " %d,\n", *(int*)($STACK_TOP-48)
  78. printf " %d,\n", *(int*)($STACK_TOP-44)
  79. printf " %d,\n", *(int*)($STACK_TOP-40)
  80. printf " %d,\n", *(int*)($STACK_TOP-36)
  81. printf " %d,\n", *(int*)($STACK_TOP-32)
  82. printf " %d,\n", *(int*)($STACK_TOP-28)
  83. printf " %d,\n", *(int*)($STACK_TOP-24)
  84. printf " %d,\n", *(int*)($STACK_TOP-20)
  85. printf " %d,\n", *(int*)($STACK_TOP-16)
  86. printf " %d,\n", *(int*)($STACK_TOP-12)
  87. printf " %d,\n", *(int*)($STACK_TOP-8)
  88. printf " %d,\n", *(int*)($STACK_TOP-4)
  89. printf " \n"
  90. printf " %d\n", $eflags
  91. printf "]\n"
  92. printf "---END JSON---\n"
  93. set logging off
  94. end