debug: Call depth: Print ", depth=..." in the debug header
authorPavel Filipenský <pfilipensky@samba.org>
Fri, 26 Aug 2022 09:42:42 +0000 (11:42 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 26 Jan 2023 14:10:36 +0000 (14:10 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15287

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/util/debug.c

index 1e28a4a2dac19219877d26457467cbaf11d168d5..04537bdc142861b23cda7835acfa430c8c666a05 100644 (file)
@@ -1852,6 +1852,16 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
                }
        }
 
+       if (debug_call_depth > 0) {
+               state.hs_len += snprintf(state.header_str + state.hs_len,
+                                        sizeof(state.header_str) - state.hs_len,
+                                        ", depth=%zu",
+                                        debug_call_depth);
+               if (state.hs_len >= sizeof(state.header_str) - 1) {
+                       goto full;
+               }
+       }
+
        state.header_str[state.hs_len] = ']';
        state.hs_len++;
        if (state.hs_len < sizeof(state.header_str) - 1) {