summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2018-04-13 18:02:39 +0000
committerDavide Italiano <davide@freebsd.org>2018-04-13 18:02:39 +0000
commit24fff2429cb612dfe4293ccb93e664f02671ef8a (patch)
tree0acb1c7aa47c872fb6cec978ccec570aec218334 /lldb/packages/Python/lldbsuite/test
parent43a919f667884855c44be5f55f75e8611fc41967 (diff)
downloadbcm5719-llvm-24fff2429cb612dfe4293ccb93e664f02671ef8a.tar.gz
bcm5719-llvm-24fff2429cb612dfe4293ccb93e664f02671ef8a.zip
[Command] Implement `statistics` command.
This allows us to collect useful metrics about lldb debugging sessions. I thought that an example would be better than a thousand words: Process 19705 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000fb4 blah`main at blah.c:3 1 int main(void) { 2 int a = 6; -> 3 return 0; 4 } (lldb) statistics enable (lldb) frame var a (int) a = 6 (lldb) expr a (int) $1 = 6 (lldb) statistics disable (lldb) statistics dump Number of expr evaluation successes : 1 Number of expr evaluation failures : 0 Number of frame var successes : 1 Number of frame var failures : 0 Future improvements might include: 1. Passing a file, or implementing categories. The way this patch has been implemented is generic enough to allow this to be extended easily without breaking the grammar. 2. Adding an SBAPI and Python API for use in scripts. Thanks to Jim Ingham for discussing the design with me. <rdar://problem/36555975> Differential Revision: https://reviews.llvm.org/D45547 llvm-svn: 330043
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/stats/Makefile3
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/stats/main.c18
3 files changed, 26 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/stats/Makefile
new file mode 100644
index 00000000000..f5a47fcc46c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py b/lldb/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py
new file mode 100644
index 00000000000..48e49ed009b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/stats/main.c
new file mode 100644
index 00000000000..9adb3a09a08
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats/main.c
@@ -0,0 +1,18 @@
+// Test that the lldb command `statistics` works.
+
+int main(void) {
+ int patatino = 27;
+ //%self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
+ //%self.expect("statistics enable")
+ //%self.expect("statistics enable", substrs=['already enabled'], error=True)
+ //%self.expect("expr patatino", substrs=['27'])
+ //%self.expect("statistics disable")
+ //%self.expect("statistics dump", substrs=['expr evaluation successes : 1', 'expr evaluation failures : 0'])
+ //%self.expect("frame var", substrs=['27'])
+ //%self.expect("statistics enable")
+ //%self.expect("frame var", substrs=['27'])
+ //%self.expect("statistics disable")
+ //%self.expect("statistics dump", substrs=['frame var successes : 1', 'frame var failures : 0'])
+
+ return 0;
+}
OpenPOWER on IntegriCloud