* [Qemu-devel] GDB debugging of QEMU. @ 2013-08-09 16:45 Yaodong Yang 2013-08-09 16:56 ` Peter Maydell 0 siblings, 1 reply; 6+ messages in thread From: Yaodong Yang @ 2013-08-09 16:45 UTC (permalink / raw) To: qemu-devel; +Cc: Yaodong Yang [-- Attachment #1: Type: text/plain, Size: 667 bytes --] Hello everyone, I have a simple question about the debugging of qemu. I used the qemu-1.5.1, and added several .c and .h files related the block drivers. I want to debug my own implementations using gdb. but I have no idea how to do it. I tried the following commands. ./configure --enable-debug --disable-werror --enable-kvm --prefix=/usr/local/kvm make -j4 sudo make install gdb sudo /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda ubuntu.img -m 1024. Could someone give me some guidance on how to use gdb in QEMU. I know the basic usage of gdb for simple .c file, but I really donot know how to use it in QEMU. Thanks a lot in advance! Yaodong [-- Attachment #2: Type: text/html, Size: 967 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] GDB debugging of QEMU. 2013-08-09 16:45 [Qemu-devel] GDB debugging of QEMU Yaodong Yang @ 2013-08-09 16:56 ` Peter Maydell 2013-08-09 17:11 ` Yaodong Yang 0 siblings, 1 reply; 6+ messages in thread From: Peter Maydell @ 2013-08-09 16:56 UTC (permalink / raw) To: Yaodong Yang; +Cc: qemu-devel On 9 August 2013 17:45, Yaodong Yang <yaodong.yangy@gmail.com> wrote: > I tried the following commands. > > ./configure --enable-debug --disable-werror --enable-kvm > --prefix=/usr/local/kvm --disable-werror is usually not a good idea for developers. > make -j4 > > sudo make install > > gdb sudo /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda > ubuntu.img -m 1024. Why are you running qemu as root here? (ie why 'sudo'?) > Could someone give me some guidance on how to use gdb in QEMU. > I know the basic usage of gdb for simple .c file, but I really > do not know how to use it in QEMU. There is no particular difference. QEMU is a bigger program but has no particular gotchas for being debugged. -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] GDB debugging of QEMU. 2013-08-09 16:56 ` Peter Maydell @ 2013-08-09 17:11 ` Yaodong Yang 2013-08-09 17:14 ` Peter Maydell 0 siblings, 1 reply; 6+ messages in thread From: Yaodong Yang @ 2013-08-09 17:11 UTC (permalink / raw) To: Peter Maydell; +Cc: Yaodong Yang, qemu-devel [-- Attachment #1: Type: text/plain, Size: 1801 bytes --] Hello Peter, Best, Yaodong ---------------------------------------------- Yaodong Yang Ph.D. Student Department of Computer Science & Engineering University of Nebraska-Lincoln Email: yaodong.yangy@gmail.com OR yyang@cse.unl.edu On Aug 9, 2013, at 11:56 AM, Peter Maydell <peter.maydell@linaro.org> wrote: > On 9 August 2013 17:45, Yaodong Yang <yaodong.yangy@gmail.com> wrote: >> I tried the following commands. >> >> ./configure --enable-debug --disable-werror --enable-kvm >> --prefix=/usr/local/kvm > > --disable-werror is usually not a good idea for developers. I see, I will get rid of it in my development. > >> make -j4 >> >> sudo make install >> >> gdb sudo /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda >> ubuntu.img -m 1024. > > Why are you running qemu as root here? (ie why 'sudo'?) In my implementation, I need to read and write to other raw disks, so I think I need the root permission to run this program. > >> Could someone give me some guidance on how to use gdb in QEMU. >> I know the basic usage of gdb for simple .c file, but I really >> do not know how to use it in QEMU. > > There is no particular difference. QEMU is a bigger program > but has no particular gotchas for being debugged. I think I did not make my question clear. I do not know 1. how to add "-g" flag when compile QEMU, in order to use gdb 2. how to invoke QEMU with gdb, because my previous attempt failed. "gdb sudo /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda" by the way, when I add storagemanager.c and storagemanager.h to the root directory, in order to compile and link them, I add storagemanger.o in Makefile.objs, as "block-obj-y += nbd.o block.o storagemanager.o" in line 10. Thanks a lot! > > -- PMM [-- Attachment #2: Type: text/html, Size: 5110 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] GDB debugging of QEMU. 2013-08-09 17:11 ` Yaodong Yang @ 2013-08-09 17:14 ` Peter Maydell 2013-08-09 17:25 ` Max Filippov 0 siblings, 1 reply; 6+ messages in thread From: Peter Maydell @ 2013-08-09 17:14 UTC (permalink / raw) To: Yaodong Yang; +Cc: qemu-devel On 9 August 2013 18:11, Yaodong Yang <yaodong.yangy@gmail.com> wrote: > I think I did not make my question clear. I do not know > 1. how to add "-g" flag when compile QEMU, in order to use gdb This is what passing --enable-debug to configure does. > 2. how to invoke QEMU with gdb, > because my previous attempt failed. "gdb sudo > /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda" This won't work because you're running gdb as your own user and attempting to debug a program running as root. 'sudo gdb qemu-system-x86_64 ...' will probably work. (Also, you almost certainly want to run gdb on the binary that you just built rather than on the binary in /usr/local/kvm/bin which is presumably whatever older version was last installed.) -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] GDB debugging of QEMU. 2013-08-09 17:14 ` Peter Maydell @ 2013-08-09 17:25 ` Max Filippov 2013-08-09 18:45 ` Yaodong Yang 0 siblings, 1 reply; 6+ messages in thread From: Max Filippov @ 2013-08-09 17:25 UTC (permalink / raw) To: Peter Maydell; +Cc: Yaodong Yang, qemu-devel On Fri, Aug 9, 2013 at 9:14 PM, Peter Maydell <peter.maydell@linaro.org> wrote: > On 9 August 2013 18:11, Yaodong Yang <yaodong.yangy@gmail.com> wrote: >> 2. how to invoke QEMU with gdb, >> because my previous attempt failed. "gdb sudo >> /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda" > > This won't work because you're running gdb as your own > user and attempting to debug a program running as root. > 'sudo gdb qemu-system-x86_64 ...' will probably work. > > (Also, you almost certainly want to run gdb on the binary > that you just built rather than on the binary in > /usr/local/kvm/bin which is presumably whatever older > version was last installed.) You also need --args when you pass arguments to the application being debugged, so the command line looks like sudo gdb --args /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda -- Thanks. -- Max ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] GDB debugging of QEMU. 2013-08-09 17:25 ` Max Filippov @ 2013-08-09 18:45 ` Yaodong Yang 0 siblings, 0 replies; 6+ messages in thread From: Yaodong Yang @ 2013-08-09 18:45 UTC (permalink / raw) To: Max Filippov; +Cc: Peter Maydell, Yaodong Yang, qemu-devel [-- Attachment #1: Type: text/plain, Size: 1278 bytes --] It works! Thank you very much! Best, Yaodong ---------------------------------------------- Yaodong Yang Ph.D. Student Department of Computer Science & Engineering University of Nebraska-Lincoln Email: yaodong.yangy@gmail.com OR yyang@cse.unl.edu On Aug 9, 2013, at 12:25 PM, Max Filippov <jcmvbkbc@gmail.com> wrote: > On Fri, Aug 9, 2013 at 9:14 PM, Peter Maydell <peter.maydell@linaro.org> wrote: >> On 9 August 2013 18:11, Yaodong Yang <yaodong.yangy@gmail.com> wrote: >>> 2. how to invoke QEMU with gdb, >>> because my previous attempt failed. "gdb sudo >>> /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda" >> >> This won't work because you're running gdb as your own >> user and attempting to debug a program running as root. >> 'sudo gdb qemu-system-x86_64 ...' will probably work. >> >> (Also, you almost certainly want to run gdb on the binary >> that you just built rather than on the binary in >> /usr/local/kvm/bin which is presumably whatever older >> version was last installed.) > > You also need --args when you pass arguments to the application > being debugged, so the command line looks like > > sudo gdb --args /usr/local/kvm/bin/qemu-system/x86_64 -s -enable-kvm -hda > > -- > Thanks. > -- Max [-- Attachment #2: Type: text/html, Size: 4363 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-08-09 18:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-08-09 16:45 [Qemu-devel] GDB debugging of QEMU Yaodong Yang 2013-08-09 16:56 ` Peter Maydell 2013-08-09 17:11 ` Yaodong Yang 2013-08-09 17:14 ` Peter Maydell 2013-08-09 17:25 ` Max Filippov 2013-08-09 18:45 ` Yaodong Yang
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.