|
From: | Shobhit |
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 22:27:35 +0530 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 |
On 19/06/24 21:45, Himanshu Chauhan wrote:
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 1bSo 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 :1234Remote 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>
On pressing CTRL+C, I am getting the following line:
>> Thread 1 received signal SIGINT, Interrupt.
>> 0x0000000080007bac in ?? ()
Instead of the following:
Thread 4 received signal SIGINT, Interrupt.
[Switching to Thread 1.4]
_start () at test.S:10
10 1: j 1b
And on doing subsequent info register calls, the x5 register is
still set as 0x0.
RegardsShobhit
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”
RegardsHimanshu
[Prev in Thread] | Current Thread | [Next in Thread] |