diff options
author | Alex Cameron <ascottcameron@gmail.com> | 2019-11-18 15:11:29 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-11-18 15:12:55 +0100 |
commit | 10b851434324f82e9ad11d39f501f2d8b921642a (patch) | |
tree | bc5be67a4f53c56adcb6eb1e283509a94f1eb62f /lldb/tools/debugserver | |
parent | 8c8c941844080625fd2989bd4045cdd5db4bb908 (diff) | |
download | bcm5719-llvm-10b851434324f82e9ad11d39f501f2d8b921642a.tar.gz bcm5719-llvm-10b851434324f82e9ad11d39f501f2d8b921642a.zip |
[lldb] Fix JSON parser to allow empty arrays
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=39405
```
alexc@kitty:~/work/wiredtiger/build_posix$ cat breakpoint.json
[{"Breakpoint" : {"BKPTOptions" : {"AutoContinue" : false,"ConditionText" : "","EnabledState" : true,"IgnoreCount" : 0,"OneShotState" : false},"BKPTResolver" : {"Options" : {"NameMask" : [56],"Offset" : 0,"SkipPrologue" : true,"SymbolNames" : ["__wt_btcur_search"]},"Type" : "SymbolName"},"Hardware" : false,"SearchFilter" : {"Options" : {},"Type" : "Unconstrained","Foo" : []}}}]
```
**Before**
```
(lldb) breakpoint read --file breakpoint.json
error: Invalid JSON from input file: /home/alexc/work/wiredtiger/build_posix/breakpoint.json.
```
**After**
```
(lldb) breakpoint read --file breakpoint.json
New breakpoints:
Breakpoint 1: where = libwiredtiger-3.2.2.so`__wt_btcur_search + 15 at bt_cursor.c:522:5, address = 0x00007ffff576ab2f
```
Reviewers: xbolva00, davide, labath
Reviewed By: davide, labath
Subscribers: mgorny, jingham, labath, davide, JDevlieghere, lldb-commits
Tags: #llvm, #lldb
Differential Revision: https://reviews.llvm.org/D68179
Diffstat (limited to 'lldb/tools/debugserver')
-rw-r--r-- | lldb/tools/debugserver/source/JSON.cpp | 12 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/JSON.h | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lldb/tools/debugserver/source/JSON.cpp b/lldb/tools/debugserver/source/JSON.cpp index 1b37767256d..12d96d4ed4d 100644 --- a/lldb/tools/debugserver/source/JSON.cpp +++ b/lldb/tools/debugserver/source/JSON.cpp @@ -516,13 +516,16 @@ JSONValue::SP JSONParser::ParseJSONArray() { std::string value; std::string key; while (true) { - JSONValue::SP value_sp = ParseJSONValue(); + JSONParser::Token token = GetToken(value); + if (token == JSONParser::Token::ArrayEnd) + return JSONValue::SP(array_up.release()); + JSONValue::SP value_sp = ParseJSONValue(value, token); if (value_sp) array_up->AppendObject(value_sp); else break; - JSONParser::Token token = GetToken(value); + token = GetToken(value); if (token == JSONParser::Token::Comma) { continue; } else if (token == JSONParser::Token::ArrayEnd) { @@ -537,6 +540,11 @@ JSONValue::SP JSONParser::ParseJSONArray() { JSONValue::SP JSONParser::ParseJSONValue() { std::string value; const JSONParser::Token token = GetToken(value); + return ParseJSONValue(value, token); +} + +JSONValue::SP JSONParser::ParseJSONValue(const std::string &value, + const Token &token) { switch (token) { case JSONParser::Token::ObjectStart: return ParseJSONObject(); diff --git a/lldb/tools/debugserver/source/JSON.h b/lldb/tools/debugserver/source/JSON.h index b1c4a4c9db8..70bfdd7259a 100644 --- a/lldb/tools/debugserver/source/JSON.h +++ b/lldb/tools/debugserver/source/JSON.h @@ -292,6 +292,8 @@ public: JSONValue::SP ParseJSONValue(); protected: + JSONValue::SP ParseJSONValue(const std::string &value, const Token &token); + JSONValue::SP ParseJSONObject(); JSONValue::SP ParseJSONArray(); |