Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87790C433F5 for ; Thu, 24 Mar 2022 16:28:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 722E384102; Thu, 24 Mar 2022 17:28:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=unixzen.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=unixzen.com header.i=@unixzen.com header.b="p6WZEBQB"; dkim=pass (1024-bit key) header.d=unixzen.com header.i=@unixzen.com header.b="JbKi34JP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B2EBC8410A; Thu, 24 Mar 2022 17:28:03 +0100 (CET) Received: from mx.dal1.terarocket.io (unknown [IPv6:2001:19f0:6401:8d3:5400:1ff:fe4f:75e6]) by phobos.denx.de (Postfix) with ESMTP id A5ABF840CE for ; Thu, 24 Mar 2022 17:28:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=unixzen.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=kallisti5@unixzen.com Received: by mx.dal1.terarocket.io (Postfix, from userid 1001) id 01A8F5E779; Thu, 24 Mar 2022 16:27:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mx.dal1.terarocket.io 01A8F5E779 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unixzen.com; s=default; t=1648139280; bh=dQ8EmOYaiv0MH4x+Qli+98iR+Obezx+IfndUOIWP0Vg=; h=Date:From:Subject:To:Cc:In-Reply-To:References:From; b=p6WZEBQBN57MQlrsU5l39qaFSSbr1izT4e+QBh84h0LqpvzGJHvr2knV7NNcaL9fK XFvYyKwrwb7ew/gEYquKwEnTn+XdvpI1gr46bqTcHWA5uz3k8C6Se0IVgO6YMxbjWC h/M3N6qokhKp3y/aY9HYLnRSdbRDZLOPGH3nXyoc= Received: from mx.dal1.terarocket.io (localhost [IPv6:::1]) by mx.dal1.terarocket.io (Postfix) with ESMTPSA id AE7AC5E567; Thu, 24 Mar 2022 16:27:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mx.dal1.terarocket.io AE7AC5E567 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unixzen.com; s=default; t=1648139271; bh=dQ8EmOYaiv0MH4x+Qli+98iR+Obezx+IfndUOIWP0Vg=; h=Date:From:Subject:To:Cc:In-Reply-To:References:From; b=JbKi34JPvkPCDla3szy1+Dog/LrVXggo36qEEthrgeroacbdKjAW/zLXVt3DQ13Zr OmRdrFGMbvqEisGs9JDTtp8zcLSrUyt6e5aC32eYFkJx5voesOXP6J+qzUOKzdMwxM HAgm0rbJNwRJplAUgz4GpKubXz45oGyNMqDhT65w= MIME-Version: 1.0 Date: Thu, 24 Mar 2022 16:27:51 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.13.0 From: "Alexander von Gluck IV" Message-ID: <427b81979230ed96d1b18935e2a9e97b@unixzen.com> Subject: Re: [RFC] Dumping load addresses - bootefi qemu gdb remote debugging To: "Bin Meng" , "Heinrich Schuchardt" , "Heinrich Schuchardt" Cc: "U-Boot Mailing List" In-Reply-To: References: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean See "[PATCH] efi_loader: Expose relocated address for gdb debugging purpo= ses"=0A=0A=0AThis actually solves the problem by exposing (previously hid= den) relocated address.=0A=0ANow it's a *LOT* easier to debug u-boot load= ed EFI binaries using the exposed address:=0AThis is helpful on pretty mu= ch every architecture (arm, arm64, riscv64)=0A=0A=0A(gdb) target extended= -remote 127.0.0.1:1234=0ARemote debugging using 127.0.0.1:1234=0A0x000000= 0000001000 in ?? ()=0A=0A(gdb) add-symbol-file u-boot 0xfff66000=0Aadd sy= mbol table from file "u-boot" at=0A .text_addr =3D 0xfff66000=0A(y or n) = y=0AReading symbols from u-boot...=0A=0A=0A**ADDRESS from this new log_in= fo:**=0A=0A(gdb) add-symbol-file objects/haiku/riscv64/debug_1/system/boo= t/efi/boot_loader_efi 0xbe6c6000=0Aadd symbol table from file "objects/ha= iku/riscv64/debug_1/system/boot/efi/boot_loader_efi" at=0A .text_addr =3D= 0xbe6c6000=0A(y or n) y=0AReading symbols from objects/haiku/riscv64/deb= ug_1/system/boot/efi/boot_loader_efi...=0A=0A(gdb) break platform_start_k= ernel=0ABreakpoint 1 at 0xbe6ca87c: file ../src/system/boot/platform/efi/= start.cpp, line 178.=0A=0A(gdb) c=0AContinuing.=0A=0ABreakpoint 1, platfo= rm_start_kernel () at ../src/system/boot/platform/efi/start.cpp:178=0A178= smp_init_other_cpus();=0A=0A^^ success!=0A=0A=0AThanks to apalos in IRC= for helping to identity where to add this!=0A=0A -- Alex=0A=0A=0A=0AMarc= h 24, 2022 10:27 AM, "Bin Meng" wrote:=0A> +Heinrich= Schuchardt=0A> =0A> On Thu, Mar 24, 2022 at 10:51 PM Alex wrote:=0A> =0A>> Good morning!=0A>> =0A>> So, some time ago I w= rote a short guide on how to debug EFI bootloaders started=0A>> by u-boot= in qemu.=0A>> =0A>> https://www.haiku-os.org/blog/kallisti5/2021-01-17_d= ebugging_riscv-64_bootloader_in_qemu=0A>> =0A>> At the time it worked, ho= wever figuring the elf load addresses from u-boot was extremely=0A>> diff= icult and required compiling it with full tracing and taking guesses at= =0A>> various EFI: Entry efi_load_image messages until I found the correc= t address.=0A>> =0A>> Is there an easier way to find the load addresses? = If not, a more verbose message=0A>> on non-debug builds might be extremel= y useful here.=0A>> =0A>> "positioning image at address 0xfe6b0000" or so= mething=0A>> =0A>> using the leveraged kernel_addr_r (0x84000000) was not= enough.=0A>> =0A>> -- Alex