Debug information formats
TinyCC supports two debug information formats:- STABS - Default debug format (traditional Unix format)
- DWARF - Modern debug format (versions 2-5)
Generating debug symbols
DWARF debug information provides better compatibility with modern debuggers like GDB and LLDB.
Runtime backtraces
TinyCC can generate stack backtraces at runtime without external tools.Enabling backtraces
1
Compile with backtrace support
Use the Example with custom depth:
-bt option to enable runtime stack traces:2
Run the program
When a runtime error occurs, TCC automatically prints a stack trace:Output example:
Backtrace API
When compiled with-bt, the __TCC_BACKTRACE__ macro is defined and you can trigger backtraces programmatically:
Using standard debuggers
GDB integration
TinyCC-generated executables can be debugged with GDB:1
Compile with debug symbols
2
Run GDB
3
Debug commands
Common GDB commands:
DWARF with GDB
For better GDB compatibility, use DWARF debug format:Debug-only code
Use preprocessor macros to include debug-only code:Bounds checking
TinyCC includes optional runtime bounds checking to detect memory errors.Enabling bounds checking
Bounds checking is available on i386, x86_64, ARM, ARM64, and RISC-V 64.
Types of errors detected
Bounds checking catches:Bounds checking environment variables
Control bounds checking behavior:Disabling bounds checking in code
Temporarily disable bounds checking for specific code sections:Symbol information
TinyCC preserves symbol information for debugging and dynamic linking.Viewing symbols
Exporting symbols
Debug information in shared libraries
Compile shared libraries with debug symbols:Bounds checking code is not included in shared libraries. The main executable must be compiled with
-b for bounds checking.Runtime debugging with -run
Debug code directly with-run:
Profiling support
Create a profiling version of TCC:Limitations
Configuration
Build-time debug configuration
Configure debug features during TCC compilation:See also
- Configuration - Build configuration options
- API Reference - Compilation flags
- Quickstart - Getting started guide