From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=brian.richardson@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0DC372263DD66 for ; Mon, 16 Apr 2018 08:26:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 08:26:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="37767479" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by fmsmga002.fm.intel.com with ESMTP; 16 Apr 2018 08:26:42 -0700 Received: from orsmsx113.amr.corp.intel.com (10.22.240.9) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 16 Apr 2018 08:26:41 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.92]) by ORSMSX113.amr.corp.intel.com ([169.254.9.55]) with mapi id 14.03.0319.002; Mon, 16 Apr 2018 08:26:41 -0700 From: "Richardson, Brian" To: Johannes Swoboda , "edk2-devel@lists.01.org" CC: "clemens.hlauschek@inso.tuwien.ac.at" Thread-Topic: [edk2] Source code debugging of OVMF Thread-Index: AQHT1XN65UgrZ2/EM0iOpVuRkeB8T6QDg5Cg Date: Mon, 16 Apr 2018 15:26:40 +0000 Message-ID: <80AC2BAA3152784F98F581129E5CF5AFA47BB72C@ORSMSX114.amr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzk0NzAzY2ItMGVjNy00ZGFjLWFhN2ItMjJlMWRjYmZkY2FkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImxaeWsrYnJqQVZcLytWVXQzNUg1OGhpMzdkTFdzVFdpT1pNTURMekx2UmcwPSJ9 dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Subject: Re: Source code debugging of OVMF X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2018 15:26:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This page was recently added to the TianoCore wiki. Please let me know if t= his is useful info: https://github.com/tianocore/tianocore.github.io/wiki/How-to-debug-OVMF-wit= h-QEMU-using-GDB=20 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=20 -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Joha= nnes 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 cod= e 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 p= rocess. Is that possible? I understand I can start qemu with the options -s -S. This gives me a virtu= al machine that awaits connection of a gdb debugger and further instruction= s. After connecting with gdb, I can instruct the machine to continue execution= . Unsurprisingly, there is nothing else I can do, because gdb lacks the rel= evant symbols. I tried to read in the OVMF.fd file, as i would do with a binary that I wou= ld debug, but gdb can't handle the file. It seems to be possible to load an efi app with the file command, but not t= his one. I found one other person trying to achieve the same five years ago. [3] sug= gests 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=20 > been loaded is missing might be possible. However, it appears to me this is may contain informatio= n 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 deter= mining 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 sou= rce 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=3D0x402 -debugcon file:qemu.ovmf.log" as demonstrated h= ere 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]:=20 http://edk2-devel.narkive.com/LRWe2mSQ/using-gdb-on-ovmf-with-symbols [4]:=20 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