XRPL-Labs / xrpld-hooks

ISC License
94 stars 28 forks source link

Release mode for TRACE* macros missing in macro.h #42

Closed vbar closed 2 years ago

vbar commented 2 years ago

Issue Description

Hooks Builder implemented conditionally-disabled tracing (saving space by not including debugging strings in the hook) in hookmacro.h:

#ifdef NDEBUG
#define DEBUG 0
#else
#define DEBUG 1
#endif

#define TRACEVAR(v) if (DEBUG) trace_num((uint32_t)(#v), (uint32_t)(sizeof(#v) - 1), (int64_t)v);
#define TRACEHEX(v) if (DEBUG) trace((uint32_t)(#v), (uint32_t)(sizeof(#v) - 1), (uint32_t)(v), (uint32_t)(sizeof(v)), 1);
#define TRACEXFL(v) if (DEBUG) trace_float((uint32_t)(#v), (uint32_t)(sizeof(#v) - 1), (int64_t)v);
#define TRACESTR(v) if (DEBUG) trace((uint32_t)(#v), (uint32_t)(sizeof(#v) - 1), (uint32_t)(v), sizeof(v), 0);

New macro.h header has the old implementation:

#define TRACEVAR(v) trace_num((uint32_t)(#v), (uint32_t)(sizeof(#v) - 1), (int64_t)v);
#define TRACEHEX(v) trace((uint32_t)(#v), (uint32_t)(sizeof(#v)), (uint32_t)(v), (uint32_t)(sizeof(v)), 1);
#define TRACEXFL(v) trace_float((uint32_t)(#v), (uint32_t)(sizeof(#v)), (int64_t)v);
#define TRACESTR(v) trace((uint32_t)(#v), (uint32_t)(sizeof(#v)), (uint32_t)(v), sizeof(v), 0);

(note also the inconsistent name sizes).

Steps to Reproduce

Open an example in Hooks builder, add `#define NDEBUG to the top, compile.

Expected Result

It should produce a smaller wasm that doesn't call trace*...

Actual Result

...but has no effect.