wallace updated this revision to Diff 253748.
wallace added a comment.

Added a stop command invocation in the test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77107/new/

https://reviews.llvm.org/D77107

Files:
  lldb/test/API/tools/intel-features/intel-pt/test/Makefile
  lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
  lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
  lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===================================================================
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@
       result.SetStatus(lldb::eReturnStatusFailed);
       return false;
     }
+    result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
     return true;
   }
 
@@ -290,6 +291,7 @@
                  s.GetData());
       result.AppendMessage(res.GetOutput());
     }
+    result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
     return true;
   }
 
@@ -428,6 +430,7 @@
       }
       result.AppendMessage(res.GetOutput());
     }
+    result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
     return true;
   }
 
@@ -480,6 +483,7 @@
       result.SetStatus(lldb::eReturnStatusFailed);
       return false;
     }
+    result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
     return true;
   }
 
Index: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,27 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+////
+//// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//// See https://llvm.org/LICENSE.txt for license information.
+//// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+////
+////===----------------------------------------------------------------------===//
+//
+
+#include <iostream>
+#include <cstdlib>
+
+using namespace std;
+
+int fun(int a) {
+  return rand() + 1;
+}
+
+int main() {
+  int z = 0;
+  for(int i = 0; i < 10000; i++) {
+    z += fun(z);
+  }
+
+  cout << z << endl; // Break 1
+  return 0;
+}
Index: lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
===================================================================
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,58 @@
+from __future__ import print_function
+
+import os
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
+
+    @skipIf(oslist=no_match(['linux']))
+    @skipIf(archs=no_match(['i386', 'x86_64']))
+    @skipIfRemote
+    def test_basic_flow(self):
+        """Test collection, decoding, and dumping instructions"""
+        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.")
+
+        self.build()
+
+        self.runCmd("plugin load " + plugin_file)
+
+        exe = self.getBuildArtifact("a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        self.runCmd("b main")
+        self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+
+        self.runCmd("r")
+        # We start tracing from main
+        self.runCmd("processor-trace start all")
+        self.runCmd("c")
+        # We check the trace after the for loop
+
+        # We find the start address of the 'fun' function for a later check
+        target = self.dbg.GetSelectedTarget()
+        fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+            .GetStartAddress().GetLoadAddress(target)
+
+        # We print the last instructions
+        self.expect("processor-trace show-instr-log -c 100",
+            patterns=[
+                "rand", # We expect to see a reference to the rand function
+                        # within the last instructions
+                hex(fun_start_adddress),  # We expect to have seen the first
+                                          # instruction of 'fun'
+                "at main.cpp:21" # We expect to see the exit condition of
+                                 # the for loop
+            ])
+
+        self.runCmd("processor-trace stop")
Index: lldb/test/API/tools/intel-features/intel-pt/test/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to