Merge "Fix more JDWP bugs." into dalvik-dev
diff --git a/src/debugger.cc b/src/debugger.cc
index 4c47e00..40405eb 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -612,13 +612,14 @@
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 b92fbfe..8a702a1 100644
--- a/src/debugger.h
+++ b/src/debugger.h
@@ -140,7 +140,7 @@
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 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" },