From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web09.26849.1653307281101684581 for ; Mon, 23 May 2022 05:01:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GYFTS+aX; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: osteffen@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653307280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aA/DXK/UDJeIB/Xankxa5hgbnTH6cd6kVA7F6pF0HJo=; b=GYFTS+aXPrEXP3bWfz3ao9EYT+J+1eBnMdfHF93ITwnq5BlcHvlu/n0tGoOb3rY+C4AlrD JjZidQgGgijo06dNuSHAaSJKMEKgkICfpKJDgY8vBaL9nYBAQNV4gM647TpjeSBE7u06DG WR6xWvoqsI/dxBXFrvTkqN5BG+zqmVE= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-108-6jd9nUMdNdS74o5wpcoTTw-1; Mon, 23 May 2022 08:01:19 -0400 X-MC-Unique: 6jd9nUMdNdS74o5wpcoTTw-1 Received: by mail-vk1-f197.google.com with SMTP id c26-20020ac5ca1a000000b00357a3d5b348so198703vkm.12 for ; Mon, 23 May 2022 05:01:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=aA/DXK/UDJeIB/Xankxa5hgbnTH6cd6kVA7F6pF0HJo=; b=S7jCletHItXuSddjUsCDX2eOEhr8VXE3o3pUZ+MLCbJJ+5+D/qCftYnUYRM4Vvb3Cw GpXpWcKvPftUQj1euaN70bpDVjds9xXgVi8538oC16VIye+Kn7NHo0au8rkrqZg5Pu+S W9YCt/11dAob0dZRn9oqKg0E5FauiM9NshwVfu7lXlT/SmLheYlaRgqmHg6P4eEasqio /i2NKqK/fdmNV3kZxhFCMrtAe/1V29+av7RxoG+iv3MCJxbCRXT2LWaceDUWG1RGmQs/ qnI/KYKdcfYng2qHY2p+sUpCEChUTH3gIjLnQadM1auYeoMl9hyg6dagcVqyne0tr12m c0Og== X-Gm-Message-State: AOAM531TJ+jzerphWpYQ/XGx/Bopop3wJ3bD1QWeDsA80c4fpcLnytbm ZvsgTK/ubfNDKEhsP207UklB9Bd7az+1K4k6Kvy6k1FYW1N6FwctQVdyf1aAvjNKpnJ/hZrn6Jv S3621nTTAc799CCBE5+YRwTqSbAjuRA== X-Received: by 2002:a05:6102:32c6:b0:333:bdd3:14f6 with SMTP id o6-20020a05610232c600b00333bdd314f6mr8250854vss.19.1653307278801; Mon, 23 May 2022 05:01:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNro8sUHswi5y9l1SBcoX8jGd3yqalJdew3zy6CHnvc+6C6C8Cx+UEaLSMJQBp2f/3eAijq1lClS5+BzC9juc= X-Received: by 2002:a05:6102:32c6:b0:333:bdd3:14f6 with SMTP id o6-20020a05610232c600b00333bdd314f6mr8250802vss.19.1653307277883; Mon, 23 May 2022 05:01:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Oliver Steffen" Date: Mon, 23 May 2022 14:01:10 +0200 Message-ID: Subject: Re: [edk2-devel] Debugging Ovmf with GDB: No symbol is recognized To: devel@edk2.groups.io, koenig_regina@arcor.de Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=osteffen@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Regina, I am not sure if I can help you with exactly the approach you are describin= g. Are you aware of the efi_gdb.py script in BaseToosl/Scripts? This can be used to debug OVMF with Qemu and gdb. See these messages: https://edk2.groups.io/g/devel/message/89621 https://edk2.groups.io/g/devel/message/77969 - Oliver On Mon, May 23, 2022 at 3:03 AM koenig_regina via groups.io wrote: > > Hi, I am trying to debug OVMF as suggested in https://retrage.github.io/2= 019/12/05/debugging-ovmf-en.html. > Almost every step seems to work fine. > > I built edk2 as follow: > ------------------------------ > $ git clone git@github.com:tianocore/edk2.git\ > $ cd edk2$ git submodule update --init --recursive > $ make -C BaseTools > $ source ./edksetup.sh > $ build -p OvmfPkg/OvmfPkgX64.dsc -b DEBUG -a X64 -t GCC5 > > > My Makefile looks like this: > -------------------------------------- > #!/usr/bin/env make > > SHELL=3D/bin/bash > > LOG=3Ddebug.log > OVMFBASE=3Dedk2/Build/OvmfX64/DEBUG_GCC5/ > OVMFCODE=3D$(OVMFBASE)/FV/OVMF_CODE.fd > OVMFVARS=3D$(OVMFBASE)/FV/OVMF_VARS.fd > QEMU=3Dqemu-system-x86_64 > QEMUFLAGS=3D-drive format=3Draw,file=3Dfat:rw:image \ > -drive if=3Dpflash,format=3Draw,readonly,file=3D$(OVMFCODE) \ > -drive if=3Dpflash,format=3Draw,file=3D$(OVMFVARS) \ > -debugcon file:$(LOG) -global isa-debugcon.iobase=3D0x402 \ > -serial stdio \ > -nographic \ > -nodefaults > > run: > $(QEMU) $(QEMUFLAGS) > > debug: > $(QEMU) $(QEMUFLAGS) -s -S > > .PHONY: run debug > > As first step, I let it run to get a debug.log where all the loading addr= esses are stored: > -------------------------------------------------------------------------= -------------------------------------------- > $ make run > > > Here an example of the information stored in debug.log: > -------------------------------------------------------------------------= ------- > $ less debug.log > ... > The 0th FV start address is 0x0000082000 > ... > Loading PEIM at 0x0000082BFC0 > Entry Point =3D 0x0000082F40A PcdPeim.efi > ... > > > To extract the .text section from *.efi binaries, I need peinfo: > -------------------------------------------------------------------------= ---------------- > $ git clone git@github.com:retrage/peinfo.git > $ cd peinfo > $ make > > I use peinfo in a bash script (gen_symbol_offset.sh) to get the symbol ad= dresses: > .........................................................................= ....................... > #!/bin/bash > > LOG=3D"debug.log" > BUILD=3D"edk2/Build/OvmfX64/DEBUG_GCC5/X64" > PEINFO=3D"peinfo/peinfo" > > cat ${LOG} | grep Loading | grep -i efi | while read LINE; do > BASE=3D"`echo ${LINE} | cut -d " " -f4`" > NAME=3D"`echo ${LINE} | cut -d " " -f6 | tr -d "[:cntrl:]"`" > ADDR=3D"`${PEINFO} ${BUILD}/${NAME} \ > | grep -A 5 text | grep VirtualAddress | cut -d " " -f2`" > TEXT=3D"`python -c "print(hex(${BASE} + ${ADDR}))"`" > SYMS=3D"`echo ${NAME} | sed -e "s/\.efi/\.debug/g"`" > echo "add-symbol-file ${BUILD}/${SYMS} ${TEXT}" > done > > ...and create a script for gdb to add the symbol files: > -------------------------------------------------------------------------= ---- > $ bash gen_symbol_offsets.sh > gdbscript > $ cat gdb > ... > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x82c380 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterP= ei.debug 0x831080 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerPei.de= bug 0x833100 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformPei.debug 0x835= 100 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/PeiCore.debug 0x7ee8240 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeIpl.debug 0x7ee3240 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3Resume2Pei.debug 0x7e= df240 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuMpPei.debug 0x7ed624= 0 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeCore.debug 0x7ea8240 > add-symbol-file edk2/Build/OvmfX64/DEBUG_GCC5/X64/DevicePathDxe.debug 0x7= b8f240 > ... > > Second step is to run it again with -s -S flags, Qemu waits for connectio= n > ---------------------------------------------------------------- > $ make debug > > > In a second Terminal I type: > ------------------------------------------------- > $ gdb > (gdb) source gdbscript > .... > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/UsbBusDxe.debug" at > .text_addr =3D 0x6c85240 > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/UsbKbDxe.debug" at > .text_addr =3D 0x6cb3240 > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/UsbMassStorageDxe.debug" at > .text_addr =3D 0x6c6d240 > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/QemuVideoDxe.debug" at > .text_addr =3D 0x6c66240 > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/VirtioGpuDxe.debug" at > .text_addr =3D 0x6c60240 > add symbol table from file "/home/koenigr/Memtest/git/edk2/Build/OvmfX64/= DEBUG_GCC5/X64/Shell.debug" at > .text_addr =3D 0x64f5240 > > The next three commands are just to verify that the symbols are loaded co= rrectly: > -------------------------------------------------------------------------= --------------------------------------------- > (gdb) info functions CoreHandleProtocol > All functions matching regular expression "CoreHandleProtocol": > File /.../edk2/MdeModulePkg/Core/Dxe/Hand/Handle.c: > EFI_STATUS CoreHandleProtocol(EFI_HANDLE, EFI_GUID *, void **); > > (gdb) info address CoreHandleProtocol > Symbol "CoreHandleProtocol" is a function at address 0x7ea4aa9. > > (gdb) info symbol 0x82F40A > _ModuleEntryPoint in section .text of /home/koenigr/Memtest/git/edk2/Buil= d/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug > > > (gdb) b CoreHandleProtocol > (gdb) b *0x82F40A > Breakpoint 2 at 0x82f40a: file /home/koenigr/Memtest/git/edk2/MdePkg/Libr= ary/PeimEntryPoint/PeimEntryPoint.c, line 33. > > (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) c > Qemu starts to continue.... > The debugger should stop at a breakpoint, so that we could do source code= level debug. > > !!!BUT NOTHING HAPPENS.!! > OVMF.fd starts und runs until the Shell is loaded and is waiting for user= input. BUT NO STOP at any breakpoint. > > Do you have any suggestions what might be the reason why it does not work= ? > > Thanks in advance, > Regina K=C3=B6nig >=20