How can I use gdb to debug qemu? I have been googling but couldn't find anything concrete.
- @ismail Hi..Can anyone help me get started with debugging qemu with gdb? The information provided below is not very clear to me. Configuring the debug flags alone is not meeting my requirements. (May be I am missing something totally) My requirement is to use gdb to debug segfaults happening to my custom qemu. Please note that I do NOT want to debug something else (kernel) with qemu and gdb.Sandhya Kumar– Sandhya Kumar2015-07-22 12:53:52 +00:00Commented Jul 22, 2015 at 12:53
Add a comment |
2 Answers
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.
3 Comments
webbertiger
+1 for --disable-pie. My gdb 6.7.1 sees the same issue if pie is enabled.
Ciro Santilli OurBigBook.com
--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/…gwshi
remind maybe this answer is old, use --disable-pie I can't compile qemu master
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.
1 Comment
Ciro Santilli OurBigBook.com
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.