qemu-arm
[Top][All Lists]
Advanced

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

[Qemu-arm] Regarding some issues with gdb


From: Sayandeep Saha
Subject: [Qemu-arm] Regarding some issues with gdb
Date: Wed, 8 Aug 2018 22:20:40 +0530

Hi,

I am Sayandeep Saha, a PhD scholar form Indian Institute of Technology, Kharagpur.  I am working on a project where I need to use gdb in the following ways to tweak a program at runtime:

1. Modify register values.

2. Modify an instruction (say replacing the opcode with another opcode or nop).

3. Modify constants in instructions (e.g. ldr  r0, [pc, #12] can be changed to 
ldr  r0, [pc, #8]; or the branch target can be changed)

I successfully made all these changes on my X86-64 Intel machine. However, for ARM I tried with QEMU. The test case was a simple C program for calculating factorials using loops. I ran the following commands:

Compilation:
arm-linux-gnueabi-gcc -g -static -Xlinker -N -mthumb -masm-syntax-unified factorial.c -o factorial

Run:
qemu-arm -g 1234 -L /usr/arm-linux-gnueabihf/ ./factorial

Next, I invoked gdb-multiarch from another shell to debug the program.


However, when I try to change some instruction using "set" command of GDB, it says "The memory location cannot be accessed".
Surprisingly, I can print the already existing contents of those memory locations using gdb's print command. Also, I could modify register values successfully.

I am really confused and wander whether it is possible to change memory contents within QEMU, or not. If it is possible, what is the step by step procedure for that.

 

Sayandeep Saha

PhD Student,
Indian Institute of Technology,
Kharagpur, India-721302

reply via email to

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