aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
lldb-vscode has an issue when run in stdout/stdin mode because it will send all stdout generated by scripts through well.. stdout :) This is problematic for any adapter using lldb-vscode in that mode since it will not produce DAP messages. Even if we ignore that the method explicitly says that None is only returned in EOF situation which was not the case. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70883 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -54,33 +54,32 @@ '''Decode a JSON packet that starts with the content length and is followed by the JSON bytes from a file 'f'. Returns None on EOF. ''' - line = f.readline().decode("utf-8") - if len(line) == 0: - return None # EOF. - - # Watch for line that starts with the prefix - prefix = 'Content-Length: ' - if line.startswith(prefix): - # Decode length of JSON bytes - if verbose: - print('content: "%s"' % (line)) - length = int(line[len(prefix):]) - if verbose: - print('length: "%u"' % (length)) - # Skip empty line - line = f.readline() - if verbose: - print('empty: "%s"' % (line)) - # Read JSON bytes - json_str = f.read(length) - if verbose: - print('json: "%s"' % (json_str)) - if trace_file: - trace_file.write('from adaptor:\n%s\n' % (json_str)) - # Decode the JSON bytes into a python dictionary - return json.loads(json_str) - - return None + while True: + line = f.readline().decode("utf-8") + if len(line) == 0: + return None # EOF. + + # Watch for line that starts with the prefix + prefix = 'Content-Length: ' + if line.startswith(prefix): + # Decode length of JSON bytes + if verbose: + print('content: "%s"' % (line)) + length = int(line[len(prefix):]) + if verbose: + print('length: "%u"' % (length)) + # Skip empty line + line = f.readline() + if verbose: + print('empty: "%s"' % (line)) + # Read JSON bytes + json_str = f.read(length) + if verbose: + print('json: "%s"' % (json_str)) + if trace_file: + trace_file.write('from adaptor:\n%s\n' % (json_str)) + # Decode the JSON bytes into a python dictionary + return json.loads(json_str) def packet_type_is(packet, packet_type):
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -54,33 +54,32 @@ '''Decode a JSON packet that starts with the content length and is followed by the JSON bytes from a file 'f'. Returns None on EOF. ''' - line = f.readline().decode("utf-8") - if len(line) == 0: - return None # EOF. - - # Watch for line that starts with the prefix - prefix = 'Content-Length: ' - if line.startswith(prefix): - # Decode length of JSON bytes - if verbose: - print('content: "%s"' % (line)) - length = int(line[len(prefix):]) - if verbose: - print('length: "%u"' % (length)) - # Skip empty line - line = f.readline() - if verbose: - print('empty: "%s"' % (line)) - # Read JSON bytes - json_str = f.read(length) - if verbose: - print('json: "%s"' % (json_str)) - if trace_file: - trace_file.write('from adaptor:\n%s\n' % (json_str)) - # Decode the JSON bytes into a python dictionary - return json.loads(json_str) - - return None + while True: + line = f.readline().decode("utf-8") + if len(line) == 0: + return None # EOF. + + # Watch for line that starts with the prefix + prefix = 'Content-Length: ' + if line.startswith(prefix): + # Decode length of JSON bytes + if verbose: + print('content: "%s"' % (line)) + length = int(line[len(prefix):]) + if verbose: + print('length: "%u"' % (length)) + # Skip empty line + line = f.readline() + if verbose: + print('empty: "%s"' % (line)) + # Read JSON bytes + json_str = f.read(length) + if verbose: + print('json: "%s"' % (json_str)) + if trace_file: + trace_file.write('from adaptor:\n%s\n' % (json_str)) + # Decode the JSON bytes into a python dictionary + return json.loads(json_str) def packet_type_is(packet, packet_type):
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits