簡體   English   中英

GDB 中未顯示 SMP 線程

[英]SMP threads not showing in GDB

嘗試調試多 CPU SoC (Amlogic A113X) 並遇到問題。 所以我有這個調試配置: A113X(JTAG) -> Segger J-Link V11 -> OpenOCD -> gdb-multiarch 一切都已連接並且看起來還不錯,但是 GDB 只顯示 1 個線程(應該是 4 - 每個 CPU 一個):

(gdb) info threads
  Id   Target Id         Frame 
* 1    Remote target     0xffffff8009853364 in arch_spin_lock (lock=<optimized out>) at ./arch/arm64/include/asm/spinlock.h:89

同時根據 Telenet 'targets' 命令有 4 個調試目標:

> targets            
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* A113X.a53.0        aarch64    little A113X.cpu          halted
 1  A113X.a53.1        aarch64    little A113X.cpu          halted
 2  A113X.a53.2        aarch64    little A113X.cpu          unknown
 3  A113X.a53.3        aarch64    little A113X.cpu          halted

在這種特殊情況下,Core 2 被關閉。

當我停止 CPU 然后在 GDB 中得到這個 output:

(gdb) continue
Continuing.
^CA113X.a53.1 halted in AArch64 state due to debug-request, current mode: EL1H
cpsr: 0x800001c5 pc: 0xffffff8009853364
MMU: enabled, D-Cache: enabled, I-Cache: enabled
A113X.a53.3 halted in AArch64 state due to debug-request, current mode: EL1H
cpsr: 0x800000c5 pc: 0xffffff80098532b4
MMU: enabled, D-Cache: enabled, I-Cache: enabled

Program received signal SIGINT, Interrupt.
0xffffff8009853364 in arch_spin_lock (lock=<optimized out>) at ./arch/arm64/include/asm/spinlock.h:89
89      asm volatile(
(gdb) where
#0  0xffffff8009853364 in arch_spin_lock (lock=<optimized out>) at ./arch/arm64/include/asm/spinlock.h:89
#1  do_raw_spin_lock (lock=<optimized out>) at ./include/linux/spinlock.h:148
#2  __raw_spin_lock (lock=<optimized out>) at ./include/linux/spinlock_api_smp.h:145
#3  _raw_spin_lock (lock=0xffffffc01fb86a00) at kernel/locking/spinlock.c:151
#4  0xffffff80090c2114 in try_to_wake_up (p=0xffffffc01963a880, state=<optimized out>, wake_flags=0) at kernel/sched/core.c:2110
#5  0xffffff80090c239c in wake_up_process (p=<optimized out>) at kernel/sched/core.c:2203
#6  0xffffff80090b1b7c in wake_up_worker (pool=<optimized out>) at kernel/workqueue.c:837
#7  insert_work (pwq=<optimized out>, work=<optimized out>, head=<optimized out>, extra_flags=<optimized out>) at kernel/workqueue.c:1310
#8  0xffffff80090b1d10 in __queue_work (cpu=0, wq=0xdf2, work=0x8df2) at kernel/workqueue.c:1460
#9  0xffffff80090b1fc8 in queue_work_on (cpu=8, wq=0xffffffc01dbb5c00, work=0xffffffc01ccb82a0) at kernel/workqueue.c:1485
#10 0xffffff800191d068 in ?? ()
#11 0xffffffc0138664e8 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

我的 OpenOCD 配置有問題嗎? SMP 配置看起來不錯,因為它停止了所有 4 個內核。 這里有什么問題? 預先感謝。

這是openocd配置:

telnet_port 4444
gdb_port 3333
source [find interface/jlink.cfg]
transport select jtag
adapter speed 1000
scan_chain
set _CHIPNAME A113X
set _DAPNAME $_CHIPNAME.dap
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id 0x5ba00477
dap create $_DAPNAME -chain-position $_CHIPNAME.cpu
echo "$_CHIPNAME.cpu"
set CA53_DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
set CA53_CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}
set _num_ca53 4
set _ap_num 0
set smp_targets ""

proc setup_a5x {core_name dbgbase ctibase num boot} {
    for { set _core 0 } { $_core < $num } { incr _core } {
        set _TARGETNAME $::_CHIPNAME.$core_name.$_core
        set _CTINAME $_TARGETNAME.cti

        cti create $_CTINAME -dap $::_DAPNAME -ap-num $::_ap_num \
            -baseaddr [lindex $ctibase $_core]
    
        target create $_TARGETNAME aarch64 -dap $::_DAPNAME -cti $_CTINAME -coreid $_core
        set ::smp_targets "$::smp_targets $_TARGETNAME"
    }
}

setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 1
echo "SMP targets:$smp_targets"
eval "target smp $smp_targets"
targets $_CHIPNAME.a53.0

以及 OpenOCD 的 output:

Open On-Chip Debugger 0.11.0+dev-00640-ge83eeb44a (2022-04-21-10:10)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
A113X.cpu
SMP targets: A113X.a53.0 A113X.a53.1 A113X.a53.2 A113X.a53.3
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V11 compiled Mar  3 2022 10:16:14
Info : Hardware version: 11.00
Info : VTarget = 3.309 V
Info : clock speed 1000 kHz
Info : JTAG tap: A113X.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x5)
Info : A113X.a53.0: hardware has 6 breakpoints, 4 watchpoints
Info : A113X.a53.1: hardware has 6 breakpoints, 4 watchpoints
Error: JTAG-DP STICKY ERROR
Warn : target A113X.a53.2 examination failed
Info : A113X.a53.3: hardware has 6 breakpoints, 4 watchpoints
Info : A113X.a53.0 cluster 0 core 0 multi core
Info : A113X.a53.1 cluster 0 core 1 multi core
Info : A113X.a53.3 cluster 0 core 3 multi core
Info : starting gdb server for A113X.a53.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : New GDB Connection: 1, Target A113X.a53.0, state: halted
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
A113X.a53.1 halted in AArch64 state due to debug-request, current mode: EL1H
cpsr: 0x800001c5 pc: 0xffffff8009853364
MMU: enabled, D-Cache: enabled, I-Cache: enabled
A113X.a53.3 halted in AArch64 state due to debug-request, current mode: EL1H
cpsr: 0x800000c5 pc: 0xffffff80098532b4
MMU: enabled, D-Cache: enabled, I-Cache: enabled

我嘗試結合hwthreadtargete smp來實現多核。

為每個核心添加“-rtos hwthread”,例如

target create   ......   -rtos hwthread

在我看來,OpenOCD 將一個內核視為一個hwthread ,因此為每個內核設置hwthread 以下是信息線程的響應。

(gdb) i threads
  Id   Target Id                                           Frame 
* 1    Thread 1 (Name: riscv.cpu0.0, state: debug-request) 0x8000000a in _mstart ()
  2    Thread 2 (Name: riscv.cpu0.1, state: debug-request) 0x82000000 in ?? ()
  3    Thread 3 (Name: riscv.cpu0.2, state: debug-request) 0x82000000 in ?? ()
  4    Thread 4 (Name: riscv.cpu0.3, state: debug-request) 0x82000000 in ?? ()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM