qemu-riscv
[Top][All Lists]
Advanced

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

Re: Is there a way to check values of registers before and after running


From: Himanshu Chauhan
Subject: Re: Is there a way to check values of registers before and after running a program on qemu-system-risc64v?
Date: Wed, 19 Jun 2024 21:45:55 +0530



On Wed, Jun 19, 2024 at 9:20 PM Shobhit <shobhit32t@gmail.com> wrote:
Thank you for responding, Himanshu. 

Actually I wanted to check the value of registers, in order to verify if I am able to correctly load the program to the qemu.

I used the command you recommended. 
Using the "-S -s" command opens the qemu window with a black screen, with the word "PAUSED" written in the title bar. After that when I run riscv-gdb and do target remote, I get the following lines

>> Remote debugging using :1234
>> 0x0000000000001000 in ?? ()

And if I try to do run, I get the following error

>> The "remote" target does not support "run".  Try "help target" or "continue".

Typing "continue", leads to the terminal printing "Continuing.", followed by no blinking cursor (what looks like an infinite loop or pause).

Fist add the following at the end of the program:
1: j 1b
 
So it looks like:
.option norvc

.section .text.init
.global _start

_start:
    addi x5, x0, 6
    addi x5, x0, 4

1:  j 1b

Second,
At "Continuing",
Press CTRL+c and you will fall to GDB prompt again. Like so,

 (gdb) target remote :1234
Remote debugging using :1234
0x0000000000001000 in ?? ()
(gdb) continue
Continuing.
^C
Thread 4 received signal SIGINT, Interrupt.
[Switching to Thread 1.4]
_start () at test.S:10
10      1:      j 1b

(gdb) info registers
ra             0x0      0x0
sp             0x0      0x0
gp             0x0      0x0
tp             0x0      0x0
t0             0x4      4
t1             0x0      0
t2             0x0      0
fp             0x0      0x0
s1             0x0      0
a0             0x3      3
a1             0x87e00000       2279604224
a2             0x1028   4136
a3             0x0      0
a4             0x0      0
a5             0x0      0
a6             0x0      0
a7             0x0      0
s2             0x0      0
s3             0x0      0
s4             0x0      0
s5             0x0      0
s6             0x0      0
s7             0x0      0
s8             0x0      0
s9             0x0      0
s10            0x0      0
s11            0x0      0
t3             0x0      0
t4             0x0      0
t5             0x0      0
t6             0x0      0
pc             0x80000008       0x80000008 <_start+8>


Regards
Shobhit

On Wed, 19 Jun 2024 at 10:11, hchauhan@ventanamicro.com <hchauhan@ventanamicro.com> wrote:
Hi Shobhit,

Add "-S -s” to qemu command line.

riscv64-unknown-linux-gnu-gdb new.elf

Then, on GDB command line

"target remote :1234"

Run: “info registers”

Regards
Himanshu

From: qemu-riscv-bounces+hchauhan=ventanamicro.com@nongnu.org <qemu-riscv-bounces+hchauhan=ventanamicro.com@nongnu.org> on behalf of Shobhit <shobhit32t@gmail.com>
Date: Tuesday, 18 June 2024 at 10:20 PM
To: qemu-riscv@nongnu.org <qemu-riscv@nongnu.org>
Subject: Is there a way to check values of registers before and after running a program on qemu-system-risc64v?

I am trying to run a very basic RISC V assembly program on qemu-system-riscv64, is there a way to check/monitor the value of some particular registers before and after loading the program? I have tried passing -monitor stdio flag to qemu-system-risc64v, but it doesn't give me the values of registers.

This is the program I am running on bare metal risc64v emulator

.option norvc

.section .text.init
.global _start

_start:
    addi x5, x0, 6

    addi x5, x0, 4


And I am using ld script to load the program at the location 0x80000000 in memory.

This is the command I am using to start the emulator: qemu-system-riscv64 -machine virt -monitor stdio -cpu rv64 -smp 4 -m 128M -bios default new.elf

Here new.elf is the executable elf file created after compiling the above assembly program.


reply via email to

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