diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2021-02-05 21:09:08 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-09 23:14:34 +0100 |
commit | 0a9dde4a04c1228025d292f44113cb8f9cebbfba (patch) | |
tree | 02ff80ac0ecd56c9f9d9a7f28e606bdef4a358f8 /usage.c | |
parent | Git 2.30.1 (diff) | |
download | git-0a9dde4a04c1228025d292f44113cb8f9cebbfba.tar.xz git-0a9dde4a04c1228025d292f44113cb8f9cebbfba.zip |
usage: trace2 BUG() invocations
die() messages are traced in trace2, but BUG() messages are not. Anyone
tracking die() messages would have even more reason to track BUG().
Therefore, write to trace2 when BUG() is invoked.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'usage.c')
-rw-r--r-- | usage.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -266,6 +266,10 @@ int BUG_exit_code; static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_list params) { char prefix[256]; + va_list params_copy; + static int in_bug; + + va_copy(params_copy, params); /* truncation via snprintf is OK here */ if (file) @@ -274,6 +278,13 @@ static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_lis snprintf(prefix, sizeof(prefix), "BUG: "); vreportf(prefix, fmt, params); + + if (in_bug) + abort(); + in_bug = 1; + + trace2_cmd_error_va(fmt, params_copy); + if (BUG_exit_code) exit(BUG_exit_code); abort(); |