Below is a list of useful snippets I took from the GDB manual to reference later. Print exceptions: p $_exception Define a function to rebuild a program from within gdb define reload set confirm off shell make file ./your_app run end Run with catch throw and without initial breakpoint: gdb -ex "catch throw" -ex "run" --args To look at some context, we can display ten lines of source surrounding the current line with the l (list) command. ...
Non blocking server read in zig
I have started to work on a new small Zig project. The application has 2 tasks it has to perform. It has to listen for incoming HTTP requests and handle them, and it also has to periodically check if it has to message me a reminder I scheduled for myself through a Telegram bot. I just wanted to get something working quickly, so for handling incoming HTTP requests I used Zig’s std.http.Server struct. This worked fine enough, I had it in a loop like this to wait for incoming requests: ...
The advantage of statically built applications (Linux)
Recently I ran into some issues with a C++ application I was working on. The official Linux distribution we supported for the application is Ubuntu 20.4. This version of Ubuntu is pretty outdated now a days, and is even nearing its EoL date. On my development machine I prefer to run the latest LTS version. Building the application in a newer Ubuntu version (f.e. 24.4) however, produced a binary that would instantly crash on the officially supported platform. Not only that was an issue though. If I were to send a build of the application that happened to be built in Debug mode to a colleague, the application also crashed instantly, even though it worked fine on my machine. The reason for this: shared libraries. ...
Link-time substitution (C/C++): test hardware dependent code
Link-time substitution is one of three methods to create test doubles for your project. Test doubles are used to replace pieces of code that your software depends on (the code under test, or CUT), but that are hard to use in combination with (automated) tests like unit tests. For software developers the most difficult type of code to test will probably be code that is hardware dependent. Without test doubles, it is not possible to unit test how your CUT responds to, for example, a temperature sensor that outputs different temperatures, or a sensor that breaks while the application is running. ...