public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Richardson, Brian" <brian.richardson@intel.com>
To: Johannes Swoboda <johannes.swoboda@student.tuwien.ac.at>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "clemens.hlauschek@inso.tuwien.ac.at"
	<clemens.hlauschek@inso.tuwien.ac.at>
Subject: Re: Source code debugging of OVMF
Date: Mon, 16 Apr 2018 15:26:40 +0000	[thread overview]
Message-ID: <80AC2BAA3152784F98F581129E5CF5AFA47BB72C@ORSMSX114.amr.corp.intel.com> (raw)
In-Reply-To: <f825a2148078828bf5ed38b4a48d02b2@student.tuwien.ac.at>

This page was recently added to the TianoCore wiki. Please let me know if this is useful info:
https://github.com/tianocore/tianocore.github.io/wiki/How-to-debug-OVMF-with-QEMU-using-GDB 

Thanks ... br
---
Brian Richardson, Senior Technical Marketing Engineer, Intel Software
brian.richardson@intel.com -- @intel_brian (Twitter & WeChat)
https://software.intel.com/en-us/meet-the-developers/evangelists/team/brian-richardson 

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Johannes Swoboda
Sent: Monday, April 16, 2018 7:09 AM
To: edk2-devel@lists.01.org
Cc: clemens.hlauschek@inso.tuwien.ac.at
Subject: [edk2] Source code debugging of OVMF

Hello everyone,

I'm doing a research project on efi security. I would like to do source code debugging of OVMF. I want to step through the OVMF source code, set break points, et cetera, preferably with gdb. I want to debug the overall boot process. Is that possible?

I understand I can start qemu with the options -s -S. This gives me a virtual machine that awaits connection of a gdb debugger and further instructions.

After connecting with gdb, I can instruct the machine to continue execution. Unsurprisingly, there is nothing else I can do, because gdb lacks the relevant symbols.
I tried to read in the OVMF.fd file, as i would do with a binary that I would debug, but gdb can't handle the file.
It seems to be possible to load an efi app with the file command, but not this one.

I found one other person trying to achieve the same five years ago. [3] suggests that something like this
> (gdb) add-symbol-file ../edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug
> The address where ../edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug has 
> been loaded is missing
might be possible. However, it appears to me this is may contain information regarding Shell.efi, an efi-app; but I don't want to debug an app. I want to debug the overall boot process.

I'm quoting some terminal output to clarify what I'm trying to achieve:
[johannes@johannes-laptop OVMF_efi_hello_world]$ gdb [...]
(gdb) file OVMF.fd
"/home/johannes/18S/bakk/uefi_virtual/OVMF_efi_hello_world/OVMF.fd": not in executable format: File format not recognized
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
warning: No executable has been specified and target does not support determining executable automatically.  Try using the "file" command.
0x000000000000fff0 in ?? ()
(gdb) step
Cannot find bounds of current function
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb) continue
Continuing.
[ovmf loads in qemu window]

I can redirect ovmf debug messages into a text file[1].
As far as I understand, there is a way to do source code level debugging
*with* ovmf, to debug efi-apps that are e.g. run via the efi shell[2], with the help of SourceLevelDebugPkg[4], but this package cannot be used to source level debug the overall boot process, right?

Is it possible to do source level debugging of ovmf?
Is it possible to step through ovmf, one instruction or function call at a time?
How are you ovmf developer debugging it?

If you could point me to the right direction, that would be great.

Kind regards,
Johannes

[1]: I managed to do so via the qemu options -global
isa-debugcon.iobase=0x402 -debugcon file:qemu.ovmf.log" as demonstrated here https://www.linux-kvm.org/downloads/lersek/ovmf-whitepaper-c770f8c.txt
[2]:https://github.com/tianocore/tianocore.github.io/wiki/OVMF-FAQ#how-do-i-enable-source-level-debugging-with-ovmf
[3]: 
http://edk2-devel.narkive.com/LRWe2mSQ/using-gdb-on-ovmf-with-symbols
[4]: 
https://github.com/tianocore/tianocore.github.io/wiki/SourceLevelDebugPkg
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2018-04-16 15:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 11:09 Source code debugging of OVMF Johannes Swoboda
2018-04-16 15:26 ` Richardson, Brian [this message]
2018-04-16 16:03   ` Blibbet
2018-04-20 13:32   ` Johannes Swoboda
2018-04-16 16:13 ` Laszlo Ersek
2018-04-16 16:53   ` Palmer, Thomas
2018-04-16 18:25   ` Rebecca Cran
2018-04-16 19:57     ` Laszlo Ersek
2018-04-19  2:46     ` Rebecca Cran
2018-04-19  8:41       ` Laszlo Ersek
2018-04-20 14:54       ` gdb reload-uefi missing EFI_SYSTEM_TABLE_POINTER [was: Source code debugging of OVMF] Johannes Swoboda
2018-04-20 15:20         ` Laszlo Ersek
2018-04-20 15:58           ` Palmer, Thomas
2018-04-20 16:38             ` Johannes Swoboda
2018-04-20 16:45               ` Palmer, Thomas
2018-04-20 16:49               ` Rebecca Cran
2018-04-24  2:13         ` Gary Lin
2018-05-24 12:52           ` Johannes Swoboda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80AC2BAA3152784F98F581129E5CF5AFA47BB72C@ORSMSX114.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox