1
0

vcpudebug.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include <precomp.h>
  2. #include <wasabicfg.h>
  3. #include "vcpudebug.h"
  4. #include <api/script/debugger/jitd.h>
  5. VCPUDebugger::VCPUDebugger() {
  6. filter.setFilterObject(&reentryfilter);
  7. }
  8. VCPUDebugger::~VCPUDebugger() {
  9. }
  10. // ------------------------------------------------------------------------
  11. // instruction pointer
  12. int VCPUDebugger::getVIP() {
  13. return WASABI_API_MAKIDEBUG->debugger_getVIP();
  14. }
  15. // script descriptor (vcpuid)
  16. int VCPUDebugger::getVSD() {
  17. return WASABI_API_MAKIDEBUG->debugger_getVSD();
  18. }
  19. // variables stack pointer
  20. int VCPUDebugger::getVSP() {
  21. return WASABI_API_MAKIDEBUG->debugger_getVSP();
  22. }
  23. // call stack pointer
  24. int VCPUDebugger::getVCC() {
  25. return WASABI_API_MAKIDEBUG->debugger_getVCC();
  26. }
  27. // ------------------------------------------------------------------------
  28. void VCPUDebugger::trace() {
  29. int i;
  30. for (i=0;i<jitds.getNumItems();i++) {
  31. MakiJITD *jitd = jitds.enumItem(i);
  32. if (jitd->getVCPUId() == getVSD()) {
  33. jitd->trace();
  34. }
  35. }
  36. }
  37. MakiJITD *VCPUDebugger::getJITD(int vcpuid) {
  38. int i;
  39. for (i=0;i<jitds.getNumItems();i++) {
  40. MakiJITD *jitd = jitds.enumItem(i);
  41. if (jitd->getVCPUId() == vcpuid)
  42. return jitd;
  43. }
  44. return NULL;
  45. }
  46. // if this returns 1, you should not call eventComplete!
  47. int VCPUDebugger::filterEvent(int vcpuid, int eventid) {
  48. MakiJITD *jitd = getJITD(vcpuid);
  49. if (!jitd || !jitd->isOnHold()) {
  50. WASABI_API_WND->pushModalWnd();
  51. scopestack.push(0);
  52. return 0;
  53. }
  54. filter.enterScope((vcpuid<<16) + eventid); // (vcpuid<<16) + eventid
  55. if (filter.mustLeave()) {
  56. filter.leaveScope();
  57. return 1;
  58. }
  59. WASABI_API_WND->pushModalWnd();
  60. scopestack.push(1);
  61. return 0;
  62. }
  63. void VCPUDebugger::eventComplete() {
  64. int n;
  65. scopestack.pop(&n);
  66. WASABI_API_WND->popModalWnd();
  67. if (n) {
  68. filter.leaveScope();
  69. }
  70. }
  71. int VCPUDebugger::isActive() {
  72. foreach(jitds)
  73. if (jitds.getfor()->isActive())
  74. return 1;
  75. endfor;
  76. return 0;
  77. }
  78. MakiJITD *VCPUDebugger::createJITD(int vcpuid) {
  79. MakiJITD *jitd = new MakiJITD(this, vcpuid);
  80. jitds.addItem(jitd);
  81. return jitd;
  82. }
  83. const char *VCPUDebugger::getCodeBlock(int vcpuid) {
  84. return WASABI_API_MAKIDEBUG->debugger_getCodeBlock(vcpuid);
  85. }