Log In

libgdiagnostics

Published 2 months ago3 minute read

libgdiagnostics is GCC's diagnostic-handling code wrapped up as a shared library, with a opaque pure C API that other tools can use, covering things like:

A sarif-replay command-line tool is also provided, which takes SARIF files as input, and uses libgdiagnostics to "replay" any diagnostics within them as if they were GCC diagnostics.

Experimental implementation added in GCC 15

Header: libgdiagnostics.h

API documentation: https://gcc.gnu.org/onlinedocs/libgdiagnostics/

┏━━━━━━━━━━━━━━━━━━ GCC ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┣━━━━━━━ Other projects ━━━━━━━┫ ┃┌───┐ ┌───┐ ┌──────────────────────────┐ ┃ ┏...┓ ┏...┓ ┏━ binutils ━┓ ┃│gcc│ ┌┴──┐│ │ sarif-replay │ ┃ ┃ ┃ ┃ ┃ ┃ ┌──┐ ┌──┐ ┃ ┃└─o─┘┌┴──┐├┘ ├──────────────────────────┤ ┃ ┗━┆━┛ ┗━┆━┛ ┃ │as│ │ld│ ┃ ┃ ┆ │cc1├┘ │A tool for dumping .sarif │ ┃ ┆ ┆ ┃ └─o┘ └─o┘ ┃ ┃ ┆ └─o─┘ ┌─────────────────────┐│files as if they were GCC │ ┃ ┆ ┆ ┃ ┆(in C)┆ ┃ ┃ ┆ ┆etc │ dg-lint ││diagnostics (C++, GPLv3) │ ┃ ┆ ┆ ┗━━━┆━━━━━━┆━━┛ ┃ ┆ ┆ ├─────────────────────┤└────────────o─────────────┘ ┃ ┆ ┆ ┆ ┆ ┃ ┆ ┆ │ (internal tool) │ ┆ ┃ ┆ ┆ ┆ ┆ ┃ ┆ ┆ └────────────o────────┘ ┆ ┗━━━━━┆━━━━━┓ ┆ ┆ ┆ ┃ ┆ ┆ ┆ ┆ ┆ ┃ ┆ ┆ ┆ ┃ ┆ ┆ ┌──────────────o────────────────┐ ┌──o─────────────────────o──┐ ┃ ┆ ┆ ┆ ┃ ┆ ┆ │ libgdiagnostics.py (GPLv3) │ │ libgdiagnostics+.h (GPLv3)│ ┃ ┆ ┆ ┆ ┃ ┆ ┆ ├───────────────────────────────┤ ├───────────────────────────┤ ┃ ┆ ┆ ┆ ┃ ┆ ┆ │Python 3 bindings, using ctypes│ │A header-only C++ wrapper │ ┃ ┆ ┆ ┆ ┃ ┆ ┆ └──────────────o────────────────┘ │API giving syntactic sugar │ ┃ ┆ ┆ ┆ ┃ ┆ ┆ ┆ │on top of the C API │ ┃ ┆ ┆ ┆ ┃ ┆ ┆ ┆ └────────────o──────────────┘ ┃ ┆ ┆ ┆ ┃ ┆ ┆ ┆ ┆ ┗━━┆━━━━━━━━━┆━━━━━━┆━━━┓ ┃ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┃ ┃ ┆ ┆ ┌──────────────o────────────────────────────────o────────────────────o─────────o──────o─┐ ┃ ┃ ┆ ┆ │ libgdiagnostics.h/.so (GPLv3) │ ┃ ┃┌─o────o──┐├───────────────────────────────────────────────────────────────────────────────────────┤ ┃ ┃│global_dc││ An opaque C API (with stable ABI) for emitting diagnostics, │ ┃ ┃└─o────o──┘│ with source quoting, fix-it hints, SARIF output, execution │ ┃ ┃ ┆ ┆ │ paths, etc (internals implemented using GCC's subset of C++11) │ ┃ ┃ ┆ ┆ └─────────────────────o────────────────────────────────────o────────────────────────────┘ ┃ ┃ ┆ ┆ ┆ ┆ ┃ ┃┌─o────o─────────────────────────o────────────────────────────────────o─────┐ ┃ ┃│ GCC's diagnostics subsystem (implemented in GCC's subset of C++11) │ ┃ ┃└───────────────────────────────────────────────────────────────────────────┘ ┃ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

History

  • 2024-06-25: Refactoring to help libdiagnostics:
  • 2024-06-18: Refactoring to help libdiagnostics: removed "tree" dependency from diagnostic paths

  • 2024-01-23: Added "Planned structure for GCC 15" diagram to wiki page
  • 2023-11-21: v2 of prototype

  • 2023-11-15: C++ example of dumping a SARIF file

  • 2023-11-06: Initial prototype posted to mailing list

  • Origin:
    publisher logo
    gnu
    Loading...
    Loading...

    You may also like...