diff options
author | Chaoren Lin <chaorenl@google.com> | 2015-06-23 03:17:01 +0000 |
---|---|---|
committer | Chaoren Lin <chaorenl@google.com> | 2015-06-23 03:17:01 +0000 |
commit | 7a30608026825c7c558f029384d257d016992775 (patch) | |
tree | a01e080331f15f194376c62d6e8e1748190f0858 /lldb/tools/debugserver/source/RNBRemote.cpp | |
parent | 7e37afb77e067ce939f101955bf88d8ef8df389c (diff) | |
download | bcm5719-llvm-7a30608026825c7c558f029384d257d016992775.tar.gz bcm5719-llvm-7a30608026825c7c558f029384d257d016992775.zip |
Revert "Reduced packet counts to the remote GDB server where possible."
This reverts commit 0cc0745ea9c68d7fdcadc9904cee3f13c96dae60.
Due to breakage on Linux build bot:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/3436
llvm-svn: 240371
Diffstat (limited to 'lldb/tools/debugserver/source/RNBRemote.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/RNBRemote.cpp | 199 |
1 files changed, 6 insertions, 193 deletions
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 00a0c9bd4bb..2385246a200 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -29,7 +29,6 @@ #include "DNBDataRef.h" #include "DNBLog.h" #include "DNBThreadResumeActions.h" -#include "JSONGenerator.h" #include "RNBContext.h" #include "RNBServices.h" #include "RNBSocket.h" @@ -196,7 +195,6 @@ RNBRemote::CreatePacketTable () t.push_back (Packet (query_process_info, &RNBRemote::HandlePacket_qProcessInfo, NULL, "qProcessInfo", "Replies with multiple 'key:value;' tuples appended to each other.")); // t.push_back (Packet (query_symbol_lookup, &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "qSymbol", "Notify that host debugger is ready to do symbol lookups")); t.push_back (Packet (json_query_thread_extended_info, &RNBRemote::HandlePacket_jThreadExtendedInfo, NULL, "jThreadExtendedInfo", "Replies with JSON data of thread extended information.")); - t.push_back (Packet (json_query_threads_info, &RNBRemote::HandlePacket_jThreadsInfo , NULL, "jThreadsInfo", "Replies with JSON data with information about all threads.")); t.push_back (Packet (start_noack_mode, &RNBRemote::HandlePacket_QStartNoAckMode , NULL, "QStartNoAckMode", "Request that " DEBUGSERVER_PROGRAM_NAME " stop acking remote protocol packets")); t.push_back (Packet (prefix_reg_packets_with_tid, &RNBRemote::HandlePacket_QThreadSuffixSupported , NULL, "QThreadSuffixSupported", "Check if thread specific packets (register packets 'g', 'G', 'p', and 'P') support having the thread ID appended to the end of the command")); t.push_back (Packet (set_logging_mode, &RNBRemote::HandlePacket_QSetLogging , NULL, "QSetLogging:", "Check if register packets ('g', 'G', 'p', and 'P' support having the thread ID prefix")); @@ -2454,52 +2452,6 @@ gdb_regnum_with_fixed_width_hex_register_value (std::ostream& ostrm, } } -struct StackMemory -{ - uint8_t bytes[2*sizeof(nub_addr_t)]; - nub_size_t length; -}; -typedef std::map<nub_addr_t, StackMemory> StackMemoryMap; - - -static void -ReadStackMemory (nub_process_t pid, nub_thread_t tid, StackMemoryMap &stack_mmap) -{ - DNBRegisterValue reg_value; - if (DNBThreadGetRegisterValueByID(pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_FP, ®_value)) - { - uint32_t frame_count = 0; - uint64_t fp = 0; - if (reg_value.info.size == 4) - fp = reg_value.value.uint32; - else - fp = reg_value.value.uint64; - while (fp != 0) - { - // Make sure we never recurse more than 256 times so we don't recurse too far or - // store up too much memory in the expedited cache - if (++frame_count > 256) - break; - - const nub_size_t read_size = reg_value.info.size*2; - StackMemory stack_memory; - stack_memory.length = read_size; - if (DNBProcessMemoryRead(pid, fp, read_size, stack_memory.bytes) != read_size) - break; - // Make sure we don't try to put the same stack memory in more than once - if (stack_mmap.find(fp) != stack_mmap.end()) - break; - // Put the entry into the cache - stack_mmap[fp] = stack_memory; - // Dereference the frame pointer to get to the previous frame pointer - if (reg_value.info.size == 4) - fp = ((uint32_t *)stack_memory.bytes)[0]; - else - fp = ((uint64_t *)stack_memory.bytes)[0]; - } - } -} - rnb_err_t RNBRemote::SendStopReplyPacketForThread (nub_thread_t tid) { @@ -2626,26 +2578,11 @@ RNBRemote::SendStopReplyPacketForThread (nub_thread_t tid) } else if (tid_stop_info.details.exception.type) { - ostrm << "metype:" << std::hex << tid_stop_info.details.exception.type << ';'; - ostrm << "mecount:" << std::hex << tid_stop_info.details.exception.data_count << ';'; + ostrm << "metype:" << std::hex << tid_stop_info.details.exception.type << ";"; + ostrm << "mecount:" << std::hex << tid_stop_info.details.exception.data_count << ";"; for (int i = 0; i < tid_stop_info.details.exception.data_count; ++i) - ostrm << "medata:" << std::hex << tid_stop_info.details.exception.data[i] << ';'; + ostrm << "medata:" << std::hex << tid_stop_info.details.exception.data[i] << ";"; } - - // Add expedited stack memory so stack backtracing doesn't need to read anything from the - // frame pointer chain. - StackMemoryMap stack_mmap; - ReadStackMemory (pid, tid, stack_mmap); - if (!stack_mmap.empty()) - { - for (const auto &stack_memory : stack_mmap) - { - ostrm << "memory:" << HEXBASE << stack_memory.first << '='; - append_hex_value (ostrm, stack_memory.second.bytes, stack_memory.second.length, false); - ostrm << ';'; - } - } - return SendPacket (ostrm.str ()); } return SendPacket("E51"); @@ -4825,136 +4762,11 @@ get_integer_value_for_key_name_from_json (const char *key, const char *json_stri } rnb_err_t -RNBRemote::HandlePacket_jThreadsInfo (const char *p) -{ - JSONGenerator::Array threads_array; - - std::ostringstream json; - std::ostringstream reply_strm; - // If we haven't run the process yet, return an error. - if (m_ctx.HasValidProcessID()) - { - nub_process_t pid = m_ctx.ProcessID(); - - nub_size_t numthreads = DNBProcessGetNumThreads (pid); - for (nub_size_t i = 0; i < numthreads; ++i) - { - nub_thread_t tid = DNBProcessGetThreadAtIndex (pid, i); - - struct DNBThreadStopInfo tid_stop_info; - - JSONGenerator::DictionarySP thread_dict_sp(new JSONGenerator::Dictionary()); - - thread_dict_sp->AddIntegerItem("tid", tid); - - std::string reason_value("none"); - if (DNBThreadGetStopReason (pid, tid, &tid_stop_info)) - { - switch (tid_stop_info.reason) - { - case eStopTypeInvalid: - break; - case eStopTypeSignal: - if (tid_stop_info.details.signal.signo != 0) - reason_value = "signal"; - break; - case eStopTypeException: - if (tid_stop_info.details.exception.type != 0) - reason_value = "exception"; - break; - case eStopTypeExec: - reason_value = "exec"; - break; - } - if (tid_stop_info.reason == eStopTypeSignal) - { - thread_dict_sp->AddIntegerItem("signal", tid_stop_info.details.signal.signo); - } - else if (tid_stop_info.reason == eStopTypeException && tid_stop_info.details.exception.type != 0) - { - thread_dict_sp->AddIntegerItem("metype", tid_stop_info.details.exception.type); - JSONGenerator::ArraySP medata_array_sp(new JSONGenerator::Array()); - for (nub_size_t i=0; i<tid_stop_info.details.exception.data_count; ++i) - { - medata_array_sp->AddItem(JSONGenerator::IntegerSP(new JSONGenerator::Integer(tid_stop_info.details.exception.data[i]))); - } - thread_dict_sp->AddItem("medata", medata_array_sp); - } - } - - thread_dict_sp->AddStringItem("reason", reason_value); - - const char *thread_name = DNBThreadGetName (pid, tid); - if (thread_name && thread_name[0]) - thread_dict_sp->AddStringItem("name", thread_name); - - - thread_identifier_info_data_t thread_ident_info; - if (DNBThreadGetIdentifierInfo (pid, tid, &thread_ident_info)) - { - if (thread_ident_info.dispatch_qaddr != 0) - thread_dict_sp->AddIntegerItem("qaddr", thread_ident_info.dispatch_qaddr); - } - DNBRegisterValue reg_value; - - if (g_reg_entries != NULL) - { - JSONGenerator::DictionarySP registers_dict_sp(new JSONGenerator::Dictionary()); - - for (uint32_t reg = 0; reg < g_num_reg_entries; reg++) - { - // Expedite all registers in the first register set that aren't - // contained in other registers - if (g_reg_entries[reg].nub_info.set == 1 && - g_reg_entries[reg].nub_info.value_regs == NULL) - { - if (!DNBThreadGetRegisterValueByID (pid, tid, g_reg_entries[reg].nub_info.set, g_reg_entries[reg].nub_info.reg, ®_value)) - continue; - - std::ostringstream reg_num; - reg_num << std::dec << g_reg_entries[reg].gdb_regnum; - // Encode native byte ordered bytes as hex ascii - registers_dict_sp->AddBytesAsHexASCIIString(reg_num.str(), reg_value.value.v_uint8, g_reg_entries[reg].nub_info.size); - } - } - thread_dict_sp->AddItem("registers", registers_dict_sp); - } - - // Add expedited stack memory so stack backtracing doesn't need to read anything from the - // frame pointer chain. - StackMemoryMap stack_mmap; - ReadStackMemory (pid, tid, stack_mmap); - if (!stack_mmap.empty()) - { - JSONGenerator::ArraySP memory_array_sp(new JSONGenerator::Array()); - - for (const auto &stack_memory : stack_mmap) - { - JSONGenerator::DictionarySP stack_memory_sp(new JSONGenerator::Dictionary()); - stack_memory_sp->AddIntegerItem("address", stack_memory.first); - stack_memory_sp->AddBytesAsHexASCIIString("bytes", stack_memory.second.bytes, stack_memory.second.length); - memory_array_sp->AddItem(stack_memory_sp); - } - thread_dict_sp->AddItem("memory", memory_array_sp); - } - threads_array.AddItem(thread_dict_sp); - } - - std::ostringstream strm; - threads_array.Dump (strm); - std::string binary_packet = binary_encode_string (strm.str()); - if (!binary_packet.empty()) - return SendPacket (binary_packet.c_str()); - } - return SendPacket ("E85"); - -} - -rnb_err_t RNBRemote::HandlePacket_jThreadExtendedInfo (const char *p) { nub_process_t pid; std::ostringstream json; + std::ostringstream reply_strm; // If we haven't run the process yet, return an error. if (!m_ctx.HasValidProcessID()) { @@ -5184,7 +4996,8 @@ RNBRemote::HandlePacket_jThreadExtendedInfo (const char *p) json << "}"; std::string json_quoted = binary_encode_string (json.str()); - return SendPacket (json_quoted); + reply_strm << json_quoted; + return SendPacket (reply_strm.str()); } } return SendPacket ("OK"); |