summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/main.cpp
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/inheritance/main.cpp
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/inheritance/main.cpp')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/main.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/main.cpp
new file mode 100644
index 00000000000..78cac2c8965
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/main.cpp
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdint.h>
+
+class A
+{
+public:
+ A(int a) :
+ m_a(a)
+ {
+ }
+ virtual ~A(){}
+ virtual int get2() const { return m_a; }
+ virtual int get() const { return m_a; }
+protected:
+ int m_a;
+};
+
+class B : public A
+{
+public:
+ B(int a, int b) :
+ A(a),
+ m_b(b)
+ {
+ }
+
+ ~B() override
+ {
+ }
+
+ int get2() const override
+ {
+ return m_b;
+ }
+ int get() const override
+ {
+ return m_b;
+ }
+
+protected:
+ int m_b;
+};
+
+struct C
+{
+ C(int c) : m_c(c){}
+ virtual ~C(){}
+ int m_c;
+};
+
+class D : public C, public B
+{
+public:
+ D(int a, int b, int c, int d) :
+ C(c),
+ B(a, b),
+ m_d(d)
+ {
+ }
+protected:
+ int m_d;
+};
+int main (int argc, char const *argv[], char const *envp[])
+{
+ D *good_d = new D(1, 2, 3, 4);
+ D *d = nullptr;
+ return d->get();
+}
+
OpenPOWER on IntegriCloud