Skip to content

Commit 8806ac3

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 fe9fba8 commit 8806ac3

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

lldb/source/Target/Statistics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ TargetStats::ToJSON(Target &target,
202202
if (process_sp->GetDynamicLoader())
203203
dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
204204
target_metrics_json.try_emplace("dyldPluginName", dyld_plugin_name);
205+
206+
if (process_sp->GetCoreFile())
207+
target_metrics_json.try_emplace("coreFilePath",
208+
process_sp->GetCoreFile().GetPath());
205209
}
206210
target_metrics_json.try_emplace("sourceMapDeduceCount",
207211
m_source_map_deduce_count);

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

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

33
import json
4+
import os
5+
46
import lldb
57
from lldbsuite.test.decorators import *
68
from lldbsuite.test.lldbtest import *
@@ -157,3 +159,24 @@ def test_command_stats_force(self):
157159
stats_force.GetAsJSON(stream_force)
158160
debug_stats_force = json.loads(stream_force.GetData())
159161
self.assertEqual(debug_stats_force["totalDebugInfoByteSize"], 445)
162+
163+
def test_command_stats_coredump(self):
164+
"""
165+
Test to see if the coredump path is included in statistics dump.
166+
"""
167+
yaml_file = "minidump.yaml"
168+
minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
169+
self.yaml2obj(yaml_file, minidump_path)
170+
target = self.dbg.CreateTarget(None)
171+
process = target.LoadCore(minidump_path)
172+
self.assertTrue(process.IsValid())
173+
174+
stats_options = lldb.SBStatisticsOptions()
175+
stats = target.GetStatistics(stats_options)
176+
stream = lldb.SBStream()
177+
stats.GetAsJSON(stream)
178+
debug_stats = json.loads(stream.GetData())
179+
self.assertTrue("targets" in debug_stats)
180+
target_info = debug_stats["targets"][0]
181+
self.assertTrue("coreFilePath" in target_info)
182+
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)