qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

single stepping with gdb+qemu does not seem to work on SRET instruction


From: Yann Sionneau
Subject: single stepping with gdb+qemu does not seem to work on SRET instruction
Date: Sun, 14 Feb 2021 19:59:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello RISC-V qemu hackers,

I am trying to debug some uClibc-ng risc-v port issues, and while doing
so I tried to single step the kernel->user space transition.

I realized that when I was breaking on SRET insn in kernel, if I do
"si", I would expect to single step and end up at PC == $SEPC but it
does not seem to be the case.

Any idea why? Is it a bug or a known limitation? Or even normal behaviour?

Thanks for your insight :)

PS : my qemu --version says 5.2.0

Details of my qemu cmdline and debug session:

#############################

I run qemu like this:

fallen@fallen-ThinkPad-X260:~/dev/buildroot/build_riscv/images$ export
PATH="/home/fallen/dev/buildroot/build_riscv/host/bin:${PATH}"
fallen@fallen-ThinkPad-X260:~/dev/buildroot/build_riscv/images$
qemu-system-riscv64 -M virt -bios fw_jump.elf -kernel Image -append
"rootwait root=/dev/vda ro" -drive file=rootfs.ext2,format=raw,id=hd0
-device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device
virtio-net-device,netdev=net0 -nographic -s -S

Here is my GDB debugging session:

fallen@fallen-ThinkPad-X260:~/dev/buildroot/build_riscv$
./host/bin/riscv64-buildroot-linux-uclibc-gdb build/linux-5.10.7/vmlinux
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu
--target=riscv64-buildroot-linux-uclibc".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/linux-5.10.7/vmlinux...
(No debugging symbols found in build/linux-5.10.7/vmlinux)
(gdb) target remote :1234
Remote debugging using :1234
0x0000000000001000 in ?? ()
(gdb) b handle_syscall
Breakpoint 1 at 0xffffffe000201296
(gdb) c
Continuing.

Breakpoint 1, 0xffffffe000201296 in handle_exception ()

(gdb) b *0xffffffe000201350
Breakpoint 2 at 0xffffffe000201350
(gdb) c
Continuing.

Breakpoint 2, 0xffffffe000201350 in handle_exception ()
(gdb) display /i $pc
1: x/i $pc
=> 0xffffffe000201350 <handle_exception+412>:    sret
(gdb) p/x $sepc
$1 = 0xffffffe0008b6cd6
(gdb) si

Breakpoint 1, 0xffffffe000201296 in handle_exception ()
1: x/i $pc
=> 0xffffffe000201296 <handle_exception+226>:    sd    a0,280(sp)
(gdb) c
Continuing.

Breakpoint 2, 0xffffffe000201350 in handle_exception ()
1: x/i $pc
=> 0xffffffe000201350 <handle_exception+412>:    sret
(gdb) p/x $sepc
$2 = 0xffffffe0004a62c0
(gdb) si

Breakpoint 1, 0xffffffe000201296 in handle_exception ()

etc...

Regards,

-- 

Yann





reply via email to

[Prev in Thread] Current Thread [Next in Thread]