From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.42.138; helo=nam03-by2-obe.outbound.protection.outlook.com; envelope-from=christopher.co@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0138.outbound.protection.outlook.com [104.47.42.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D87F2098C21A for ; Mon, 16 Jul 2018 19:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pg9klPWH2BtvWwRjilCc8B0s7a9GQmsaG2T6ayKLkPI=; b=YwtQmd5wGctUdIUc6LncSzc7onhmhP8tL9s1mWvkOGW5EmrfsBr7rGv3BkW4BlDJeaDGbDGJoMPA1RPVlul9DGbRVZudM1EAng+lbPtOOnPfvAtFu7dNJvjbMUIIsCw8Rl2ZWBTQJe6vcnj2lwWvM3/5HVouW5BwuLyQKbj9izE= Received: from DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) by DM5PR2101MB1062.namprd21.prod.outlook.com (52.132.128.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.1; Tue, 17 Jul 2018 02:05:45 +0000 Received: from DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::b4d3:dabb:9372:9740]) by DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::b4d3:dabb:9372:9740%2]) with mapi id 15.20.0995.004; Tue, 17 Jul 2018 02:05:45 +0000 From: Chris Co To: "edk2-devel@lists.01.org" CC: Ard Biesheuvel , Leif Lindholm , Michael D Kinney Thread-Topic: [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library Thread-Index: AQHUHXKrAFwrC5JoCEOD88Z1/HY/IA== Date: Tue, 17 Jul 2018 02:05:45 +0000 Message-ID: <20180717020529.19496-4-christopher.co@microsoft.com> References: <20180717020529.19496-1-christopher.co@microsoft.com> In-Reply-To: <20180717020529.19496-1-christopher.co@microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN2PR01CA0041.prod.exchangelabs.com (2603:10b6:804:2::51) To DM5PR2101MB1128.namprd21.prod.outlook.com (2603:10b6:4:a8::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2001:4898:80e8:9:79cf:d6d4:d0ef:f79b] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB1062; 6:RFWmuhGHVrI8lEWKFhTIqFItkmSMbq9STZToAG2ihCtpjTM5g43APXMsVy4Vb5wV1Xse103ietqMBD4cnYeC3C+B1RTduInuPzuWXooHyvjpua8YMwNwNmQNfJjNScA+0bXoaITKZn4or3InT1KwIZiyAuwx8cDPUmZrzgh7E77HJYVA+uwxQ01ximGKcSxbH9AZpnU6ZCJ+RDyHlq49bmq0Bt6zQWbxSiSueOyVITcDt590TqKAz/YBt0bvRyd253S3NA/7H4ER6+JfpZSM0vS3J0Pahg63rK2xqXY1GUBtoldYGxWsdssEwWQCOWogEk3wwOUikQ2OLgrvIVbXyYKpbRxNN9Y0fVScPE5dQUYurSpPgP0MS4Db8sMFCtq+hq5sFvDfkSxTyca9AbCNHPgTgzYIpmltpisWUHJq4tQxkU8j0rAoDymJY/Gsy9Hqfl5cNzSDVrDfAXPfmkGvTA==; 5:/2Apn8jem+VMd4pd13WipEYx4j3830A9RkhwjbYCtDo3n93JhOlm3KbrYxgmIN1B+j2QMGDwcuXeAvqqoeb3EnS5xLgyOV/Ksq2nAWZIL/5q4WACOOU97/HFlfughxbljME8igBO6bcQdREf9+qZg6A/L040auniB1I+bLKkJn0=; 7:9CZYxhGtcoioW0OHb0YH26F1Z9zpFR1Z13q9+Fj+OaPvILRAMZeL0sENpBL/MgNdk4b+t5Us0cEqNa+BL/H7P+gsX1m1JAQYHl6yL1F5SS80wbqwDgQ8gA2lLm22lkMeu06lWzvCnDQN7IrClTfJTsjxuM3VbiRVQZ+ODD5e0nDJy+aPq2qDSpuY/TSEekMNTBx0JfgWT2gYgn47GOF8cX1jZO7zaxm0V1+V3dC631JtDrBMSufs4w3ZKazLzFfI x-ms-office365-filtering-correlation-id: c56b91b5-59d4-4df3-fb06-08d5eb89ce3a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7193020); SRVR:DM5PR2101MB1062; x-ms-traffictypediagnostic: DM5PR2101MB1062: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Co@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(211171220733660)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(2018427008)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DM5PR2101MB1062; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1062; x-forefront-prvs: 073631BD3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(376002)(396003)(39860400002)(136003)(47530400004)(189003)(199004)(52116002)(16799955002)(256004)(53376002)(15188155005)(86362001)(86612001)(2501003)(5250100002)(53936002)(76176011)(386003)(6506007)(68736007)(7736002)(102836004)(186003)(2906002)(46003)(1076002)(6116002)(6512007)(6306002)(54906003)(22452003)(305945005)(99286004)(316002)(11346002)(486006)(5640700003)(6486002)(2616005)(25786009)(2900100001)(72206003)(106356001)(97736004)(4326008)(10090500001)(2351001)(105586002)(478600001)(8936002)(81156014)(81166006)(14454004)(966005)(6916009)(8676002)(10290500003)(36756003)(5660300001)(446003)(6436002)(476003); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1062; H:DM5PR2101MB1128.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8P9gwUDAup1xFGo+j0Xt6iof9zKAunoUT2ZOMjcF4WNFf4DUXh+5S5jrFxAkD4Vr6CfsqV53zCVALhVp8hw7ZppHn0PREXdogstap95FeMwIU661BMqAeJN5y/VVAcCQNli0ye4ay+wJtEE/Xt35hdE3k/npLTAMN+cGyGTOUAxyfr5clVUscY79Q/LJ/bgxZ3D3LWvPXOm9Tjx25AMxqONcLk7DgkO2trj9j/99yKH6BKbMUTeYSrLBDg47fD+mKwxo7bZtQz0uF6MRPDgIuSlh7VvjHKMwNypbwDBuoHyc3Q2x/PrixxBmtFvHpi3CM5R3vxXonn9V5/xb7A9+fRLHZDvyJpPjFy8y81/A4bU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c56b91b5-59d4-4df3-fb06-08d5eb89ce3a X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2018 02:05:45.0343 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1062 Subject: [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, 17 Jul 2018 02:05:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This debug library provides support for importing symbols to debug using Lauterbach. Derived from: ArmPkg\Library\DebugPeCoffExtraActionLib 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/LauterbachPeCoff= ExtraActionLib.c | 142 ++++++++++++++++++++ Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachPeCoff= ExtraActionLib.inf | 41 ++++++ 2 files changed, 183 insertions(+) diff --git a/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/Laut= erbachPeCoffExtraActionLib.c b/Platform/Microsoft/Library/LauterbachPeCoffE= xtraActionLib/LauterbachPeCoffExtraActionLib.c new file mode 100644 index 000000000000..0adfacdbe5cf --- /dev/null +++ b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachP= eCoffExtraActionLib.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 IMPLI= ED. + +**/ + +#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 =3D AsciiStrStr (Name, "/cygdrive/"); + if (Ptr =3D=3D NULL) { + return Name; + } + + for (Index =3D 9, Index2 =3D 0; (Index < (Size + 9)) && (Ptr[Index] !=3D= '\0'); Index++, Index2++) { + Temp[Index2] =3D Ptr[Index]; + if (Temp[Index2] =3D=3D '/') { + Temp[Index2] =3D '\\' ; + } + + if (Index2 =3D=3D 1) { + Temp[Index2 - 1] =3D Ptr[Index]; + Temp[Index2] =3D ':'; + } + } + + return Temp; +} + + +/** + Performs additional actions after a PE/COFF image has been loaded and re= located. + + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that descri= bes the + PE/COFF image that has already been loaded and rel= ocated. + +**/ +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", DeCygwi= nPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(Imag= eContext->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", DeCygwin= PathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(Image= Context->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->SizeOf= Headers))); +#else + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint= =3D0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_PO= INT (ImageContext->EntryPoint))); +#endif + } else { + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p EntryPoint= =3D0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_PO= INT (ImageContext->EntryPoint))); + } +} + + + +/** + Performs additional actions just before a PE/COFF image is unloaded. An= y resources + that were allocated by PeCoffLoaderRelocateImageExtraAction() must be fr= eed. + + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that descri= bes 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", DeCygwinPathIfN= eeded (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) I= mageContext->ImageAddress)); + } +} diff --git a/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/Laut= erbachPeCoffExtraActionLib.inf b/Platform/Microsoft/Library/LauterbachPeCof= fExtraActionLib/LauterbachPeCoffExtraActionLib.inf new file mode 100644 index 000000000000..2cfc51b0578f --- /dev/null +++ b/Platform/Microsoft/Library/LauterbachPeCoffExtraActionLib/LauterbachP= eCoffExtraActionLib.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 BS= D License +# which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. +# +# +#**/ + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D LauterbachPeCoffExtraActionLib + FILE_GUID =3D F5D296F5-C546-431F-8CAC-3E91043B452D + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PeCoffExtraActionLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D ARM +# + +[Sources.common] + LauterbachPeCoffExtraActionLib.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib --=20 2.16.2.gvfs.1.33.gf5370f1