Skip to main content
TinyCC provides multiple debugging capabilities including debug symbols, runtime backtraces, and integration with standard debuggers.

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 -bt option to enable runtime stack traces:
Example with custom depth:
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:
DWARF 4 and 5 provide the best compatibility with modern versions of GDB (7.0+).

Debug-only code

Use preprocessor macros to include debug-only code:
Compile with debug macros:

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:
Disabling bounds checking should only be done in performance-critical sections where memory safety is guaranteed.

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:
Errors are reported with full context:

Profiling support

Create a profiling version of TCC:

Limitations

Debug limitations:
  • Signal handlers are not compatible with bounds checking
  • Fork in multi-threaded applications may cause issues with bounds checking
  • Generated code with -b is slower and larger
  • Some optimizations are disabled with debug symbols

Configuration

Build-time debug configuration

Configure debug features during TCC compilation:

See also