Author: Walter Erquinigo Date: 2021-06-21T19:35:05-07:00 New Revision: 2e11f4e06804e53cee95e63fdc9e5152f8444abb
URL: https://github.com/llvm/llvm-project/commit/2e11f4e06804e53cee95e63fdc9e5152f8444abb DIFF: https://github.com/llvm/llvm-project/commit/2e11f4e06804e53cee95e63fdc9e5152f8444abb.diff LOG: [lldb-vscode] Add simple DAP logs dump to investigate flakiness in tests A few times tests have been flaky, presumably by crashed of lldb-vscode itself. They can be caught by looking at the DAP logs, so I'm dumping them when the session ends. Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py Removed: ################################################################################ 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 9eeebdbf76091..df057d5e63aa6 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -87,27 +87,39 @@ def read_packet(f, verbose=False, trace_file=None): def packet_type_is(packet, packet_type): return 'type' in packet and packet['type'] == packet_type +def dump_dap_log(log_file): + print("========= DEBUG ADAPTER PROTOCOL LOGS =========") + if log_file is None: + print("no log file available") + else: + with open(log_file, "r") as file: + print(file.read()) + print("========= END =========") + -def read_packet_thread(vs_comm): +def read_packet_thread(vs_comm, log_file): done = False - while not done: - packet = read_packet(vs_comm.recv, trace_file=vs_comm.trace_file) - # `packet` will be `None` on EOF. We want to pass it down to - # handle_recv_packet anyway so the main thread can handle unexpected - # termination of lldb-vscode and stop waiting for new packets. - done = not vs_comm.handle_recv_packet(packet) + try: + while not done: + packet = read_packet(vs_comm.recv, trace_file=vs_comm.trace_file) + # `packet` will be `None` on EOF. We want to pass it down to + # handle_recv_packet anyway so the main thread can handle unexpected + # termination of lldb-vscode and stop waiting for new packets. + done = not vs_comm.handle_recv_packet(packet) + finally: + dump_dap_log(log_file) class DebugCommunication(object): - def __init__(self, recv, send, init_commands): + def __init__(self, recv, send, init_commands, log_file=None): self.trace_file = None self.send = send self.recv = recv self.recv_packets = [] self.recv_condition = threading.Condition() self.recv_thread = threading.Thread(target=read_packet_thread, - args=(self,)) + args=(self, log_file)) self.process_event_body = None self.exit_status = None self.initialize_body = None @@ -943,7 +955,7 @@ def __init__(self, executable=None, port=None, init_commands=[], log_file=None, stderr=subprocess.PIPE, env=adaptor_env) DebugCommunication.__init__(self, self.process.stdout, - self.process.stdin, init_commands) + self.process.stdin, init_commands, log_file) elif port is not None: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', port)) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits