PelionIoT / mbed-trace

mbed trace library
Apache License 2.0
18 stars 15 forks source link

Flash size can be limited by defining MBED_TRACE_MAX_LEVEL #53

Closed AnttiKauppila closed 7 years ago

AnttiKauppila commented 7 years ago

Currently e.g. Nanomesh-applications contains > 2500 tr_debug calls. This will cause a huge impact to flash size If app developer is only interested of error traces, he still had to include all the other traces as well to his build. This can now be tackled by defining MBED_TRACE_MAX_LEVEL, which will leave out every unneeded trace functions from builds.

jupe commented 7 years ago

Thanks, that was something what I've thinking already long time but haven't time to do. Another thing would be that we could select some how individual component to use trace instead "all-on"/"all-off" but it's probably more complex to implement.. CC: @tommikas @SeppoTakalo

tommikas commented 7 years ago

Tricky without touching every source file...

Could do something like:

Early in mbed_trace.h

#ifdef MBED_TRACE_DISABLE_TRACES
//undef/set to 0 the tracing enabling macros
#endif

In source files:

#define MBED_TRACE_DISABLE_TRACES
#include "mbed-trace/mbed_trace.h"

or even

#if MBED_CONF_<lib_name>_TRACES == 0
#define MBED_TRACE_DISABLE_TRACES
#endif
#include "mbed-trace/mbed_trace.h"

which would make it possible to use the mbed-os config system to control tracing for each compatible module from the mbed_app.json.

Anyway, outside the scope of this PR.

AnttiKauppila commented 7 years ago

CliNode size 4072388 dropped to 4050728 (~21kB) using ...MAX_LEVEL=2 (errors & cmdline traces) in simulator build