Debugging C++ Multithreaded Programs with GDB

Debugging C++ Multithreaded Programs with GDB

We are currently in a multi-core era, and multithreaded programs are very common. This article will explore how to debug C++ multithreaded programs. Example Code This article designs a demo multithreaded program where the main thread starts two business threads that execute the functions business_1 and business_2. Each of these functions defines a counter object … Read more

GDB Debugging Method (10) – Core Dump

GDB Debugging Method (10) - Core Dump

Technical experience sharing, welcome to follow and provide guidance In the process of system development, the version deployed on the device is usually the release version, which generally does not contain debugging information. When issues arise, how do we troubleshoot? In fact, Linux provides the core dump feature, which generates a core file when a … Read more

GDB Debugging Method (9) – Printing Linked Lists

GDB Debugging Method (9) - Printing Linked Lists

When debugging issues, it is common to encounter linked lists, and manually calculating and filling in linked lists with GDB can be quite cumbersome. However, pwndbg provides a very useful command called telescope that helps us automatically parse linked lists. Conditions for Printing Linked Lists with Telescope When programmers design linked lists, the structures can … Read more

GDB Debugging Methods (8) – Pwndbg

GDB Debugging Methods (8) - Pwndbg

After using GDB for a while, you may find that some features, such as viewing stack layouts, are not very convenient to use directly with GDB. However, the core issues of operating systems often lie in memory management. For example, printing a doubly linked list is not easy to handle with GDB alone. So, is … Read more

GDB Debugging Methods (7) – Multithreaded Debugging

GDB Debugging Methods (7) - Multithreaded Debugging

In practical GDB debugging experience, multithreaded debugging is more common, as many system designs are based on threads. Therefore, when a binary has issues, they often reside in a specific thread. At this point, GDB needs to correctly switch to the corresponding thread and then run. If you simply switch to a specific thread and … Read more

GDB Debugging Method (5) – Debugging Dynamic Libraries

GDB Debugging Method (5) - Debugging Dynamic Libraries

In my personal experience, in most cases, GDB debugging can be used to debug the behavior of a specific dynamic library independently. This allows for convenient problem localization directly on the device where the anomaly occurs. This article introduces how to use GDB to locate issues for a single dynamic library on a production device. … Read more

GDB Debugging Methods (6) – Debugging Techniques

GDB Debugging Methods (6) - Debugging Techniques

With good debugging information, using GDB for debugging becomes very simple. This article introduces common debugging techniques that are frequently used in operating systems. Compilation Environment and Runtime Environment Before discussing common debugging techniques, we must clarify what a compilation environment is and what a runtime environment is. Essentially, when operating systems are released, the … Read more

Practical Implementation of Generating GDB Files with JAVA Based on GDAL

Practical Implementation of Generating GDB Files with JAVA Based on GDAL

Introduction In previous blogs, I have introduced the reading of gdb files, the GIS tool GDAL (Part III) reading gdb data, and an article on exploring GDAL’s support for FileGDB drivers on Windows. These articles mainly discuss the reading of gdb files and simple read/write operations. In practical work, gdb is a rich type of … Read more

GDB Debugging Methods (4) – Debugging Information

GDB Debugging Methods (4) - Debugging Information

The key to whether a program is easy to debug lies in the completeness of the debugging information. This article provides a brief introduction to what DWARF debugging information is based on this premise. What is DWARF Debugging With Attributed Record Formats is a debugging information format used by many compilers, which allows for easy … Read more

GDB Debugging Methods (3) – Simple Debugging

GDB Debugging Methods (3) - Simple Debugging

We know that ptrace frequently issues PTRACE_GETREGS and PTRACE_SETREGS commands, modifying the PC register, allowing the process to be controlled by gdb and execute related commands at the trace point. This article uses a simple program to demonstrate basic debugging tasks using gdb. What to Debug Based on the understanding of ptrace, we can summarize … Read more