From nobody Mon Dec 23 17:25:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515975847207439.0212135528385; Sun, 14 Jan 2018 16:24:07 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 722B5222DDBE7; Sun, 14 Jan 2018 16:18:45 -0800 (PST) Received: from mail.paulo.ac (mail.paulo.ac [34.238.86.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D144B222DDBE2 for ; Sun, 14 Jan 2018 16:18:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.paulo.ac (Postfix) with ESMTP id 7314CC08892; Mon, 15 Jan 2018 00:23:58 +0000 (UTC) Received: from mail.paulo.ac ([127.0.0.1]) by localhost (mail.paulo.ac [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YpWwF9zR64YC; Mon, 15 Jan 2018 00:23:55 +0000 (UTC) Received: from thor.domain.name (177.204.15.215.dynamic.adsl.gvt.net.br [177.204.15.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.paulo.ac (Postfix) with ESMTPSA id 87795C0888F; Mon, 15 Jan 2018 00:23:53 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=34.238.86.106; helo=mail.paulo.ac; envelope-from=paulo@paulo.ac; receiver=edk2-devel@lists.01.org X-Virus-Scanned: amavisd-new at paulo.ac X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: mail.paulo.ac (amavisd-new); dkim=pass (1024-bit key) header.d=paulo.ac DKIM-Filter: OpenDKIM Filter v2.11.0 mail.paulo.ac 87795C0888F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=paulo.ac; s=default; t=1515975835; bh=ONhcVAes+Gj4kA9MNmVvWEiwaUUgLPZy5sXR9WUVRzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=Rrv7wmlXHHrjxej2pdzkDTVj/HFVJESYfb/fJylf+916RJtu0Qir1Ke0TDvgxeBX0 ADHJCE0s0nezgQrrZpvp0WkoiA9yTxLje5skoATqV3ICLJuYm/CWgSQOx7UEY1KKz3 tKpr9ST7nu8KmTEKxF3CZj7/PNuTguYWNNwI5x1Y= From: Paulo Alcantara To: edk2-devel@lists.01.org Date: Sun, 14 Jan 2018 22:23:30 -0200 Message-Id: <0791b20a070a1e49d0d908aca8e6ddd5191ce071.1515974582.git.paulo@paulo.ac> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [RFC v5 2/8] UefiCpuPkg/CpuExceptionHandlerLib: Export GetPdbFileName() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Eric Dong MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function will be used by both IA32 and X64 exception handling in order to print out image module names during stack unwinding. Cc: Eric Dong Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Paulo Alcantara --- UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c | 60 = +++++++++++++++++++- UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h | 14 = +++++ UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 59 = ------------------- 3 files changed, 73 insertions(+), 60 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c index 01b0610364..d9abbd772d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c @@ -54,6 +54,11 @@ CONST CHAR8 *mExceptionNameStr[] =3D { =20 #define EXCEPTION_KNOWN_NAME_NUM (sizeof (mExceptionNameStr) / sizeof (CH= AR8 *)) =20 +// +// Unknown PDB file name +// +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mUnknownPdbFileName =3D "????"; + /** Get ASCII format string exception name by exception type. =20 @@ -177,4 +182,57 @@ ReadAndVerifyVectorInfo ( VectorInfo ++; } return EFI_SUCCESS; -} \ No newline at end of file +} + +/** + Get absolute path and file name of PDB file in PE/COFF image. + + @param[in] ImageBase Base address of PE/COFF image. + @param[out] PdbAbsoluteFilePath Absolute path of PDB file. + @param[out] PdbFileName File name of PDB file. +**/ +VOID +GetPdbFileName ( + IN UINTN ImageBase, + OUT CHAR8 **PdbAbsoluteFilePath, + OUT CHAR8 **PdbFileName + ) +{ + VOID *PdbPointer; + CHAR8 *Str; + + // + // Get PDB file name from PE/COFF image + // + PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID *)ImageBase); + if (PdbPointer =3D=3D NULL) { + // + // No PDB file name found. Set it to an unknown file name. + // + *PdbFileName =3D (CHAR8 *)mUnknownPdbFileName; + if (PdbAbsoluteFilePath !=3D NULL) { + *PdbAbsoluteFilePath =3D NULL; + } + } else { + // + // Get file name portion out of PDB file in PE/COFF image + // + Str =3D (CHAR8 *)((UINTN)PdbPointer + + AsciiStrLen ((CHAR8 *)PdbPointer) - sizeof *Str); + for (; *Str !=3D '/' && *Str !=3D '\\'; Str--) { + ; + } + + // + // Set PDB file name (also skip trailing path separator: '/' or '\\') + // + *PdbFileName =3D Str + 1; + + if (PdbAbsoluteFilePath !=3D NULL) { + // + // Set absolute file path of PDB file + // + *PdbAbsoluteFilePath =3D PdbPointer; + } + } +} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h index e10d9379d5..64c7094513 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -327,5 +327,19 @@ AsmGetTssTemplateMap ( OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap ); =20 +/** + Get absolute path and file name of PDB file in PE/COFF image. + + @param[in] ImageBase Base address of PE/COFF image. + @param[out] PdbAbsoluteFilePath Absolute path of PDB file. + @param[out] PdbFileName File name of PDB file. +**/ +VOID +GetPdbFileName ( + IN UINTN ImageBase, + OUT CHAR8 **PdbAbsoluteFilePath, + OUT CHAR8 **PdbFileName + ); + #endif =20 diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHan= dler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler= .c index 4db9f6465e..523dce95c9 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -14,11 +14,6 @@ =20 #include "CpuExceptionCommon.h" =20 -// -// Unknown PDB file name -// -GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mUnknownPdbFileName =3D "????"; - /** Return address map of exception handler template so that C code can gene= rate exception tables. @@ -403,60 +398,6 @@ DumpCpuContext ( ); } =20 -/** - Get absolute path and file name of PDB file in PE/COFF image. - - @param[in] ImageBase Base address of PE/COFF image. - @param[out] PdbAbsoluteFilePath Absolute path of PDB file. - @param[out] PdbFileName File name of PDB file. -**/ -STATIC -VOID -GetPdbFileName ( - IN UINTN ImageBase, - OUT CHAR8 **PdbAbsoluteFilePath, - OUT CHAR8 **PdbFileName - ) -{ - VOID *PdbPointer; - CHAR8 *Str; - - // - // Get PDB file name from PE/COFF image - // - PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID *)ImageBase); - if (PdbPointer =3D=3D NULL) { - // - // No PDB file name found. Set it to an unknown file name. - // - *PdbFileName =3D (CHAR8 *)mUnknownPdbFileName; - if (PdbAbsoluteFilePath !=3D NULL) { - *PdbAbsoluteFilePath =3D NULL; - } - } else { - // - // Get file name portion out of PDB file in PE/COFF image - // - Str =3D (CHAR8 *)((UINTN)PdbPointer + - AsciiStrLen ((CHAR8 *)PdbPointer) - sizeof *Str); - for (; *Str !=3D '/' && *Str !=3D '\\'; Str--) { - ; - } - - // - // Set PDB file name (also skip trailing path separator: '/' or '\\') - // - *PdbFileName =3D Str + 1; - - if (PdbAbsoluteFilePath !=3D NULL) { - // - // Set absolute file path of PDB file - // - *PdbAbsoluteFilePath =3D PdbPointer; - } - } -} - /** Dump stack contents. =20 --=20 2.14.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel