레이블이 dev tip인 게시물을 표시합니다. 모든 게시물 표시
레이블이 dev tip인 게시물을 표시합니다. 모든 게시물 표시

2012년 10월 22일 월요일

git 이미 존재하는 local branch가 remote branch를 tracking하게 하기

http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch

git 버전에 따라 command가 다르다.
  1.8.X) $git branch -u [local_branch] [remote_upstream]
  1.7.X) $git branch --set-upstream [local_branch] [remote_upstream]

1.8.X는 [local_branch]를 생략하면 현재 local branch를 이용해서 설정한다.
1.7.X는 [local_branch]를 생략하면 remote_upstream과 같은 이름의 branch를 생성해 버리므로, 이미 존재하는 local branch를 tracking으로 연결하려면 생략하면 안된다.

2012년 10월 15일 월요일

반드시 알아야 할 8 gdb tricks

https://blogs.oracle.com/ksplice/entry/8_gdb_tricks_you_should

위 글의 내용을 알아보기 편하게 정리 함.

1. break WHERE if COND
  "if COND"를 추가로 덧붙여서 특정 조건일 때 break를 걸 수 있다. loop안에 걸거나 특별한 케이스에 재현되는 버그를 잡을 때 쓰기 좋겠다.

2. command
  break point를 잡은 후에 "command 1"과 같이 break point에 올 때마다 실행되는 command를 추가할 수 있다. 디버그 정보 프린트 할 때 쓰면 컴파일할 필요없이 원하는 정보를 break point에 올 때 마다 볼 수 있다.
  (의문) if COND가 추가된 경우면 COND를 만족하는 경우만 실행되려나? --> 테스트 필요.

3. gdb --args
  gdb 옵션에 "--args"를 쓰고 바이너리 -> argument 순서로 넣고 실행하면 된다. gdb 바이너리 한 다음에 gdb shell에서 "set args ..." 하는 것 보다는 반복 수행하기 훨 편하겠다.

4. source 파일 위치 지정
  1) directory [source_path]
    bin안에 있는 symbol의 path가 relative인 경우, 이렇게 하면 알아서 찾아준다.
  2) set substitute-path [path_in_bin] [path_to_sources]
    bin의 symbol이 absolute인 경우, 이렇게 하면 알아서 path앞부분을 substitute해서 찾아준다.

5. macro도 gdb에서 챙겨가면서 써 보자.
  빌드 옵션에 -ggdb3 를 추가하면 macro도 gdb에서 보면서 처리할 수 있다.

6. gdb variable
  set $varname = 4
  이런 형태로 gdb variable을 설정할 수 있다. if COND에 들어갈 COND를 만들어 두면 쉽게 써먹을 수 있다. 복잡한 expression은 적절히 variable로 만들면 되겠다.

7. Register variable
  $sp, $pi, $rsi 와 같이 architecture마다 존재하는 register는 predefined variable로 들어있다. if COND에 포함해서 사용할 수 있다.

8. 'x' command
  'x' command로 특정 메모리에 있는 내용을 특정 포맷으로 출력할 수 있다.
  x/FMT ADDRESS
  FMT는 종류가 많으니 'help x'로 풀 리스트를 확인하자. 쓸만한건 여기다 리스트업 한다.
    x : hex
    d : signed decimal
    c : character
    i : instruction
    s : C style string
  (Example : gdb shell)
  $x/s 0xffffffff0089ffae
  ...

Android emulator gdbserver 설정

http://jovechia.blogspot.kr/2009/04/how-to-use-gdbserver-on-android.html

덧붙임)
  1. gdbserver는 사용하고 있는 NDK toolchain에 prebuild되어 있는 녀석을 넣으면 된다.
  2. gdbserver옵션이 android emulator에 기본 탑재된 녀석과 다를 수 있으므로 확인하고 사용한다.

2012년 9월 25일 화요일

tmux 사용법

http://blog.outsider.ne.kr/trackback/699

*추가

다른 terminal로 연결한 경우, 다음과 같이 가장 최근의 session에 연결할 수 있다.

$tmux attach-session

tmux에서 연결된 세션을 끊고 client를 종료하려면

{bind-key} d

Ctrl+B를 이미 다른 용도로 사용하고 있는 경우라면 $HOME/.tmux.conf 파일에 다음과 같이 Ctrl+A로 변경해둔다.

set-option -g prefix C-a

2012년 2월 6일 월요일

Linux time utility

특정 process의 수행시간을 측정하는 utility : time

간단하게 time뒤에 process를 실행하는 command를 넣으면 된다.


$ time tar -zcf some_tar_ball.tar.gz

2011년 10월 6일 목요일

ssh client에 있는 Xserver를 DISPLAY에 설정하기

ssh접속하는 경우에, DISPLAY를 자동으로 설정하게 하여서 추가적인 작업없이 Xserver를 바로 사용할 수 있게 하는 script. .bash_profile에 넣어두면 된다.

export DISPLAY=`echo $SSH_CLIENT |cut -d ' ' -f 1`:0.0

This bash script set "DISPLAY" environment variable automatically with your ssh client IP address. Put this line in ".bash_profile" if you want to run this whenever you login with ssh connection.

2011년 10월 5일 수요일

Eclipse Helios + CDT에서 tab as space설정

Window ->Preferences -> C/C++ -> Code Style
Profile에 있는 Edit...버튼
Profile name변경
Indentation탭 -> General settings에 있는 Tab policy에서 Spaces only선택


Open Window -> Preferences -> C/C++ -> Code Style dialog
Press "Edit..." button at the right of profile.
Edit profile name
Indentation tab -> General settings -> Tab policy : Select "Spaces only"


2011년 7월 28일 목요일

vim search pattern tips

1. regex 중 matching pattern reuse
  1) %s/abcd\(.*\)z/aaaa\1a/g
    --> "abcd"로 시작해서 "z"로 끝나는 문자열을 "aaaa"로 시작해서 "a"로 끝나는 문자열로 바꾼다.
    --> 예) abcd1234z --> aaaa1234a, abcdefghi..z --> aaaaefghi..a
  2) %s/abcd\(.*{1,10}\)123\(.*\)0/1234\1abc\2z/g
    --> "abcd*123*0" 형태의 문자열을 "1234*abc*z"형태로 바꾼다.
    --> 예) abcdefg1234560 --> 1234efgabc456z

2011년 7월 12일 화요일

bash : 특정 process status 표시하기

한줄 command로 특정 process status를 표시하는 방법.

$ ps -ef |grep [process_bin] |grep -v grep \
|cut -d ' ' -f 2 |xargs -i cat /proc/{}/status

* cut 명령어 부분은 ps -ef의 표시 방법에 따라서 적절하게 변경해야 한다.
* grep명령어 부분은 grep [P]rocess_bin 과 같이 "[]"를 이용해서 하나로 쓸 수 있다.

ps | grep 사용하면서 grep process표시하지 않도록 하기

http://www.cyberciti.biz/tips/grepping-ps-output-without-getting-grep.html

example)
$ ps -ef |grep [L]libraryLauncher

2011년 6월 20일 월요일

2011년 5월 16일 월요일

git for survival #2

1. Clone a specific branch(s)
$ git init
$ git remote add -t [branch0] -t [branch1] ... [remote_name] [git_url]
$ git fetch
$ git checkout -b [local_branch_name] [remote_name]/[remote_branch]

2011년 4월 29일 금요일

Print out template class info in C++

Use __PRETTY_FUNCTION__ in any where you want to print out.

template <class T>
class MyClass {
public:
  MyClass() { cout << __PRETTY_FUNCTION__ << endl; }
};


MyClass<int> myInstance;
...

This code will print out :


MyClass<T>::MyClass() [with T = int]

2011년 3월 31일 목요일

switch between vi and shell

in vi : Ctrl+z
--> shell
--> type 'fg'
in vi : again

linux time print out in C

format : YYYY-MM-DD HH:mm:ss:ms

#include <time.h>
#include <sys/time.h>


...



struct timeval tv;
struct tm *lt;
gettimeofday(&tv, 0);
lt = localtime(&(tv.tv_sec));
fprintf(stderr, " >> %4d-%02d-%02d %02d:%02d:%02d.%03d \n", 1900 + lt->tm_year, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, int(tv.tv_usec/1000.));

2011년 3월 28일 월요일

sed for survival

1. What is sed?
  1) stream editor
    (1) input --(edited)--> output

2. Essential command
  1) s : substitution
    (1) 4 parts of command
      a. s : command
      b. /../../ : delimiter
      c. ^fjdkal : regular expression pattern search pattern
      d. fdjj : replacement string
    (2) Use '/' as a delimiter
      a. '\' : sed 's\/user\/local\/bin/common\/bin' <old >new
      b. '_' : sed 's_/user_/local_/bin_/common_/bin' <old >new
      c. ':' : sed 's:/user:/local:/bin/common:/bin' <old >new
      d. '|' : sed 's|/user/local/bin|common/bin' <old > new
    (3) Use '&' as matched string
      a. add parenthesis to a pattern : sed 's/abc/(&)/' <old <new
        - '&' means pattern, in this command, "abc"

  2) '-e' command
    (1) Combines multiple commands into a single process.

  3) Substitute flags
    (1) /g : global replacement, as in vi

3. Others
  1) File names
    (1) any argument that doesn't start with sed option, it is the file name.

  2) -f : use sed command file
    (1) sed -f sedcommands <old >new

  3) '\' : to divide sed command into multiple lines.

  4) Bourne shall(bash) quote : using ' to quote commands in multiple lines.

  5) Restricting to a line number
    (1) by number : sed '3 s/[0-9][0-9]*//' <old <new
      a. remove the first number in the 3rd line.
    (2) by pattern : sed '/^#/ s/[0-9][0-9]*//' <old <new
      a. remove the first number which is starting with '#'.

Regular expression for survival

0. A truth for the regular expression
  Regular expression is used to matching pattern in a line. (Not laid on multiple lines.)

1. The Structure of a regular expression
  1) Anchors
    (1) ^ : begin of a line
    (2) $ : end of a line
    (3) \< ... \> : word level matching.

  2) Character sets
    (1) . : any char except the EOL char.
    (2) [...] : any char in brackets.
      a. range : [a-z], [0-9], [A-Za-z0-9_]
      b. order : "^T[a-z][aeiou] " : Tha, The, Thi, ...
    (3) [^...] : negate pattern. except chars in brackets.
    (4) \( ... \) : remembered pattern. use it with "\1 ~ \9"

  3) Modifiers : follows a character set. if not, not a modifier.
    (1) * : 0 or more copies
    (2) {a,b} : # of copies between a and b.

2010년 12월 20일 월요일

git color 설정 (by leesangho)

$ git config --global color.ui "auto"

This command let 'git status' show more colorful text.