debugfs?

  /proc/  밑에 리눅스 커널과 직접 통신이 가능한 file 형태의 인터페이스를 만들어 쓰듯이, debugfs 라는 가상의 메모리 타입 파일 시스템에 디버깅용 인터페이스를 만들어 사용하는 것을 말합니다. 


마운트 방법

$ > mount -t debugfs none /sys/kernel/debug/


 위와 같이 마운트 한후, /sys/kernel/debug/ 디렉토리에 들어가 보면, 리눅스 커널에서 만들어 놓은 디버깅용 인터페이스 파일들을 확인할 수 있습니다. 


example

/ > mount -t debugfs none /sys/kernel/debug


/ > cd /sys/kernel/debug


/sys/kernel/debug > ls

at91_clk        gpio            memblock        wakeup_sources

at91_gpio       hid             mmc0

bdi             ieee80211       usb


/sys/kernel/debug/ > cat at91_gpio

Pin     PIOA            PIOB            PIOC            PIOD


0:      A               A               GPIO:1          A

1:      A               A               GPIO:1          A

2:      GPIO:1          A               GPIO:1          A

3:      GPIO:1          A               GPIO:1          A

4:      GPIO:1          A               GPIO:1          GPIO:1

5:      GPIO:1          A               GPIO:1          GPIO:1

6:      GPIO:1          A               GPIO:1          A

7:      B               A               GPIO:1          A

8:      GPIO:1          GPIO:1          GPIO:1          A

9:      A               A               GPIO:1          A

10:     A               A               GPIO:1          A

11:     A               GPIO:1          GPIO:1          A

12:     A               GPIO:1          GPIO:1          A

13:     A               GPIO:1          GPIO:1          A

14:     GPIO:1          GPIO:1          GPIO:1          GPIO:1

15:     A               GPIO:1          GPIO:1          IRQ:edge-both

16:     A               GPIO:1          GPIO:0          A

17:     A               GPIO:1          GPIO:1          A

18:     A               GPIO:1          GPIO:1          A

19:     A               A               GPIO:1          GPIO:0

20:     A               A               GPIO:0          GPIO:0

21:     GPIO:1          A               GPIO:0          GPIO:1

22:     GPIO:1          A               GPIO:1          A

23:     GPIO:1          A               GPIO:1          A

24:     B               A               GPIO:1          A

25:     B               A               GPIO:1          A

26:     B               A               GPIO:1          A

27:     B               A               GPIO:1          A

28:     B               A               GPIO:0          A

29:     B               A               GPIO:1          A

30:     GPIO:1          A               GPIO:1          A

31:     GPIO:1          A               GPIO:1          A


/sys/kernel/debug/ > cd mmc0


/sys/kernel/debug/mmc0 > ls

clock             ios               pending_events    req

completed_events  mmc0:b368         regs              state


/sys/kernel/debug/mmc0 > cat clock 

50000000



API

 debug fs 를 만드는 api 는 kernel source 검색을 통해 확인 할 수 있습니다. 

대표적인 api 는 아래와 같으며, 이 api 를 시작으로 분석하면 쉽게 익힐 수 있습니다.


fs/debugfs/inode.c

struct dentry *debugfs_create_file(const char *name, mode_t mode, struct dentry *parent, void *data, const struct file_operations *fops);


'development' 카테고리의 다른 글

openwrt  (0) 2015.02.24
[network] nat 설정법  (0) 2015.01.15
[driver] ipTime N150UA-4dBi  (8) 2014.09.16
[program] unused variable 문제  (0) 2013.08.02
[program] 32bit CPU 에서 64bit 변수 사용 문제  (0) 2013.07.25
블로그 이미지

김유석0

,