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 <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Paulo Alcantara <paulo@paulo.ac>
---
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[] = {
#define EXCEPTION_KNOWN_NAME_NUM (sizeof (mExceptionNameStr) / sizeof (CHAR8 *))
+//
+// Unknown PDB file name
+//
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mUnknownPdbFileName = "????";
+
/**
Get ASCII format string exception name by exception type.
@@ -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 = PeCoffLoaderGetPdbPointer ((VOID *)ImageBase);
+ if (PdbPointer == NULL) {
+ //
+ // No PDB file name found. Set it to an unknown file name.
+ //
+ *PdbFileName = (CHAR8 *)mUnknownPdbFileName;
+ if (PdbAbsoluteFilePath != NULL) {
+ *PdbAbsoluteFilePath = NULL;
+ }
+ } else {
+ //
+ // Get file name portion out of PDB file in PE/COFF image
+ //
+ Str = (CHAR8 *)((UINTN)PdbPointer +
+ AsciiStrLen ((CHAR8 *)PdbPointer) - sizeof *Str);
+ for (; *Str != '/' && *Str != '\\'; Str--) {
+ ;
+ }
+
+ //
+ // Set PDB file name (also skip trailing path separator: '/' or '\\')
+ //
+ *PdbFileName = Str + 1;
+
+ if (PdbAbsoluteFilePath != NULL) {
+ //
+ // Set absolute file path of PDB file
+ //
+ *PdbAbsoluteFilePath = 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
);
+/**
+ 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
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.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 @@
#include "CpuExceptionCommon.h"
-//
-// Unknown PDB file name
-//
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mUnknownPdbFileName = "????";
-
/**
Return address map of exception handler template so that C code can generate
exception tables.
@@ -403,60 +398,6 @@ DumpCpuContext (
);
}
-/**
- 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 = PeCoffLoaderGetPdbPointer ((VOID *)ImageBase);
- if (PdbPointer == NULL) {
- //
- // No PDB file name found. Set it to an unknown file name.
- //
- *PdbFileName = (CHAR8 *)mUnknownPdbFileName;
- if (PdbAbsoluteFilePath != NULL) {
- *PdbAbsoluteFilePath = NULL;
- }
- } else {
- //
- // Get file name portion out of PDB file in PE/COFF image
- //
- Str = (CHAR8 *)((UINTN)PdbPointer +
- AsciiStrLen ((CHAR8 *)PdbPointer) - sizeof *Str);
- for (; *Str != '/' && *Str != '\\'; Str--) {
- ;
- }
-
- //
- // Set PDB file name (also skip trailing path separator: '/' or '\\')
- //
- *PdbFileName = Str + 1;
-
- if (PdbAbsoluteFilePath != NULL) {
- //
- // Set absolute file path of PDB file
- //
- *PdbAbsoluteFilePath = PdbPointer;
- }
- }
-}
-
/**
Dump stack contents.
--
2.14.3
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel