[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 1 20:50:42 PST 2024


================
@@ -70,3 +73,26 @@ def test_stats_api(self):
             True,
             'Make sure the "failures" key in in "frameVariable" dictionary"',
         )
+
+    def test_command_stats_api(self):
+        """
+        Test GetCommandInterpreter::GetStatistics() API.
+        """
+        self.build()
+        exe = self.getBuildArtifact("a.out")
+        lldbutil.run_to_name_breakpoint(self, "main")
+
+        interp = self.dbg.GetCommandInterpreter()
+        result = lldb.SBCommandReturnObject()
+        interp.HandleCommand("bt", result)
+
+        stream = lldb.SBStream()
+        res = interp.GetStatistics().GetAsJSON(stream)
+        command_stats = json.loads(stream.GetData())
+
+        # Verify bt command is correctly parsed into final form.
+        self.assertEqual(command_stats["thread backtrace"], 1)
+        # Verify original raw command is not duplicatedly captured.
+        self.assertNotIn("bt", command_stats)
+        # Verify bt's regex command is not duplicatedly captured.
+        self.assertNotIn("_regexp-bt", command_stats)
----------------
clayborg wrote:

Same worry here as the above inline comment in the previous test if a fresh lldb process isn't used for each test. Might need to do FileCheck test?

https://github.com/llvm/llvm-project/pull/80375


More information about the lldb-commits mailing list