android studio debugging process zygote (unsuccessfully)

The only system processes are generally system_process debugging process, but also as a display, and I just want debugging process under zygote, the result toss for a long time (as with source code debugging). I am here is to modify the source code debugger active wait process when the zygote fork.
System version 4.4.4, modified files are:

/home/haidragon/Desktop/android/libcore/dalvik/src/main/java/dalvik/system/Zygote.java

android studio debugging process zygote (unsuccessfully)

......................................
    public static boolean systemInSafeMode = false;

    private Zygote() {}
//-----------------------haidragon-----------------------//
     private static volatile boolean mWaiting = false;
    public static boolean isDebuggerConnected() {
        return VMDebug.isDebuggerConnected();
    }
    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");
        //byte[] data = new byte[] { 0 };     // 0 == "waiting for debugger"
        //Chunk waitChunk = new Chunk(ChunkHandler.type("WAIT"), data, 0, 1);
        //DdmServer.sendChunk(waitChunk);

        mWaiting = true;
        while (!isDebuggerConnected()) {
            try { Thread.sleep(200); }
            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 < 1300) {
                System.out.println("waiting for debugger to settle...");
                try { Thread.sleep(200); }
                catch (InterruptedException ie) {}
            } else {
                System.out.println("debugger has settled (" + delta + ")");
                break;
            }
        }
    }
//-----------------------haidragon-----------------------//
    private static int i=0;
    private static void preFork() {
        i++;
        if(i>3){
       waitForDebugger();
    }
        Daemons.stop();
        waitUntilAllThreadsStopped();
    }
        ......................................
因为这里是不能用android.os.Debug.waitForDebugger()的,因为没有android.os.debug包。
但是我们可以去看这个实现。发现在4.4.4中它实现就是在 '/home/haidragon/Desktop/android/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java' 内。通过'/home/haidragon/Desktop/android/frameworks/base/core/java/android/os/Debug.java' 这个类调用的。

android studio debugging process zygote (unsuccessfully)
Other systems are not the same thing I saw more than 5 System dalvik / system directory of the runtime moves to the art inside.
Here we regenerate system.img brush into the phone. He creates three processes wait for the debugger connection.
android studio debugging process zygote (unsuccessfully)
The phone would have been stuck there.
android studio debugging process zygote (unsuccessfully)
Then I could not find zygote process, I look into the phone port of additional useless. To write here. Back or use gdb / gdbserver additional way to debug it. I toss this is the case as.

Guess you like

Origin blog.51cto.com/haidragon/2416769