ssm-lang / Scoria

This is an embedding of the Sparse Synchronous Model, in Haskell!
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Design Debug interface #24

Closed j-hui closed 3 years ago

j-hui commented 3 years ago

There should be a uniform interface for assertions, debugging, and emitting traces, that is used across the generated C code and the platform-generic runtime, but that has a platform-specific implementation. This is useful because each platform might have a different way of logging information (or may even ignore debug statements altogether if not applicable).

A related interface should exist within the Haskell interpreter, to support emitting an Output trace from a program, or for just evaluating it purely.

This all involves some slight code reorganization, but first requires us to figure out what the interface should look like. I like the idea of splitting this interface into 4 levels:

All these will take the form of macros, to ensure that they are zero-cost when not needed. the ERROR, WARN, and INFO macros should all take a variable number of arguments and support printf-style formatting.

WARN and INFO will essentially be print statements, i.e., WARN("this should have your attention: %d\n", x) and INFO("some potentially useful debug information: %d\n", x).

At the ERROR level, we should have ERROR("this is bad: %d\n", x), which prints the error and quits (similar to Linux's BUG macro) , and ERROR_ON(condition, "that error condition was met: %d", x) (similar to Linux's BUG_ON).

For TRACE, we should start with one primitive per notable event in the event trace. Since we expect the output to be in a parseable format, the formatting of each primitive should all be defined in one place (rather than scattered throughout the runtime implementation and generated code). The TRACE primitives should all be #define TRACE_WTV do {} while(0); for non-trace platforms.

j-hui commented 3 years ago

Related to (subtask of) #17

sedwards-lab commented 3 years ago

Worry about this later, John. Focus on getting an end-to-end flow working for the paper.

j-hui commented 3 years ago

Closed in #46