summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jdwp/jdwp_handler.cc85
1 files changed, 51 insertions, 34 deletions
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index c7db5e9667..b30a6a218b 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -1563,7 +1563,7 @@ static const JdwpHandlerMap gHandlerMap[] = {
/* VirtualMachine command set (1) */
{ 1, 1, handleVM_Version, "VirtualMachine.Version" },
{ 1, 2, handleVM_ClassesBySignature, "VirtualMachine.ClassesBySignature" },
- //1, 3, VirtualMachine.AllClasses
+ { 1, 3, NULL, "VirtualMachine.AllClasses" },
{ 1, 4, handleVM_AllThreads, "VirtualMachine.AllThreads" },
{ 1, 5, handleVM_TopLevelThreadGroups, "VirtualMachine.TopLevelThreadGroups" },
{ 1, 6, handleVM_Dispose, "VirtualMachine.Dispose" },
@@ -1575,23 +1575,23 @@ static const JdwpHandlerMap gHandlerMap[] = {
{ 1, 12, handleVM_Capabilities, "VirtualMachine.Capabilities" },
{ 1, 13, handleVM_ClassPaths, "VirtualMachine.ClassPaths" },
{ 1, 14, HandleVM_DisposeObjects, "VirtualMachine.DisposeObjects" },
- //1, 15, HoldEvents
- //1, 16, ReleaseEvents
+ { 1, 15, NULL, "VirtualMachine.HoldEvents" },
+ { 1, 16, NULL, "VirtualMachine.ReleaseEvents" },
{ 1, 17, handleVM_CapabilitiesNew, "VirtualMachine.CapabilitiesNew" },
- //1, 18, RedefineClasses
- //1, 19, SetDefaultStratum
- { 1, 20, handleVM_AllClassesWithGeneric, "VirtualMachine.AllClassesWithGeneric"},
- //1, 21, InstanceCounts
+ { 1, 18, NULL, "VirtualMachine.RedefineClasses" },
+ { 1, 19, NULL, "VirtualMachine.SetDefaultStratum" },
+ { 1, 20, handleVM_AllClassesWithGeneric, "VirtualMachine.AllClassesWithGeneric" },
+ { 1, 21, NULL, "VirtualMachine.InstanceCounts" },
/* ReferenceType command set (2) */
{ 2, 1, handleRT_Signature, "ReferenceType.Signature" },
{ 2, 2, handleRT_ClassLoader, "ReferenceType.ClassLoader" },
{ 2, 3, handleRT_Modifiers, "ReferenceType.Modifiers" },
- //2, 4, Fields
- //2, 5, Methods
+ { 2, 4, NULL, "ReferenceType.Fields" },
+ { 2, 5, NULL, "ReferenceType.Methods" },
{ 2, 6, handleRT_GetValues, "ReferenceType.GetValues" },
{ 2, 7, handleRT_SourceFile, "ReferenceType.SourceFile" },
- //2, 8, NestedTypes
+ { 2, 8, NULL, "ReferenceType.NestedTypes" },
{ 2, 9, handleRT_Status, "ReferenceType.Status" },
{ 2, 10, handleRT_Interfaces, "ReferenceType.Interfaces" },
{ 2, 11, handleRT_ClassObject, "ReferenceType.ClassObject" },
@@ -1599,9 +1599,9 @@ static const JdwpHandlerMap gHandlerMap[] = {
{ 2, 13, handleRT_SignatureWithGeneric, "ReferenceType.SignatureWithGeneric" },
{ 2, 14, handleRT_FieldsWithGeneric, "ReferenceType.FieldsWithGeneric" },
{ 2, 15, handleRT_MethodsWithGeneric, "ReferenceType.MethodsWithGeneric" },
- //2, 16, Instances
- //2, 17, ClassFileVersion
- //2, 18, ConstantPool
+ { 2, 16, NULL, "ReferenceType.Instances" },
+ { 2, 17, NULL, "ReferenceType.ClassFileVersion" },
+ { 2, 18, NULL, "ReferenceType.ConstantPool" },
/* ClassType command set (3) */
{ 3, 1, handleCT_Superclass, "ClassType.Superclass" },
@@ -1616,9 +1616,9 @@ static const JdwpHandlerMap gHandlerMap[] = {
/* Method command set (6) */
{ 6, 1, handleM_LineTable, "Method.LineTable" },
- //6, 2, VariableTable
- //6, 3, Bytecodes
- //6, 4, IsObsolete
+ { 6, 2, NULL, "Method.VariableTable" },
+ { 6, 3, NULL, "Method.Bytecodes" },
+ { 6, 4, NULL, "Method.IsObsolete" },
{ 6, 5, handleM_VariableTableWithGeneric, "Method.VariableTableWithGeneric" },
/* Field command set (8) */
@@ -1627,13 +1627,13 @@ static const JdwpHandlerMap gHandlerMap[] = {
{ 9, 1, handleOR_ReferenceType, "ObjectReference.ReferenceType" },
{ 9, 2, handleOR_GetValues, "ObjectReference.GetValues" },
{ 9, 3, handleOR_SetValues, "ObjectReference.SetValues" },
- //9, 4, (not defined)
- //9, 5, MonitorInfo
+ { 9, 4, NULL, "ObjectReference.UNUSED" },
+ { 9, 5, NULL, "ObjectReference.MonitorInfo" },
{ 9, 6, handleOR_InvokeMethod, "ObjectReference.InvokeMethod" },
{ 9, 7, handleOR_DisableCollection, "ObjectReference.DisableCollection" },
{ 9, 8, handleOR_EnableCollection, "ObjectReference.EnableCollection" },
{ 9, 9, handleOR_IsCollected, "ObjectReference.IsCollected" },
- //9, 10, ReferringObjects
+ { 9, 10, NULL, "ObjectReference.ReferringObjects" },
/* StringReference command set (10) */
{ 10, 1, handleSR_Value, "StringReference.Value" },
@@ -1646,13 +1646,13 @@ static const JdwpHandlerMap gHandlerMap[] = {
{ 11, 5, handleTR_ThreadGroup, "ThreadReference.ThreadGroup" },
{ 11, 6, handleTR_Frames, "ThreadReference.Frames" },
{ 11, 7, handleTR_FrameCount, "ThreadReference.FrameCount" },
- //11, 8, OwnedMonitors
+ { 11, 8, NULL, "ThreadReference.OwnedMonitors" },
{ 11, 9, handleTR_CurrentContendedMonitor, "ThreadReference.CurrentContendedMonitor" },
- //11, 10, Stop
- //11, 11, Interrupt
+ { 11, 10, NULL, "ThreadReference.Stop" },
+ { 11, 11, NULL,"ThreadReference.Interrupt" },
{ 11, 12, handleTR_SuspendCount, "ThreadReference.SuspendCount" },
- //11, 13, OwnedMonitorsStackDepthInfo
- //11, 14, ForceEarlyReturn
+ { 11, 13, NULL, "ThreadReference.OwnedMonitorsStackDepthInfo" },
+ { 11, 14, NULL, "ThreadReference.ForceEarlyReturn" },
/* ThreadGroupReference command set (12) */
{ 12, 1, handleTGR_Name, "ThreadGroupReference.Name" },
@@ -1670,23 +1670,40 @@ static const JdwpHandlerMap gHandlerMap[] = {
/* EventRequest command set (15) */
{ 15, 1, handleER_Set, "EventRequest.Set" },
{ 15, 2, handleER_Clear, "EventRequest.Clear" },
- //15, 3, ClearAllBreakpoints
+ { 15, 3, NULL, "EventRequest.ClearAllBreakpoints" },
/* StackFrame command set (16) */
{ 16, 1, handleSF_GetValues, "StackFrame.GetValues" },
{ 16, 2, handleSF_SetValues, "StackFrame.SetValues" },
{ 16, 3, handleSF_ThisObject, "StackFrame.ThisObject" },
- //16, 4, PopFrames
+ { 16, 4, NULL, "StackFrame.PopFrames" },
/* ClassObjectReference command set (17) */
{ 17, 1, handleCOR_ReflectedType,"ClassObjectReference.ReflectedType" },
/* Event command set (64) */
- //64, 100, Composite <-- sent from VM to debugger, never received by VM
+ { 64, 100, NULL, "Event.Composite" }, // sent from VM to debugger, never received by VM
{ 199, 1, handleDDM_Chunk, "DDM.Chunk" },
};
+static const char* GetCommandName(size_t cmdSet, size_t cmd) {
+ for (int i = 0; i < (int) arraysize(gHandlerMap); i++) {
+ if (gHandlerMap[i].cmdSet == cmdSet && gHandlerMap[i].cmd == cmd) {
+ return gHandlerMap[i].descr;
+ }
+ }
+ return "?UNKNOWN?";
+}
+
+static std::string DescribeCommand(const JdwpReqHeader* pHeader, int dataLen) {
+ std::string result;
+ result += "REQ: ";
+ result += GetCommandName(pHeader->cmdSet, pHeader->cmd);
+ result += StringPrintf(" (dataLen=%d id=0x%06x)", dataLen, pHeader->id);
+ return result;
+}
+
/*
* Process a request from the debugger.
*
@@ -1694,7 +1711,6 @@ static const JdwpHandlerMap gHandlerMap[] = {
*/
void JdwpState::ProcessRequest(const JdwpReqHeader* pHeader, const uint8_t* buf, int dataLen, ExpandBuf* pReply) {
JdwpError result = ERR_NONE;
- int i, respLen;
if (pHeader->cmdSet != kJDWPDdmCmdSet) {
/*
@@ -1732,19 +1748,20 @@ void JdwpState::ProcessRequest(const JdwpReqHeader* pHeader, const uint8_t* buf,
expandBufAddSpace(pReply, kJDWPHeaderLen);
- for (i = 0; i < (int) arraysize(gHandlerMap); i++) {
- if (gHandlerMap[i].cmdSet == pHeader->cmdSet && gHandlerMap[i].cmd == pHeader->cmd) {
- LOG(VERBOSE) << StringPrintf("REQ: %s (cmd=%d/%d dataLen=%d id=0x%06x)", gHandlerMap[i].descr, pHeader->cmdSet, pHeader->cmd, dataLen, pHeader->id);
+ size_t i;
+ for (i = 0; i < arraysize(gHandlerMap); i++) {
+ if (gHandlerMap[i].cmdSet == pHeader->cmdSet && gHandlerMap[i].cmd == pHeader->cmd && gHandlerMap[i].func != NULL) {
+ LOG(VERBOSE) << DescribeCommand(pHeader, dataLen);
result = (*gHandlerMap[i].func)(this, buf, dataLen, pReply);
break;
}
}
if (i == arraysize(gHandlerMap)) {
- LOG(ERROR) << StringPrintf("REQ: UNSUPPORTED (cmd=%d/%d dataLen=%d id=0x%06x)", pHeader->cmdSet, pHeader->cmd, dataLen, pHeader->id);
+ LOG(ERROR) << DescribeCommand(pHeader, dataLen);
if (dataLen > 0) {
HexDump(buf, dataLen);
}
- LOG(FATAL) << "command not implemented"; // make it *really* obvious
+ LOG(ERROR) << "command not implemented";
result = ERR_NOT_IMPLEMENTED;
}
@@ -1763,7 +1780,7 @@ void JdwpState::ProcessRequest(const JdwpReqHeader* pHeader, const uint8_t* buf,
Set4BE(replyBuf + 0, kJDWPHeaderLen);
}
- respLen = expandBufGetLength(pReply) - kJDWPHeaderLen;
+ size_t respLen = expandBufGetLength(pReply) - kJDWPHeaderLen;
if (false) {
LOG(INFO) << "reply: dataLen=" << respLen << " err=" << result << (result != ERR_NONE ? " **FAILED**" : "");
if (respLen > 0) {