Tracing a program with strace generates a lot of output because of the sheer number of syscalls every program calls during its runtime. This can become overwhelming very quickly, making it hard to analyze the trace and find what you are looking for. Fortunately, strace has several features that allow you to limit which syscalls … Continue reading Limiting which Syscalls to Trace with Strace| Abstract Expression
One of the great strengths of strace as a debugging tool is that it shows you what a program is doing regardless of whether it was compiled with debug info or not. The downside of this is that you only see the program’s syscall. You can use this information to deduce what is happening in … Continue reading Finding out where Syscalls are Called From: Stack Traces with Strace| Abstract Expression
There is probably no debugging tool on Linux that is more valuable and versatile than strace. This tool shows us all the calls a program makes to the operating system, including the data it transmits to the operating system via these calls and the return values sent back by the OS. Therefore, it can give … Continue reading Introduction to Strace| Abstract Expression
When we debug a program with printf() we have to recompile it whenever we add new printf() statements! Right!? Wrong! With gdb we can add printf() statements without recompiling a program and even add them while it is running. Adding Printfs with GDB Let’s say we have the following example program that computes the sum … Continue reading Dynamic Printf Debugging with GDB| Abstract Expression
Modern UNIX shells like bash (default on Linux) and zsh (default on macOS) keep a history of all the commands you enter. The easiest way to access this history is by pressing the up and down cursor keys to browse through the last commands. But this is only the tip of the iceberg. There are … Continue reading Making the most of your Shells History on Linux and macOS| Abstract Expression
Most programmers prefer to write code over debugging it. Unfortunately, code breaks a lot more often than we would like and it often breaks in situations that are hard to debug. Therefore, an essential skill as a programmer is to know how to debug your code (and that of others). When facing our first bug … Continue reading Getting started with GDB| Abstract Expression
So you have set up your Raspberry Pi as a home server and everything works as intended. But what if the SD card fails and all the data you stored on your Raspberry Pi is suddenly lost forever? All storage devices containing important data need to be backed up on a regular basis. And this … Continue reading Simple Raspberry Pi Backup| Abstract Expression
When we declare a variable of type int and we don’t tell the compiler if it is supposed to be signed or unsigned it is signed by default: This is true for all integer number types (short, int, long, long long). But there is one exception: The char type! The char Type is Special According … Continue reading The Anomaly of the char Type in C| Abstract Expression
So there is a process running on your machine and you know it has opened one or more ports but you don’t know the port numbers. Let’s find out how to retrieve them!| Abstract Expression
Structures allow us to combine several variables to create a new data type. Some other languages support the same concept but call it “records”. If you come from object-oriented program…| Abstract Expression