3

Does Ada/GNAT supports something like the automatic tracing of the execution of a program (or selected packages/procedures/functions) for debug purposes? I am not interested in a logger package.

Imagine working on a real old Ada project and using a debugger to step through the code is not an option. In my opinion adding text outputs often helps to understand the code:

if A and B or C then
   Ada.Text_IO.Put_Line ("1");

   [...]
else
   Ada.Text_IO.Put_Line ("2");

   [...]
end if;

But adding such text outputs is a manual process and it takes time to do it on complex code.

Marcello90
  • 1,313
  • 4
  • 18
  • 33

1 Answers1

4

You might want to have a look at rr. I've never used it myself, but it might very well work with Ada.

DeeDee
  • 5,654
  • 7
  • 14
  • 1
    It indeed works. Nifty tool! Any good gdb frontend to use with? – Álex Oct 10 '19 at 16:52
  • @Álex: Nice! Can't help you with a front-end, but some people seem to use their IDE (see [rr wiki](https://github.com/mozilla/rr/wiki/Using-rr-in-an-IDE)). Maybe you could use the `gdb` interface of GPS. – DeeDee Oct 10 '19 at 19:30
  • @Álex: You could try to connect to the `gdbserver` interface exposed by `rr replay` from the GPS IDE "Debugger Console" (see also the [GNAT UG](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_and_program_execution.html#remote-debugging-with-gdbserver)). – DeeDee Oct 10 '19 at 20:29
  • Thanks, @DeeDee, I will try that. – Álex Oct 11 '19 at 10:12
  • Is `rr` limited to a Linux based operating system? Alternatives for Windows? – Marcello90 Oct 27 '19 at 00:16
  • 1
    @Marcello90: It seems that `rr` is Linux only and no viable Windows alternative exists at the time of writing. Microsoft did create an equivalent functionality for Windows named ["Time Travel Debugging"](https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-overview) (which is part of WinDbg Preview), but I'm afraid that WinDbg cannot be used in this case. WinDbg requires a different (proprietary) file format for debugging symbols ([PDB](https://en.wikipedia.org/wiki/Program_database)) which isn't supported by GCC. – DeeDee Oct 27 '19 at 11:34