Fix some DDMS stuff I'd broken, and fix HexDump's double-spacing.
Change-Id: I6583458a818406197744cc640b0993f73cfd5384
diff --git a/src/debugger.cc b/src/debugger.cc
index 51e43c1..6d3f80c 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -851,11 +851,11 @@
size_t char_count = (name.get() != NULL) ? name->GetLength() : 0;
const jchar* chars = name->GetCharArray()->GetData();
- size_t byte_count = char_count*2 + sizeof(uint32_t)*2;
- std::vector<uint8_t> bytes(byte_count);
+ std::vector<uint8_t> bytes;
JDWP::Append4BE(bytes, t->GetThinLockId());
JDWP::AppendUtf16BE(bytes, chars, char_count);
- Dbg::DdmSendChunk(type, bytes.size(), &bytes[0]);
+ CHECK_EQ(bytes.size(), char_count*2 + sizeof(uint32_t)*2);
+ Dbg::DdmSendChunk(type, bytes);
}
}
@@ -899,6 +899,10 @@
Dbg::DdmSendChunkV(type, vec, 1);
}
+void Dbg::DdmSendChunk(uint32_t type, const std::vector<uint8_t>& bytes) {
+ DdmSendChunk(type, bytes.size(), &bytes[0]);
+}
+
void Dbg::DdmSendChunkV(uint32_t type, const struct iovec* iov, int iovcnt) {
if (gJdwpState == NULL) {
LOG(VERBOSE) << "Debugger thread not active, ignoring DDM send: " << type;
@@ -969,7 +973,7 @@
* [u4]: current number of objects allocated
*/
uint8_t heap_count = 1;
- std::vector<uint8_t> bytes(4 + (heap_count * (4 + 8 + 1 + 4 + 4 + 4 + 4)));
+ std::vector<uint8_t> bytes;
JDWP::Append4BE(bytes, heap_count);
JDWP::Append4BE(bytes, 1); // Heap id (bogus; we only have one heap).
JDWP::Append8BE(bytes, MilliTime());
@@ -978,7 +982,8 @@
JDWP::Append4BE(bytes, Heap::GetTotalMemory()); // Current heap size in bytes.
JDWP::Append4BE(bytes, Heap::GetBytesAllocated());
JDWP::Append4BE(bytes, Heap::GetObjectsAllocated());
- Dbg::DdmSendChunk(CHUNK_TYPE("HPIF"), bytes.size(), &bytes[0]);
+ CHECK_EQ(bytes.size(), 4U + (heap_count * (4 + 8 + 1 + 4 + 4 + 4 + 4)));
+ Dbg::DdmSendChunk(CHUNK_TYPE("HPIF"), bytes);
}
enum HpsgSolidity {