user12691131
user12691131

Reputation: 11

Attach GDB to Qemu running different kernels on each smp

How do I attach gdb to ARM Qemu board with each smp running different kernels? When I use gdb options, I can only specify one kernel with the file option in gdb.

Qemu Command :

qemu-system-aarch64 -M virt -smp 2 \
-display none -nographic \
-device loader,file=f1.axf,cpu-num=0 \
-device loader,file=f2.axf,cpu-num=1 -s -S

gdb commands ran:

gdb-multiarch
target remote localhost:1234
file f1.axf

After this, gdb shows two threads, both showing debug source as f1.axf.

If I pass f2.axf in file option, both thread show source and debug info from f2.axf.

There is no error message from gdb

Setup:

Upvotes: 1

Views: 484

Answers (1)

user12691131
user12691131

Reputation: 11

I had to add each smp cpu as an Arm Cpucluster in my Qemu board file. Make sure that you assign different cluster index to each cpu, else they will attach to same GDB. So for N number of clusters, you can attach N gdbs. After that gdb can be attached to Qemu listening on port 1234, using following commands:

gdb-multiarch
target extended :1234
file f1.axf
add-inferior
inferior 2
attach 2
file f2.axf
info thread

Add as many inferiors as many cpu clusters you have. To attach to cluster 4, add command attach 4 in gdb.

Upvotes: 0

Related Questions