Commit db08c53fdd542bb7f83b ("scripts/gdb: fix parameter handling in $lx_per_cpu") changed the parameter handling of lx_per_cpu to use GdbValue instead of parsing the variable name. Update the documentation to reflect the new lx_per_cpu usage. Update the hrtimer_bases example to use rb_tree instead of the timerqueue_head.next pointer removed in commit 511885d7061eda3eb1fa ("lib/timerqueue: Rely on rbtree semantics for next timer").
Unified · Split
| @@ -127,35 +127,31 @@ Examples of using the Linux-provided gdb helpers · 126 unmodified lines | |||
| 127 | 127 | ||
| 128 | - Make use of the per-cpu function for the current or a specified CPU:: | 128 | - Make use of the per-cpu function for the current or a specified CPU:: |
| 129 | 129 | ||
| 130 | (gdb) p $lx_per_cpu("runqueues").nr_running | 130 | (gdb) p $lx_per_cpu(runqueues).nr_running |
| 131 | $3 = 1 | 131 | $3 = 1 |
| 132 | (gdb) p $lx_per_cpu("runqueues", 2).nr_running | 132 | (gdb) p $lx_per_cpu(runqueues, 2).nr_running |
| 133 | $4 = 0 | 133 | $4 = 0 |
| 134 | 134 | ||
| 135 | - Dig into hrtimers using the container_of helper:: | 135 | - Dig into hrtimers using the container_of helper:: |
| 136 | 136 | ||
| 137 | (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next | 137 | (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost |
| 138 | (gdb) p *$container_of($next, "struct hrtimer", "node") | 138 | (gdb) p *$container_of($leftmost, "struct hrtimer", "node") |
| 139 | $5 = { | 139 | $5 = { |
| 140 | node = { | 140 | node = { |
| 141 | node = { | 141 | node = { |
| 142 | __rb_parent_color = 18446612133355256072, | 142 | __rb_parent_color = 18446612686384860673, |
| 143 | rb_right = 0x0 <irq_stack_union>, | 143 | rb_right = 0xffff888231da8b00, |
| 144 | rb_left = 0x0 <irq_stack_union> | 144 | rb_left = 0x0 |
| 145 | }, | 145 | }, |
| 146 | expires = { | 146 | expires = 1228461000000 |
| 147 | tv64 = 1835268000000 | ||
| 148 | } | ||
| 149 | }, | 147 | }, |
| 150 | _softexpires = { | 148 | _softexpires = 1228461000000, |
| 151 | tv64 = 1835268000000 | 149 | function = 0xffffffff8137ab20 <tick_nohz_handler>, |
| 152 | }, | 150 | base = 0xffff888231d9b4c0, |
| 153 | function = 0xffffffff81078232 <tick_sched_timer>, | 151 | state = 1 '\001', |
| 154 | base = 0xffff88003fd0d6f0, | 152 | is_rel = 0 '\000', |
| 155 | state = 1, | 153 | is_soft = 0 '\000', |
| 156 | start_pid = 0, | 154 | is_hard = 1 '\001' |
| 157 | start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, | ||
| 158 | start_comm = "swapper/2\000\000\000\000\000\000" | ||
| 159 | } | 155 | } |
| 160 | 156 | ||
| 161 | 157 | ||
| @@ -120,35 +120,31 @@ Kgdb内核调试器、QEMU等虚拟机管理程序或基于JTAG的硬件接口 · 119 unmodified lines | |||
| 120 | 120 | ||
| 121 | - 对当前或指定的CPU使用per-cpu函数:: | 121 | - 对当前或指定的CPU使用per-cpu函数:: |
| 122 | 122 | ||
| 123 | (gdb) p $lx_per_cpu("runqueues").nr_running | 123 | (gdb) p $lx_per_cpu(runqueues).nr_running |
| 124 | $3 = 1 | 124 | $3 = 1 |
| 125 | (gdb) p $lx_per_cpu("runqueues", 2).nr_running | 125 | (gdb) p $lx_per_cpu(runqueues, 2).nr_running |
| 126 | $4 = 0 | 126 | $4 = 0 |
| 127 | 127 | ||
| 128 | - 使用container_of查看更多hrtimers信息:: | 128 | - 使用container_of查看更多hrtimers信息:: |
| 129 | 129 | ||
| 130 | (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next | 130 | (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost |
| 131 | (gdb) p *$container_of($next, "struct hrtimer", "node") | 131 | (gdb) p *$container_of($leftmost, "struct hrtimer", "node") |
| 132 | $5 = { | 132 | $5 = { |
| 133 | node = { | 133 | node = { |
| 134 | node = { | 134 | node = { |
| 135 | __rb_parent_color = 18446612133355256072, | 135 | __rb_parent_color = 18446612686384860673, |
| 136 | rb_right = 0x0 <irq_stack_union>, | 136 | rb_right = 0xffff888231da8b00, |
| 137 | rb_left = 0x0 <irq_stack_union> | 137 | rb_left = 0x0 |
| 138 | }, | 138 | }, |
| 139 | expires = { | 139 | expires = 1228461000000 |
| 140 | tv64 = 1835268000000 | ||
| 141 | } | ||
| 142 | }, | 140 | }, |
| 143 | _softexpires = { | 141 | _softexpires = 1228461000000, |
| 144 | tv64 = 1835268000000 | 142 | function = 0xffffffff8137ab20 <tick_nohz_handler>, |
| 145 | }, | 143 | base = 0xffff888231d9b4c0, |
| 146 | function = 0xffffffff81078232 <tick_sched_timer>, | 144 | state = 1 '\001', |
| 147 | base = 0xffff88003fd0d6f0, | 145 | is_rel = 0 '\000', |
| 148 | state = 1, | 146 | is_soft = 0 '\000', |
| 149 | start_pid = 0, | 147 | is_hard = 1 '\001' |
| 150 | start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, | ||
| 151 | start_comm = "swapper/2\000\000\000\000\000\000" | ||
| 152 | } | 148 | } |
| 153 | 149 | ||
| 154 | 150 | ||
| @@ -116,35 +116,31 @@ Kgdb內核調試器、QEMU等虛擬機管理程序或基於JTAG的硬件接口 · 115 unmodified lines | |||
| 116 | 116 | ||
| 117 | - 對當前或指定的CPU使用per-cpu函數:: | 117 | - 對當前或指定的CPU使用per-cpu函數:: |
| 118 | 118 | ||
| 119 | (gdb) p $lx_per_cpu("runqueues").nr_running | 119 | (gdb) p $lx_per_cpu(runqueues).nr_running |
| 120 | $3 = 1 | 120 | $3 = 1 |
| 121 | (gdb) p $lx_per_cpu("runqueues", 2).nr_running | 121 | (gdb) p $lx_per_cpu(runqueues, 2).nr_running |
| 122 | $4 = 0 | 122 | $4 = 0 |
| 123 | 123 | ||
| 124 | - 使用container_of查看更多hrtimers信息:: | 124 | - 使用container_of查看更多hrtimers信息:: |
| 125 | 125 | ||
| 126 | (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next | 126 | (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost |
| 127 | (gdb) p *$container_of($next, "struct hrtimer", "node") | 127 | (gdb) p *$container_of($leftmost, "struct hrtimer", "node") |
| 128 | $5 = { | 128 | $5 = { |
| 129 | node = { | 129 | node = { |
| 130 | node = { | 130 | node = { |
| 131 | __rb_parent_color = 18446612133355256072, | 131 | __rb_parent_color = 18446612686384860673, |
| 132 | rb_right = 0x0 <irq_stack_union>, | 132 | rb_right = 0xffff888231da8b00, |
| 133 | rb_left = 0x0 <irq_stack_union> | 133 | rb_left = 0x0 |
| 134 | }, | 134 | }, |
| 135 | expires = { | 135 | expires = 1228461000000 |
| 136 | tv64 = 1835268000000 | ||
| 137 | } | ||
| 138 | }, | 136 | }, |
| 139 | _softexpires = { | 137 | _softexpires = 1228461000000, |
| 140 | tv64 = 1835268000000 | 138 | function = 0xffffffff8137ab20 <tick_nohz_handler>, |
| 141 | }, | 139 | base = 0xffff888231d9b4c0, |
| 142 | function = 0xffffffff81078232 <tick_sched_timer>, | 140 | state = 1 '\001', |
| 143 | base = 0xffff88003fd0d6f0, | 141 | is_rel = 0 '\000', |
| 144 | state = 1, | 142 | is_soft = 0 '\000', |
| 145 | start_pid = 0, | 143 | is_hard = 1 '\001' |
| 146 | start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, | ||
| 147 | start_comm = "swapper/2\000\000\000\000\000\000" | ||
| 148 | } | 144 | } |
| 149 | 145 | ||
| 150 | 146 | ||
| @@ -141,7 +141,7 @@ LxCpus() · 140 unmodified lines | |||
| 141 | class PerCpu(gdb.Function): | 141 | class PerCpu(gdb.Function): |
| 142 | """Return per-cpu variable. | 142 | """Return per-cpu variable. |
| 143 | 143 | ||
| 144 | $lx_per_cpu("VAR"[, CPU]): Return the per-cpu variable called VAR for the | 144 | $lx_per_cpu(VAR[, CPU]): Return the per-cpu variable called VAR for the |
| 145 | given CPU number. If CPU is omitted, the CPU of the current context is used. | 145 | given CPU number. If CPU is omitted, the CPU of the current context is used. |
| 146 | Note that VAR has to be quoted as string.""" | 146 | Note that VAR has to be quoted as string.""" |
| 147 | 147 | ||
| @@ -158,7 +158,7 @@ PerCpu() · 10 unmodified lines | |||
| 158 | class PerCpuPtr(gdb.Function): | 158 | class PerCpuPtr(gdb.Function): |
| 159 | """Return per-cpu pointer. | 159 | """Return per-cpu pointer. |
| 160 | 160 | ||
| 161 | $lx_per_cpu_ptr("VAR"[, CPU]): Return the per-cpu pointer called VAR for the | 161 | $lx_per_cpu_ptr(VAR[, CPU]): Return the per-cpu pointer called VAR for the |
| 162 | given CPU number. If CPU is omitted, the CPU of the current context is used. | 162 | given CPU number. If CPU is omitted, the CPU of the current context is used. |
| 163 | Note that VAR has to be quoted as string.""" | 163 | Note that VAR has to be quoted as string.""" |
| 164 | 164 | ||