[Lldb-commits] [PATCH] D70883: [vscode.py] Make read_packet only return None when EOF
António Afonso via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun Dec 1 20:36:52 PST 2019
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):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70883.231630.patch
Type: text/x-patch
Size: 2347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191202/2dd5c410/attachment.bin>
More information about the lldb-commits
mailing list