use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by AOSPA.
the class DdmHandleHello method sendWAIT.
/**
* Send up a WAIT chunk. The only currently defined value for "reason"
* is zero, which means "waiting for a debugger".
*/
public static void sendWAIT(int reason) {
byte[] data = new byte[] { (byte) reason };
Chunk waitChunk = new Chunk(CHUNK_WAIT, data, 0, 1);
DdmServer.sendChunk(waitChunk);
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by AOSPA.
the class DdmHandleViewDebug method captureLayers.
/** Returns a buffer with region details & bitmap of every single view. */
private Chunk captureLayers(View rootView) {
ByteArrayOutputStream b = new ByteArrayOutputStream(1024);
DataOutputStream dos = new DataOutputStream(b);
try {
ViewDebug.captureLayers(rootView, dos);
} catch (IOException e) {
return createFailChunk(1, "Unexpected error while obtaining view hierarchy: " + e.getMessage());
} finally {
try {
dos.close();
} catch (IOException e) {
// ignore
}
}
byte[] data = b.toByteArray();
return new Chunk(CHUNK_VURT, data, 0, data.length);
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by AOSPA.
the class Debug method waitForDebugger.
/**
* Wait until a debugger attaches. As soon as the debugger attaches,
* this returns, so you will need to place a breakpoint after the
* waitForDebugger() call if you want to start tracing immediately.
*/
public static void waitForDebugger() {
if (!VMDebug.isDebuggingEnabled()) {
//System.out.println("debugging not enabled, not waiting");
return;
}
if (isDebuggerConnected())
return;
// if DDMS is listening, inform them of our plight
System.out.println("Sending WAIT chunk");
// 0 == "waiting for debugger"
byte[] data = new byte[] { 0 };
Chunk waitChunk = new Chunk(ChunkHandler.type("WAIT"), data, 0, 1);
DdmServer.sendChunk(waitChunk);
mWaiting = true;
while (!isDebuggerConnected()) {
try {
Thread.sleep(SPIN_DELAY);
} catch (InterruptedException ie) {
}
}
mWaiting = false;
System.out.println("Debugger has connected");
/*
* There is no "ready to go" signal from the debugger, and we're
* not allowed to suspend ourselves -- the debugger expects us to
* be running happily, and gets confused if we aren't. We need to
* allow the debugger a chance to set breakpoints before we start
* running again.
*
* Sit and spin until the debugger has been idle for a short while.
*/
while (true) {
long delta = VMDebug.lastDebuggerActivity();
if (delta < 0) {
System.out.println("debugger detached?");
break;
}
if (delta < MIN_DEBUGGER_IDLE) {
System.out.println("waiting for debugger to settle...");
try {
Thread.sleep(SPIN_DELAY);
} catch (InterruptedException ie) {
}
} else {
System.out.println("debugger has settled (" + delta + ")");
break;
}
}
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by crdroidandroid.
the class Debug method waitForDebugger.
/**
* Wait until a debugger attaches. As soon as the debugger attaches,
* this returns, so you will need to place a breakpoint after the
* waitForDebugger() call if you want to start tracing immediately.
*/
public static void waitForDebugger() {
if (!VMDebug.isDebuggingEnabled()) {
//System.out.println("debugging not enabled, not waiting");
return;
}
if (isDebuggerConnected())
return;
// if DDMS is listening, inform them of our plight
System.out.println("Sending WAIT chunk");
// 0 == "waiting for debugger"
byte[] data = new byte[] { 0 };
Chunk waitChunk = new Chunk(ChunkHandler.type("WAIT"), data, 0, 1);
DdmServer.sendChunk(waitChunk);
mWaiting = true;
while (!isDebuggerConnected()) {
try {
Thread.sleep(SPIN_DELAY);
} catch (InterruptedException ie) {
}
}
mWaiting = false;
System.out.println("Debugger has connected");
/*
* There is no "ready to go" signal from the debugger, and we're
* not allowed to suspend ourselves -- the debugger expects us to
* be running happily, and gets confused if we aren't. We need to
* allow the debugger a chance to set breakpoints before we start
* running again.
*
* Sit and spin until the debugger has been idle for a short while.
*/
while (true) {
long delta = VMDebug.lastDebuggerActivity();
if (delta < 0) {
System.out.println("debugger detached?");
break;
}
if (delta < MIN_DEBUGGER_IDLE) {
System.out.println("waiting for debugger to settle...");
try {
Thread.sleep(SPIN_DELAY);
} catch (InterruptedException ie) {
}
} else {
System.out.println("debugger has settled (" + delta + ")");
break;
}
}
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by crdroidandroid.
the class DdmHandleHeap method handleHPDU.
/*
* Handle a "HeaP DUmp" request.
*
* This currently just returns a result code. We could pull up
* the entire contents of the file and return them, but hprof dump
* files can be a few megabytes.
*/
private Chunk handleHPDU(Chunk request) {
ByteBuffer in = wrapChunk(request);
byte result;
/* get the filename for the output file */
int len = in.getInt();
String fileName = getString(in, len);
if (false)
Log.d("ddm-heap", "Heap dump: file='" + fileName + "'");
try {
Debug.dumpHprofData(fileName);
result = 0;
} catch (UnsupportedOperationException uoe) {
Log.w("ddm-heap", "hprof dumps not supported in this VM");
result = -1;
} catch (IOException ioe) {
result = -1;
} catch (RuntimeException re) {
result = -1;
}
/* create a non-empty reply so the handler fires on completion */
byte[] reply = { result };
return new Chunk(CHUNK_HPDU, reply, 0, reply.length);
}
Aggregations