[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] gdb and qemu-system-aarch64 setup - breakpoint not re
From: |
Raghunath Lolur |
Subject: |
Re: [Qemu-discuss] gdb and qemu-system-aarch64 setup - breakpoint not reached |
Date: |
Fri, 8 Aug 2014 16:32:42 +0530 |
Hello Peter Maydell,
Many thanks for your quick help.
Please find my answers inlined below:
On Fri, Aug 8, 2014 at 2:34 AM, Peter Maydell <address@hidden> wrote:
> On 7 August 2014 21:45, Raghunath Lolur
> <address@hidden> wrote:
>> I am using qemu-system emulator (qemu-system-aarch64) and gdb
>> (aarch64-linux-gnu-gdb) to debug a c program, both running on the same
>> system, i686-pc-linux-gnu on Ubuntu 12.04 LTS. However, with the gdb,
>> if I set a breakpoint and issue 'continue' command, it shows
>> continuing....and never reaches the breakpoint set.
>>
>> I am requesting help towards understanding the problem and resolving
>> it. Thanks in advance.
>>
>> Qemu version: 2.0.50 and gdb version : 7.8
>>
>> The steps I followed to set up debugging aarch64 program in qemu-system are:
>>
>> Terminal 1
>> ==========
>> $ cd /home/user1/qemu-aarch64/qemu.
>> git
>>
>> /home/user1/qemu-aarch64/qemu.git$
>> ./aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57
>> -machine type=virt -nographic -smp 1 -m 2047 -kernel
>> ../linux.git/arch/arm64/boot/Image -s -S
>>
>> Now, the execution freezes and I presume qemu along with gdbserver is
>> listening on port 1234
>
> This looks a bit odd. You haven't provided a guest filesystem, so how
> are you putting your adds2-output test program inside the guest OS?
I am a naive user of qemu. I am experimenting still, so I was trying
many things.
I have built qemu-system-aarch64 by following the steps in
http://www.bennee.com/~alex/blog/2014/05/09/running-linux-in-qemus-aarch64-system-emulation-mode/
By guest file system, do you mean something like buildroot? If yes, I
am using buildroot, as an initial RAM filesystem.
In the above case, I will not be able to access local file system.
>
> If you don't use "-s -S" does QEMU successfully boot your guest OS
> image and let you run the test program somehow?
Yes, it successfully boots.
However, to run the test program, I have to access local file system as below:
$ ./aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57
-machine type=virt -nographic -smp 1 -m 1024 -kernel
../linux.git/arch/arm64/boot/Image --append "console=ttyAMA0" -fsdev
local,id=r,path=/home/user1,security_model=none -device
virtio-9p-device,fsdev=r,mount_tag=r
and then mounting it using
$ mount -t 9p -o trans=virtio r /mnt
Enter "root/<with-no-passwd>" at login prompt, mount the local file
system as above.
Now, If I run the test program it displays "Hello AArch64 World!!!" on
the console.
>
> Do you really want to run an entire AArch64 guest OS kernel and
> your test program inside it, then attempt to debug the test program
> using the QEMU debug stub? There's no awareness in this
> configuration of individual guest OS processes, so if you put a
> breakpoint on a particular address then it will fire when execution
> hits that address for *any* process, not just the test binary.
> Maybe you wanted to use linux-user mode instead?
Many Many Thanks for reminding me about linux-user mode. In fact, I
built qemu-aarch64, the user emulation mode qemu some time ago and
also its static version with binfmt to run GCC test suite on my
i686-pc-linux-gnu host successfully. I did not know that this can be
used for remote debugging. After your hint, I searched the web and
using it as below:
$ export QEMU_LD_PREFIX=/home/user1/aarch64-crossbuild-gcc4.9.1/sysroot
$ /home/user1/qemu-aarch64/qemu-usermode/aarch64-linux-user/qemu-aarch64
-g 1234 adds2-output
Now, the gdbserver listens on port 1234
Next, in another terminal, I ran cross gdb to establish remote debug
connection. (Steps in Terminal 2 in my first post in this thread)
SUCCESS. Breakpoints hit, values of variables update and shown
properly. It is quite fast also.
>
> If you really do want to debug one process inside a complete
> guest OS, then you would be better off with running a gdb
> or gdbserver inside the guest and attaching to that, but unfortunately
> we haven't implemented that support quite yet. It ought to be in
> QEMU 2.2 though since I'm working on it at the moment.
Ah, that's why my trials with gdbserver on guest OS failed.
I built gdbserver for aarch64. I booted the guest OS using
qemu-system-aarch64, enabled local file system and then ran gdbserver
in guest OS as below:
root$ /home/user1/aarch64-crossbuild-gcc4.9.1/crossnative/bin/gdbserver
localhost:1234
In another terminal, when I tried to establish a remote debug
connection with my cross gdb (aarch64-linux-gnu-gdb), it failed.
My experiment to build gdb for target aarch64 also failed, since
building expat library (expat-2.1.0.tar.gz) with
--host=aarch64-linux-gnu failed, saying that "No support for aarch64".
Anyway, I was able to debug a program using gdb remote debug feature
and qemu user mode emulator. Thanks once again for your time.
>
> thanks
> -- PMM