From 6ff3c8fde9623dadad726dbd5e1658585c321751 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 13 Oct 2009 13:06:03 -0700 Subject: [PATCH] Add JDWP ReferenceType.ClassObject handler. For bug 2157236. --- vm/Debugger.c | 9 +++++++++ vm/Debugger.h | 1 + vm/jdwp/JdwpHandler.c | 23 ++++++++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/vm/Debugger.c b/vm/Debugger.c index 31193500f..86adbb671 100644 --- a/vm/Debugger.c +++ b/vm/Debugger.c @@ -512,6 +512,15 @@ const char* dvmDbgGetClassDescriptor(RefTypeId id) } /* + * Convert a RefTypeId to an ObjectId. + */ +ObjectId dvmDbgGetClassObject(RefTypeId id) +{ + ClassObject* clazz = refTypeIdToClassObject(id); + return objectToObjectId((Object*) clazz); +} + +/* * Return the superclass of a class (will be NULL for java/lang/Object). */ RefTypeId dvmDbgGetSuperclass(RefTypeId id) diff --git a/vm/Debugger.h b/vm/Debugger.h index b41318cd7..189e2be92 100644 --- a/vm/Debugger.h +++ b/vm/Debugger.h @@ -159,6 +159,7 @@ void dvmDbgExit(int status); * Class, Object, Array */ const char* dvmDbgGetClassDescriptor(RefTypeId id); +ObjectId dvmDbgGetClassObject(RefTypeId id); RefTypeId dvmDbgGetSuperclass(RefTypeId id); ObjectId dvmDbgGetClassLoader(RefTypeId id); u4 dvmDbgGetAccessFlags(RefTypeId id); diff --git a/vm/jdwp/JdwpHandler.c b/vm/jdwp/JdwpHandler.c index 16d9a5d3a..1163fde3b 100644 --- a/vm/jdwp/JdwpHandler.c +++ b/vm/jdwp/JdwpHandler.c @@ -665,8 +665,6 @@ static JdwpError handleRT_Interfaces(JdwpState* state, const u1* buf, int dataLen, ExpandBuf* pReply) { RefTypeId refTypeId; - u4 numInterfaces; - int i; refTypeId = dvmReadRefTypeId(&buf); @@ -679,6 +677,25 @@ static JdwpError handleRT_Interfaces(JdwpState* state, } /* + * Return the class object corresponding to this type. + */ +static JdwpError handleRT_ClassObject(JdwpState* state, + const u1* buf, int dataLen, ExpandBuf* pReply) +{ + RefTypeId refTypeId; + ObjectId classObjId; + + refTypeId = dvmReadRefTypeId(&buf); + classObjId = dvmDbgGetClassObject(refTypeId); + + LOGV(" RefTypeId %llx -> ObjectId %llx\n", refTypeId, classObjId); + + expandBufAddObjectId(pReply, classObjId); + + return ERR_NONE; +} + +/* * Returns the value of the SourceDebugExtension attribute. * * JDB seems interested, but DEX files don't currently support this. @@ -1980,7 +1997,7 @@ static const JdwpHandlerMap gHandlerMap[] = { //2, 8, NestedTypes { 2, 9, handleRT_Status, "ReferenceType.Status" }, { 2, 10, handleRT_Interfaces, "ReferenceType.Interfaces" }, - //2, 11, ClassObject + { 2, 11, handleRT_ClassObject, "ReferenceType.ClassObject" }, { 2, 12, handleRT_SourceDebugExtension, "ReferenceType.SourceDebugExtension" }, { 2, 13, handleRT_SignatureWithGeneric, -- 2.11.0