Skip to content

Commit 2780f26

Browse files
committed
gdb: Improve debug scripts organization and output
Enhance debugging scripts with the following improvements: - Show backtraces for all threads during hard fault (not just current thread) - Clean up capture_race_state.gdb formatting and variable naming - Add GDB UI settings to combined_debug.gdb for better readability - Display only basename for files - Disable pagination - Enable pretty printing - Improve timestamp logging format in race condition debugging - Clean up comments and standardize debug message formatting The changes make debugging output more comprehensive and consistent.
1 parent eaaf330 commit 2780f26

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

scripts/capture_race_state.gdb

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
set pagination off
2-
set print pretty on
3-
4-
# Initialize tracking variables
51
set $cycle = 1
62

73
break async_context_base_remove_when_pending_worker
84
commands
95
silent
10-
printf "\n[Cycle: %d] remove worker: %p\n", $cycle, worker
11-
printf "[TIMESTAMP] Exit: %llu\n", timestamp_exit
12-
info args
13-
info address worker
14-
x/16wx worker
15-
set $w = (async_when_pending_worker_t *)worker
16-
p *$w
17-
if ($w->do_work != 0x1000a499)
18-
printf "\n[CORRUPTED] do_work changed from 0x1000a499 to %p!\n", $w->do_work
6+
printf "[Cycle: %d] remove worker: %p\n", $cycle, worker
7+
printf "[INFO] Enter: %llu; Exit: %llu\n", timestamp_enter, timestamp_exit
8+
x/4wx worker
9+
set $worker = (async_when_pending_worker_t *)worker
10+
p *$worker
11+
if ($worker->do_work != 0x1000a499)
12+
printf "[ERROR] do_work changed from 0x1000a499 to %p!\n", $worker->do_work
1913
end
20-
# Log but don't break for these fields
21-
if ($w->next != 0 && ($w->next < 0x20000000 || $w->next > 0x20042000))
22-
printf "\n[WARNING] next pointer invalid: %p\n", $w->next
14+
if ($worker->next != 0 && ($worker->next < 0x20000000 || $worker->next > 0x20042000))
15+
printf "[WARNING] next pointer invalid: %p\n", $worker->next
2316
end
24-
if ($w->work_pending > 1)
25-
printf "\n[WARNING] work_pending invalid: %d\n", $w->work_pending
17+
if ($worker->work_pending > 1)
18+
printf "[WARNING] work_pending invalid: %d\n", $worker->work_pending
2619
end
2720
bt
2821
set $cycle = $cycle + 1
@@ -33,12 +26,11 @@ break async_context_base_execute_once
3326
commands
3427
silent
3528
set $worker = (async_when_pending_worker_t *)self->when_pending_list
36-
printf "\n[Cycle: %d] execute once: %p\n", $cycle, $worker
37-
printf "[TIMESTAMP] Enter: %llu\n", timestamp_enter
29+
printf "[Cycle: %d] execute once: %p\n", $cycle, $worker
30+
printf "[INFO] Enter: %llu; Exit: %llu\n", timestamp_enter, timestamp_exit
3831
if $worker != 0
3932
x/4wx $worker
4033
p *$worker
41-
# Print timestamp info if worker exists
4234
end
4335
continue
4436
end

scripts/combined_debug.gdb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Load the race‑capture script that watches execute_sync()
1+
set filename-display basename
2+
set pagination off
3+
set print pretty on
24
source scripts/capture_race_state.gdb
3-
# Load the standard hard‑fault diagnostics
45
source scripts/hardfault_debug.gdb

scripts/hardfault_debug.gdb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ commands
88
set $fault_pc = *((unsigned int *)$sp + 6)
99
printf "\nCode around faulting PC (0x%08x):\n", $fault_pc
1010
disassemble $fault_pc-8, $fault_pc+8
11-
bt
11+
thread apply all backtrace
1212
echo \n==========================================\n
1313
end

0 commit comments

Comments
 (0)