Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0332e5c authored by Theodore Dubois's avatar Theodore Dubois
Browse files

Add flag to have system server wait for a debugger to attach

Sometimes you want to step through something early in system server
startup. For an app, you can run am set-debug-app, but nothing similar
exists yet for system server. This adds a system property that behaves
similarly.

The check for VMDebug.isDebuggingEnabled should ensure this doesn't
trigger in user builds where system server is not debuggable.

Test: boot normally
Test: boot, set property, stop && start, system server waits for debugger
Flag: EXEMPT DEBUG
Change-Id: Ida56935cf9069360a16e9053e573fccbfd85e58b
parent 7cc648a9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -296,6 +296,7 @@ import com.android.server.wm.ActivityTaskManagerService;
import com.android.server.wm.WindowManagerGlobalLock;
import com.android.server.wm.WindowManagerService;

import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;

import java.io.File;
@@ -776,6 +777,12 @@ public final class SystemServer implements Dumpable {
    }

    private void run() {
        if (VMDebug.isDebuggingEnabled()
                && SystemProperties.getBoolean("debug.system_server.jdwp_wait", false)) {
            Slog.i(TAG, "System server is waiting for debugger before starting...");
            Debug.waitForDebugger();
        }

        TimingsTraceAndSlog t = new TimingsTraceAndSlog();
        try {
            t.traceBegin("InitBeforeStartServices");