본문 바로가기

Programming/Linux_Kernel

Playing with ptrace, Part I 원문 : http://www.linuxjournal.com/article/6100 ptrace 는 리눅스에 입문한 나에게 마법과 같은 기능이다. 물론 제약이 있겠지만, 언듯 보면 이것은 Linux의 process 보호의 컨샙을 넘나들며, 동작을 한다. 이 놀라운 기능을 조금씩 알아가는것은 나에게 커다란 즐거움이다. Using ptrace allows you to set up system call interception and modification at the user level. Have you ever wondered how system calls can be intercepted? Have you ever tried fooling the kernel by changing system call arg.. 더보기
Playing with ptrace, Part II 원문 : http://www.linuxjournal.com/node/6210/print In Part II of his series on ptrace, Pradeep tackles the more advanced topics of setting breakpoints and injecting code into running processes. In Part I of this article [LJ, November 2002], we saw how ptrace can be used to trace system calls and change system call arguments. In this article, we investigate advanced techniques like setting breakpoi.. 더보기
paper on debugging kernel oops or hang 출처 : http://mail.nl.linux.org/kernelnewbies/2003-08/msg00347.html To: "'kernelnewbies@nl.linux.org'" Subject: paper on debugging kernel oops or hang From: "HABBINGA,ERIK (HP-Loveland,ex1)" Date: Mon, 25 Aug 2003 14:30:10 -0700 List-archive: List-help: List-owner: List-post: List-software: Listar version 1.0.0 List-subscribe: List-unsubscribe: Original-Recipient: rfc822;kernelnewbies-archive@nl.l.. 더보기
diff 를 이용한 kernel patch 만들기 - 또다른 문서 원문 : http://wiki.kldp.org/wiki.php/SubmittingPatches How to Get Your Change Into the Linux Kernel or Care And Operation Of Your Linus Torvalds 리눅스 커널에 여러분의 패치(역자주:원본에는 change를 사용하였으나 문맥상 patch로 번역함)를 반영하는 법 혹은 여러분의 Linux Torvalds를 치료하고 수술하는 법 For a person or company who wishes to submit a change to the Linux kernel, the process can sometimes be daunting if you're not familiar with "the system." .. 더보기
diff를 이용한 kernel patch 만들기 원문 : http://kltp.kldp.org/stories.php?story=02/06/23/4844278 [ 패치파일 만들어 적용하기 ] 작성자 : 정택진 (nveteran@netian.com) 작성일 : 2002. 6. 23. 1. 패치파일 만들기 (diff 이용) - diff 의 쓰임 : 두 대상간의 차이점만을 모아 파일로 저장한다. - 확장자 : .diff or .patch - 만들기 전에는 make clean, make distclean, make mrproper 등을 수행하여, 컴파일된 파일을 모두 삭제한 뒤 만듭니다. - 아래 설명들은 pwd 를 항상 생각하면서 도움이 됩니다. * 실제 소스 코드를 통한 테스트를 합시다. - 대상 : wu-ftpd-2.6.2.tar.gz # cd /usr/.. 더보기
Linux Kernel 에 대한 문서들 여기 있는 내용들만 알아도 Linux Kernel 에 대해서 전반적인 지식은 습득할 수 있을 것이다. 이렇게 방대한 내용이 한글로 작업되어있다는 것만으로도 얼마나 감사한 일인지 모른다. 번역해 주신 분들에게 감사함을 표한다. 원문 : http://katalog.egloos.com/3191241 1 일반 문서 ¶ Unreliable Guide To Hacking The Linux Kernel (김남형) 리눅스 커널 해커들을 위한 입문서 Kernel Analysis HOWTO (김남형) 리눅스 커널을 구성하는 각 부분을 정의하고 그 부분을 수행하는 주된 함수와 자료 구조, 그리고 이들이 어떻게 동작하는지에 대한 설명 임베디드 시스템 개발자를 위한 리눅스 커널 (남상규) 리눅스 커널을 임베디드 시스템에 포팅하.. 더보기
ptrace 번역 윈도우에 hooking 이 있다면 Linux 에는 ptrace 가 있다. (이게 무슨말인지 아는사람? 둘다 무척 잼있는(?) 기술이다.) 이것을 번역해 놓으신 분이 있으셔서 고맙게도 자료를 떠 왔다. 원문 : http://blog.naver.com/int_com?Redirect=Log&logNo=80055576334 정말 날림으로 번역했다 ㅠㅠ ;;; 그냥 원문 읽자니 잘 집중도 안되서 번역하면서 읽으면 잘 될거 같아서 ㅎㅎ 원문 주소 -> http://linuxgazette.net/issue81/sandeep.html ------------------------------------------------------------ 1. introduction ptrace()는 한 프로세스가 다른 프로세스의 .. 더보기
warning: function declaration isn't a prototype gcc 로 빌드하다보면 다음과 같은 warning 을 만나게 된다. warning: function declaration isn't a prototype 신경쓰여서 찾아봤더니 다음과 같은 의미가 있다고 한다. warning 없는 compile 을 위하여... > gcc: gcc version 2.95.3 20010315 (release) > > i get these warnings on a project i'm trying to port using > arm-linux-gcc .. is there some place i can find a more detailed > description of what these warnings mean and how i can clean them up? i > am h.. 더보기
HOWTO do Linux kernel development 리눅스 커널 개발자가 되는 일은 정말 길고도 힘든 길일것 같다. 하지만, 그렇기에 정말 멋진 일이 아닐까.. 나는 지금 그 길의 첫발을 딛고 있다. 원문 : http://wiki.kldp.org/wiki.php/HOWTO_do_Linux_kernel_development FrontPage › LinuxdocSgml/Majordomo-KLDP › HOWTO_do_Linux_kernel_development 원문: "HOWTO do Linux kernel development" 저자: Greg Kroah-Hartman 번역: 조수형 HOWTO do Linux kernel development 이 문서는 이 주제에 대한 가장 중요한 문서로 어떻게 리눅스 커널 개발자가 되고 어떻게 리눅스 커널 개발 커뮤니티와 .. 더보기
sigaction() 원문 : http://blog.naver.com/msd102?Redirect=Log&logNo=150009176058 ------------------------------------------------------------------------------------------- #include int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); sigaction() 시스템 호출은 특정 시그널의 수신에 대해서 취할 액션을 설정하거나 변경하기 위해서 사용된다. signum는 시그널을 명시한다. SIGKILL과 SIGSTOP를 제외한 모든 시그널이 타당한 시그널이 될 수 있다. 만약 act가 null이 아니라면 .. 더보기
blocked signal 검사와 변경 : sigprocmask 원문 : http://kr.blog.yahoo.com/jinynet9/1011.html ------------------------------------------------------------------------------------------- signal mask - 프로세스에게 전달되지 않도록 블럭된 signals 들의 집합 #include int sigprocmask(int how, sigset_t * set, sigset_t * oset);- sigprocmask는 시그널 마스크를 검사하거나 변경하는데 쓰인다. how SIG_BLOCK - 새로운 시그널 마스크는 현재의 시그널 마스크와 set에 의해 지정된 시그널 마스크의 합집합이다. - 즉, set는 블럭시키고자 하는 추가적인 시그널들을 .. 더보기
Linux Signal Handling 원문 : http://www.linuxjournal.com/article/3985 APUE 책만 보니까 실제 리눅스에서 signal 처리가 궁금해 졌다. 아래 문서에 잘 나와있다. -------------------------------------------------------------------------------------------- The Linux Signals Handling Model May 1st, 2000 by Moshe Bar in · Software Communication is the key to healthy relationships between threads and the kernel; these are the signals they use to communicate. 양.. 더보기
gprof 를 이용한 profiling 원문 : http://blog.naver.com/doky99?Redirect=Log&logNo=20005409020 사용하면 완전 좋을 듯하나.. 내가 하는 과제에서는 gmon.out 파일이 나오지 않는다. ㅜㅜ arm 은 되는게 너무 없다..;; ------------------------------------------------------------------------------------------ gprof를 사용한 프로파일링 By Vinayak Hegde 한글번역 전정호 이 글은 한글번역판입니다. 원문은 여기에서 볼 수 있습니다. 연재 소개 리눅스(와 다른 유닉스)에는 같이 사용하여 놀라운 기능을 하는 작고 멋진 도구들이 많다. 이런 소프트웨어를 사용하거나 직접 만들면 재미있다. 나는 이번 .. 더보기
strace man page STRACE(1) STRACE(1) NAME strace - trace system calls and signals SYNOPSIS strace [ -dffhiqrtttTvxx ] [ -acolumn ] [ -eexpr ] ... [ -ofile ] [ -ppid ] ... [ -sstrsize ] [ -uusername ] [ -Evar=val ] ... [ -Evar ] ... [ command [ arg ... ] ] strace -c [ -eexpr ] ... [ -Ooverhead ] [ -Ssortby ] [ command [ arg ... ] ] DESCRIPTION In the simplest case strace runs the specified command until it exits... 더보기
_alloca 와 smart point 얼마전 stack 에 동적 메모리를 할당하는 _alloca 라는 함수를 들었다. 힙을 스택처럼 사용하는 smart point 와 스택을 힙처럼 사용하는 _alloca 중 어떤것이 더 효율적일까? _alloca 는 스택에 공간을 미리 할당해서 힙처럼 사용할 수 있도록 해준다. smart point 는 힙을 사용하되 스택풀기에 들어가면 할당한 memory 를 자동으로 해제시켜 주는 코드를 포함하도록 힙포인터를 수정한것이다. 자세한 내용은 아래의 포스팅을 참고.. _alloca 는 smart point 에 대해 비교적 가볍지만, 사용상 주의할 점이 존재한다. 이 주의할 점이 좀 애매한 편이여서 편하게 코딩하다가는 자칫 알수없는 오류를 만들어 내기 쉬운 부분이 있다... 더보기
ptrace() 함수의 PTRACE_ATTACH 옵션 사용시 stop 문제 해결 원문 : http://letsme.com/tag/ptrace -------------------------------------------------------------------------------------------- 리눅스에서 ptrace() 함수의 PTRACE_ATTACH 옵션을 사용하여 특정 프로세스에 attach 할 경우에 return value는 정상이지만 해당 프로세스에 attach 가 되지 않고 detach 후에도 프로세스가 STOP 인 상태로 남게되는 경우가 있습니다. 이런 경우에 ptrace() 함수를 사용하여 attach한 직후에 sleep() 이나 usleep() 함수를 사용하여 스케쥴링을 시키면 원하는대로 동작을 하게 됩니다. ptrace(PTRACE_ATTACH, pid,.. 더보기
Process Tracing Using Ptrace - By Sandeep S 원문 : http://linuxgazette.net/issue81/sandeep.html ------------------------------------------------------------------------------------------- The ptrace system call is crucial to the working of debugger programs like gdb - yet its behaviour is not very well documented - unless you believe that the best documentation is kernel source itself! I shall attempt to demonstrate how ptrace can be used t.. 더보기
How to code debuggers 원문 : http://t-a-w.blogspot.com/2007/03/how-to-code-debuggers.html ------------------------------------------------------------------------------------------ Coding low-level infrastructure like kernels, compilers, and linkers can be very scary, and most programmers stay as far away from them as they can. And the scariest of all are debuggers, which rip apart warm flesh of innocent programs, and .. 더보기
/Proc/[pid]/stat 에서 보이는 정보 분석하기 출력되는 정보를 다음과 같은 순서로 해석하면 된다. FLDNUM FMT ARG OUTPUT 1 %d task->pid 18173 2 (%s) task->comm (run-mozilla.sh) 3 %c state S 4 %d ppid 932 5 %d task->pgrp 18173 6 %d task->session 904 7 %d tty_nr 0 8 %d tty_pgrp -1 9 %lu task->flags 0 10 %lu task->min_flt 186 11 %lu task->cmin_flt 118 12 %lu task->maj_flt 483 13 %lu task->cmaj_flt 470 14 %lu task->times.tms_utime 0 15 %lu task->times.tms_stime 0 16 %.. 더보기