Maria developers/captains,
Prior to posing it as a final patch contribution or opening a JIRA ticket, I wanted to propose this idea.
The attached patch adds what amounts to compile-time checking for unmatched DBUG_ENTER/DBUG_LEAVE (DBUG_RETURN, DBUG_VOID_RETURN) by introducing a variable in DBUG_ENTER which is only used in DBUG_LEAVE. This allows any compiler which can robustly detect unused variables to detect the mismatch at compile-time. There is already a run-time check for this case, but it is somewhat limited as it requires _db_return_ to be called in order to detect the mismatch, and this is in practice not always the case. Particularly three cases allow this to escape detection:
- Some instrumented functions are called only from non-instrumented functions.
- Some instrumented functions are called only from non-returning functions, such as abort or die functions.
- Some instrumented functions are called from functions who call my_end or my_thread_end (making cs unavailable) before returning.
In any case please see the attached DRAFT patch for a full implementation of the idea. Note one bit of ugliness is that non-returning functions, after this patch, must be marked explicitly as DBUG_ENTER_NO_RETURN -- this actually is not really a bad thing, though in and of itself.
Regards,
Jeremy