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>
This commit is contained in:
committed by
Junio C Hamano
parent
773e25afc4
commit
0a9dde4a04
11
usage.c
11
usage.c
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user