Skip to content

Commit e23c0ed

Browse files
Tom Yangkusmour
Tom Yang
authored andcommitted
initialized and terminated events should only report stats summaries
Summary: Initialized and terminated events currently produce very noisy statistics. This change makes it so that these events only record stats **summaries**. This means removing fields like breakpoints information and module identifiers. One notable addition is the `totalSharedLibraryEventHitCount` field to target stats, which was previously only calculated in the VSCode extension. A full list of remaining stats can be seen in the description of D45575705, where I remove unnecessary stats-pruning code in the extension. Note: in D45575705, I hoist `totalSharedLibraryEventHitCount` from inside `targetInfo` into the containing context. I could've done that here as well, but decided not to since it seemed like a target-specific stat. Maybe I should do it here too? UPDATE: 2024/02/18 - fixed the `GetStatistics` function call. Test Plan: ``` lldb-dotest -p TestVSCode_eventStatistic ``` Tested in D45575705 with example scuba. Reviewers: jeffreytan, wanyi, hyubo Reviewed By: jeffreytan Differential Revision: https://phabricator.intern.facebook.com/D45755840 Tasks: T151692977
1 parent c81405b commit e23c0ed

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

lldb/test/API/tools/lldb-dap/eventStatistic/TestVSCode_eventStatistic.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,17 @@
1212

1313
class TestDAP_eventStatistic(lldbdap_testcase.DAPTestCaseBase):
1414

15-
def check_statistic(self, statistics):
15+
def check_statistics_summary(self, statistics):
1616
self.assertTrue(statistics['totalDebugInfoByteSize'] > 0)
1717
self.assertTrue(statistics['totalDebugInfoEnabled'] > 0)
1818
self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0)
1919

20-
self.assertIsNotNone(statistics['memory'])
2120
self.assertNotIn('modules', statistics.keys())
2221

23-
def check_target(self, statistics):
22+
def check_target_summary(self, statistics):
2423
# lldb-dap debugs one target at a time
2524
target = json.loads(statistics['targets'])[0]
26-
self.assertTrue(target['totalBreakpointResolveTime'] > 0)
27-
28-
breakpoints = target['breakpoints']
29-
self.assertIn('foo',
30-
breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'],
31-
'foo is a symbol breakpoint')
32-
self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'),
33-
'target has source line breakpoint in main.cpp')
25+
self.assertIn('totalSharedLibraryEventHitCount', target)
3426

3527
@skipIfWindows
3628
@skipIfRemote
@@ -65,8 +57,8 @@ def test_terminated_event(self):
6557
self.continue_to_exit()
6658

6759
statistics = self.dap_server.wait_for_terminated()['statistics']
68-
self.check_statistic(statistics)
69-
self.check_target(statistics)
60+
self.check_statistics_summary(statistics)
61+
self.check_target_summary(statistics)
7062

7163
@skipIfWindows
7264
@skipIfRemote
@@ -77,21 +69,12 @@ def test_initialized_event(self):
7769
totalDebugInfoByteSize > 0
7870
totalDebugInfoEnabled > 0
7971
totalModuleCountHasDebugInfo > 0
80-
totalBreakpointResolveTime > 0
8172
...
8273
'''
8374

8475
program_basename = "a.out.stripped"
8576
program = self.getBuildArtifact(program_basename)
8677
self.build_and_launch(program)
87-
# Set breakpoints
88-
functions = ['foo']
89-
breakpoint_ids = self.set_function_breakpoints(functions)
90-
self.assertEquals(len(breakpoint_ids), len(functions), 'expect one breakpoint')
91-
main_bp_line = line_number('main.cpp', '// main breakpoint 1')
92-
breakpoint_ids.append(self.set_source_breakpoints('main.cpp', [main_bp_line]))
93-
94-
self.continue_to_breakpoints(breakpoint_ids)
9578
statistics = self.dap_server.initialized_event['statistics']
96-
self.check_statistic(statistics)
79+
self.check_statistics_summary(statistics)
9780
self.continue_to_exit()

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,12 @@ void FilterAndGetValueForKey(const lldb::SBStructuredData data, const char *key,
14861486
}
14871487
}
14881488

1489-
void addStatistic(llvm::json::Object &event) {
1490-
lldb::SBStructuredData statistics = g_dap.target.GetStatistics();
1489+
void addStatisticsSummary(llvm::json::Object &event) {
1490+
lldb::SBStatisticsOptions options;
1491+
options.SetSummaryOnly(true);
1492+
lldb::SBStructuredData statistics =
1493+
g_dap.target.GetStatistics(options);
1494+
14911495
bool is_dictionary =
14921496
statistics.GetType() == lldb::eStructuredDataTypeDictionary;
14931497
if (!is_dictionary)
@@ -1506,13 +1510,13 @@ void addStatistic(llvm::json::Object &event) {
15061510

15071511
llvm::json::Object CreateTerminatedEventObject() {
15081512
llvm::json::Object event(CreateEventObject("terminated"));
1509-
addStatistic(event);
1513+
addStatisticsSummary(event);
15101514
return event;
15111515
}
15121516

15131517
llvm::json::Object CreateInitializedEventObject() {
15141518
llvm::json::Object event(CreateEventObject("initialized"));
1515-
addStatistic(event);
1519+
addStatisticsSummary(event);
15161520
return event;
15171521
}
15181522

0 commit comments

Comments
 (0)