diff options
| -rw-r--r-- | src/debugger.cc | 13 | ||||
| -rw-r--r-- | src/debugger.h | 2 | ||||
| -rw-r--r-- | src/jdwp/jdwp_handler.cc | 25 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/debugger.cc b/src/debugger.cc index 4c47e00a60..40405ebe2d 100644 --- a/src/debugger.cc +++ b/src/debugger.cc @@ -612,13 +612,14 @@ uint8_t Dbg::GetClassObjectType(JDWP::RefTypeId refTypeId) { return 0; } -bool Dbg::GetSignature(JDWP::RefTypeId refTypeId, std::string& signature) { - Object* o = gRegistry->Get<Object*>(refTypeId); - if (o == NULL || !o->IsClass()) { - return false; +JDWP::JdwpError Dbg::GetSignature(JDWP::RefTypeId refTypeId, std::string& signature) { + JDWP::JdwpError status; + Class* c = DecodeClass(refTypeId, status); + if (c == NULL) { + return status; } - signature = ClassHelper(o->AsClass()).GetDescriptor(); - return true; + signature = ClassHelper(c).GetDescriptor(); + return JDWP::ERR_NONE; } bool Dbg::GetSourceFile(JDWP::RefTypeId refTypeId, std::string& result) { diff --git a/src/debugger.h b/src/debugger.h index b92fbfe5ba..8a702a1f42 100644 --- a/src/debugger.h +++ b/src/debugger.h @@ -140,7 +140,7 @@ class Dbg { static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids); static void GetObjectType(JDWP::ObjectId objectId, JDWP::JdwpTypeTag* pRefTypeTag, JDWP::RefTypeId* pRefTypeId); static uint8_t GetClassObjectType(JDWP::RefTypeId refTypeId); - static bool GetSignature(JDWP::RefTypeId refTypeId, std::string& signature); + static JDWP::JdwpError GetSignature(JDWP::RefTypeId refTypeId, std::string& signature); static bool GetSourceFile(JDWP::RefTypeId refTypeId, std::string& source_file); static uint8_t GetObjectTag(JDWP::ObjectId objectId); static size_t GetTagWidth(JDWP::JdwpTag tag); diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc index 5e4487cdac..99916bd234 100644 --- a/src/jdwp/jdwp_handler.cc +++ b/src/jdwp/jdwp_handler.cc @@ -416,10 +416,7 @@ static JdwpError handleVM_CapabilitiesNew(JdwpState* state, const uint8_t* buf, return ERR_NONE; } -/* - * Cough up the complete list of classes. - */ -static JdwpError handleVM_AllClassesWithGeneric(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) { +static JdwpError handleVM_AllClasses(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply, bool generic) { std::vector<JDWP::RefTypeId> classes; Dbg::GetClassList(classes); @@ -437,13 +434,23 @@ static JdwpError handleVM_AllClassesWithGeneric(JdwpState* state, const uint8_t* expandBufAdd1(pReply, refTypeTag); expandBufAddRefTypeId(pReply, classes[i]); expandBufAddUtf8String(pReply, descriptor); - expandBufAddUtf8String(pReply, genericSignature); + if (generic) { + expandBufAddUtf8String(pReply, genericSignature); + } expandBufAdd4BE(pReply, status); } return ERR_NONE; } +static JdwpError handleVM_AllClasses(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) { + return handleVM_AllClasses(state, buf, dataLen, pReply, false); +} + +static JdwpError handleVM_AllClassesWithGeneric(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) { + return handleVM_AllClasses(state, buf, dataLen, pReply, true); +} + /* * Given a referenceTypeID, return a string with the JNI reference type * signature (e.g. "Ljava/lang/Error;"). @@ -453,8 +460,10 @@ static JdwpError handleRT_Signature(JdwpState* state, const uint8_t* buf, int da VLOG(jdwp) << StringPrintf(" Req for signature of refTypeId=0x%llx", refTypeId); std::string signature; - if (!Dbg::GetSignature(refTypeId, signature)) { - return ERR_INVALID_CLASS; + + JdwpError status = Dbg::GetSignature(refTypeId, signature); + if (status != ERR_NONE) { + return status; } expandBufAddUtf8String(pReply, signature); return ERR_NONE; @@ -1563,7 +1572,7 @@ static const JdwpHandlerMap gHandlerMap[] = { /* VirtualMachine command set (1) */ { 1, 1, handleVM_Version, "VirtualMachine.Version" }, { 1, 2, handleVM_ClassesBySignature, "VirtualMachine.ClassesBySignature" }, - { 1, 3, NULL, "VirtualMachine.AllClasses" }, + { 1, 3, handleVM_AllClasses, "VirtualMachine.AllClasses" }, { 1, 4, handleVM_AllThreads, "VirtualMachine.AllThreads" }, { 1, 5, handleVM_TopLevelThreadGroups, "VirtualMachine.TopLevelThreadGroups" }, { 1, 6, handleVM_Dispose, "VirtualMachine.Dispose" }, |