티스토리 뷰

728x90

ADB 명령어로 현재 디바이스에서 실행 중인 모든 프로세스를 확인하는 방법에 대해서 알아보겠습니다.

 

Android는 리눅스 기반에서 동작하는 OS이기 때문에, shell 명령어를 사용하여 프로세스 리스트를 확인할 수 있습니다.

 

실행 중인 프로세스 리스트

아래와 같이 "adb shell ps -ef" 명령어는 디바이스에서 동작하고 있는 시스템뿐만 아니라 앱 프로세스를 모두 출력합니다.

$ adb shell ps -ef
UID            PID  PPID C STIME TTY          TIME CMD
root             1     0 17 10:18:23 ?    00:00:03 init second_stage
root             2     0 0 10:18:23 ?     00:00:00 [kthreadd]
root             3     2 0 10:18:23 ?     00:00:00 [rcu_gp]
root             4     2 0 10:18:23 ?     00:00:00 [slub_flushwq]
root             5     2 0 10:18:23 ?     00:00:00 [netns]
....
u0_a158       3605   399 1 10:19:16 ?     00:00:00 com.google.android.rkpdapp
u0_a104       3646   399 1 10:19:17 ?     00:00:00 com.google.android.projection.gearhead:shared
u0_a105       3698   399 1 10:19:18 ?     00:00:00 com.google.android.partnersetup
u0_a72        3736   399 0 10:19:19 ?     00:00:00 com.google.android.packageinstaller
u0_a98        3757   399 0 10:19:19 ?     00:00:00 com.google.android.onetimeinitializer
u0_a118       3876   399 4 10:19:20 ?     00:00:00 com.google.android.contacts
u0_a101       3956   399 0 10:19:21 ?     00:00:00 com.google.android.configupdater
u0_a133       3995   399 2 10:19:21 ?     00:00:00 com.android.remoteprovisioner

 

grep 명령어나 결과를 에디터로 열어, 원하는 앱의 프로세스 정보(PID 등)을 확인할 수 있습니다.

 

프로세스의 쓰레드 리스트

"adb shell ps -T <PID>" 명령어는 어떤 프로세스에서 동작하는 모든 스레드 리스트를 확인할 수 있습니다. 인자로 PID를 전달해야 합니다.

 

아래는 pid 3736(com.google.android.packageinstaller)의 모든 스레드를 출력합니다.

$ adb shell ps -T 3736
USER           PID   TID  PPID     VSZ    RSS WCHAN            ADDR S CMD            
u0_a72        3736  3736   399 13721328 33688 0                   0 S ackageinstaller
u0_a72        3736  3741   399 13721328 33688 0                   0 S Signal Catcher
u0_a72        3736  3745   399 13721328 33688 0                   0 S perfetto_hprof_
u0_a72        3736  3746   399 13721328 33688 0                   0 S Jit thread pool
u0_a72        3736  3747   399 13721328 33688 0                   0 S HeapTaskDaemon
u0_a72        3736  3748   399 13721328 33688 0                   0 S ReferenceQueueD
u0_a72        3736  3750   399 13721328 33688 0                   0 S FinalizerDaemon
u0_a72        3736  3751   399 13721328 33688 0                   0 S FinalizerWatchd
u0_a72        3736  3752   399 13721328 33688 0                   0 S binder:3736_1
u0_a72        3736  3754   399 13721328 33688 0                   0 S binder:3736_2
u0_a72        3736  3776   399 13721328 33688 0                   0 S Profile Saver
728x90