Debugger.hx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C)2005-2012 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package cpp.vm;
  23. import haxe.CallStack;
  24. class Debugger
  25. {
  26. public static inline var BRK_THIS = -2;
  27. public static inline var BRK_TERMINATE = -1;
  28. public static inline var BRK_NONE = 0;
  29. public static inline var BRK_ASAP = 1;
  30. public static inline var BRK_STEP = 2;
  31. public static inline var BRK_ENTER = 3;
  32. public static inline var BRK_LEAVE = 4;
  33. public static function setHandler(inHandler:Void->Void)
  34. {
  35. untyped __global__.__hxcpp_dbg_set_handler(inHandler);
  36. }
  37. public static function setThread(?inDebugThread:Thread)
  38. {
  39. untyped __global__.__hxcpp_dbg_set_thread(inDebugThread==null?Thread.current().handle:inDebugThread.handle);
  40. }
  41. // Generate a handler callback ASAP
  42. public static function setBreak(inMode:Int)
  43. {
  44. untyped __global__.__hxcpp_dbg_set_break(inMode);
  45. }
  46. public static function exit()
  47. {
  48. untyped __global__.__hxcpp_dbg_set_break(BRK_TERMINATE);
  49. }
  50. public static function breakBad()
  51. {
  52. untyped __global__.__hxcpp_dbg_set_break(BRK_THIS);
  53. }
  54. // Breakpoint
  55. public static function addBreakpoint(inFileId:Int, inLine:Int)
  56. {
  57. untyped __global__.__hxcpp_breakpoints_add(inFileId, inLine);
  58. }
  59. public static function getBreakpoints() : Array<String>
  60. {
  61. return untyped __global__.__hxcpp_dbg_breakpoints_get();
  62. }
  63. public static function deleteBreakpoint(inI:Int)
  64. {
  65. untyped __global__.__hxcpp_dbg_breakpoints_delete(inI);
  66. }
  67. // Thread - todo
  68. // public static function suspendAll()
  69. // Callstack
  70. public static function getStackFrames() : Array<haxe.StackItem>
  71. {
  72. return untyped __global__.__hxcpp_dbg_stack_frames_get();
  73. }
  74. public static function getStackVars(inFrame:Int) : Array<String>
  75. {
  76. return untyped __global__.__hxcpp_dbg_get_stack_vars(inFrame);
  77. }
  78. public static function getStackVar(inFrame:Int,inVar:String) : Dynamic
  79. {
  80. return untyped __global__.__hxcpp_dbg_get_stack_var(inFrame,inVar);
  81. }
  82. public static function setStackVar(inFrame:Int,inVar:String, inValue:Dynamic)
  83. {
  84. untyped __global__.__hxcpp_dbg_set_stack_var(inFrame,inVar,inValue);
  85. }
  86. public static function getFiles() : Array<String>
  87. {
  88. return untyped __global__.__hxcpp_dbg_get_files();
  89. }
  90. }