Skip to content

Commit 3c68cf2

Browse files
committed
Add coreFilePath to statistics.cpp for targets, and add a test to validate it's included in the stats output
1 parent fae64ad commit 3c68cf2

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

lldb/source/Target/Statistics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ TargetStats::ToJSON(Target &target,
207207
if (process_sp->GetDynamicLoader())
208208
dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
209209
target_metrics_json.try_emplace("dyldPluginName", dyld_plugin_name);
210+
211+
if (process_sp->GetCoreFile())
212+
target_metrics_json.try_emplace("coreFilePath",
213+
process_sp->GetCoreFile().GetPath());
210214
}
211215
target_metrics_json.try_emplace("sourceMapDeduceCount",
212216
m_source_map_deduce_count);

lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Test the SBAPI for GetStatistics()
22

33
import json
4+
import os
45

56
import lldb
67
from lldbsuite.test.decorators import *
@@ -185,3 +186,24 @@ def test_core_load_time(self):
185186
target_info = debug_stats["targets"][0]
186187
self.assertTrue("loadCoreTime" in target_info)
187188
self.assertTrue(float(target_info["loadCoreTime"]) > 0.0)
189+
190+
def test_command_stats_coredump(self):
191+
"""
192+
Test to see if the coredump path is included in statistics dump.
193+
"""
194+
yaml_file = "minidump.yaml"
195+
minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
196+
self.yaml2obj(yaml_file, minidump_path)
197+
target = self.dbg.CreateTarget(None)
198+
process = target.LoadCore(minidump_path)
199+
self.assertTrue(process.IsValid())
200+
201+
stats_options = lldb.SBStatisticsOptions()
202+
stats = target.GetStatistics(stats_options)
203+
stream = lldb.SBStream()
204+
stats.GetAsJSON(stream)
205+
debug_stats = json.loads(stream.GetData())
206+
self.assertTrue("targets" in debug_stats)
207+
target_info = debug_stats["targets"][0]
208+
self.assertTrue("coreFilePath" in target_info)
209+
self.assertEqual(target_info["coreFilePath"], minidump_path)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--- !minidump
2+
Streams:
3+
- Type: SystemInfo
4+
Processor Arch: AMD64
5+
Processor Level: 6
6+
Processor Revision: 15876
7+
Number of Processors: 40
8+
Platform ID: Linux
9+
CSD Version: 'Linux 3.13.0-91-generic'
10+
CPU:
11+
Vendor ID: GenuineIntel
12+
Version Info: 0x00000000
13+
Feature Info: 0x00000000
14+
- Type: ThreadList
15+
Threads:
16+
- Thread Id: 0x2896BB
17+
Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700100000000000FFFFFFFF0000FFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B040A812FF7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050D0A75BBA7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
18+
Stack:
19+
Start of Memory Range: 0x0
20+
Content: ''
21+
- Type: Memory64List
22+
Memory Ranges:
23+
- Start of Memory Range: 0x1000
24+
Data Size: 0x100
25+
Content : ''
26+
- Start of Memory Range: 0x2000
27+
Data Size: 0x20
28+
Content : ''
29+
- Start of Memory Range: 0x3000
30+
Data Size: 0x400
31+
Content : ''
32+
- Start of Memory Range: 0x5000
33+
Data Size: 0x500
34+
Content : ''
35+
- Start of Memory Range: 0x5500
36+
Data Size: 0x500
37+
Content : ''
38+
...

0 commit comments

Comments
 (0)