Author: jmolenda Date: Thu Jun 4 01:03:03 2015 New Revision: 239013 URL: http://llvm.org/viewvc/llvm-project?rev=239013&view=rev Log: Make the function that parses the json packets in debugserver a little more resilient to freely formatted json. Greg's change in r238279 made the json output from StructuredData unconditionally pretty-printed and the spaces were confusing debugserver.
Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=239013&r1=239012&r2=239013&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Thu Jun 4 01:03:03 2015 @@ -4481,16 +4481,28 @@ get_integer_value_for_key_name_from_json uint64_t retval = INVALID_NUB_ADDRESS; std::string key_with_quotes = "\""; key_with_quotes += key; - key_with_quotes += "\":"; + key_with_quotes += "\""; const char *c = strstr (json_string, key_with_quotes.c_str()); if (c) { c += key_with_quotes.size(); - errno = 0; - retval = strtoul (c, NULL, 10); - if (errno != 0) + + while (*c != '\0' && (*c == ' ' || *c == '\t' || *c == '\n' || *c == '\r')) + c++; + + if (*c == ':') { - retval = INVALID_NUB_ADDRESS; + c++; + + while (*c != '\0' && (*c == ' ' || *c == '\t' || *c == '\n' || *c == '\r')) + c++; + + errno = 0; + retval = strtoul (c, NULL, 10); + if (errno != 0) + { + retval = INVALID_NUB_ADDRESS; + } } } return retval; _______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits