public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: Chris Co <Christopher.Co@microsoft.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: Re: [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library
Date: Tue, 31 Jul 2018 21:56:37 +0100	[thread overview]
Message-ID: <20180731205637.wxvzwq2xnbiaieju@bivouac.eciton.net> (raw)
In-Reply-To: <20180717020529.19496-4-christopher.co@microsoft.com>

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 <ard.biesheuvel@linaro.org>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Christopher Co <christopher.co@microsoft.com>
> ---
>  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.<BR>
> +Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
> +Portions copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation. All rights reserved.<BR>
> +
> +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 <PiDxe.h>
> +#include <Library/PeCoffLib.h>
> +
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/PeCoffExtraActionLib.h>
> +#include <Library/PrintLib.h>
> +
> +
> +/**
> +  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.<BR>
> +# Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
> +# Copyright (c) Microsoft Corporation. All rights reserved.<BR>
> +#
> +# 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
> 


  reply	other threads:[~2018-07-31 20:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  2:05 [PATCH edk2-platforms 0/3] Add Platform-Generic Packages to support Windows IoT Core Chris Co
2018-07-17  2:05 ` [PATCH edk2-platforms 1/3] Platform/Microsoft: Add SdMmc Dxe Driver Chris Co
2018-07-31 20:33   ` Leif Lindholm
2018-08-02  0:05     ` Chris Co
2018-08-02 11:38       ` Leif Lindholm
2018-07-17  2:05 ` [PATCH edk2-platforms 2/3] Platform/Microsoft: Add MsPkg Chris Co
2018-07-31 20:38   ` Leif Lindholm
2018-07-17  2:05 ` [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library Chris Co
2018-07-31 20:56   ` Leif Lindholm [this message]
2018-07-31 20:59     ` Ard Biesheuvel
2018-08-01  9:39       ` Leif Lindholm
2018-08-02  1:27         ` Chris Co
2018-08-02 11:22           ` Leif Lindholm

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=20180731205637.wxvzwq2xnbiaieju@bivouac.eciton.net \
    --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