2015년 11월 14일 토요일

spelling checker

LANG=C aspell -c <file>

2015년 11월 10일 화요일

gdbserver

gdbserver 실행 (Target)
# gdbserver --attach :5039 <PID>
Attached; pid = 7148
Listening on port 5039
 
 또는
 
# gdbserver :5039 <BINARY PATH>
Process xxx created; pid = 6232
Listening on port 5039
 
 
gdb 실행 (Host)
$ gdb-multiarch
(gdb) set arch arm
(gdb) file <BINARY PATH>
(gdb) target remote [gdbserver ip]:5039
 
 
참고
https://sourceware.org/gdb/wiki/BuildingCrossGDBandGDBserver

gdb

  • 심볼파일 로드
(gdb) symbol-file 


  • 사용 가능한 명령어 리스트
(gdb) <tab><tab>
(gdb) 명령 <tab><tab>
  • 콜스택
(gdb) bt
(gdb) i s
  • 레지스터 보기
(gdb) i r
(gdb) i r pc
(gdb) p/x $pc
(gdb) set $sp += 4 
  • 변수 값 보기
(gdb) p 변수
(gdb) x 변수
  • 포인터 대상 출력
(gdb) p {구조체 또는 클래스}어드레스
(gdb) p *(구조체 또는 클래스*)어드레스
(gdb) p *this
  • 구조체 또는 클래스의 크기 구하기
(gdb) p sizeof(구조체 또는 클래스)

  • 메모리맵
(gdb) i files
$ cat /proc/<pid>/maps

  • print 출력 길이 제한
(gdb) set print elements 숫자

  • print format
(gdb) set print pretty on


  • print 옵션
(gdb) show print [항목]
(gdb) set print 항목 값

  • 배열 P 에서 N개의 요소를 출력
(gdb) p P@N

  • myVector 의 배열 주소
myVector._M_impl._M_start

  • 로칼 변수
(gdb) i lo
  • 타입 보기
(gdb) i ty

함수 정의 보기
(gdb) i fu

변수 보기
(gdb) i va


스택 프레임 정보
(gdb) i f
(gdb) fr [번호]

줄 정보
(gdb) i li

소스 리스트 보기
(gdb) i sources

공유라이브러리 보기
(gdb) i sh

시그널 핸들 상태
(gdb) i h


실행 옵션
빌드 옵션 확인
-configuration

-nx 설정파일 실행 안 함

부트시퀀스
  1. -interpreter 옵션 처리.
  2. 시스템 설정 파일 실행(/etc/gdb/gdbinit)
  3. 사용자 설정 파일 실행(~/.gdbinit)
  4. -iex 및 -ix 옵션을 순서대로 실행
  5. -ex 와 -x 를 제외한나머지 옵션 실행
  6. 현재 디렉토리의 설정 파일 실행(./.gdbinit) (set auto-load local-gdbinit on 필요)
  7. auto-load
    Disable auto-load $ gdb -iex "set auto-load python-scripts off" myprogram
  8. -ex 및 -x 옵션을 순서대로 처리
  9. command history 로드
참고
https://sourceware.org/gdb/onlinedocs/gdb/index.html
https://sourceware.org/gdb/wiki/BuildingCrossGDBandGDBserver

arm 레지스터 이름

r9, sb, static base r10, sl, stack limit
r11, fp, frame pointer
r12, ip, intra-procedure call scratch register
r13, sp, stack pointer
r14, lr, link register
r15, pc, program counter

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/ch06s02s01.html

2015년 10월 29일 목요일

~/.ssh/config

# Command line
$ ssh <유저명>@HostName -p <포트 번호> -i <비밀키의 풀패스>
 
== 
 
# ~/.ssh/config
Host <별명>  
HostName <IP Address or Host name>
Port <포트 번호>
User <유저명>
IdentityFile <비밀키의 풀패스>


참고
https://dobest.io/ssh-without-password/

Install libnfc on ubuntu 12.04

Ubuntu 12.04 LTS

$ sudo apt-get install dh-autoreconf libusb-0.1-4 libusb-dev

$ git clone https://github.com/nfc-tools/libnfc.git
$ cd libnfc
$ git checkout libnfc-1.7.1
$ git clean -d -f -x
$ git remote|grep -q anonscm||git remote add anonscm git://anonscm.debian.org/collab-maint/libnfc.git
$ git fetch anonscm
$ git checkout remotes/anonscm/master debian
$ git reset
$ dpkg-buildpackage -uc -us -b

$ sudo dpkg -i ../libnfc*.deb
 
 
 
 
Problem 
--------------------------------------------------------------------------------
$ sudo nfc-list
nfc-list uses libnfc libnfc-1.7.1-12-gb978c45
error   libnfc.driver.pn53x_usb Unable to set USB configuration (Device or resource busy)
No NFC device found.

 
$ dmesg | tail
[1400911.505643] usb 2-1.4: new full-speed USB device number 7 using ehci-pci
[1400911.637956] usb 2-1.4: New USB device found, idVendor=04e6, idProduct=5591
[1400911.637961] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[1400911.637964] usb 2-1.4: Product: SCL3711-NFC&RW
[1400911.637967] usb 2-1.4: Manufacturer: SCM Micro
[1400911.641239] pn533 2-1.4:1.0: NFC: NXP PN533 firmware ver 2.7 now attached
[1401061.395200] usb 2-1.4: usbfs: interface 0 claimed by pn533 while 'nfc-list' sets config #1

--------------------------------------------------------------------------------

Solution
--------------------------------------------------------------------------------

restart or unplug the device, unload modules (sudo modprobe -r pn533 nfc), then re-plug the device.
 
$ nfc-list
nfc-list uses libnfc libnfc-1.7.1-12-gb978c45
error   libnfc.driver.pn53x_usb Unable to set USB configuration (Operation not permitted)
No NFC device found.

$ sudo nfc-list
nfc-list uses libnfc libnfc-1.7.1-12-gb978c45
NFC device: SCM Micro / SCL3711-NFC&RW opened
-------------------------------------------------------------------------------- 
 
참고
http://nfc-tools.org/index.php?title=Libnfc#Debian_.2F_Ubuntu
http://forums.nfc-tools.org/topic/668/solved-scl3711-interface-0-claimed-by-pn533-nfclist-sets-conf/

2015년 10월 20일 화요일

thread id

NAME
       pthread_self - 호출하는 쓰레드의 ID 획득

SYNOPSIS
       #include <pthread.h>

       pthread_t pthread_self(void);

       컴파일 및 링크시 -pthread 옵션을 추가해야 함.

DESCRIPTION
       The  pthread_self() function returns the ID of the calling thread.  This is the same value that is returned in
       *thread in the pthread_create(3) call that created this thread.

RETURN VALUE
       이 함수는 항상 성공하며, 호출하는 쓰레드의 ID를 반환한다.