debug
Distribution of debug information
Updated in 2024-08.
Note: The article will likely get frequent updates in the next few days.
This article describes some approaches to distribute debug information. Commands below will use two simple C files for demonstration.
cat > a.c <<eof
void foo(int);
int main() { foo(42); }
eof
cat > b.c <<eof
#include <stdio.h>
void foo(int x) { printf("%d\n", x); }
eof…
DWARF in reproducible builds
Deterministic builds with clang and lld describes several degrees of build determinism. Here is the description of local determinism:
…Like incremental basic determinism, but builds are also independent of the name of the build directory. Builds of the same source code on the same machine produce exactly the same output every time, independent of the location of the source checkout directory or the build directory.
ELF Hacks
我喜欢基于代码片段的学习,之前学习过一些binutils和其他处理ELF的工具的奇技淫巧,了解到很多概念,比如weak symbol、common section、RPATH、把资源文件嵌入ELF等,昨天创建了一个项目https://github.com/MaskRay/ElfHacks整理了很多自包含的例子。
…调试技巧2
之前写过一篇《Debug Hacks》和调试技巧。
CFLAGS使用-g3
对于重度使用macro的程序很有用,可以在gdb里使用info macro NAME、macro expand EXPR等命令了,print参数里的macro也可以展开。
《Debug Hacks》和调试技巧
下篇见调试技巧2。
Debug Hacks
作者为吉冈弘隆、大和一洋、大岩尚宏、安部东洋、吉田俊辅,有中文版《Debug Hacks中文版—深入调试的技术和工具》。这本书涉及了很多调试技巧,对调试器使用、内核调试方法、常见错误的原因,还介绍了systemtap、strace、ltrace等一大堆工具,非常值得一读。