|
microfmt
Zero-allocation C++ formatting for constrained environments
|
Embeds GDB pretty printers for microfmt types into the binary. More...
Go to the source code of this file.
Embeds GDB pretty printers for microfmt types into the binary.
Including this header anywhere in a program (typically once, from the translation unit containing main) embeds the full contents of tools/gdb/microfmt_printers.py into a .debug_gdb_scripts section via inline assembly. When the resulting binary is loaded in GDB, GDB auto-loads and runs that script, registering pretty printers for every microfmt sink/buffer/logger type – no source command, no <binary>-gdb.py file, and no sys.path setup required.
This still requires GDB's auto-load safe-path to include the path of the binary containing this section (GDB disables auto-loading from untrusted locations by default); see https://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-safe-path.html
This file is generated by tools/gdb/generate_embedded_header.py from tools/gdb/microfmt_printers.py – do not hand-edit it. Regenerate it whenever the printer script changes.
Embedding costs a copy of the (small) Python source in every translation unit that includes this header for a distinct binary; the "MS" section flags let the linker fold identical copies within the same binary into one, so including it from multiple translation units of the same program is free.
The .debug_gdb_scripts mechanism relies on GNU-assembler inline asm syntax and is only meaningful to GDB, so this header is a silent no-op – it defines nothing and emits no section – on compilers other than Clang/GCC targeting ELF (e.g. MSVC, Mach-O). Guarded on __clang__/__GNUC__ and __ELF__ rather than platform, so it also no-ops under clang-cl, which defines _MSC_VER but not GNU inline-asm syntax in its default mode.