[16.12.3] SAMPLE_KPROBE 확인하기 - iamroot9C-arm/linux GitHub Wiki
[16/12/3] SAMPLE_KPROBE 확인하기
목적
Yocto로 빌드한 커널 4.8 버전에서 SAMPLE_KPROBE config를 enable 하여, qemu 에서 kprobe 동작을 확인해 본다.
Yocto 로 커널 빌드 및 QEMU 실행하기
http://wavy00.blogspot.kr/2016/11/yocto-qemu-arm-64bit.html
SAMPLE_KPROBE 빌드
yocto에서 menuconfig 실행하기
bitbake linux-yocto -c menuconfig
--> select SAMPLE_KPROBE
yocto에서 커널 빌드하기 bitbake -k linux-yocto or bitbake linux-yocto -c compile -f 이미지 생성하기
bitbake core-image-full-cmdline -f
QEMU에서 SAMPLE_KPROBE 확인하기
QEMU 실행하기
runqemu qemuarm64
copy kprobe_example.ko file to target
cd [poky home]/build/tmp
rcp ./linux-qemuarm64-standard-build/samples/kprobes/kprobe_example.ko [email protected]:/
QEMUARM64 Target 에서 ko 설치
cd /
insmod kprobe_example.ko
kprobe 확인하기
cd /sys/kernel/debug/kprobes/
root@qemuarm64:/sys/kernel/debug/kprobes# ls -al
total 0
drwxr-xr-x 2 root root 0 Jan 1 1970 .
drwx------ 13 root root 0 Jan 1 1970 ..
-r--r--r-- 1 root root 0 Jan 1 1970 blacklist
-rw------- 1 root root 0 Dec 3 11:35 enabled
-r--r--r-- 1 root root 0 Jan 1 1970 list
root@qemuarm64:/sys/kernel/debug/kprobes#
root@qemuarm64:/sys/kernel/debug/kprobes# cat list
ffffff800809b318 k _do_fork+0x0
QEMU에서 ftrace 살펴보기
function_graph 사용하기
cd /sys/kernel/debug/tracing echo 1 > tracing_on echo > trace echo function_graph > current_trace echo _do_fork > set_graph_function cat trace
살펴볼 ftrace 내용
root@qemuarm64:/sys/kernel/debug/tracing# ls -al total 0 drwx------ 6 root root 0 Jan 1 1970 . drwx------ 13 root root 0 Jan 1 1970 .. -r--r--r-- 1 root root 0 Jan 1 1970 README -r--r--r-- 1 root root 0 Jan 1 1970 available_events -r--r--r-- 1 root root 0 Jan 1 1970 available_filter_functions -r--r--r-- 1 root root 0 Jan 1 1970 available_tracers -rw-r--r-- 1 root root 0 Jan 1 1970 buffer_size_kb -r--r--r-- 1 root root 0 Jan 1 1970 buffer_total_size_kb -rw-r--r-- 1 root root 0 Dec 3 11:11 current_tracer -r--r--r-- 1 root root 0 Jan 1 1970 dyn_ftrace_total_info -r--r--r-- 1 root root 0 Jan 1 1970 enabled_functions drwxr-xr-x 48 root root 0 Jan 1 1970 events --w------- 1 root root 0 Jan 1 1970 free_buffer drwxr-xr-x 2 root root 0 Jan 1 1970 instances -rw-r--r-- 1 root root 0 Jan 1 1970 kprobe_events -r--r--r-- 1 root root 0 Jan 1 1970 kprobe_profile -rw-r--r-- 1 root root 0 Jan 1 1970 max_graph_depth drwxr-xr-x 2 root root 0 Jan 1 1970 options drwxr-xr-x 3 root root 0 Jan 1 1970 per_cpu -r--r--r-- 1 root root 0 Jan 1 1970 printk_formats -r--r--r-- 1 root root 0 Jan 1 1970 saved_cmdlines -rw-r--r-- 1 root root 0 Jan 1 1970 saved_cmdlines_size -rw-r--r-- 1 root root 0 Jan 1 1970 set_event -rw-r--r-- 1 root root 0 Jan 1 1970 set_event_pid -rw-r--r-- 1 root root 0 Jan 1 1970 set_ftrace_filter -rw-r--r-- 1 root root 0 Jan 1 1970 set_ftrace_notrace -rw-r--r-- 1 root root 0 Jan 1 1970 set_ftrace_pid -r--r--r-- 1 root root 0 Dec 3 11:11 set_graph_function -r--r--r-- 1 root root 0 Jan 1 1970 set_graph_notrace -rw-r--r-- 1 root root 0 Dec 3 11:08 trace -rw-r--r-- 1 root root 0 Jan 1 1970 trace_clock --w--w---- 1 root root 0 Jan 1 1970 trace_marker -rw-r--r-- 1 root root 0 Jan 1 1970 trace_options -r--r--r-- 1 root root 0 Jan 1 1970 trace_pipe -rw-r--r-- 1 root root 0 Jan 1 1970 tracing_cpumask -rw-r--r-- 1 root root 0 Jan 1 1970 tracing_on -rw-r--r-- 1 root root 0 Jan 1 1970 tracing_thresh
root@qemuarm64:/sys/kernel/debug/tracing/events# ls -al total 0 drwxr-xr-x 48 root root 0 Jan 1 1970 . drwx------ 6 root root 0 Jan 1 1970 .. drwxr-xr-x 21 root root 0 Jan 1 1970 block drwxr-xr-x 53 root root 0 Jan 1 1970 btrfs drwxr-xr-x 16 root root 0 Jan 1 1970 clk drwxr-xr-x 16 root root 0 Jan 1 1970 compaction drwxr-xr-x 4 root root 0 Jan 1 1970 cpuhp -rw-r--r-- 1 root root 0 Jan 1 1970 enable drwxr-xr-x 97 root root 0 Jan 1 1970 ext4 drwxr-xr-x 5 root root 0 Jan 1 1970 fib drwxr-xr-x 3 root root 0 Jan 1 1970 fib6 drwxr-xr-x 12 root root 0 Jan 1 1970 filelock drwxr-xr-x 4 root root 0 Jan 1 1970 filemap drwxr-xr-x 15 root root 0 Jan 1 1970 ftrace drwxr-xr-x 4 root root 0 Jan 1 1970 gpio -r--r--r-- 1 root root 0 Jan 1 1970 header_event -r--r--r-- 1 root root 0 Jan 1 1970 header_page drwxr-xr-x 9 root root 0 Jan 1 1970 iommu drwxr-xr-x 5 root root 0 Jan 1 1970 ipi drwxr-xr-x 7 root root 0 Jan 1 1970 irq drwxr-xr-x 18 root root 0 Jan 1 1970 jbd2 drwxr-xr-x 14 root root 0 Jan 1 1970 kmem drwxr-xr-x 4 root root 0 Jan 1 1970 migrate drwxr-xr-x 7 root root 0 Jan 1 1970 module drwxr-xr-x 3 root root 0 Jan 1 1970 napi drwxr-xr-x 12 root root 0 Jan 1 1970 net drwxr-xr-x 46 root root 0 Jan 1 1970 nfs drwxr-xr-x 45 root root 0 Jan 1 1970 nfs4 drwxr-xr-x 20 root root 0 Dec 3 10:38 nfsd drwxr-xr-x 3 root root 0 Jan 1 1970 oom drwxr-xr-x 4 root root 0 Jan 1 1970 pagemap drwxr-xr-x 24 root root 0 Jan 1 1970 power drwxr-xr-x 3 root root 0 Jan 1 1970 printk drwxr-xr-x 17 root root 0 Jan 1 1970 random drwxr-xr-x 4 root root 0 Jan 1 1970 raw_syscalls drwxr-xr-x 3 root root 0 Jan 1 1970 rcu drwxr-xr-x 17 root root 0 Jan 1 1970 regmap drwxr-xr-x 6 root root 0 Jan 1 1970 rpm drwxr-xr-x 25 root root 0 Jan 1 1970 sched drwxr-xr-x 4 root root 0 Jan 1 1970 signal drwxr-xr-x 5 root root 0 Jan 1 1970 skb drwxr-xr-x 4 root root 0 Jan 1 1970 sock drwxr-xr-x 33 root root 0 Jan 1 1970 sunrpc drwxr-xr-x 3 root root 0 Jan 1 1970 swiotlb drwxr-xr-x 512 root root 0 Jan 1 1970 syscalls drwxr-xr-x 4 root root 0 Jan 1 1970 task drwxr-xr-x 14 root root 0 Jan 1 1970 timer drwxr-xr-x 3 root root 0 Jan 1 1970 udp drwxr-xr-x 17 root root 0 Jan 1 1970 vmscan drwxr-xr-x 6 root root 0 Jan 1 1970 workqueue drwxr-xr-x 32 root root 0 Jan 1 1970 writeback