[Lldb-commits] [lldb] [LLDB][Statistics] Add coreFilePath to Target stats (PR #161448)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 2 11:34:34 PST 2025
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/161448
>From 3c68cf2e57284b9bfdd1bc3db5125279e69a7ffd Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Tue, 30 Sep 2025 14:22:08 -0700
Subject: [PATCH] Add coreFilePath to statistics.cpp for targets, and add a
test to validate it's included in the stats output
---
lldb/source/Target/Statistics.cpp | 4 ++
.../stats_api/TestStatisticsAPI.py | 22 +++++++++++
.../functionalities/stats_api/minidump.yaml | 38 +++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 lldb/test/API/functionalities/stats_api/minidump.yaml
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index f7311a8b24416..0881fad68de2f 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -207,6 +207,10 @@ TargetStats::ToJSON(Target &target,
if (process_sp->GetDynamicLoader())
dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
target_metrics_json.try_emplace("dyldPluginName", dyld_plugin_name);
+
+ if (process_sp->GetCoreFile())
+ target_metrics_json.try_emplace("coreFilePath",
+ process_sp->GetCoreFile().GetPath());
}
target_metrics_json.try_emplace("sourceMapDeduceCount",
m_source_map_deduce_count);
diff --git a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
index d7249df350fc1..054c7e2567b12 100644
--- a/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
+++ b/lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
@@ -1,6 +1,7 @@
# Test the SBAPI for GetStatistics()
import json
+import os
import lldb
from lldbsuite.test.decorators import *
@@ -185,3 +186,24 @@ def test_core_load_time(self):
target_info = debug_stats["targets"][0]
self.assertTrue("loadCoreTime" in target_info)
self.assertTrue(float(target_info["loadCoreTime"]) > 0.0)
+
+ def test_command_stats_coredump(self):
+ """
+ Test to see if the coredump path is included in statistics dump.
+ """
+ yaml_file = "minidump.yaml"
+ minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
+ self.yaml2obj(yaml_file, minidump_path)
+ target = self.dbg.CreateTarget(None)
+ process = target.LoadCore(minidump_path)
+ self.assertTrue(process.IsValid())
+
+ stats_options = lldb.SBStatisticsOptions()
+ stats = target.GetStatistics(stats_options)
+ stream = lldb.SBStream()
+ stats.GetAsJSON(stream)
+ debug_stats = json.loads(stream.GetData())
+ self.assertTrue("targets" in debug_stats)
+ target_info = debug_stats["targets"][0]
+ self.assertTrue("coreFilePath" in target_info)
+ self.assertEqual(target_info["coreFilePath"], minidump_path)
diff --git a/lldb/test/API/functionalities/stats_api/minidump.yaml b/lldb/test/API/functionalities/stats_api/minidump.yaml
new file mode 100644
index 0000000000000..d04ca1ae0dc12
--- /dev/null
+++ b/lldb/test/API/functionalities/stats_api/minidump.yaml
@@ -0,0 +1,38 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Processor Level: 6
+ Processor Revision: 15876
+ Number of Processors: 40
+ Platform ID: Linux
+ CSD Version: 'Linux 3.13.0-91-generic'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x2896BB
+ Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700100000000000FFFFFFFF0000FFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B040A812FF7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050D0A75BBA7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ Stack:
+ Start of Memory Range: 0x0
+ Content: ''
+ - Type: Memory64List
+ Memory Ranges:
+ - Start of Memory Range: 0x1000
+ Data Size: 0x100
+ Content : ''
+ - Start of Memory Range: 0x2000
+ Data Size: 0x20
+ Content : ''
+ - Start of Memory Range: 0x3000
+ Data Size: 0x400
+ Content : ''
+ - Start of Memory Range: 0x5000
+ Data Size: 0x500
+ Content : ''
+ - Start of Memory Range: 0x5500
+ Data Size: 0x500
+ Content : ''
+...
More information about the lldb-commits
mailing list