Fix more JDWP bugs.
Change-Id: I475d14e196a7463e70f7cce6a8b8d77f867e9e46
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index 5e4487c..99916bd 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -416,10 +416,7 @@
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 @@
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 @@
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 @@
/* 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" },