반응형


터미널 프롬프트상에서 아래의 커맨드를 입력하면 에러 코드에 대한 정보가 출력됩니다.

cat /usr/include/bits/errno.h
cat /usr/include/asm-generic/errno.h
cat /usr/include/asm-generic/errno-base.h

참고사이트 : http://www.basiclinuxcommands.com/2008/07/linux-error-codes-basic-linux-command.html

반응형
반응형

SVN 백업 및 복구는 관리자 명령이기 때문에 슈퍼유저(root) 권한으로 실행해야합니다.

1. 백업 방법
 (1) 백업하고자 하는 저장소의 상위 디렉토리로 이동합니다.
 (2) 아래의 명령어를 사용하여 덤프파일을 생성합니다.
svnadmin dump [저장소 경로(상대경로가능)] > [덤프파일이름]
 (3) 저장된 덤프파일을 잘 관리하면 됩니다.

2. 복구 방법
 (1) 복구하고자 하는 저장소의 상위 디렉토리로 이동합니다.
 (2) 아래의 명령어를 사용하여 복구합니다.
svnadmin load [저장소 경로(상대경로가능)] < [덤프파일이름]

※ 주의 : 꺽쇠(-_-)의 방향은 백업시에는 [경로] > [파일], 복구시에는 [경로] < [파일]
반응형
반응형
리눅스에서 프로그램을 만들다 보면 Memory Leak 체크를 할 필요성을 느낍니다.
이럴경우, Memory Leak을 찾는 툴이 valgrind입니다.
프로그램은 사이트(http://valgrind.org/)에서 받을 수 있구요~ ^^

다운받은 파일을 압축을 풀고 그 폴더에 들어간 뒤, valgrind파일을 실행시킵니다.

제가 가장 편하게 사용하는 메모리릭 체크 방법은 다음과 같습니다.
 
valgrind --leak-check=full --log-file=memcheck.txt -v --error-limit=no [프로그램경로] [인자]
 
--leak-check=full : 메모릭에러가 날 경우 소스파일명과 라인위치 출력

               이 옵션을 사용할려면 디버깅컴파일을 해야합니다. (컴파일시 -g 옵션)
--log-file : 체크결과를 저장할 로그파일명

이렇게 실행하고 나면 로그파일이 만들어지는데 이 두 부분만 보면 됩니다.


LEAK SUMMARY ( Memory Leak 요약 )
==18431== LEAK SUMMARY:
==18431==    definitely lost: 1,025 bytes in 1 blocks
==18431==    indirectly lost: 0 bytes in 0 blocks
==18431==      possibly lost: 12,749,264 bytes in 112 blocks
==18431==    still reachable: 4,240 bytes in 16 blocks
==18431==         suppressed: 0 bytes in 0 blocks
==18431== Reachable blocks (those to which a pointer was found) are not shown.
==18431== To see them, rerun with: --leak-check=full --show-reachable=yes
1블록에서 1,025만큼의 메모리 Leak이 발생했다는 걸 알 수 있습니다.
definitely lost외에 항목은 불분명한 것이므로 굳이 볼 필요는 없습니다.

LEAK DETAIL
definitely lost로 로그파일을 검색하게 되면 상세내용을 찾을 수 있습니다.
==18431== Thread 1:
==18431== 1,025 bytes in 1 blocks are definitely lost in loss record 2 of 9
==18431==    at 0x4C2179E: malloc (vg_replace_malloc.c:236)
==18431==    by 0x40A16F: make_friend_best(char*, int, int) (friend_srch.c:798)
==18431==    by 0x406A45: Friend(int, int, int, int, int, int, int, char*, char*, char*, char*, char*, int, char*, char*) (friend_thread.c:600)
==18431==    by 0x4052C6: main (friend_srch_main.c:75)
이 로그를 보게되면, 동적할당 하는 부분에서 릭이 발생했고
friend_srch.c소스에 798라인이 그 부분이라는 걸 알 수 있습니다.


메모리 릭 찾기 참 쉽죠잉?  














 
반응형
반응형

※ 스왑 파일 생성 조건
 (1) vi로 파일을 open할 경우 동일한 파일명의 스왑 파일이 숨김 파일 형태로 생성됩니다.
   - 단, 읽기전용 모드(-R)로 파일을 open할 경우에는 스왑 파일이 생성되지 않습니다.
 (2) vi로 open한 파일을 정상적으로 닫을 경우 스왑 파일이 자동으로 삭제됩니다.

하지만, vi로 파일을 열어 작업하는 도중 네트워크 상태가 불안정하거나 끊겼을 경우, 다시 동일 파일을 vi로 open 하려하면 아래와 같은 메시지가 출력됩니다. 
E325: ATTENTION
Found a swap file by the name ".test.c.swp"
          owned by: oyh dated: Tue Oct 25 23:06:24 2011
         file name: ~oyh/test/test.c
          modified: no
         user name: oyh host name: linux
        process ID: 1255 (still running)
While opening file "test.c"
             dated: Mon Oct 24 10:35:05 2011
(1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r test.c"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".test.c.swp"
    to avoid this message.
Swap file ".test.c.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

해당 파일이 이미 open 되어있다는 내용입니다.
일단, 해당 메시지가 출력되면 다른 누군가가 파일을 열어 사용하고 있지는 않은지 반드시 !!! 확인을 해야합니다.
(누군가 정말로 파일을 사용중이라면 아래의 작업은 피하시기 바랍니다......)
누군가 파일을 사용하고 있지 않을 경우, 이전에 작업하던 코드로 복구하려면, 위의 메시지에서 (Q)를 눌러 나간 후 아래의 커맨드를 입력하여 다시 파일을 open합니다.
vi -r [파일명 or 스왑파일명]           (ex) vi -r test.c

수정 작업이 완료되면 저장하고 나간 후 스왑 파일을 삭제해주면 됩니다.


반응형

+ Recent posts