diff options
author | Elliott Hughes <enh@google.com> | 2012-02-21 18:16:06 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-02-22 12:17:04 -0800 |
commit | 972a47bf0c180dee7e4c697b74dd31daaf58e008 (patch) | |
tree | 0ff325949e3aff2a3eefef05dbaf74595cf079b1 | |
parent | a656a0f6fbcf2ba3f15cae54a773b9c636dd32c1 (diff) | |
download | art-972a47bf0c180dee7e4c697b74dd31daaf58e008.zip art-972a47bf0c180dee7e4c697b74dd31daaf58e008.tar.gz art-972a47bf0c180dee7e4c697b74dd31daaf58e008.tar.bz2 |
Rename JdwpLocation.idx to the more intention-revealing dex_pc.
Change-Id: Ie111b1e715b701da528b0e6de87560b1eea793d1
-rw-r--r-- | src/debugger.cc | 8 | ||||
-rw-r--r-- | src/jdwp/jdwp.h | 2 | ||||
-rw-r--r-- | src/jdwp/jdwp_event.cc | 2 | ||||
-rw-r--r-- | src/jdwp/jdwp_handler.cc | 48 | ||||
-rw-r--r-- | src/jdwp/jdwp_main.cc | 4 |
5 files changed, 31 insertions, 33 deletions
diff --git a/src/debugger.cc b/src/debugger.cc index d2c05b7..530ffba 100644 --- a/src/debugger.cc +++ b/src/debugger.cc @@ -938,7 +938,7 @@ static void SetLocation(JDWP::JdwpLocation& location, Method* m, uintptr_t nativ location.typeTag = c->IsInterface() ? JDWP::TT_INTERFACE : JDWP::TT_CLASS; location.classId = gRegistry->Add(c); location.methodId = ToMethodId(m); - location.idx = m->IsNative() ? -1 : m->ToDexPC(native_pc); + location.dex_pc = m->IsNative() ? -1 : m->ToDexPC(native_pc); } } @@ -1682,7 +1682,7 @@ void Dbg::PostLocationEvent(const Method* m, int dex_pc, Object* this_object, in location.typeTag = c->IsInterface() ? JDWP::TT_INTERFACE : JDWP::TT_CLASS; location.classId = gRegistry->Add(c); location.methodId = ToMethodId(m); - location.idx = m->IsNative() ? -1 : dex_pc; + location.dex_pc = m->IsNative() ? -1 : dex_pc; // Note we use "NoReg" so we don't keep track of references that are // never actually sent to the debugger. 'this_id' is only used to @@ -1848,7 +1848,7 @@ void Dbg::UpdateDebugger(int32_t dex_pc, Thread* self, Method** sp) { void Dbg::WatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(gBreakpointsLock); Method* m = FromMethodId(location->methodId); - gBreakpoints.push_back(Breakpoint(m, location->idx)); + gBreakpoints.push_back(Breakpoint(m, location->dex_pc)); VLOG(jdwp) << "Set breakpoint #" << (gBreakpoints.size() - 1) << ": " << gBreakpoints[gBreakpoints.size() - 1]; } @@ -1856,7 +1856,7 @@ void Dbg::UnwatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(gBreakpointsLock); Method* m = FromMethodId(location->methodId); for (size_t i = 0; i < gBreakpoints.size(); ++i) { - if (gBreakpoints[i].method == m && gBreakpoints[i].dex_pc == location->idx) { + if (gBreakpoints[i].method == m && gBreakpoints[i].dex_pc == location->dex_pc) { VLOG(jdwp) << "Removed breakpoint #" << i << ": " << gBreakpoints[i]; gBreakpoints.erase(gBreakpoints.begin() + i); return; diff --git a/src/jdwp/jdwp.h b/src/jdwp/jdwp.h index a3f4b69..d297f6f 100644 --- a/src/jdwp/jdwp.h +++ b/src/jdwp/jdwp.h @@ -76,7 +76,7 @@ struct JdwpLocation { JdwpTypeTag typeTag; RefTypeId classId; MethodId methodId; - uint64_t idx; // A Dex PC. + uint64_t dex_pc; }; std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs); bool operator==(const JdwpLocation& lhs, const JdwpLocation& rhs); diff --git a/src/jdwp/jdwp_event.cc b/src/jdwp/jdwp_event.cc index ddcc217..5827102 100644 --- a/src/jdwp/jdwp_event.cc +++ b/src/jdwp/jdwp_event.cc @@ -766,7 +766,7 @@ bool JdwpState::PostLocationEvent(const JdwpLocation* pLoc, ObjectId thisPtr, in if (match_count != 0) { VLOG(jdwp) << "EVENT: " << matchList[0]->eventKind << "(" << match_count << " total) " << basket.className << "." << Dbg::GetMethodName(pLoc->classId, pLoc->methodId) - << " thread=" << (void*) basket.threadId << " code=" << (void*) pLoc->idx << ")"; + << " thread=" << (void*) basket.threadId << " code=" << (void*) pLoc->dex_pc << ")"; suspendPolicy = scanSuspendPolicy(matchList, match_count); VLOG(jdwp) << " suspendPolicy=" << suspendPolicy; diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc index d6b9bb3..d0e438b 100644 --- a/src/jdwp/jdwp_handler.cc +++ b/src/jdwp/jdwp_handler.cc @@ -52,7 +52,7 @@ static void jdwpReadLocation(const uint8_t** pBuf, JdwpLocation* pLoc) { pLoc->typeTag = ReadTypeTag(pBuf); pLoc->classId = ReadObjectId(pBuf); pLoc->methodId = ReadMethodId(pBuf); - pLoc->idx = Read8BE(pBuf); + pLoc->dex_pc = Read8BE(pBuf); } /* @@ -62,7 +62,7 @@ void AddLocation(ExpandBuf* pReply, const JdwpLocation* pLoc) { expandBufAdd1(pReply, pLoc->typeTag); expandBufAddObjectId(pReply, pLoc->classId); expandBufAddMethodId(pReply, pLoc->methodId); - expandBufAdd8BE(pReply, pLoc->idx); + expandBufAdd8BE(pReply, pLoc->dex_pc); } /* @@ -1201,12 +1201,10 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, * Read modifiers. Ordering may be significant (see explanation of Count * mods in JDWP doc). */ - for (uint32_t idx = 0; idx < modifierCount; idx++) { - JdwpModKind modKind = static_cast<JdwpModKind>(Read1(&buf)); - - pEvent->mods[idx].modKind = modKind; - - switch (modKind) { + for (uint32_t i = 0; i < modifierCount; ++i) { + JdwpEventMod& mod = pEvent->mods[i]; + mod.modKind = static_cast<JdwpModKind>(Read1(&buf)); + switch (mod.modKind) { case MK_COUNT: /* report once, when "--count" reaches 0 */ { uint32_t count = Read4BE(&buf); @@ -1214,28 +1212,28 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, if (count == 0) { return ERR_INVALID_COUNT; } - pEvent->mods[idx].count.count = count; + mod.count.count = count; } break; case MK_CONDITIONAL: /* conditional on expression) */ { uint32_t exprId = Read4BE(&buf); VLOG(jdwp) << " Conditional: " << exprId; - pEvent->mods[idx].conditional.exprId = exprId; + mod.conditional.exprId = exprId; } break; case MK_THREAD_ONLY: /* only report events in specified thread */ { ObjectId threadId = ReadObjectId(&buf); VLOG(jdwp) << StringPrintf(" ThreadOnly: %llx", threadId); - pEvent->mods[idx].threadOnly.threadId = threadId; + mod.threadOnly.threadId = threadId; } break; case MK_CLASS_ONLY: /* for ClassPrepare, MethodEntry */ { RefTypeId clazzId = ReadRefTypeId(&buf); VLOG(jdwp) << StringPrintf(" ClassOnly: %llx (%s)", clazzId, Dbg::GetClassName(clazzId).c_str()); - pEvent->mods[idx].classOnly.refTypeId = clazzId; + mod.classOnly.refTypeId = clazzId; } break; case MK_CLASS_MATCH: /* restrict events to matching classes */ @@ -1244,7 +1242,7 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, std::string pattern(ReadNewUtf8String(&buf)); std::replace(pattern.begin(), pattern.end(), '.', '/'); VLOG(jdwp) << " ClassMatch: '" << pattern << "'"; - pEvent->mods[idx].classMatch.classPattern = strdup(pattern.c_str()); + mod.classMatch.classPattern = strdup(pattern.c_str()); } break; case MK_CLASS_EXCLUDE: /* restrict events to non-matching classes */ @@ -1253,7 +1251,7 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, std::string pattern(ReadNewUtf8String(&buf)); std::replace(pattern.begin(), pattern.end(), '.', '/'); VLOG(jdwp) << " ClassExclude: '" << pattern << "'"; - pEvent->mods[idx].classExclude.classPattern = strdup(pattern.c_str()); + mod.classExclude.classPattern = strdup(pattern.c_str()); } break; case MK_LOCATION_ONLY: /* restrict certain events based on loc */ @@ -1261,7 +1259,7 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, JdwpLocation loc; jdwpReadLocation(&buf, &loc); VLOG(jdwp) << " LocationOnly: " << loc; - pEvent->mods[idx].locationOnly.loc = loc; + mod.locationOnly.loc = loc; } break; case MK_EXCEPTION_ONLY: /* modifies EK_EXCEPTION events */ @@ -1275,9 +1273,9 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, VLOG(jdwp) << StringPrintf(" ExceptionOnly: type=%llx(%s) caught=%d uncaught=%d", exceptionOrNull, (exceptionOrNull == 0) ? "null" : Dbg::GetClassName(exceptionOrNull).c_str(), caught, uncaught); - pEvent->mods[idx].exceptionOnly.refTypeId = exceptionOrNull; - pEvent->mods[idx].exceptionOnly.caught = caught; - pEvent->mods[idx].exceptionOnly.uncaught = uncaught; + mod.exceptionOnly.refTypeId = exceptionOrNull; + mod.exceptionOnly.caught = caught; + mod.exceptionOnly.uncaught = uncaught; } break; case MK_FIELD_ONLY: /* for field access/mod events */ @@ -1285,8 +1283,8 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, RefTypeId declaring = ReadRefTypeId(&buf); FieldId fieldId = ReadFieldId(&buf); VLOG(jdwp) << StringPrintf(" FieldOnly: %llx %x", declaring, fieldId); - pEvent->mods[idx].fieldOnly.refTypeId = declaring; - pEvent->mods[idx].fieldOnly.fieldId = fieldId; + mod.fieldOnly.refTypeId = declaring; + mod.fieldOnly.fieldId = fieldId; } break; case MK_STEP: /* for use with EK_SINGLE_STEP */ @@ -1300,20 +1298,20 @@ static JdwpError handleER_Set(JdwpState* state, const uint8_t* buf, int dataLen, VLOG(jdwp) << StringPrintf(" Step: thread=%llx", threadId) << " size=" << JdwpStepSize(size) << " depth=" << JdwpStepDepth(depth); - pEvent->mods[idx].step.threadId = threadId; - pEvent->mods[idx].step.size = size; - pEvent->mods[idx].step.depth = depth; + mod.step.threadId = threadId; + mod.step.size = size; + mod.step.depth = depth; } break; case MK_INSTANCE_ONLY: /* report events related to a specific obj */ { ObjectId instance = ReadObjectId(&buf); VLOG(jdwp) << StringPrintf(" InstanceOnly: %llx", instance); - pEvent->mods[idx].instanceOnly.objectId = instance; + mod.instanceOnly.objectId = instance; } break; default: - LOG(WARNING) << "GLITCH: unsupported modKind=" << modKind; + LOG(WARNING) << "GLITCH: unsupported modKind=" << mod.modKind; break; } } diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc index 0fad510..74d392b 100644 --- a/src/jdwp/jdwp_main.cc +++ b/src/jdwp/jdwp_main.cc @@ -453,12 +453,12 @@ std::ostream& operator<<(std::ostream& os, const JdwpTransportType& value) { std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) { os << "JdwpLocation[" << Dbg::GetClassName(rhs.classId) << "." << Dbg::GetMethodName(rhs.classId, rhs.methodId) - << "@" << rhs.idx << " " << rhs.typeTag << "]"; + << "@" << rhs.dex_pc << " " << rhs.typeTag << "]"; return os; } bool operator==(const JdwpLocation& lhs, const JdwpLocation& rhs) { - return lhs.idx == rhs.idx && lhs.methodId == rhs.methodId && + return lhs.dex_pc == rhs.dex_pc && lhs.methodId == rhs.methodId && lhs.classId == rhs.classId && lhs.typeTag == rhs.typeTag; } |