summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-09-24 15:58:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-24 15:58:25 -0700
commit405e012681aa563b1d7b66c671c90ed2deb26e41 (patch)
tree6687aa617fea8213148702c68e4da9083122eb0c
parent3011b6617232d1ef7c1687d1db9e780fce978d30 (diff)
parentdeaa8ff1b10d38add4f7c276e7be2ffc19359a14 (diff)
downloadframeworks_base-405e012681aa563b1d7b66c671c90ed2deb26e41.zip
frameworks_base-405e012681aa563b1d7b66c671c90ed2deb26e41.tar.gz
frameworks_base-405e012681aa563b1d7b66c671c90ed2deb26e41.tar.bz2
am deaa8ff1: am a7ef18fc: Merge "Some debugging support." into gingerbread
Merge commit 'deaa8ff1b10d38add4f7c276e7be2ffc19359a14' * commit 'deaa8ff1b10d38add4f7c276e7be2ffc19359a14': Some debugging support.
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java108
-rw-r--r--cmds/dumpstate/dumpstate.c10
-rw-r--r--core/java/android/view/ViewRoot.java2
-rw-r--r--libs/binder/IPCThreadState.cpp14
-rw-r--r--services/java/com/android/server/WindowManagerService.java5
5 files changed, 125 insertions, 14 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 4dee350..b073004 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -35,9 +35,7 @@ import android.util.AndroidException;
import android.view.IWindowManager;
import java.io.BufferedReader;
-import java.io.DataInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -482,6 +480,8 @@ public class Am {
}
class MyActivityController extends IActivityController.Stub {
+ final String mGdbPort;
+
static final int STATE_NORMAL = 0;
static final int STATE_CRASHED = 1;
static final int STATE_EARLY_ANR = 2;
@@ -503,6 +503,14 @@ public class Am {
int mResult;
+ Process mGdbProcess;
+ Thread mGdbThread;
+ boolean mGotGdbPrint;
+
+ MyActivityController(String gdbPort) {
+ mGdbPort = gdbPort;
+ }
+
@Override
public boolean activityResuming(String pkg) throws RemoteException {
synchronized (this) {
@@ -532,7 +540,7 @@ public class Am {
System.out.println("stack:");
System.out.print(stackTrace);
System.out.println("#");
- int result = waitControllerLocked(STATE_CRASHED);
+ int result = waitControllerLocked(pid, STATE_CRASHED);
return result == RESULT_CRASH_KILL ? false : true;
}
}
@@ -545,7 +553,7 @@ public class Am {
System.out.println("processName: " + processName);
System.out.println("processPid: " + pid);
System.out.println("annotation: " + annotation);
- int result = waitControllerLocked(STATE_EARLY_ANR);
+ int result = waitControllerLocked(pid, STATE_EARLY_ANR);
if (result == RESULT_EARLY_ANR_KILL) return -1;
return 0;
}
@@ -561,14 +569,83 @@ public class Am {
System.out.println("processStats:");
System.out.print(processStats);
System.out.println("#");
- int result = waitControllerLocked(STATE_ANR);
+ int result = waitControllerLocked(pid, STATE_ANR);
if (result == RESULT_ANR_KILL) return -1;
if (result == RESULT_ANR_WAIT) return 1;
return 0;
}
}
- int waitControllerLocked(int state) {
+ void killGdbLocked() {
+ mGotGdbPrint = false;
+ if (mGdbProcess != null) {
+ System.out.println("Stopping gdbserver");
+ mGdbProcess.destroy();
+ mGdbProcess = null;
+ }
+ if (mGdbThread != null) {
+ mGdbThread.interrupt();
+ mGdbThread = null;
+ }
+ }
+
+ int waitControllerLocked(int pid, int state) {
+ if (mGdbPort != null) {
+ killGdbLocked();
+
+ try {
+ System.out.println("Starting gdbserver on port " + mGdbPort);
+ System.out.println("Do the following:");
+ System.out.println(" adb forward tcp:" + mGdbPort + " tcp:" + mGdbPort);
+ System.out.println(" gdbclient app_process :" + mGdbPort);
+
+ mGdbProcess = Runtime.getRuntime().exec(new String[] {
+ "gdbserver", ":" + mGdbPort, "--attach", Integer.toString(pid)
+ });
+ final InputStreamReader converter = new InputStreamReader(
+ mGdbProcess.getInputStream());
+ mGdbThread = new Thread() {
+ @Override
+ public void run() {
+ BufferedReader in = new BufferedReader(converter);
+ String line;
+ int count = 0;
+ while (true) {
+ synchronized (MyActivityController.this) {
+ if (mGdbThread == null) {
+ return;
+ }
+ if (count == 2) {
+ mGotGdbPrint = true;
+ MyActivityController.this.notifyAll();
+ }
+ }
+ try {
+ line = in.readLine();
+ if (line == null) {
+ return;
+ }
+ System.out.println("GDB: " + line);
+ count++;
+ } catch (IOException e) {
+ return;
+ }
+ }
+ }
+ };
+ mGdbThread.start();
+
+ // Stupid waiting for .5s. Doesn't matter if we end early.
+ try {
+ this.wait(500);
+ } catch (InterruptedException e) {
+ }
+
+ } catch (IOException e) {
+ System.err.println("Failure starting gdbserver: " + e);
+ killGdbLocked();
+ }
+ }
mState = state;
System.out.println("");
printMessageForState();
@@ -580,6 +657,8 @@ public class Am {
}
}
+ killGdbLocked();
+
return mResult;
}
@@ -681,7 +760,19 @@ public class Am {
}
private void runMonitor() throws Exception {
- MyActivityController controller = new MyActivityController();
+ String opt;
+ String gdbPort = null;
+ while ((opt=nextOption()) != null) {
+ if (opt.equals("--gdb")) {
+ gdbPort = nextArgRequired();
+ } else {
+ System.err.println("Error: Unknown option: " + opt);
+ showUsage();
+ return;
+ }
+ }
+
+ MyActivityController controller = new MyActivityController(gdbPort);
controller.run();
}
@@ -862,7 +953,8 @@ public class Am {
" dump heap: am dumpheap [flags] <PROCESS> <FILE>\n" +
" -n: dump native heap instead of managed heap\n" +
"\n" +
- " start monitoring: am monitor\n" +
+ " start monitoring: am monitor [--gdb <port>]\n" +
+ " --gdb: start gdbserv on the given port at crash/ANR\n" +
"\n" +
" <INTENT> specifications include these flags:\n" +
" [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index a09666e..67bd9f7 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -135,11 +135,11 @@ static void dumpstate() {
run_command("PROCESSES AND THREADS", 10, "ps", "-t", "-p", "-P", NULL);
run_command("LIBRANK", 10, "librank", NULL);
- dump_file("BINDER FAILED TRANSACTION LOG", "/proc/binder/failed_transaction_log");
- dump_file("BINDER TRANSACTION LOG", "/proc/binder/transaction_log");
- dump_file("BINDER TRANSACTIONS", "/proc/binder/transactions");
- dump_file("BINDER STATS", "/proc/binder/stats");
- run_command("BINDER PROCESS STATE", 10, "sh", "-c", "cat /proc/binder/proc/*");
+ dump_file("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
+ dump_file("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
+ dump_file("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
+ dump_file("BINDER STATS", "/sys/kernel/debug/binder/stats");
+ dump_file("BINDER STATE", "/sys/kernel/debug/binder/state");
run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL);
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 6917bca..f6a06ce 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2459,6 +2459,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
if (DBG) Log.d(TAG, "WindowLayout in layoutWindow:" + params);
}
mPendingConfiguration.seq = 0;
+ //Log.d(TAG, ">>>>>> CALLING relayout");
int relayoutResult = sWindowSession.relayout(
mWindow, params,
(int) (mView.mMeasuredWidth * appScale + 0.5f),
@@ -2466,6 +2467,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
viewVisibility, insetsPending, mWinFrame,
mPendingContentInsets, mPendingVisibleInsets,
mPendingConfiguration, mSurface);
+ //Log.d(TAG, "<<<<<< BACK FROM relayout");
if (restore) {
params.restore();
}
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index a3e117f..13c58f0 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -517,12 +517,26 @@ status_t IPCThreadState::transact(int32_t handle,
}
if ((flags & TF_ONE_WAY) == 0) {
+ #if 0
+ if (code == 4) { // relayout
+ LOGI(">>>>>> CALLING transaction 4");
+ } else {
+ LOGI(">>>>>> CALLING transaction %d", code);
+ }
+ #endif
if (reply) {
err = waitForResponse(reply);
} else {
Parcel fakeReply;
err = waitForResponse(&fakeReply);
}
+ #if 0
+ if (code == 4) { // relayout
+ LOGI("<<<<<< RETURNING transaction 4");
+ } else {
+ LOGI("<<<<<< RETURNING transaction %d", code);
+ }
+ #endif
IF_LOG_TRANSACTIONS() {
TextOutput::Bundle _b(alog);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 3e4f522..7100cc5 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -5687,9 +5687,12 @@ public class WindowManagerService extends IWindowManager.Stub
int requestedWidth, int requestedHeight, int viewFlags,
boolean insetsPending, Rect outFrame, Rect outContentInsets,
Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
- return relayoutWindow(this, window, attrs,
+ //Log.d(TAG, ">>>>>> ENTERED relayout from " + Binder.getCallingPid());
+ int res = relayoutWindow(this, window, attrs,
requestedWidth, requestedHeight, viewFlags, insetsPending,
outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface);
+ //Log.d(TAG, "<<<<<< EXITING relayout to " + Binder.getCallingPid());
+ return res;
}
public void setTransparentRegion(IWindow window, Region region) {