From d9e4e0c8606f8b87e0a48aab68125dbee543bf88 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 23 Jan 2014 20:11:40 -0800 Subject: 64bit friendly printf modifiers in JDWP. Change-Id: I105da6393b31f5901036216fbfe19a71c46cf152 --- runtime/jdwp/jdwp_event.cc | 18 ++++++++++-------- runtime/jdwp/jdwp_handler.cc | 21 ++++++++++++--------- runtime/jdwp/jdwp_main.cc | 14 +++++++------- runtime/jdwp/jdwp_request.cc | 4 +++- 4 files changed, 32 insertions(+), 25 deletions(-) (limited to 'runtime/jdwp') diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc index 4aa7f13..e372c26 100644 --- a/runtime/jdwp/jdwp_event.cc +++ b/runtime/jdwp/jdwp_event.cc @@ -638,13 +638,14 @@ void JdwpState::SetWaitForEventThread(ObjectId threadId) { * go to sleep indefinitely. */ while (event_thread_id_ != 0) { - VLOG(jdwp) << StringPrintf("event in progress (%#llx), %#llx sleeping", event_thread_id_, threadId); + VLOG(jdwp) << StringPrintf("event in progress (%#" PRIx64 "), %#" PRIx64 " sleeping", + event_thread_id_, threadId); waited = true; event_thread_cond_.Wait(self); } if (waited || threadId != 0) { - VLOG(jdwp) << StringPrintf("event token grabbed (%#llx)", threadId); + VLOG(jdwp) << StringPrintf("event token grabbed (%#" PRIx64 ")", threadId); } if (threadId != 0) { event_thread_id_ = threadId; @@ -664,7 +665,7 @@ void JdwpState::ClearWaitForEventThread() { MutexLock mu(self, event_thread_lock_); CHECK_NE(event_thread_id_, 0U); - VLOG(jdwp) << StringPrintf("cleared event token (%#llx)", event_thread_id_); + VLOG(jdwp) << StringPrintf("cleared event token (%#" PRIx64 ")", event_thread_id_); event_thread_id_ = 0; @@ -820,7 +821,8 @@ bool JdwpState::PostLocationEvent(const JdwpLocation* pLoc, ObjectId thisPtr, in if (match_count != 0) { VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) " << basket.className << "." << Dbg::GetMethodName(pLoc->method_id) - << StringPrintf(" thread=%#llx dex_pc=%#llx)", basket.threadId, pLoc->dex_pc); + << StringPrintf(" thread=%#" PRIx64 " dex_pc=%#" PRIx64 ")", + basket.threadId, pLoc->dex_pc); suspend_policy = scanSuspendPolicy(match_list, match_count); VLOG(jdwp) << " suspend_policy=" << suspend_policy; @@ -885,7 +887,7 @@ bool JdwpState::PostThreadChange(ObjectId threadId, bool start) { if (match_count != 0) { VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) " - << StringPrintf("thread=%#llx", basket.threadId) << ")"; + << StringPrintf("thread=%#" PRIx64, basket.threadId) << ")"; suspend_policy = scanSuspendPolicy(match_list, match_count); VLOG(jdwp) << " suspend_policy=" << suspend_policy; @@ -968,8 +970,8 @@ bool JdwpState::PostException(const JdwpLocation* pThrowLoc, FindMatchingEvents(EK_EXCEPTION, &basket, match_list, &match_count); if (match_count != 0) { VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total)" - << StringPrintf(" thread=%#llx", basket.threadId) - << StringPrintf(" exceptId=%#llx", exceptionId) + << StringPrintf(" thread=%#" PRIx64, basket.threadId) + << StringPrintf(" exceptId=%#" PRIx64, exceptionId) << " caught=" << basket.caught << ")" << " throw: " << *pThrowLoc; if (pCatchLoc->class_id == 0) { @@ -1036,7 +1038,7 @@ bool JdwpState::PostClassPrepare(JdwpTypeTag tag, RefTypeId refTypeId, const std FindMatchingEvents(EK_CLASS_PREPARE, &basket, match_list, &match_count); if (match_count != 0) { VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) " - << StringPrintf("thread=%#llx", basket.threadId) << ") " << signature; + << StringPrintf("thread=%#" PRIx64, basket.threadId) << ") " << signature; suspend_policy = scanSuspendPolicy(match_list, match_count); VLOG(jdwp) << " suspend_policy=" << suspend_policy; diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc index 523d892..6522a62 100644 --- a/runtime/jdwp/jdwp_handler.cc +++ b/runtime/jdwp/jdwp_handler.cc @@ -48,7 +48,7 @@ std::string DescribeMethod(const MethodId& method_id) { std::string DescribeRefTypeId(const RefTypeId& ref_type_id) { std::string signature("unknown"); Dbg::GetSignature(ref_type_id, &signature); - return StringPrintf("%#llx (%s)", ref_type_id, signature.c_str()); + return StringPrintf("%#" PRIx64 " (%s)", ref_type_id, signature.c_str()); } // Helper function: write a variable-width value into the output input buffer. @@ -99,8 +99,9 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply, int32_t arg_count = request.ReadSigned32("argument count"); - VLOG(jdwp) << StringPrintf(" --> thread_id=%#llx object_id=%#llx", thread_id, object_id); - VLOG(jdwp) << StringPrintf(" class_id=%#llx method_id=%x %s.%s", class_id, + VLOG(jdwp) << StringPrintf(" --> thread_id=%#" PRIx64 " object_id=%#" PRIx64, + thread_id, object_id); + VLOG(jdwp) << StringPrintf(" class_id=%#" PRIx64 " method_id=%x %s.%s", class_id, method_id, Dbg::GetClassName(class_id).c_str(), Dbg::GetMethodName(method_id).c_str()); VLOG(jdwp) << StringPrintf(" %d args:", arg_count); @@ -111,7 +112,8 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply, argTypes[i] = request.ReadTag(); size_t width = Dbg::GetTagWidth(argTypes[i]); argValues[i] = request.ReadValue(width); - VLOG(jdwp) << " " << argTypes[i] << StringPrintf("(%zd): %#llx", width, argValues[i]); + VLOG(jdwp) << " " << argTypes[i] << StringPrintf("(%zd): %#" PRIx64, width, + argValues[i]); } uint32_t options = request.ReadUnsigned32("InvokeOptions bit flags"); @@ -143,7 +145,8 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply, expandBufAdd1(pReply, JT_OBJECT); expandBufAddObjectId(pReply, exceptObjId); - VLOG(jdwp) << " --> returned " << resultTag << StringPrintf(" %#llx (except=%#llx)", resultValue, exceptObjId); + VLOG(jdwp) << " --> returned " << resultTag + << StringPrintf(" %#" PRIx64 " (except=%#" PRIx64 ")", resultValue, exceptObjId); /* show detailed debug output */ if (resultTag == JT_STRING && exceptObjId == 0) { @@ -526,7 +529,7 @@ static JdwpError RT_ClassObject(JdwpState*, Request& request, ExpandBuf* pReply) if (status != ERR_NONE) { return status; } - VLOG(jdwp) << StringPrintf(" --> ObjectId %#llx", class_object_id); + VLOG(jdwp) << StringPrintf(" --> ObjectId %#" PRIx64, class_object_id); expandBufAddObjectId(pReply, class_object_id); return ERR_NONE; } @@ -936,7 +939,7 @@ static JdwpError TR_Name(JdwpState*, Request& request, ExpandBuf* pReply) if (error != ERR_NONE) { return error; } - VLOG(jdwp) << StringPrintf(" Name of thread %#llx is \"%s\"", thread_id, name.c_str()); + VLOG(jdwp) << StringPrintf(" Name of thread %#" PRIx64 " is \"%s\"", thread_id, name.c_str()); expandBufAddUtf8String(pReply, name); return ERR_NONE; @@ -1335,7 +1338,7 @@ static JdwpError ER_Set(JdwpState* state, Request& request, ExpandBuf* pReply) ObjectId thread_id = request.ReadThreadId(); uint32_t size = request.ReadUnsigned32("step size"); uint32_t depth = request.ReadUnsigned32("step depth"); - VLOG(jdwp) << StringPrintf(" Step: thread=%#llx", thread_id) + VLOG(jdwp) << StringPrintf(" Step: thread=%#" PRIx64, thread_id) << " size=" << JdwpStepSize(size) << " depth=" << JdwpStepDepth(depth); mod.step.threadId = thread_id; @@ -1640,7 +1643,7 @@ static std::string DescribeCommand(Request& request) { std::string result; result += "REQUEST: "; result += GetCommandName(request); - result += StringPrintf(" (length=%d id=0x%06x)", request.GetLength(), request.GetId()); + result += StringPrintf(" (length=%zu id=0x%06x)", request.GetLength(), request.GetId()); return result; } diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc index 127ebfa..928f53d 100644 --- a/runtime/jdwp/jdwp_main.cc +++ b/runtime/jdwp/jdwp_main.cc @@ -156,11 +156,11 @@ void JdwpState::SendBufferedRequest(uint32_t type, const std::vector& iov errno = 0; ssize_t actual = netState->WriteBufferedPacket(iov); if (static_cast(actual) != expected) { - PLOG(ERROR) << StringPrintf("Failed to send JDWP packet %c%c%c%c to debugger (%d of %d)", - static_cast(type >> 24), - static_cast(type >> 16), - static_cast(type >> 8), - static_cast(type), + PLOG(ERROR) << StringPrintf("Failed to send JDWP packet %c%c%c%c to debugger (%zd of %zu)", + static_cast(type >> 24), + static_cast(type >> 16), + static_cast(type >> 8), + static_cast(type), actual, expected); } } @@ -175,7 +175,7 @@ void JdwpState::SendRequest(ExpandBuf* pReq) { errno = 0; ssize_t actual = netState->WritePacket(pReq); if (static_cast(actual) != expandBufGetLength(pReq)) { - PLOG(ERROR) << StringPrintf("Failed to send JDWP packet to debugger (%d of %d)", + PLOG(ERROR) << StringPrintf("Failed to send JDWP packet to debugger (%zd of %zu)", actual, expandBufGetLength(pReq)); } } @@ -607,7 +607,7 @@ void JdwpState::ExitAfterReplying(int exit_status) { std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) { os << "JdwpLocation[" << Dbg::GetClassName(rhs.class_id) << "." << Dbg::GetMethodName(rhs.method_id) - << "@" << StringPrintf("%#llx", rhs.dex_pc) << " " << rhs.type_tag << "]"; + << "@" << StringPrintf("%#" PRIx64, rhs.dex_pc) << " " << rhs.type_tag << "]"; return os; } diff --git a/runtime/jdwp/jdwp_request.cc b/runtime/jdwp/jdwp_request.cc index a9dd1e1..7b15d6d 100644 --- a/runtime/jdwp/jdwp_request.cc +++ b/runtime/jdwp/jdwp_request.cc @@ -16,6 +16,8 @@ #include "jdwp/jdwp.h" +#include + #include "base/stringprintf.h" #include "jdwp/jdwp_priv.h" @@ -98,7 +100,7 @@ MethodId Request::ReadMethodId() { ObjectId Request::ReadObjectId(const char* specific_kind) { ObjectId id = Read8BE(); - VLOG(jdwp) << StringPrintf(" %s id %#llx", specific_kind, id); + VLOG(jdwp) << StringPrintf(" %s id %#" PRIx64, specific_kind, id); return id; } -- cgit v1.1