summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2016-09-06 04:48:36 +0000
committerSean Callanan <scallanan@apple.com>2016-09-06 04:48:36 +0000
commit4740a734bb4a4f20ae4895ded32585e54bb87afb (patch)
tree9884944c80582b90d8ff4fdbf64fd8716766f8e2 /lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array
parent24dac6afe29ccbd4455dc44d6d6bc85b04bfbc31 (diff)
downloadbcm5719-llvm-4740a734bb4a4f20ae4895ded32585e54bb87afb.tar.gz
bcm5719-llvm-4740a734bb4a4f20ae4895ded32585e54bb87afb.zip
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
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py25
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/main.c9
3 files changed, 39 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/Makefile
new file mode 100644
index 00000000000..b09a579159d
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
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]"])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/main.c
new file mode 100644
index 00000000000..95c6515e5f5
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/main.c
@@ -0,0 +1,9 @@
+struct Foo {
+ int b;
+ int c;
+};
+
+int main() {
+ struct Foo *a = 0;
+ return a[10].c;
+}
OpenPOWER on IntegriCloud