From 4f6345fde4cab04f1f5eb40311925a3613088652 Mon Sep 17 00:00:00 2001 From: Nick Bull Date: Thu, 20 Feb 2025 19:14:29 +0000 Subject: [PATCH] Improve ubt output: reduce whitespace, add colour --- backtrace_with_time/backtrace_with_time.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backtrace_with_time/backtrace_with_time.py b/backtrace_with_time/backtrace_with_time.py index 03bcc7e..d7d26fb 100644 --- a/backtrace_with_time/backtrace_with_time.py +++ b/backtrace_with_time/backtrace_with_time.py @@ -24,15 +24,19 @@ def invoke(arg, from_tty): # hitting anything we shouldn't. with udb.time.auto_reverting(), debugger_utils.breakpoints_suspended(): # Get the whole backtrace. - backtrace = debugger_utils.execute_to_string("where") + backtrace = debugger_utils.execute_to_string("where", styled=True) backtrace = backtrace.splitlines() + # The bbcount now is the largest that will be printed, so + # it can define the width of the column + bbcount_width = len(str(udb.time.get().bbcount)) + exception_hit = False for line in backtrace: if not exception_hit: # Print time at start of each backtrace line. time = udb.time.get() - print("[{}]\t{}".format(str(time.bbcount), line)) + print(f"[{time.bbcount:{bbcount_width}}] {line}") try: # Go back to previous frame debugger_utils.execute_to_string("rf")