remote-debugging-based-on-notrace32-20130619-1900

25
1/12 13/2/22 10:54 PM 2013 년년 년년년년년년 년년년년 년년 년년년 Notrace32-based Real-time Remote Debugging Method for Optimization of Mobile OS Geunsik Lim http://leemgs.fedorapeople.org Sungkyunkwan University Samsung Electronics Co., Ltd.

Upload: samsung-electronics

Post on 07-Jan-2017

24 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Remote-debugging-based-on-notrace32-20130619-1900

105/02/2023 01:12 AM

2013 년도 한국통신학회 하계종합 학술 발표회

Notrace32-based Real-time Remote Debug-ging Method for Optimization of Mobile OS

Geunsik Limhttp://leemgs.fedorapeople.org

Sungkyunkwan UniversitySamsung Electronics Co., Ltd.

Page 2: Remote-debugging-based-on-notrace32-20130619-1900

2/12

Motivation Related work Notrace32 (Previous Research) Notrace32 based Remote Debugging Model

TCP/IP Server & Client Model Ring buffer Data Management Eclipse-based GUI Client

Evaluation Conclusion

Outline

Page 3: Remote-debugging-based-on-notrace32-20130619-1900

3/12

Motivation1) CPU 와 Memory 가 제한적인 임베디드 디바이스에서 애플리케이션 스토어의 등장

2) 시스템이 리부팅되거나 , 시스템의 반응속도가 갑자기 느려지는 현상

3) 고객들의 디바이스에 대한 충성심 및 회사의 경쟁력을 확고히 하기 위하여 디버깅 기술이 중요함 .

Too many apps

Page 4: Remote-debugging-based-on-notrace32-20130619-1900

4/12

Related work

Approach Pros. Cons.Lauterbach GmbH 의 TRACE32

• 특정시점의 기간 동안의 시스템 변화 정보를 디버깅

• 원격으로 디버깅을 할 수 없다 . • 하드웨어가 반드시 있어야만 사용이

가능하다 .

LLDB (Low Level Debugger on LLVM)

• GDB 디버깅을 위한 통신규약을 통해서 실시간으로 특정 시점을 디버깅

• 특정 순간의 디버깅 정보만 파악을 할 수만 있고 , 특정 시점 동안의 시스템 변화 정보를 알 수는 없다 .

"GDB Trace-points for Linux Kernel “ by Jim Blandy

• 특정시점의 기간 동안 시스템 변화 정보를 디버깅 할 수 있다

• 로컬 디버깅만 가능하고 , Bionic C library 기반의 안드로이드 플랫폼을 위한 호환성을 제공하지 않는다 .

NoTrace32(Our previous research)

• 특정 시점동안의 시스템변화파악 가능

• 非시스템개발자가 제대로 사용 (숙련 ) 하려면 진입장벽이 높다 .

Page 5: Remote-debugging-based-on-notrace32-20130619-1900

5/12

• 실시간으로 원격으로 디버깅가능• 진입장벽 해소를 위한 GUI 인터페이스

What is the Challenges?

Page 6: Remote-debugging-based-on-notrace32-20130619-1900

6/12

Notrace32-based Real-time Remote Debugging

nt32.ko

nt32 client(Based on gdb-tracepoints using DWARF)

debugfs

tracepoints kprobe

Kernel Space

User Space

TCP/IP

nt32 Cross Tool-chain

(AR

M C

ortex-A9)

PERF_EVENTS

GD

BTracepoints

sysfs

GDB(CLI) Eclipse Based GUI Client

nt32 Service Daemon (work-queue single kernel thread)

GU

I

Server

Client

Structure kprobe

Structure kretprobe

Structure pt_regs

DDD(GUI)

Append Trace-point Handler using Kprobe

NO

TRA

CE

32

TOO

L C

HA

IN

ADB

• 이전의 연구 : 파란색 네모박스• 제안 시스템 : 빨간색 네모박스

Page 7: Remote-debugging-based-on-notrace32-20130619-1900

7/12

TCP/IP Server & Client Model• Eclipse 의 CDT(C/C++ Development Toolkit) 에 기반하여 Debug View 를 추가 .• 코드의 Breakpoint, Watch point, Variable, Register 정보를 GUI 모드로 추적 가능 .

Kernel Image

Kernel gdbserver( nc –l 1234 )

nt32 server drives Linux kernel

GDB-release reads debug information from unstripped local copy of Kernel

Eclipse

GDB Client

Kernel Image(vmlinux)

Kernel gdbserver pro-tocol over TCP/IP

GDB protocol

Host System Target System

192.168.155.20:1234

Page 8: Remote-debugging-based-on-notrace32-20130619-1900

8/12

Ring Buffer for Controlling Mass Data

Ring Buf -fer

Fetch data

Add new data

Release old data

This image shows a partially full buffer basi-cally.

This image shows a full buffer with two elements having been overwrit-ten to keep the maximum size of the memory.6 7 8 9 10 A B 5

1 2 3 4

END START

ENDSTART

Page 9: Remote-debugging-based-on-notrace32-20130619-1900

9/12

Server

Client

AndroidEmulator

Linux Desktop

WiFi

3G Network

Wired LAN

nt32.ko

nt32.ko

nt32.ko

nt32 ClientTCP/IP

DWARF debug-ging sym-bols

DWARF debug-ging sym-bols

DWARF debug-ging sym-bols

• 실험환경 : Ubuntu 12.04 LTS 가 설치된 리눅스 데스크탑 환경에서 안드로이드 모바일 디바이스에 접속을 한 후에 원격 분석 수행

Evaluation 1/3

Page 11: Remote-debugging-based-on-notrace32-20130619-1900

11/12

• Eclipse 에서 GDB 를 연동하여 커널 디버깅시에 아래와 같이 GDB 콘솔에서 Tracdpoint 관련 GDB명령을 수행하도록 한다 .

(1)

(2)

(3)(4)

Evaluation 3/3

Page 12: Remote-debugging-based-on-notrace32-20130619-1900

12/12

Conclusion and Future work

• 본 논문의 아이디어는 운영체제 레벨의 동적 적재 소프트웨어 솔루션이므로 , 안드로이드 플랫폼의 어떠한 추가적인 수정도 필요로 하지 않는다 .

• TCP/IP 기반으로 임베디드 디바이스들을 실시간으로 특정 시점 동안 원격으로 디버깅 가능하다 .

• NOTRACE32 의 진입장벽 최소화를 위해 Eclipse 기반의 Tracing GUI 클라이언트 지원한다 .

• 오픈소스로 릴리즈 하였으므로 , http://notrace32.googlecode.com/ 에서 소스코드 및 바이너리 파일들을 다운로드하여 자유롭게 추가적인 연구가 가능하다 .

• 메모리뿐만 아니라 CPU 도 실시간 디버깅을 할 수 있도록 PMU (Performance Monitoring Unit) 의 지원을 확장하면 , CPU 와 캐시 정보까지 실시간으로 디버깅이 가능할 것이다 .

CONCLUSION

FUTURE WORK

Page 13: Remote-debugging-based-on-notrace32-20130619-1900

13/12

THANK YOU FOR YOUR ATTENTIONANY QUESTIONS?

Page 14: Remote-debugging-based-on-notrace32-20130619-1900

14/12

BACKUP SLIDESIn Case We Have More Time…

Page 15: Remote-debugging-based-on-notrace32-20130619-1900

15/12

Eclipse & GDB 연동 작업 : Eclipse 3.7.2(Indigo) CDT • C/C++ 코드의 디버깅을 위해서는 Eclipse CDT 버전을 다운로드해야함 .

(2)

(1)

Page 16: Remote-debugging-based-on-notrace32-20130619-1900

16/12

Eclipse & GDB 연동 작업 : zylinCDT 플러그인 설치 • Eclipse 에서 gdb-release 을 연동하기 위하여 Eclipse 실행후에 [Help] – [ Install New Software]

메뉴에서 zylinCDT 플러그인 다운로드

(1)

(2)

(3)

Page 17: Remote-debugging-based-on-notrace32-20130619-1900

17/12

Eclipse & GDB 연동 작업 : New C Project 생성• [File] – [New] – [ C Project 생성 ] 메뉴에서

– Project name: hello– Project type: Executable – Empty

Project– Toolchain: Linux GCC– 를 선택하여 C 프로젝트를 생성하도록

한다 .

(1)

(2)(3)

(4)

Page 18: Remote-debugging-based-on-notrace32-20130619-1900

18/12

Eclipse & GDB 연동 작업 : Cross 컴파일러 셋팅• ARM 용 바이너리를 생성되도록 크로스 툴체인 경로를 셋팅하도록 한다 .

(1) (2) (3)

(2)

(2)

Page 19: Remote-debugging-based-on-notrace32-20130619-1900

19/12

Eclipse & GDB 연동 작업 : 빌드 및 실행 테스트 • [Project] – [Build Project] 을 클릭하여 ARM 용 바이너리를 빌드하도록 한다 .

(1)

(2)

(3)

Page 20: Remote-debugging-based-on-notrace32-20130619-1900

20/12

Eclipse & GDB 연동 작업 : Eclipse 에서 GDB 실행• [Run] - [Debug AS…] – [ Debug Configu-

rations] 을 선택한다 .

(1)

(2)

Page 21: Remote-debugging-based-on-notrace32-20130619-1900

21/12

Eclipse & GDB 연동 작업 : Eclipse 에서 GDB 실행• [Debugger] 탭메뉴에서 컴파일해놓은

gdb-release 명령은 연결시킨다 .(1)

(2)

(3)

* mi: Machine Interface

Page 22: Remote-debugging-based-on-notrace32-20130619-1900

22/12

Eclipse & GDB 연동 작업 : Eclipse 에서 GDB 실행• Gdb 실행시 환경 설정 작업을 자동으로 실행하도록 [Commands] 탭의 “ Run” 명령박스에

추가하도록 한다 .

(1)

(2)

(3)

(4)

Page 23: Remote-debugging-based-on-notrace32-20130619-1900

23/12

1. Host Linux PC 에서 trace-point 설정하기 (nt-gdb) list vfs_readdir (nt-gdb) trace vfs_readdir ( 또는 trace fs/readdir.c:29 )Tracepoint 1 at 0xc0958608: file fs/readdir.c, line 24.(nt-gdb) actionsEnter actions for tracepoint 1 , one per lineEnd with a line saying just “end”.>collect *file ( 또는 collect $reg)>end(nt-gdb)

2. Host Linux PC 에서 원격접속으로 타겟보드의 ls 명령 실행하기 (nt-gdb) tstartTarget#> ls /lib/libc.so.6 libm.so.6 lib 이 -2.13.so libgcc.so.1 libpthread-2.13.so librt-

2.13.so(nt-gdb) tstop3. Host Linux PC 에서 원격접속으로 타겟보드 디버깅하기(nt-gdb) tfindFound trace frame 0, tracepoint 1 #0 vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /opt/android-kernel/fs/read-

dir.c:2323 {(nt-gdb) p *file ( 또는 p $reg ; info $reg )$1 = {f_u = {fu_list = {next = 0xe58ab780, prev = 0xc1610918}, fu_rcuhead = {next =

0xe58ab780, func = 0xc1610918}}, . . . . 중간 생 략 . . . . . ra_pages = 32, mmap_miss = 0, prev_pos = -1}, f_version = 0, private_data = 0x0, f_ep_links = {next

= 0xe5337a5c, prev = 0xe5337a5c}, f_mapping = 0xe3da2d00}

해당 Tracepoint 정보가 없다면 , “Target failed to find requested trace frame” 정보를 출력함 .

Kernel 으로부터 Register 정보 얻기

print

부록 #: TCP/IP 원격 디버깅 (file read 트레이싱 )

Page 24: Remote-debugging-based-on-notrace32-20130619-1900

24/12

1. Host Linux PC 에서 trace-point 설정하기 * 해석 ) 호출이 되는 인스터럭션 정보를 알아 내도록 해보겠습니다 . (nt-gdb) disassemble /rm tty_read 

938 static ssize_t tty_read(struct file *file, char __user *buf, size_t count,939 loff_t *ppos)940 { 0xc0b68c34 <+0>: 0d c0 a0 e1mov r12, sp

0xc0b68c38 <+4>: f0 dd 2d e9 push {r4, r5, r6, r7, r8, r10, r11, r12, lr, pc} 0xc0b68c3c <+8>: 04 b0 4c e2sub r11, r12, #4 0xc0b68c40 <+12>: 08 d0 4d e2 sub sp, sp, #8 0xc0b68c44 <+16>: 04 e0 2d e5 push {lr} ; (str lr, [sp, #-4]!) . . . 아 래 생 략 . . .

(nt-gdb) trace *0xc0b68c34 Tracepoint 2 at 0xc0b68c34: file drivers/tty/tty_io.c, line 940.. (nt-gdb) actions  Enter actions for tracepoint 1, one per line. End with a line saying just "end". >collect $reg >end 

2. Host Linux PC 에서 원격접속으로 타겟보드의 ls 명령 실행하기 (nt-gdb) tstart  (nt-gdb) tstop

3. Host Linux PC 에서 원격접속으로 타겟보드 디버깅하기(nt-gdb) tfind  

Found trace frame 0, tracepoint 1321 ret = file->f_op->read(file, buf, count, pos);(nt-gdb) p $reg$1 = void

• With a /m modifier, source lines are included (if avail-able).

• With a /r modifier, raw instructions in hex are included.

부록 #: TCP/IP 원격 디버깅 (/rm 예제 )

Page 25: Remote-debugging-based-on-notrace32-20130619-1900

25/12

1. Host Linux PC 에서 네트웍 카드 func 관련 trace-point 설정하기 (nt-gdb) trace boomerang_start_xmitTracepoint 1 at 0xc86df4bc: file drivers/net/3c59x.c, line 2094.(nt-gdb) actions > collect *dev> end(nt-gdb) trace drivers/net/3c59x.c:2107 Tracepoint 2 at 0xc86df509: file drivers/net/3c59x.c, line 2107.(nt-gdb) actions > collect ioaddr> collect vp->cur_tx> end

2. Host Linux PC 에서 원격접속으로 타겟보드의 ls 명령 실행하기 (nt-gdb) tstart//...wait until packet received for a long time(nt-gdb) tstop

3. Host Linux PC 에서 원격접속으로 타겟보드 디버깅하기(nt-gdb) tfind(nt-gdb) p *dev(nt-gdb)(nt-gdb) tfind(nt-gdb) p ioaddr(nt-gdb) p vp->cur_tx(nt-gdb) list 2102 pr_debug("boomerang_start_xmit()\n"); 2103 pr_debug("%s: Trying to send a packet, Tx index %d.\n", 2104 dev->name, vp->cur_tx); 2105 }

부록 #: TCP/IP 원격 디버깅 ( 네트웍 모듈 )