Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible session trace output #1052

Closed
senier opened this issue May 24, 2022 · 0 comments · Fixed by #1053
Closed

More flexible session trace output #1052

senier opened this issue May 24, 2022 · 0 comments · Fixed by #1053
Assignees
Labels
architectural decision Discussion of design decision generator Related to generator package (SPARK code generation)

Comments

@senier
Copy link
Member

senier commented May 24, 2022

Context and Problem Statement

Debugging and validating a protocol session requires some insight into the transitions that the state machine performs. We currently have two mechanisms to achieve that: When the --debug flag is passed on the rflx generate command line, the state transitions and error output is printed to the console using Ada.Text_IO. We use this for our own tests when running on Linux. The other option is to use the Next_State function to return the next state in the main loop and print its value using the 'Image function.

Both approaches are not ideal. Ada.Text_IO may not be available for on-target debugging in embedded systems when using a limited runtime. Printing the state names from the session context only reveals those states that follow an IO state - what happens in between cannot be observed. Furthermore, using 'Image may require runtime support which may not available or desirable.

Use Cases

  • Debug protocol execution on an embedded target
  • Use debug output facilities other than Ada.Text_IO

Considered Options

O1

Replace the current Ada.Text_IO and Put_Line calls by a custom package RFLX_Debug with a procedure RFLX_Debug.Print (Text : String). The inclusion of the package and calls to the Print functions is governed by the presence of the --debug flag.

+ Little implementation effort
+ Simple, unified interface
+ Simple command line
RFLX_Debug must be provided externally
No out-of-the box use of debug functionality
No well-defined / checked API for RFLX_Debug

O1a

Like O2, but a specification file for RFLX_Debug is generated.

+ Moderate implementation effort
+ Simple, unified interface
+ Simple command line
RFLX_Debug body must be provided externally
No out-of-the box use of debug functionality

O1b

Like O1, but the RFLX_Debug package with a default implementation mapping to Ada.Text_IO is generated. An optional parameter spec can be passed to the --debug switch in which case the default body would not be generated.

+ Default behavior as convenient as current behavior
+ Compatible with current solution
More complex to implement
May result in conflicts between custom and generated trace packages

O2

Include Ada.Text_IO and generate calls to Put_Line as before if the --debug flag is used. A new optional parameter external can be passed to --debug which includes RFLX_Debug and generates calls to Print. The spec and code for RFLX_Debug must be provided by the user.

+ Default behavior as convenient as current behavior
+ Compatible with current solution
Slightly more complex to implement than O1
No well-defined / checked API for RFLX_Debug

O2b

Like O2, but a specification is generated for RFLX_Debug.

+ Default behavior as convenient as current behavior
+ Compatible with current solution
Slightly more complex to implement than O1

Decision Outcome

O2b

@senier senier added generator Related to generator package (SPARK code generation) architectural decision Discussion of design decision labels May 24, 2022
@senier senier added this to To do in RecordFlux 0.6 via automation May 24, 2022
@senier senier moved this from To do to Implementation in RecordFlux 0.6 May 24, 2022
RecordFlux 0.6 automation moved this from Implementation to Done May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architectural decision Discussion of design decision generator Related to generator package (SPARK code generation)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants