HaxeFoundation / hxcpp-debugger

Cross-platform debugger for hxcpp
Apache License 2.0
49 stars 16 forks source link

Debugger do not stops on breakpoints. #17

Closed nulld closed 7 years ago

nulld commented 7 years ago

My test file: Test.hx

class Point
{
    public var x:Int;
    public var y:Int;
    public function new() {}
}

class Test {
    static var s1:{x:Int, y:Int};

    static function main() {
        new debugger.Local(true);

        trace("Haxe is great!");
        var p = new Point();
        s(p);
    }

    static function s (s:{x:Int, y:Int})
    {
        s1 = s;
        trace( s1.x);
    }
}

build.hxml

-main Test
-cpp bin
-lib hxcpp-debugger
-debug
-D HXCPP_DEBUGGER

debugger cli output After c command, program executes until the end (see the trace from Test.hx:22)

-=- hxcpp built-in debugger in command line mode -=-
-=-      Use 'help' for help if you need it.     -=-
-=-                  Have fun!                   -=-

Thread 0 stopped in Test.main() at Test.hx:14.

1> b Test.hx:21

Breakpoint 1 set and enabled.

2> c

3> Test.hx:14: Haxe is great!
Test.hx:22: 0
Simn commented 7 years ago

I confirm that this doesn't work, even in hello world:

class Main {
    @:analyzer(ignore)
    static function main() {
        new debugger.Local(true);
        var a = 1;
        a = 2;
    }
}
main-debug.exe
-=- hxcpp built-in debugger in command line mode -=-
-=-      Use 'help' for help if you need it.     -=-
-=-                  Have fun!                   -=-
Thread 0 stopped in Main.main() at Main.hx:5.
1> b Main.hx:5
Breakpoint 1 set and enabled.
2> b Main.hx:6
Breakpoint 2 set and enabled.
3> c
4>

The generated .cpp looks fine to me:

HX_LOCAL_STACK_FRAME(_hx_pos_e47a9afac0942eb9_3_main,"Main","main",0xed0e206e,"Main.main","Main.hx",3,0x087e5c05)

void Main_obj::main(){
                HX_GC_STACKFRAME(&_hx_pos_e47a9afac0942eb9_3_main)
HXLINE(   4)         ::debugger::Local_obj::__alloc( HX_CTX ,true);
HXLINE(   5)        HX_VARI( int,a) = (int)1;
HXLINE(   6)        a = (int)2;
                }
Simn commented 7 years ago

@hughsando: If at all possible, could you check if this is a problem with Haxe or hxcpp(-debugger)? It's not so urgent if it's the latter, but if it's related to Haxe we should really try to get it fixed for 3.4.1.

hughsando commented 7 years ago

There was a problem with HXCPP_DEBUG_HASHES was not set. Should be fixed now. Function breakpoints needed a little tweak in the haxe compiler. Not sure about a hang though.

jcward commented 7 years ago

My vscode-hxcpp-debug adapter seems to have breakpoints working again in hxcpp 3.4.64! Thanks @hughsando!

I'm still having issues with the "Step Over" / (aka Next command) functionality, but that could easily be on my end.

jcward commented 7 years ago

Hmm, no, if my understanding of the Next command is correct, next is not working in hxcpp 3.4.64. It's behaving like continue.

For example, with this local debugger testcase:

class Main {
  @:analyzer(ignore)
  static function main() {
    new debugger.Local(true);
    trace("At line 5");
    var a = 1;
    trace("At line 7");
    a = 2;
    trace("At line 9... goodbye!");
  }
}

Here's what happens, next appears to be acting like continue:

>haxe -debug -D HXCPP_DEBUGGER -cp . -lib hxcpp-debugger -main Main -cpp out
...
>./out/Main-debug
-=- hxcpp built-in debugger in command line mode -=-
-=-      Use 'help' for help if you need it.     -=-
-=-                  Have fun!                   -=-

Thread 0 stopped in Main.main() at Main.hx:5.

1> next

2> Main.hx:5: At line 5
Main.hx:7: At line 7
Main.hx:9: At line 9... goodbye!

>

I would expect it to print "At line 5" and then stop at line 6. Is this correct?

I could file a new bug if you'd like, though it seems highly related to this one.

Best, -Jeff

hughsando commented 7 years ago

The step-over issue should be fixed with https://github.com/HaxeFoundation/hxcpp/commit/4a2fbdb4952b9e6ae5b10cb27962e8f10f5fd117

There is still a minor issue where you sometimes have to step twice at the beginning of a function to get going, but this will require a slightly larger fix that I might wait a bit for.

jcward commented 7 years ago

@hughsando - yes, I can confirm that 4a2fbdb / 3.4.69 fixed the step issue. And a debugger testcase too boot, nicely done!

hughsando commented 7 years ago

Feel free to extend the test if you like :)

On Mon, Mar 20, 2017 at 10:46 PM, Jeff Ward notifications@github.com wrote:

@hughsando https://github.com/hughsando - yes, I can confirm that 4a2fbdb / 3.4.69 fixed the step issue. And a debugger testcase too boot, nicely done!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/hxcpp-debugger/issues/17#issuecomment-287781399, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlp1uJWWkzrU5S1nQXmQ7A5TDFYJF4_ks5rnpE-gaJpZM4MTIEt .

nulld commented 7 years ago

@hughsando, thanks for fix.