jingoro2112 / wrench

practical embedded script interpreter
MIT License
108 stars 10 forks source link

WRD_DebugOut breaks code debugging #43

Open darksotmoon opened 4 months ago

darksotmoon commented 4 months ago

Test script

debug::print("debug out");
str::printf("end");

The first single step will stop on line 1 as expected. Client sends WRD_RequestStepInto, server executes script and sends back WRD_Ok.

Then the next single step will fail. What happens is that the client WRDebugClientInterfacePrivate::trapRunOutput will send WRD_RequestStepInto, then the server executes the code, which involves sending back WRD_DebugOut then WRD_Ok.

WRDebugClientInterfacePrivate::trapRunOutput will receive WRD_DebugOut in the loop and then send the WRD_RequestStepInto again. The server executes this and sends back WRD_Ok so the client ends up with three WRD_Ok replies. Not sure where the third WRD_Ok comes from.

The problem is that WRDebugClientInterfacePrivate::transmit is really transmit_receive so it can't receive two packets ( WRD_DebugOut then WRD_Ok) without transmitting again.

I renamed transmit to transmit_receive and then added transmit and receive functions. Then WRDebugClientInterfacePrivate::trapRunOutput looks like:

if(transmit( WrenchPacketScoped(WrenchPacket::alloc(packet)) ))
{
    bool done = false;
    while(!done)
    {
        WrenchPacket *reply = receive();
        if(reply)
        {
            if( reply->_type == WRD_DebugOut )
            {
                printf( "%s", (char*)reply->payload() );
            }
            else
                done = true;
            g_free( reply );
        }
    }
}
jingoro2112 commented 4 months ago

okay I'll look into this as soon as I can, but I am off for the week :)

On Tue, Jul 2, 2024 at 10:23 PM darksotmoon @.***> wrote:

Test script

debug::print("debug out"); str::printf("end");

The first single step will stop on line 1 as expected. Client sends WRD_RequestStepInto, server executes script and sends back WRD_Ok.

Then the next single step will fail. What happens is that the client WRDebugClientInterfacePrivate::trapRunOutput will send WRD_RequestStepInto, then the server executes the code, which involves sending back WRD_DebugOut then WRD_Ok.

WRDebugClientInterfacePrivate::trapRunOutput will receive WRD_DebugOut in the loop and then send the WRD_RequestStepInto again. The server executes this and sends back WRD_Ok so the client ends up with three WRD_Ok replies. Not sure where the third WRD_Ok comes from.

The problem is that WRDebugClientInterfacePrivate::transmit is really transmit_receive so it can't receive two packets ( WRD_DebugOut then WRD_Ok) without transmitting again.

I renamed transmit to transmit_receive and then added transmit and receive functions. Then WRDebugClientInterfacePrivate::trapRunOutput looks like:

if(transmit( WrenchPacketScoped(WrenchPacket::alloc(packet)) )) { bool done = false; while(!done) { WrenchPacket reply = receive(); if(reply) { if( reply->_type == WRD_DebugOut ) { printf( "%s", (char)reply->payload() ); } else done = true; g_free( reply ); } } }

— Reply to this email directly, view it on GitHub https://github.com/jingoro2112/wrench/issues/43, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALIKAZ7I2SGJYPSA5FLI7LZKNOANAVCNFSM6AAAAABKIUGZJCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4DONBZGU2TANQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jingoro2112 commented 1 month ago

just noting I have not forgotten, but debug remains buggy and until I need it is not going to get any love.

darksotmoon commented 1 month ago

That's ok by me. The non-debug functionality is working just fine.