From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 8A40622198F6C for ; Thu, 28 Dec 2017 19:44:06 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.paulo.ac (Postfix) with ESMTP id 7FF07C78F5B; Fri, 29 Dec 2017 03:49:02 +0000 (UTC) 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 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 7A1NCl69TlMC; Fri, 29 Dec 2017 03:48:43 +0000 (UTC) Received: from thor.domain.name (unknown [177.97.125.159]) (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 BC550C790F4; Fri, 29 Dec 2017 03:48:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.paulo.ac BC550C790F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=paulo.ac; s=default; t=1514519323; bh=zwOzxpvN30OLVozt4EwQt7lGptJ3y+sSqA2uG7JleD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDKqFfwKnOogrHYa+Pgt/LZ6hXDdNHY7z6pal16bXzRJdklKQiUQLMKSCAJ0lBPUG J0nNaCfCHKodHAdziOrA05lEcFMbryvZd9Mg7fezJxevvk2K4kWhFFf5PyW5KZxnge Nz7CUM8ckx9f2j/MqffFjAFd30x9WO7YFEvB1774= From: Paulo Alcantara To: edk2-devel@lists.01.org Cc: Paulo Alcantara , Rick Bramley , Andrew Fish , Eric Dong , Laszlo Ersek , Brian Johnson , Jeff Fan , Jiewen Yao Date: Fri, 29 Dec 2017 01:48:31 -0200 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: <00e14f85d93a2e81ab008f32020f3048fe4857fb.1510662518.git.pcacjr@zytor.com> References: <00e14f85d93a2e81ab008f32020f3048fe4857fb.1510662518.git.pcacjr@zytor.com> Subject: [RFC v4 0/6] Stack trace support in X64 exception handling 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: , X-List-Received-Date: Fri, 29 Dec 2017 03:44:07 -0000 Hi, This series adds stack trace support during IA32 and X64 CPU exceptions. Informations like back trace, stack contents and image module names (that were part of the call stack) will be dumped out. The current limitation is that it relies on available frame pointers (GCC only) in order to successfully unwind the stack. (Sorry for the very long delay - I was very busy working on something else and then went to vacations) Jiewen, I have tested it with VS2015x86 and the stack trace just hanged when printing out the first EIP (that is, no frame pointer at all). Thanks! Paulo Repo: https://github.com/pcacjr/edk2.git Branch: stacktrace_v4 Cc: Rick Bramley Cc: Andrew Fish Cc: Eric Dong Cc: Laszlo Ersek Cc: Brian Johnson Cc: Jeff Fan Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Paulo Alcantara --- v1 -> v2: * Add IA32 arch support (GCC toolchain only) * Replace hard-coded stack alignment value (16) with CPU_STACK_ALIGNMENT. * Check for proper stack and frame pointer alignments. * Fix initialization of UnwoundStacksCount to 1. * Move GetPdbFileName() to common code since it will be used by both IA32 and X64 implementations. v2 -> v3: * Fixed wrong assumption about "RIP < ImageBase" to start searching for another PE/COFF image. That is, RIP may point to lower and higher addresses for any other PE/COFF images. Both IA32 & X64. (Thanks Andrew & Jiewen) * Fixed typo: unwond -> unwound. Both IA32 & X64. (Thanks Brian) v3 -> v4: * Validate all frame/stack pointer addresses before dereferencing them as requested by Brian & Jiewen. * Correctly print out IP addresses during the stack traces (by Jeff) Paulo Alcantara (6): UefiCpuPkg/CpuExceptionHandlerLib/X64: Add stack trace support UefiCpuPkg/CpuExceptionHandlerLib: Export GetPdbFileName() UefiCpuPkg/CpuExceptionHandlerLib/Ia32: Add stack trace support UefiCpuPkg/CpuExceptionHandlerLib: Add helper to valid memory addresses UefiCpuPkg/CpuExceptionHandlerLib: Ensure valid frame/stack pointers UefiCpuPkg/CpuExceptionHandlerLib: Correctly print IP addresses UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c | 484 ++++++++++++++++++-- UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h | 41 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c | 445 +++++++++++++++++- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 384 +++++++++++++++- 4 files changed, 1296 insertions(+), 58 deletions(-) -- 2.14.3