farre / midas

A GDB/MI Visual Studio Code Debug Adapter
MIT License
29 stars 1 forks source link

Override GDB functionality #153

Open theIDinside opened 1 year ago

theIDinside commented 1 year ago

Feature TLDR: The user should be able to set checkpoints and info checkpoints from the debug console in VSCode, by typing checkpoint and info checkpoints

Problem: We need to override functionality that GDB provides.

For instance, if the user types checkpoint in the debug console, the command will fail, because we are connecting to a GDB Server instance that RR spawns - we don't let RR spawn GDB (like it does when rr replay foo).

Thus, commands like checkpoint and info checkpoints will either fail or return nothing.

Overriding this is fairly easy. Write python functions that calls the RR-GDB-Server implementations commands, and then to .gdb_rrinit; add the re-definitions of the commands info checkpoints and checkpoint.

This is not a Midas problem, but an RR/GDB problem - if a user says from the command line: rr replay foo -s 50505 -k, it will spawn rr and spit something like this out:

$ ./rr replay foo -s 12345 -k
Launch gdb with
  gdb '-l' '10000' '-ex' 'set sysroot /' '-ex' 'target extended-remote 127.0.0.1:12345' /home/cx/.local/share/rr/foo/mmap_hardlink_4_foo

If the user connects using this command, the checkpoint and info checkpoints commands will not work, as GDB will try to perform it's own version of those commands (and fail). The same goes for RR commands like when or when-tid, which are not "native" GDB commands. When RR spawns GDB for the user directly (i.e. on rr replay foo), it injects python code, which overrides these functions.

This is not essential that we implements this, since we have our own UI for setting and restarting checkpoints, however, Midas has a stated goal to be 1-to-1 with the command line, and in this case, even slightly better.