-
Notifications
You must be signed in to change notification settings - Fork 16
Getting started
Andy Li edited this page Jan 27, 2016
·
3 revisions
- Check out this repository.
- Set it as haxelib, e.g.
haxelib dev hxcpp-debugger <path to checkout dir>
. - Initialize the debugger in your
main
method:new debugger.Local(true);
- Compile your application with
-debug
and-D HXCPP_DEBUGGER
. - Run your application and debug.
We want to debug this application:
class Main {
static public function main() {
new debugger.Local(true);
trace(test(null));
}
static function test(a:String) {
return a.charAt(0);
}
}
Assuming this is saved as Main.hx
, the compilation command is: haxe -main Main -D HXCPP_DEBUGGER -lib hxcpp-debugger -debug -cpp bin
.
After this we can cd bin
and execute the executable there. It should greet us like this:
-=- hxcpp built-in debugger in command line mode -=-
-=- Use 'help' for help if you need it. -=-
-=- Have fun! -=-
1> Thread 0 stopped in 0.Main() at main:0.
We suspect that there's a problem in our test
method, so we set a breakpoint there:
break Main.test
Breakpoint 1 set and enabled.
After that we can resume execution:
2> continue
3> Thread 0 stopped in 1.Main() at test:0.
We hit our breakpoint, so let's see what variables we have here:
variables
a
Let's look at the value of a
:
4> print a
a : NULL = null
Apparently someone passed null
in and we forgot to check for that. This concludes our debugging session, but let's see what would have happened if someone passed "foo"
in instead:
5> set a = "foo"
a : String = "foo"
6> continue
7> Main.hx:4: f