From 4740a734bb4a4f20ae4895ded32585e54bb87afb Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 6 Sep 2016 04:48:36 +0000 Subject: Added the "frame diagnose" command and use its output to make crash info better. When a process stops due to a crash, we get the crashing instruction and the crashing memory location (if there is one). From the user's perspective it is often unclear what the reason for the crash is in a symbolic sense. To address this, I have added new fuctionality to StackFrame to parse the disassembly and reconstruct the sequence of dereferneces and offsets that were applied to a known variable (or fuction retrn value) to obtain the invalid pointer. This makes use of enhancements in the disassembler, as well as new information provided by the DWARF expression infrastructure, and is exposed through a "frame diagnose" command. It is also used to provide symbolic information, when available, in the event of a crash. The algorithm is very rudimentary, and it needs a bunch of work, including - better parsing for assembly, preferably with help from LLVM - support for non-Apple platforms - cleanup of the algorithm core, preferably to make it all work in terms of Operands instead of register/offset pairs - improvement of the GetExpressioPath() logic to make prettier expression paths, and - better handling of vtables. I welcome all suggestios, improvements, and testcases. llvm-svn: 280692 --- .../frame-diagnose/array/TestArray.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py new file mode 100644 index 00000000000..0f1c109676c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py @@ -0,0 +1,25 @@ +""" +Test the output of `frame diagnose` for an array access +""" + +from __future__ import print_function + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestArray(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_array(self): + TestBase.setUp(self) + self.build() + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + self.runCmd("run", RUN_SUCCEEDED) + self.expect("thread list", "Thread should be stopped", + substrs = ['stopped']) + self.expect("frame diagnose", "Crash diagnosis was accurate", substrs=["a[10]"]) -- cgit v1.2.3