-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ext] Add instruction tracing to Orbetto
See #10.
- Loading branch information
Showing
21 changed files
with
2,962 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Trace Metrics with Plotly in Dash | ||
|
||
As explained in [TRACE.md](../src/TRACE.md), Perfetto is a very useful tool for | ||
displaying trace data, but is limited in data size and display variability. | ||
Therefore, as a proof of concept, some metrics are calculated in Python. We use | ||
the Protobuf file generated by Orbetto, the SQL trace processor from Perfetto | ||
and a program counter bitmap generated by CRoaring in Orbetto. | ||
|
||
|
||
## Visualising metrics | ||
|
||
To start the local dash server you need to pass a Protobuf file when analyzing | ||
ITM data or a bitmap for code coverage data. Depending on which argument you | ||
pass, different metrics can be displayed. Use `-h` to see all options. If you | ||
are using the `-diff` flag, you will need to provide a second Protobuf file to | ||
display the metrics based on the difference between the between the two files. | ||
This is very useful for comparing different versions or settings between two | ||
runs. | ||
|
||
```sh | ||
# cd orbetto/metrics | ||
# two metrics | ||
python3 metrics.py -f /path/to/orbetto.perf -wq -dwq | ||
# difference between two traces on one metric | ||
python3 metrics.py -f /path/to/orbetto_1.perf -f2 /path/to/orbetto_1.perf -hp -diff | ||
# Code coverage for pc bitmap (beta not completely accurate) | ||
python3 metrics.py -bm /path/to/bitmap.roar -elf /path/to/elf_file.elf -cc | ||
``` | ||
|
||
Once executed, copy the URL into your browser and use the plotly interface to | ||
display the desired plot. | ||
|
||
> [!NOTE] | ||
> Some metrics take a while to calculate (mainly code coverage). | ||
|
||
## Advanced metrics and goal | ||
|
||
There are already some simple statistical techniques included that can detect | ||
outliers, but the bigger picture of this work is to do regression testing and | ||
fuzzing with statistics derived from the instruction trace. For example: | ||
|
||
- [x] Regularity of sensor readings. | ||
- [ ] Comm link throughputs. | ||
- [x] Scheduling latency vs timeouts. | ||
- [ ] Thread progress vs semaphores. | ||
- [x] Callstack changes (code coverage). | ||
|
||
All these metrics need to be combined into a large latent space that can be | ||
diffed (a kind of distance measure) between different versions of PX4 to detect | ||
bugs in the code before it flies. | ||
|
||
|
||
## GCOV | ||
|
||
There has been a quick investigation to use a more advanced and also tested | ||
tool. The most common is gcov, which is a test coverage program from GCC. Two | ||
files are required for gcov to display code coverage: | ||
|
||
- `.gcno`, which is an advanced source file you get when compiling with the | ||
GCC `-ftest-coverage` option. | ||
- `.gcda`, which is created when the GCC `-fprofile-arcs` option is run. | ||
|
||
It should be simple to get the .gcno file as the flag is already a compile | ||
option in PX4. Theoretically it should be possible to reverse engineer | ||
the `.gcda` file just from the PC values, ([documentation can be found here] | ||
(https://github.com/gcc-mirror/gcc/blob/master/gcc/gcov-io.h)) However, it is | ||
unclear how long this will take and how robust it will be. |
Oops, something went wrong.