Rate This Document
Findability
Accuracy
Completeness
Readability

Using GDB to Debug Executable Files Built by BiSheng Compiler

The executable files generated by BiSheng compiler comply with the standard debugging information format and can be debugged using the system GDB. Similar to other compilers, to ensure better debugging experience, you are advised to adjust the optimization level to -O0 and add the -g option to retain the debugging information when compiling the executable file for debugging.

The following is an example case:

1
2
3
4
5
6
7
//test.c
#include <stdio.h>

int main() {
    printf("hello world");
    return 0;
}
Run the following commands to perform compilation and start the GDB for debugging:
1
2
clang -O0 -g test.c -o a.out
gdb a.out
Figure 1 Using GDB to debug executable files built by BiSheng compiler