PreviousNext
Help > RIDE > Debugging Programs
Debugging Programs

RIDE offers basic debugging to trace how the executed code preforms. One or more RVM instructions from the current or all processes, can be executed in steps. Note that debugging is done on the compiled RVM binary code, not on the input Rittle source code.

The RVM code is sort of machine code that executes in the RVM. It is optimised to level that allows realisation of most of the RVM directly in hardware. The entire model is built around a stack machine, and all instructions take operands from the stack and return data back these.

In order to start debugging, a compilation is required in order to prepare the code and to reset the RVM for a new execution.

Using with the small program from above:

  1: var byte a=0;
  2: while a<10;
  3:    print a++,CRLF;
  4: until;
  5: .[

lines compiled: 4
code length: 48 bytes

  5: ..

000005   2a 12 01 00 00 00         .var       .sint8   V1


  5:


We have entered debugging and seeing the instruction due for execution.

Continuing further with the .. command for step execution:

 

  5: ..

00000b   12 00                     .sint8     0

  5: ..

]  0: 0

 

After executing this instruction, we see a value has been added to the data stack. The data stack always puts a new value on top of the already existing ones, and the value that is taken is always the one that is on the top.

Step-debugging further:

00000d   29 01 00                  .set       V1

  5: ..

000010   28 01 00                  .get       V1

  5: ..

]  0: 0

000013   12 0a                     .sint8     10

  5: ..

]  0: 10
] -1: 0

000015   32                        <

  5: ..

]  0: 1

000016   0a 2e 00 00 00            .ifnot     (addr 0x0000002e)

  5:

00001b   28 01 00                  .get       V1

  5: ..

]  0: 0

00001e   28 01 00                  .get       V1

  5: ..

]  0: 0
] -1: 0

000021   49                        .++

  5: ..

]  0: 1
] -1: 0

000022   29 01 00                  .set       V1

  5: ..

]  0: 0

000025   38                        CRLF

  5: ..

]  0:

] -1: 0

000026   3f                        print

  5: ..

0

000027   12 00                     .sint8     0

  5: ..

]  0: 0

000029   0a 10 00 00 00            .ifnot     (addr 0x00000010)

  5: ..

000010   28 01 00                  .get       V1

  5:

 

We now see the first printed character in the marked line (it is not marked in the actual system output), and the loop has completed its first iteration returned back to the start for a next one. We can also see that there is a blank line in the stack output between elements 0 and 1. That blank line is actually a valid data element, generated by the CRLF instruction.

Adding more dots will add more instructions traced in a single step.

  will execute two instructions,  ….  will execute three instructions, and so on.

Debugging can be done on executing batches by using the .* command to specify the number of instructions. For example:

.*50.

will execute 50 instructions before it stops for further interaction with the user.