Debug qemu with gdb

12,597

Solution 1

I got an error with GDB 7.5 -> "Error accessing memory address"

It seems there is a problem with "Position Independet Executables" ...so use

./configure --enable-debug --disable-pie

and debug should work.

Solution 2

Try the following:

./configure --enable-debug

By default qemu builds with "CFLAGS = -O2 -g" option which somehow doesn't allow debug symbols to be added. Using --enable-debug option will mean -O2 will not be added.

Share:
12,597

Related videos on Youtube

renjith
Author by

renjith

have used stackoverflow extensively to find answers...withuot even asking a question.. :) my friend and i are starting to work on a project that tries to modify qemu to meet our needs.. qemu doesnt seem to have good documentation.. so need help from ppl who have meddled with qemu before... thanx for all help in advance...

Updated on June 04, 2022

Comments

  • renjith
    renjith 6 months

    How can I use gdb to debug qemu? I have been googling but couldn't find anything concrete.

  • webbertiger
    webbertiger about 9 years
    +1 for --disable-pie. My gdb 6.7.1 sees the same issue if pie is enabled.
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com over 3 years
    At least in Ubuntu 18.04 GCC 7.4 4.0.0, the default build does -O2 -g according to make V=1 which does add debug symbols and I can see the source. The problem is that a lot of stuff is optimized out and so you lose visibility and jump around weirdly. Without -O2 we have the default -O0: stackoverflow.com/questions/1778538/… Linux kernel boot slowdown was about 3x.
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com over 3 years
    --disable-pie is not needed at least as of Ubuntu 18.04 GCC 7.4 QEMU 4.0.0. You will likely want PIE whenever possible to mitigate VM breakouts vulnerabilities: stackoverflow.com/questions/2463150/…

Related