Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 400
    • Issues 400
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Tutorials
  • logging

logging · Changes

Page history
Add things I learned while readign the sac2c code authored Mar 06, 2025 by Quinten Cabo's avatar Quinten Cabo
Hide whitespace changes
Inline Side-by-side
tutorials/logging.md 0 → 100644
View page @ c2aff25b
There are various ways to log information in the sac2c compiler.
There are kinds of ways to log information during compilation.
`src/libsac2c/support/debug.h` and `src/libsac2c/global/ctinfo.h`
1. `debug.h` is for compiler debugging for the compiler developers.
2. The functions in `ctinfo.h` which are used to actually give feedback to the caller of the compiler.
# debug.h
A modified version of the `debug.h` file by `Fred Fish`.
Modify a lot by the sac team.
These macros are for compiler debugging for the compiler developers.
Only present in a DEBUG build of the compiler.
This system allows you to print debug information to the console at different levels and for different tags.
You can get these debug messages for the entire compiler by using the `-#d` flag.
If you want to only get messages for a certain compiler phase you can specify the debug prefix of the messages you want to see `-#d,EX` for a traversal with `#define DBUG_PREFIX "EX"`.
This is possible because the `debug.h` file allows you to only print messages with a certain prefix if you want.
You set the prefix by doing `#define DBUG_PREFIX "TSM"` at the top of the file you want to debug.
# ctinfo functions
These functions actually provide feedback to the caller of the compiler.
This messages are present in both debug builds and release builds of the compiler.
The logging follows different levels of verbosity.
The caller sets the verbosity levels by using the `-v` flag.
This info is from the top of the `ctinfo.c` file:
```
* Verbose level 0:
*
* Only error messages are printed.
*
* Verbose level 1:
*
* Error messages and warnings are printed.
*
* Verbose level 2:
*
* Error messages, warnings and basic compile time information, e.g. compiler
* phases, are printed.
*
* Verbose level 3:
*
* Error messages, warnings and full compile time information are printed.
*
* Verbose level 4+:
*
* Additional compile time information is provided that typically is only
* of interest in certain situation.
*
* Default values are 1 for the product version and 3 for the developer version.
```
However `ctinfo.c` holds more logging functions like `InternalCompilerErrorBreak` which produces the `OOOOOOOPS, your program crashed the compiler 8-((` message.
Or for instance `CTIerror` which is used to print an error messages or `CTIwarn` to show warnings etc.
Clone repository
  • Styleguide
  • concepts
    • Deprecated Modules
    • Globals
    • Intermediate Code Macros
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runtime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
View All Pages