stefanbesler / twingrind

Call-graph profiling for TwinCAT 3
GNU General Public License v3.0
24 stars 3 forks source link

Pop/Push mismatch #9

Closed captain-yoshi closed 10 months ago

captain-yoshi commented 10 months ago

I have a PLC project which relies on a custom library. When following the procedure, I get his error:

$ twingrind prepare -d /c/ws/TcRobot/TcRobotExample/TcRobotExample -m /c/ws/TcRobot/TcRobotExample/TcRobotExample/hashmap
INFO:root:Updating an existing hashfile
DEBUG:root:DEMO_SIC2: guards added in 1 methods, contains (3 returns)

image

iadonkey commented 10 months ago

Do you have multiple tasks that run in parallel? If yes, this is no supported atm Custom libraries should not be an issue, twingrind even supports adding profiling to multiple libraries, as long there is only 1 concurrent task and 1 PRG and only 1 call to Twingrind.Profiler()

captain-yoshi commented 10 months ago

Nope, only one task and one program. Here is what my program looks like after the prepare command:

(* @@ PROFILER @@ *)Twingrind.Profiler.Push(1245984901);(* @@ PROFILER @@ *)
Twingrind.Profiler();

CASE ProgramState OF
    0:  // Wait one cycle, do noting
        ProgramState := 1;
    1:  // Initialization
        ....
    2:
        FOR JointNumber:=1 TO NUMBER_OF_JOINTS DO
            IF JointsConfigured[JointNumber] <> TRUE THEN
                (* @@ PROFILER @@ *)Twingrind.Profiler.Pop(1245984901); (* @@ PROFILER @@ *)RETURN;
            END_IF
        END_FOR

        ...

        // Break if not properly reconfigured
        FOR JointNumber:=1 TO NUMBER_OF_JOINTS DO
            IF JointsConfigured[JointNumber] <> TRUE THEN
                (* @@ PROFILER @@ *)Twingrind.Profiler.Pop(1245984901); (* @@ PROFILER @@ *)RETURN;
            END_IF
        END_FOR
END_CASE

(* @@ PROFILER @@ *)Twingrind.Profiler.Pop(1245984901);(* @@ PROFILER @@ *)

image

iadonkey commented 10 months ago

Please swap the first and second line so that Twingrind.Profiler(); is the first command and the Push command comes after it

Twingrind.Profiler();
(* @@ PROFILER @@ *)Twingrind.Profiler.Push(1245984901);(* @@ PROFILER @@ *)

I see that the readme is a misleading here, I usually run the prepare command and only then add the line Twingrind.Profiler(); … I’ll dhange the readme

captain-yoshi commented 10 months ago

Sweet ! It now works. Thanks for updating the README.