-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need "lighter weight" ETL_ASSERT #993
Comments
The It is accessed within the error handler via a static member function.
The invocation code in |
For example, in most of my code, I defined my own assert macro like so: We would need to define a standard 'assert_function' name for this to work with the syntax of |
Or require a macro to be defined by the user?
Then have an option for the macros in
|
I've just remembered that the error handler (which contains |
Perhaps it is simple as wrapping the definitions of |
For my "debug" builds I have been defining The problem comes when using Normally I wouldn't have a problem with this, except that all this code is inlined every time I call an ETL method that uses I think what I will do as an experiment is temporarily overwrite |
This is slightly off topic but still related. It looks as if (in my example) the compiler chooses to inline |
For my tests, I added the following lines to the bottom of
After compiling, here is the assembly for the same function I showed in my original question:
The quantitative improvement for me is the final binary size. Using To take this one step further, if I add
|
There are actually six macros to redefine, which can make it a little error prone. In my code, I added this to the macro definitions:-
|
If |
Mmm, this is not as straightforward as I first thought. |
I am using ETL on an MCU with a decently small flash size (64KB). I have bee digging through the compiler MAP file to decrease the size as much as possible for my debug build. I still want to have minimal optimization (achieved by -Og) and still have some form of assert
During my investigation, I cam across a whole chunk of functions that were larger than I expected. Looking into the list file (annotated assembly output), I found (one of many as an example) the following that uses an ETL data structure (a variant_pool in this case):
My main concern is the last part of this code which has a lot of references to
invocation_element
,invocation.stub
, etc. Upon further investigation, I discovered that this is related to how ETL implements ETL_ASSERT.Reading through the documentation on ETL's error handling here: https://www.etlcpp.com/error_handler.html and here: https://www.etlcpp.com/macros.html, I determine that, if I am not using exceptions nor the C standard assert macro, I want to use
ETL_LOG_ERRORS
.However, if looks like the implementation of error logging is what generates all this extra code.
So, my question is, is there a way (or can there by a way) to implement a lightweight assert for ETL?
For example, in most of my code, I defined my own assert macro like so:
#define MY_ASSERT(x) if (!(x)) { assert_function(); }
You don't get much debugging information, but I tend to use the debugger to back trace where an assert occurred.
The text was updated successfully, but these errors were encountered: