Closed kamih closed 7 months ago
This looks really good.
I ran into only one obvious issue: the code doesn't compile with CONSOLE=no, because the compiler detects unused variables in the debug_rule_match
function in trie.c
. I'm pretty sure this was a pre-existing issue that I didn't notice until I explicitly tested building with all of the new enable flags. I can't make a comment on the relevant code, because it doesn't show up in the changes here.
I'm running a build off of this PR on my keyboard right now, and it works the same as before, as expected.
I'm good with merging this as soon as the issue with building when CONSOLE=no is addressed. (Locally I fixed it by wrapping the entire body of the function in an #if CONSOLE
block, but I don't understand these issues as well as you, so maybe you have a better solution.
This PR covers three loosely related cleanup issues that will improve code quality and help us debug our work.
58 - We can now use the
st_debug
macro function to keep useful debug logging code around, without having to comment/uncomment it all the time. Example:If
SEQUENCE_TRANSFORM_DEBUG
is set to 0, or theST_DBG_SEQ_MATCH
flag hasn't been set viast_debug_set_flag
orst_debug_set_flag_str
, this call will do nothing. If you need to call a function only for debugging (or wrap a block a code), you can use thest_debug_check
macro function. Example:The tester now accepts -d command line options to enable these flags. The -h option has been updated to show the available flags. Example:
59 - The
SANITY_CHECK
define has been removed. The newst_assert
macro function is now used instead. This macro should be used whenever we want to make sure our assumptions are correct. Example:When compiling for the firmware, this call does nothing. In the tester, a failing assert will print a message and call
abort
, which gives us to opportunity to attach a debugger to investigate the issue. AllCDATA
andTDATA
calls are now using this to guard against OOB indexing.60 - ST feature/option defaults are now defined in
st_defaults.h
(which should be the first file included by our .c files if they need to use any of these defines). WARNING: some have been renamed!Here are the current default values:
If a user wants to change one of these, they should set it directly in their layout's
config.h
. (The tester Makefile automatically sets the ones it needs to be able to test everything.)