본문 바로가기

Code

개발하기 좋은 Font http://www.dafont.com/bitstream-vera-mono.font http://m.blog.naver.com/inningga/130092388628 더보기
빠르게 랜덤변수 발생시키기 int g_seed;int fastrand() { g_seed = (214013 * g_seed + 2531011);return (g_seed >> 16) & 0x7FFF;} 기존에는 아래와 같은 방식으로 랜덤 변수를 생성하였었다.time_t seconds;time(&seconds);srand((unsigned int)seconds);//srand((unsigned)time(0));v0 = rand() % 10; 하지만 이 방식은 초당으로 seed 가 변해서 그런지, 랜덤숫자가 빠르게 변하지 않는 단점이 있다. 이 대신에 fastrand 를 사용하면, 빠른 속도로 랜덤한 변수를 얻을 수 있다. 더보기
Get(다운로드) android L-preview source code. 구글이 android L-preview 에 대한 source code branch 를 공개하였습니다.이 포스팅에서는 L-preview 를 포함한 google android source code 다운받는 법을 한글로 간단히 기술하겠습니다. 다만, 아직 L-preview 의 source code 는 완전하지 않은것으로 보입니다.구글이 공개한 Nexus5 의 바이너리에서는 SQLite 가 3.7.14 버전이었던데 비해아직 git 에서 받은 소스코드에는 이전 버전인 3.7.11 이 올라와 있습니다. https://android.googlesource.com/platform/manifest 사이트에 접속하면 많은 브랜치 명들을 볼 수 있습니다. 왼쪽에 more 를 누르고 나오는 branch 명 중에서 원하는 것을.. 더보기
[gdb] handle gdb error "single stepping until exit ... from function which has no line number information" I meet gdb error.GDB print this error instead of print current line of source code.GDB 를 사용하는 중 소스코드가 안보이고 아래와 같은 애러가 발생하였습니다. single stepping until exit ... from function which has no line number information so I introduce a cool solution to you.이것에 대한 해법을 적어보도록 하겠습니다. I already add '-g' option on my Makefile. and I add '-ggdb -O0' option regarding googleing result. but main cause is GDB versio.. 더보기
poll, sysfs sample code poll 사용 예제 man page 에는 poll_wait 가 대기를 시켜준다고 하는데..아무리 사용해 봐도 poll_wait 는 대기를 하지 않고 바로 return 처리된다. 이에 wait_event_interruptible 을 사용 하였다. 주문한 책이 오면 poll_wait 에 대해 좀 더 읽어 본 후 재업하도록 하겠다. DECLARE_WAIT_QUEUE_HEAD(wait_queue); unsigned int onegun_driver_poll(struct file *file, poll_table * wait){printk("%s()++\n", __func__);//poll_wait(file, &wait_queue, wait); /* normal case */if (wait_event_interrup.. 더보기
linux - t32 로 code 영역 dump 뜨기 코드영역을 비교해 보려고 다음과 같이 덤프를 떳는데 한참 작은 size 만 덤프가 되었다. data.save.binary "D:\c_expat_code_2.dat" 0x40031000++0x1d000 다시한번 시도해 보니 bus 애러가 난다. 이유인 즉슨... linux 는 4kb 단위로 demanding page 를 한다. 따라서 hit 가 되지 않은 code 영역은 ram 상에 없고, map 되어 있지 않으므로 애러가 나고 덤프되던 영역까지만 저장이 되는 것이다. 코드 영역이 40031000-4004e000 r-xp 00000000 b3:02 25236034 /mnt/data/factoryfs/lib/libexpat.so.1.5.0 이정도 크기라면, 해당 영역을 뒤져가며 다 dump 를 떠야지만 co.. 더보기
objdump - 실행파일에서 asm code 확인 objdump 의 여러 기능이 있지만 다음과 같은 기능이 있습니다. 바로 실행 파일에서 sam code 를 바로 확인해 볼 수 있는거지요. 옵션을 보면 source 와 매칭을 시킬 수도 있을것 같은데 좀 더 익숙해 지면 업데이트 하겠습니다. >objdump -d a.out | grep -A10 '' 08052cbc : 8052cbc: 0d c0 a0 e1 30 or $0x30e1a0c0,%eax 8052cc1: d8 2d e9 04 b0 4c fsubrs 0x4cb004e9 8052cc7: e2 38 loop 8052d01 8052cc9: 30 90 e5 00 40 a0 xor %dl,0xa04000e5(%eax) 8052ccf: e1 00 loope 8052cd1 8052cd1: 00 53 e3 add.. 더보기