Skip to content
Andy Li edited this page Jan 27, 2016 · 3 revisions

Basic approach

  1. Check out this repository.
  2. Set it as haxelib, e.g. haxelib dev hxcpp-debugger <path to checkout dir>.
  3. Initialize the debugger in your main method: new debugger.Local(true);
  4. Compile your application with -debug and -D HXCPP_DEBUGGER.
  5. Run your application and debug.

Compilation Example

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.

Usage example

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
Clone this wiki locally