Debugger.hx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package cpp.vm;
  2. import haxe.Stack;
  3. class Debugger
  4. {
  5. public static inline var BRK_THIS = -2;
  6. public static inline var BRK_TERMINATE = -1;
  7. public static inline var BRK_NONE = 0;
  8. public static inline var BRK_ASAP = 1;
  9. public static inline var BRK_STEP = 2;
  10. public static inline var BRK_ENTER = 3;
  11. public static inline var BRK_LEAVE = 4;
  12. public static function setHandler(inHandler:Void->Void)
  13. {
  14. untyped __global__.__hxcpp_dbg_set_handler(inHandler);
  15. }
  16. public static function setThread(?inDebugThread:Thread)
  17. {
  18. untyped __global__.__hxcpp_dbg_set_thread(inDebugThread==null?Thread.current().handle:inDebugThread.handle);
  19. }
  20. // Generate a handler callback ASAP
  21. public static function setBreak(inMode:Int)
  22. {
  23. untyped __global__.__hxcpp_dbg_set_break(inMode);
  24. }
  25. public static function exit()
  26. {
  27. untyped __global__.__hxcpp_dbg_set_break(BRK_TERMINATE);
  28. }
  29. public static function breakBad()
  30. {
  31. untyped __global__.__hxcpp_dbg_set_break(BRK_THIS);
  32. }
  33. // Breakpoint
  34. public static function addBreakpoint(inFileId:Int, inLine:Int)
  35. {
  36. untyped __global__.__hxcpp_breakpoints_add(inFileId, inLine);
  37. }
  38. public static function getBreakpoints() : Array<String>
  39. {
  40. return untyped __global__.__hxcpp_dbg_breakpoints_get();
  41. }
  42. public static function deleteBreakpoint(inI:Int)
  43. {
  44. untyped __global__.__hxcpp_dbg_breakpoints_delete(inI);
  45. }
  46. // Thread - todo
  47. // public static function suspendAll()
  48. // Callstack
  49. public static function getStackFrames() : Array<haxe.StackItem>
  50. {
  51. return untyped __global__.__hxcpp_dbg_stack_frames_get();
  52. }
  53. public static function getStackVars(inFrame:Int) : Array<String>
  54. {
  55. return untyped __global__.__hxcpp_dbg_get_stack_vars(inFrame);
  56. }
  57. public static function getStackVar(inFrame:Int,inVar:String) : Dynamic
  58. {
  59. return untyped __global__.__hxcpp_dbg_get_stack_var(inFrame,inVar);
  60. }
  61. public static function setStackVar(inFrame:Int,inVar:String, inValue:Dynamic)
  62. {
  63. untyped __global__.__hxcpp_dbg_set_stack_var(inFrame,inVar,inValue);
  64. }
  65. public static function getFiles() : Array<String>
  66. {
  67. return untyped __global__.__hxcpp_dbg_get_files();
  68. }
  69. }