[Lldb-commits] [PATCH] D61687: Update Python tests for lldb-server on Windows

Hui Huang via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 13 21:02:47 PDT 2019


Hui added inline comments.


================
Comment at: packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py:24-27
+        # Replace path separators in the json string either with "\\\\" or "/" on Windows.
+        triple = self.dbg.GetSelectedPlatform().GetTriple()
+        if re.match(".*-.*-windows", triple):
+            module_path = module_path.replace(os.path.sep, '/')
----------------
clayborg wrote:
> labath wrote:
> > It sounds like you could just unconditionally replace all backslashes with double-backslashes here. That would result in us also correctly handling posix paths that happen to contain a backslash.
> Remove
The 'jModulesInfo' packet is a json string. I tested with json.loads as follows.
It seemed to me that module_path needs to be escaped, i.e. 'd:\\\\abc' or be  'd:/abc'.

not-working case:

```
>>> module_path = 'd:\abc'
>>> json.dumps(module_path)
'"d:\\u0007bc"'
>>> json.loads('[{"[file":"%s"}]' % json.dumps(module_path))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 1 column 13 (char 12)

```
working case:

```
>>> module_path = 'd:\\\\abc'
>>> json.loads('[{"[file":"%s"}]' % module_path)
[{u'[file': u'd:\\abc'}]
```





Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61687/new/

https://reviews.llvm.org/D61687





More information about the lldb-commits mailing list