From 22887ff964ee9135417f7c0f99915296b710934f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 16 Nov 2022 11:51:47 +0100 Subject: [PATCH] Revert "Send statistics in initialized event" The test is failing on linux. This reverts commits 7fe3586cda5b683766ec6b6d5ca2d98c2baaf162 and d599ac41aabddeb2442db7b31faacf143d63abe4. --- .../lldbsuite/test/tools/lldb-vscode/vscode.py | 3 - .../{eventStatistic => terminated-event}/Makefile | 0 .../TestVSCode_terminatedEvent.py} | 64 +++++----------------- .../{eventStatistic => terminated-event}/foo.cpp | 0 .../{eventStatistic => terminated-event}/foo.h | 0 .../{eventStatistic => terminated-event}/main.cpp | 0 lldb/tools/lldb-vscode/JSONUtils.cpp | 6 -- lldb/tools/lldb-vscode/JSONUtils.h | 6 -- lldb/tools/lldb-vscode/lldb-vscode.cpp | 4 +- 9 files changed, 17 insertions(+), 66 deletions(-) rename lldb/test/API/tools/lldb-vscode/{eventStatistic => terminated-event}/Makefile (100%) rename lldb/test/API/tools/lldb-vscode/{eventStatistic/TestVSCode_eventStatistic.py => terminated-event/TestVSCode_terminatedEvent.py} (63%) rename lldb/test/API/tools/lldb-vscode/{eventStatistic => terminated-event}/foo.cpp (100%) rename lldb/test/API/tools/lldb-vscode/{eventStatistic => terminated-event}/foo.h (100%) rename lldb/test/API/tools/lldb-vscode/{eventStatistic => terminated-event}/main.cpp (100%) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py index 49f268a..c2de4ad 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -134,7 +134,6 @@ class DebugCommunication(object): self.configuration_done_sent = False self.frame_scopes = {} self.init_commands = init_commands - self.initialized_event = None @classmethod def encode_content(cls, s): @@ -232,8 +231,6 @@ class DebugCommunication(object): self._process_stopped() tid = body['threadId'] self.thread_stop_reasons[tid] = body - elif event == 'initialized': - self.initialized_event = packet elif event == 'breakpoint': # Breakpoint events come in when a breakpoint has locations # added or removed. Keep track of them so we can look for them diff --git a/lldb/test/API/tools/lldb-vscode/eventStatistic/Makefile b/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/eventStatistic/Makefile rename to lldb/test/API/tools/lldb-vscode/terminated-event/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py b/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py similarity index 63% rename from lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py rename to lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py index 2b76307..ae364a5 100644 --- a/lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py +++ b/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py @@ -10,27 +10,7 @@ import lldbvscode_testcase import re import json -class TestVSCode_eventStatistic(lldbvscode_testcase.VSCodeTestCaseBase): - - def check_statistic(self, statistics): - self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) - self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) - self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) - - self.assertIsNotNone(statistics['memory']) - self.assertNotIn('modules', statistics.keys()) - - def check_target(self, statistics): - # lldb-vscode debugs one target at a time - target = json.loads(statistics['targets'])[0] - self.assertTrue(target['totalBreakpointResolveTime'] > 0) - - breakpoints = target['breakpoints'] - self.assertIn('foo', - breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'], - 'foo is a symbol breakpoint') - self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'), - 'target has source line breakpoint in main.cpp') +class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase): @skipIfWindows @skipIfRemote @@ -65,34 +45,20 @@ class TestVSCode_eventStatistic(lldbvscode_testcase.VSCodeTestCaseBase): self.continue_to_exit() statistics = self.vscode.wait_for_terminated()['statistics'] - self.check_statistic(statistics) - self.check_target(statistics) + self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) + self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) + self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) - @skipIfWindows - @skipIfRemote - @expectedFailureAll(oslist=['linux'], archs=['arm', 'aarch64']) - def test_initialized_event(self): - ''' - Initialized Event - Now contains the statistics of a debug session: - totalDebugInfoByteSize > 0 - totalDebugInfoEnabled > 0 - totalModuleCountHasDebugInfo > 0 - totalBreakpointResolveTime > 0 - ... - ''' + self.assertIsNotNone(statistics['memory']) + self.assertNotIn('modules', statistics.keys()) - program_basename = "a.out.stripped" - program = self.getBuildArtifact(program_basename) - self.build_and_launch(program) - # Set breakpoints - functions = ['foo'] - breakpoint_ids = self.set_function_breakpoints(functions) - self.assertEquals(len(breakpoint_ids), len(functions), 'expect one breakpoint') - main_bp_line = line_number('main.cpp', '// main breakpoint 1') - breakpoint_ids.append(self.set_source_breakpoints('main.cpp', [main_bp_line])) + # lldb-vscode debugs one target at a time + target = json.loads(statistics['targets'])[0] + self.assertTrue(target['totalBreakpointResolveTime'] > 0) - self.continue_to_breakpoints(breakpoint_ids) - statistics = self.vscode.initialized_event['statistics'] - self.check_statistic(statistics) - self.continue_to_exit() + breakpoints = target['breakpoints'] + self.assertIn('foo', + breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'], + 'foo is a symbol breakpoint') + self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'), + 'target has source line breakpoint in main.cpp') diff --git a/lldb/test/API/tools/lldb-vscode/eventStatistic/foo.cpp b/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/eventStatistic/foo.cpp rename to lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp diff --git a/lldb/test/API/tools/lldb-vscode/eventStatistic/foo.h b/lldb/test/API/tools/lldb-vscode/terminated-event/foo.h similarity index 100% rename from lldb/test/API/tools/lldb-vscode/eventStatistic/foo.h rename to lldb/test/API/tools/lldb-vscode/terminated-event/foo.h diff --git a/lldb/test/API/tools/lldb-vscode/eventStatistic/main.cpp b/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/eventStatistic/main.cpp rename to lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp index f57fae7..53f1d50 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.cpp +++ b/lldb/tools/lldb-vscode/JSONUtils.cpp @@ -1209,12 +1209,6 @@ llvm::json::Object CreateTerminatedEventObject() { return event; } -llvm::json::Object CreateInitializedEventObject() { - llvm::json::Object event(CreateEventObject("initialized")); - addStatistic(event); - return event; -} - std::string JSONToString(const llvm::json::Value &json) { std::string data; llvm::raw_string_ostream os(data); diff --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h index 2400cbc..c812ec8 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.h +++ b/lldb/tools/lldb-vscode/JSONUtils.h @@ -491,12 +491,6 @@ CreateRunInTerminalReverseRequest(const llvm::json::Object &launch_request, /// A body JSON object with debug info and breakpoint info llvm::json::Object CreateTerminatedEventObject(); -/// Create a "Initialized" JSON object that contains statistics -/// -/// \return -/// A body JSON object with debug info -llvm::json::Object CreateInitializedEventObject(); - /// Convert a given JSON object to a string. std::string JSONToString(const llvm::json::Value &json); diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp index 269ff4c..21d2bc2 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -687,7 +687,7 @@ void request_attach(const llvm::json::Object &request) { g_vsc.SendJSON(llvm::json::Value(std::move(response))); if (error.Success()) { SendProcessEvent(Attach); - g_vsc.SendJSON(CreateInitializedEventObject()); + g_vsc.SendJSON(CreateEventObject("initialized")); } } @@ -1754,7 +1754,7 @@ void request_launch(const llvm::json::Object &request) { SendProcessEvent(Attach); // this happens when doing runInTerminal else SendProcessEvent(Launch); - g_vsc.SendJSON(CreateInitializedEventObject()); + g_vsc.SendJSON(llvm::json::Value(CreateEventObject("initialized"))); } // "NextRequest": { -- 2.7.4