diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/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):