[Lldb-commits] [PATCH] D27289: Return "thread-pcs" in jstopinfo on Linux/Android.
Jason Majors via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 30 17:24:58 PST 2016
jmajors created this revision.
jmajors added a reviewer: labath.
jmajors added a subscriber: lldb-commits.
Herald added a subscriber: danalbert.
To prevent costly calls to the server to get the PC for every thread,
add all the thread's PCs to the jstopinfo message. This also makes the
Linux/Android server behave like the macOS server.
https://reviews.llvm.org/D27289
Files:
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -415,18 +415,20 @@
static void WriteRegisterValueInHexFixedWidth(
StreamString &response, NativeRegisterContextSP ®_ctx_sp,
- const RegisterInfo ®_info, const RegisterValue *reg_value_p) {
+ const RegisterInfo ®_info, const RegisterValue *reg_value_p,
+ lldb::ByteOrder byte_order) {
RegisterValue reg_value;
if (!reg_value_p) {
Error error = reg_ctx_sp->ReadRegister(®_info, reg_value);
if (error.Success())
reg_value_p = ®_value;
// else log.
}
+ bool little_endian = byte_order == lldb::eByteOrderLittle;
if (reg_value_p) {
AppendHexValue(response, (const uint8_t *)reg_value_p->GetBytes(),
- reg_value_p->GetByteSize(), false);
+ reg_value_p->GetByteSize(), little_endian);
} else {
// Zero-out any unreadable values.
if (reg_info.byte_size > 0) {
@@ -436,6 +438,13 @@
}
}
+static void WriteRegisterValueInHexFixedWidth(
+ StreamString &response, NativeRegisterContextSP ®_ctx_sp,
+ const RegisterInfo ®_info, const RegisterValue *reg_value_p) {
+ WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, reg_info,
+ reg_value_p, lldb::eByteOrderBig);
+}
+
static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread,
bool abridged) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
@@ -570,6 +579,7 @@
if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
thread_obj_sp->SetObject("registers", registers_sp);
+
thread_obj_sp->SetObject("tid", std::make_shared<JSONNumber>(tid));
if (signum != 0)
thread_obj_sp->SetObject("signal", std::make_shared<JSONNumber>(signum));
@@ -721,6 +731,41 @@
"jstopinfo field for pid %" PRIu64,
__FUNCTION__, m_debugged_process_sp->GetID());
}
+
+ uint32_t i = 0;
+ ByteOrder byte_order = endian::InlHostByteOrder();
+ response.PutCString("thread-pcs");
+ char delimiter = ':';
+ for (NativeThreadProtocolSP thread_sp;
+ (thread_sp = m_debugged_process_sp->GetThreadAtIndex(i)) != nullptr;
+ ++i) {
+ NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
+ if (!reg_ctx_sp)
+ continue;
+
+ uint32_t reg_to_read = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ const RegisterInfo* const reg_info_p =
+ reg_ctx_sp->GetRegisterInfoAtIndex(reg_to_read);
+
+ RegisterValue reg_value;
+ Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
+ __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name : "<unnamed-register>",
+ reg_to_read, error.AsCString());
+ continue;
+ }
+
+ response.PutChar(delimiter);
+ delimiter = ',';
+ WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p,
+ ®_value, byte_order);
+ }
+
+ response.PutChar(';');
}
//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27289.79846.patch
Type: text/x-patch
Size: 3524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161201/54f0597e/attachment-0001.bin>
More information about the lldb-commits
mailing list