커널 패닉 디버깅할 때 crash-utility를 아주 많이 쓰죠.
수 많은 명령어 중 ps를 소개하려고 합니다.
ps -p
프로세스 전체의 부모와 자식 프로세스 정보를 보여줘요.
crash64> ps -p
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 0 TASK: ffffffc0f865f300 CPU: 1 COMMAND: "swapper/1"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 0 TASK: ffffffc0f86b8000 CPU: 2 COMMAND: "swapper/2"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 0 TASK: ffffffc0f86b8b80 CPU: 3 COMMAND: "swapper/3"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 1 TASK: ffffffc0f8658000 CPU: 1 COMMAND: "init"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 2 TASK: ffffffc0f8658b80 CPU: 2 COMMAND: "kthreadd"
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 2 TASK: ffffffc0f8658b80 CPU: 2 COMMAND: "kthreadd"
PID: 3 TASK: ffffffc0f8659700 CPU: 0 COMMAND: "ksoftirqd/0"
ps -p [pid]
만약 perf라 프로세스의 부모 프로세스를 알고 싶으면 아래 명령어를 치면 되죠.
crash64> ps -p 25
PID: 0 TASK: ffffffc001580e40 CPU: 0 COMMAND: "swapper/0"
PID: 2 TASK: ffffffc0f8658b80 CPU: 2 COMMAND: "kthreadd"
PID: 25 TASK: ffffffc0f81f3980 CPU: 2 COMMAND: "perf"
ps -c
전체 프로세스의 부모/자식 프로세스 관계를 줄 세우고 싶으면 좋은 명령어에요.
PID: 1 TASK: ffffffc0f8658000 CPU: 1 COMMAND: "init"
PID: 453 TASK: ffffffc0f7149700 CPU: 2 COMMAND: "ueventd"
PID: 481 TASK: ffffffc0f7135080 CPU: 1 COMMAND: "logd"
PID: 482 TASK: ffffffc0f7137300 CPU: 2 COMMAND: "servicemanager"
PID: 483 TASK: ffffffc0f7134500 CPU: 3 COMMAND: "hwservicemanage"
PID: 484 TASK: ffffffc0f29ba280 CPU: 2 COMMAND: "vndservicemanag"
PID: 485 TASK: ffffffc0f29b9700 CPU: 1 COMMAND: "logd.daemon"
PID: 486 TASK: ffffffc0f29bae00 CPU: 3 COMMAND: "logd.reader"
PID: 487 TASK: ffffffc0f29bb980 CPU: 3 COMMAND: "logd.writer"
PID: 488 TASK: ffffffc0f29bc500 CPU: 2 COMMAND: "logd.control"
PID: 490 TASK: ffffffc0f7132e00 CPU: 1 COMMAND: "keymaster@3.0-s"
PID: 491 TASK: ffffffc0f7132280 CPU: 0 COMMAND: "vold"
PID: 499 TASK: ffffffc0f7130000 CPU: 1 COMMAND: "vold"
ps -a [pid]
유저 공간에서 생성된 프로세스의 Property(생성 시 Argument..)을 알고 싶을 때 써요.
crash> ps -a 389
PID: 389 TASK: eb066940 CPU: 0 COMMAND: "sdcard"
ARG: /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
ENV: VIBE_PIPE_PATH=/dev/pipes
PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
LD_LIBRARY_PATH=/vendor/lib:/system/lib
ANDROID_BOOTLOGO=1
ANDROID_ROOT=/system
ANDROID_ASSETS=/system/app
ANDROID_DATA=/data
ANDROID_STORAGE=/storage
ASEC_MOUNTPOINT=/mnt/asec
LOOP_MOUNTPOINT=/mnt/obb
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/webviewchromium.jar:/system/framework/com.pompeii.frameworks.jar:/system/framework/qcmediaplayer.jar:/system/framework/org.codeaurora.Performance.jar
EXTERNAL_ADD_STORAGE=/storage/external_SD
SECONDARY_STORAGE=/storage/external_SD
EXTERNAL_STORAGE=/storage/emulated/legacy
EMULATED_STORAGE_SOURCE=/mnt/shell/emulated
EMULATED_STORAGE_TARGET=/storage/emulated
EXTERNAL_ADD_STORAGE=/storage/external_SD
LD_PRELOAD=/system/lib/libNimsWrap.so
ANDROID_PROPERTY_WORKSPACE=9,0
ps -G
각 프로세스 별로 메모리를 얼마나 쓰고 있는지 각 VSZ/RSS 정보롤 보여주고, 전체 시스템에서 쓰고 있는 비율도 보여줘요. 메모리 디버깅할 때 정말로 유용한 커맨드라고 생각되는군요.
crash64> ps -G
PID PPID CPU TASK ST %MEM VSZ RSS COMM
0 0 0 ffffffc001580e40 RU 0.0 0 0 [swapper/0]
0 0 1 ffffffc0f865f300 RU 0.0 0 0 [swapper/1]
// .. 생략..
17171 981 1 ffffffc035768b80 IN 0.5 1823116 33012 com.android.mms
17238 2511 2 ffffffc0f1b06780 IN 0.3 1657776 18528 dboxed_process0
17565 979 1 ffffffc070ab5080 IN 0.7 2344024 41808 droid.bluetooth
17852 2 1 ffffffc068dc3980 IN 0.0 0 0 [kworker/1:2H]
'[Debugging] Tips' 카테고리의 다른 글
IPI (Inter Processor Interrupts) 소개 및 디버깅 패치 (1) (0) | 2023.05.04 |
---|---|
[crash-utility]wakelock - rbtree debugging(디버깅) (0) | 2023.05.04 |
crash-utility(crashtool) - 리다이렉션 커맨드 (0) | 2023.05.04 |
crash-utility(crashtool) - runq awk 명령어 (0) | 2023.05.04 |
[crash-utility] wakelock 디버깅(rbtree: wakelocks_tree) (0) | 2023.05.04 |