Adding a debugger to ros.el
I have brought up the ros.el emacs package a number of times now, as it has become a package that I use multiple times a day. A little while ago, I had the idea to see if I could add a debugger function, to take advantage of the emacs-gdb functionality.
The implementation took me down a rabbit hole of learning about how tramp handles remote connections, as well as how gdb links shared librarys. Most interesting was ROS’s reliance on environment variables for linking. Nothing wrong with it, you just don’t really realise it until you are trying to get the remote gdb shell to work. Emacs-gdb doesn’t inherit from the target’s environment, which means it won’t find the required shared libraries in your workspace. Once I realised I could just pull a sneaky $env | grep $ROS_DISTRO
to grab all of the related ROS variables, things got easy. All I had to do was then pass these environment variables as the launch argument set env $var
to gdb.
You can see my how I implemented this here: Github PR. I have also created a devel branch which I will be using for impementing features I’d like to see. The original author of ros.el is a busy dude, and I don’t think he would appreciate me spamming the shit out of his repo. I’ll just space out the PR’s.
I made a little video recording showing off the process of selecting a Containerised ROS1 workspace, debugging an executable, then a nodelet, then switching to a completely separate ROS2 container and debugging a simplepublisher node. The idea was to show off ros.el a bit, since the github doesn’t do the package justice…
“Now I can see how awful my code is at a register level…”