summaryrefslogtreecommitdiffstats
path: root/lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
diff options
context:
space:
mode:
authorAbhishek Aggarwal <abhishek.a.aggarwal@intel.com>2017-08-07 15:26:11 +0000
committerAbhishek Aggarwal <abhishek.a.aggarwal@intel.com>2017-08-07 15:26:11 +0000
commit307db0f8974d1b28d7b237cb0d50895efc7f6e6b (patch)
tree33e703e75ec17b74787dc273146ccf3a3e1810db /lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
parent9581b42589d72d1c931c4bcbc0101df7c507e27e (diff)
downloadbcm5719-llvm-307db0f8974d1b28d7b237cb0d50895efc7f6e6b.tar.gz
bcm5719-llvm-307db0f8974d1b28d7b237cb0d50895efc7f6e6b.zip
Tool for using Intel(R) Processor Trace hardware feature
Summary: 1. Provide single library for all Intel specific hardware features instead of individual libraries for each feature 2. Added Intel(R) Processor Trace hardware feature in this single library. Details about the tool implementing this feature is as follows: Tool developed on top of LLDB to provide its users the execution trace of the debugged inferiors. Tool's API are exposed as C++ object oriented interface in a shared library. API are designed especially to be easily integrable with IDEs providing LLDB as an application debugger. Entire API is also available as Python functions through a script bridging interface allowing development of python modules. This patch also provides a CLI wrapper to use the Tool through LLDB's command line. Highlights of the Tool and the wrapper are given below: ****************************** Intel(R) Processor Trace Tool: ****************************** - Provides execution trace of the debugged application - Uses Intel(R) Processor Trace hardware feature (already implemented inside LLDB) for this purpose -- Collects trace packets generated by this feature from LLDB, decodes and post-processes them -- Constructs the execution trace of the application -- Presents execution trace as a list of assembly instructions - Provides 4 APIs (exposed as C++ object oriented interface) -- start trace with configuration options for a thread/process, -- stop trace for a thread/process, -- get the execution flow (assembly instructions) for a thread, -- get trace specific information for a thread - Easily integrable into IDEs providing LLDB as application debugger - Entire API available as Python functions through script bridging interface -- Allows developing python apps on top of Tool - README_TOOL.txt provides more details about the Tool, its dependencies, building steps and API usage - Tool ready to use through LLDB's command line -- CLI wrapper has been developed on top of the Tool for this purpose ********************************* CLI wrapper: cli-wrapper-pt.cpp ********************************* - Provides 4 commands (syntax similar to LLDB's CLI commands): -- processor-trace start -- processor-trace stop -- processor-trace show-trace-options -- processor-trace show-instr-log - README_CLI.txt provides more details about commands and their options Signed-off-by: Abhishek Aggarwal <abhishek.a.aggarwal@intel.com> Reviewers: clayborg, jingham, lldb-commits, labath Reviewed By: clayborg Subscribers: ravitheja, emaste, krytarowski, mgorny Differential Revision: https://reviews.llvm.org/D33035 llvm-svn: 310261
Diffstat (limited to 'lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py')
-rw-r--r--lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py169
1 files changed, 169 insertions, 0 deletions
diff --git a/lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py b/lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
new file mode 100644
index 00000000000..f571252e26f
--- /dev/null
+++ b/lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
@@ -0,0 +1,169 @@
+"""
+Test mpx-table command.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestMPXTable(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ @skipIf(compiler="clang")
+ @skipIf(oslist=no_match(['linux']))
+ @skipIf(archs=no_match(['i386', 'x86_64']))
+ @skipIf(compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports
+ #Intel(R) Memory Protection Extensions (Intel(R) MPX).
+ def test_show_command(self):
+ """Test 'mpx-table show' command"""
+ self.build()
+
+ lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+ lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+ plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+ if not os.path.isfile(plugin_file):
+ self.skipTest("features plugin missing.")
+ plugin_command = " "
+ seq = ("plugin", "load", plugin_file)
+ plugin_command = plugin_command.join(seq)
+ self.runCmd(plugin_command)
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.b1 = line_number('main.cpp', '// Break 1.')
+ self.b2 = line_number('main.cpp', '// Break 2.')
+ self.b3 = line_number('main.cpp', '// Break 3.')
+ self.b4 = line_number('main.cpp', '// Break 4.')
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b1, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b2, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b3, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b4, num_expected_locations=1)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ target = self.dbg.GetSelectedTarget()
+ process = target.GetProcess()
+
+ if (process.GetState() == lldb.eStateExited):
+ self.skipTest("Intel(R) MPX is not supported.")
+ else:
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 1."])
+
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 2."])
+
+ # Check that out of scope pointer cannot be reached.
+ #
+ self.expect("mpx-table show a",
+ substrs = ['Invalid pointer.'],
+ error = True)
+
+ self.expect("mpx-table show tmp",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 3."])
+
+ # Check that the pointer value is correctly updated.
+ #
+ self.expect("mpx-table show tmp",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x2',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 4."])
+
+ # After going back to main(), check that out of scope pointer cannot be
+ # reached.
+ #
+ self.expect("mpx-table show tmp",
+ substrs = ['Invalid pointer.'],
+ error = True)
+
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ def test_set_command(self):
+ """Test 'mpx-table set' command"""
+ self.build()
+
+ lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+ lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+ plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+ if not os.path.isfile(plugin_file):
+ self.skipTest("features plugin missing.")
+ plugin_command = " "
+ seq = ("plugin", "load", plugin_file)
+ plugin_command = plugin_command.join(seq)
+ self.runCmd(plugin_command)
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.b1 = line_number('main.cpp', '// Break 1.')
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b1, num_expected_locations=1)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ target = self.dbg.GetSelectedTarget()
+ process = target.GetProcess()
+
+ if (process.GetState() == lldb.eStateExited):
+ self.skipTest("Intel(R) MPX is not supported.")
+ else:
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 1."])
+
+ # Check that the BT Entry doesn't already contain the test values.
+ #
+ self.expect("mpx-table show a", matching=False,
+ substrs = ['lbound = 0xcafecafe',
+ ', ubound = 0xbeefbeef'])
+
+ # Set the test values.
+ #
+ self.expect("mpx-table set a 0xcafecafe 0xbeefbeef", error = False)
+
+ # Verify that the test values have been correctly written in the BT
+ # entry.
+ #
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0xcafecafe',
+ ', ubound = 0xbeefbeef'],
+ error = False)
+
+
OpenPOWER on IntegriCloud