From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::436; helo=mail-wr1-x436.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1156A210C42BA for ; Tue, 31 Jul 2018 13:56:41 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h15-v6so17989772wrs.7 for ; Tue, 31 Jul 2018 13:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=l5DlpRxCYk3M3BQM8SYuxo3apSPAYlU/GD1IJGB0V2Y=; b=dsbq41x7Dm7P7hw1zsL8aylP0tPd3zHGZ9U0lITMill69sY3c/WgUsXombwXrYtcAz Fjz8XoMozC0MoK/MmyI91RWmD8+lbgAYlInkNaPO9vZG0HkXcy9Wn48QvnObLjjdWorm GlLVA4FEjeWUVbD/vjTUeKbj6KARyRDanjt8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=l5DlpRxCYk3M3BQM8SYuxo3apSPAYlU/GD1IJGB0V2Y=; b=Mcom+eqEha2vmkkAxCwMz2QZAzREFMKPS+kPsNmsJ9WP/cbP10bFG8qVikUhMBTLaT 75C0kW0ftRkvD4VusIaDYmYLvdOq3Vj5BT4CpWCZE4OIrPvsPwBacwUuho2OVbpwEhr0 DHDZdrpLpkpDDfAi4wT/g52YxRhRDiHsjJdtLv3H1qUHCKBmsP9BVgHr/W9zMPJ9L50u 9C/UisuAhSzoZsItAACYAO91pXBYGCVS/d5KfME58lybtodLfuL2Zz+3exA236rbKUa5 fclbznEKWznOzXs3NuEv0wDMY9RAYwKyVLxx3cPMt4+VV5Sh6QgbLY70WtQJy5R0jUCp aq+g== X-Gm-Message-State: AOUpUlFsT9/Kh4nO9lqckyIvIeJiqOcUrRr4eWGFuKNZrTgLsE1iqARA CAO7LU7dAYdETo4ghRLo5pZDPaSpq7A= X-Google-Smtp-Source: AAOMgpc8KDM3pVGphj/YgfLxCgFwf5Cwv5pDifAXzrQk7tuJseeyuDEUY5WNl06Hpg6RTbIWLhJWGg== X-Received: by 2002:adf:b243:: with SMTP id y3-v6mr23065729wra.90.1533070600151; Tue, 31 Jul 2018 13:56:40 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x129-v6sm4989396wme.11.2018.07.31.13.56.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 13:56:38 -0700 (PDT) Date: Tue, 31 Jul 2018 21:56:37 +0100 From: Leif Lindholm To: Chris Co Cc: "edk2-devel@lists.01.org" , Ard Biesheuvel , Michael D Kinney Message-ID: <20180731205637.wxvzwq2xnbiaieju@bivouac.eciton.net> References: <20180717020529.19496-1-christopher.co@microsoft.com> <20180717020529.19496-4-christopher.co@microsoft.com> MIME-Version: 1.0 In-Reply-To: <20180717020529.19496-4-christopher.co@microsoft.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2018 20:56:42 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 17, 2018 at 02:05:45AM +0000, Chris Co wrote: > This debug library provides support for importing symbols to > debug using Lauterbach. > > Derived from: ArmPkg\Library\DebugPeCoffExtraActionLib I'm not seeing any difference between this one and the original other than the addition of the Microsoft copyright statement and updating of the debug printouts to modern style. I would be happy to take this as a patch to the original, but I don't see what benefit this copy brings. What prevents you from using the original? / Leif > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Christopher Co > --- > Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.c | 142 ++++++++++++++++++++ > Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.inf | 41 ++++++ > 2 files changed, 183 insertions(+) > > diff --git a/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.c b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.c > new file mode 100644 > index 000000000000..0adfacdbe5cf > --- /dev/null > +++ b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.c > @@ -0,0 +1,142 @@ > +/**@file > + > +Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
> +Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
> +Portions copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
> +Copyright (c) Microsoft Corporation. All rights reserved.
> + > +This program and the accompanying materials > +are licensed and made available under the terms and conditions of the BSD License > +which accompanies this distribution. The full text of the license may be found at > +http://opensource.org/licenses/bsd-license.php > + > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > + > +/** > + If the build is done on cygwin the paths are cygpaths. > + /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert > + them to work with RVD commands > + > + @param Name Path to convert if needed > + > +**/ > +CHAR8 * > +DeCygwinPathIfNeeded ( > + IN CHAR8 *Name, > + IN CHAR8 *Temp, > + IN UINTN Size > + ) > +{ > + CHAR8 *Ptr; > + UINTN Index; > + UINTN Index2; > + > + Ptr = AsciiStrStr (Name, "/cygdrive/"); > + if (Ptr == NULL) { > + return Name; > + } > + > + for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); Index++, Index2++) { > + Temp[Index2] = Ptr[Index]; > + if (Temp[Index2] == '/') { > + Temp[Index2] = '\\' ; > + } > + > + if (Index2 == 1) { > + Temp[Index2 - 1] = Ptr[Index]; > + Temp[Index2] = ':'; > + } > + } > + > + return Temp; > +} > + > + > +/** > + Performs additional actions after a PE/COFF image has been loaded and relocated. > + > + If ImageContext is NULL, then ASSERT(). > + > + @param ImageContext Pointer to the image context structure that describes the > + PE/COFF image that has already been loaded and relocated. > + > +**/ > +VOID > +EFIAPI > +PeCoffLoaderRelocateImageExtraAction ( > + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext > + ) > +{ > +#if !defined(MDEPKG_NDEBUG) > + CHAR8 Temp[512]; > +#endif > + > + if (ImageContext->PdbPointer) { > +#ifdef __CC_ARM > +#if (__ARMCC_VERSION < 500000) > + // Print out the command for the RVD debugger to load symbols for this image > + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); > +#else > + // Print out the command for the DS-5 to load symbols for this image > + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); > +#endif > +#elif __GNUC__ > + // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required > + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Data.load.elf %a /reloc .text at 0x%p /nocode /noclear\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); > +#else > + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint))); > +#endif > + } else { > + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint))); > + } > +} > + > + > + > +/** > + Performs additional actions just before a PE/COFF image is unloaded. Any resources > + that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed. > + > + If ImageContext is NULL, then ASSERT(). > + > + @param ImageContext Pointer to the image context structure that describes the > + PE/COFF image that is being unloaded. > + > +**/ > +VOID > +EFIAPI > +PeCoffLoaderUnloadImageExtraAction ( > + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext > + ) > +{ > +#if !defined(MDEPKG_NDEBUG) > + CHAR8 Temp[512]; > +#endif > + > + if (ImageContext->PdbPointer) { > +#ifdef __CC_ARM > + // Print out the command for the RVD debugger to load symbols for this image > + DEBUG ((DEBUG_ERROR, "unload symbols_only %a\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)))); > +#elif __GNUC__ > + // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required > + DEBUG ((DEBUG_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); > +#else > + DEBUG ((DEBUG_ERROR, "Unloading %a\n", ImageContext->PdbPointer)); > +#endif > + } else { > + DEBUG ((DEBUG_ERROR, "Unloading driver at 0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress)); > + } > +} > diff --git a/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.inf b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.inf > new file mode 100644 > index 000000000000..2cfc51b0578f > --- /dev/null > +++ b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoffExtraActionLib.inf > @@ -0,0 +1,41 @@ > +#/** @file > +# PeCoff extra action libary for DXE phase that run Unix emulator. > +# > +# Lib to provide memory journal status code reporting Routines > +# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
> +# Portions copyright (c) 2010, Apple Inc. All rights reserved.
> +# Copyright (c) Microsoft Corporation. All rights reserved.
> +# > +# This program and the accompanying materials > +# are licensed and made available under the terms and conditions of the BSD License > +# which accompanies this distribution. The full text of the license may be found at > +# http://opensource.org/licenses/bsd-license.php > +# > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > +# > +# > +#**/ > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = LauterbachPeCoffExtraActionLib > + FILE_GUID = F5D296F5-C546-431F-8CAC-3E91043B452D > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = PeCoffExtraActionLib > + > +# > +# The following information is for reference only and not required by the build tools. > +# > +# VALID_ARCHITECTURES = ARM > +# > + > +[Sources.common] > + LauterbachPeCoffExtraActionLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + DebugLib > -- > 2.16.2.gvfs.1.33.gf5370f1 >