Open j-delaney opened 7 years ago
For an example that's easier to mess around with you can also use the Python REPL:
$ python
>>> import json
>>> dict = {'status': 'success', 'data': {'output': '(s) foo = (arr = "\xf7)'}, 'type': 'response'}
>>> json.dumps(dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj)
File "python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf7 in position 18: invalid start byte
I ran into this same issue and used your workaround as well. Thanks! :tada:
The following command output can't be properly decoded:
dispatch_request -- Response: {"status": "success", "data": {"output": "(i32) a = 0\n(const char *) path = 0x0000000000024580 \"UH\\x89H\u0005\""}, "type": "response"}
which causes UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 60: invalid continuation byte
.
The code I'm debugging is like
{
int a = 0;
const char* path = "foo";
}
and if I set a breakpoint on the first line "frame variable" in lldb will output
(i32) a = 0
(const char *) path = 0x0000000000024580 "UH\x89H"
due to the fact that path hasn't been initialized yet and is just garbled memory, which voltron tries to make python decode as utf8.
Summary
In some cases, calling
frame variables
from Voltron causing the following stacktrace:The line having the issues looks like
I did a little bit of digging and it looks like the issue might be that the default encoding for
json.dumps
is "utf-8" but in this particular case it needs to be "iso-8859-1". I've found a temporary workaround of changing the offending line to:Steps to Reproduce
char.cpp
with the following contents:int main() { struct s foo = {{(char)247, '\0'}}; return 0; }
clang++: Apple LLVM version 8.1.0 (clang-802.0.42) python: Python 2.7.10 :: Anaconda custom (x86_64) voltron: 0.1.7 voltron-web: 0.1.1 lldb: lldb-370.0.42 os: macOS 10.12.5