2009年8月26日 星期三

Linux debug by using strace

We can use strace to find which libraries are used of the specified program.
Another point is that you can find which configure file was opened by the specified program. Does the specified program open the wrong configuration files not as you expected?

# strace ./myprog -l 1234 -d 4
execve("./tsa", ["./myprog", "-l", "1234", "-d", "4"], [/* 53 vars */]) = 0
brk(0) = 0x9adb000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=108397, ...}) = 0
mmap2(NULL, 108397, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f7e000
close(3) = 0
open("/lib/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \30l\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=131528, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f7d000
mmap2(0x6bd000, 98784, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x6bd000
mmap2(0x6d2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14) = 0x6d2000
mmap2(0x6d4000, 4576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x6d4000
close(3) = 0
open("/lib/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\344h\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=210324, ...}) = 0
mmap2(0x68b000, 163952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x68b000
mmap2(0x6b2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26) = 0x6b2000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3

2009年8月24日 星期一

讓我們一起飛吧 張茂松 2008-06-08 賽40: 27~31

1. 因為沒有翅膀, 所以不能飛 (基督徒才有翅膀)
基督徒有
a. 禱告的翅膀
b. 信心的翅膀
c. 屬天的翅膀 (支取上帝的祝福)
d. 屬靈的翅膀
2. 跟雞在一起, 不知道可以飛
3. 因為從來沒用過翅膀, 所以不會飛
4. 因為害怕, 所以不敢飛
5. 因為沒願景, 就隨便飛
6. 沒熱情就懶的飛
7. 因為不在靈風中, 就靠自己飛

2009年8月13日 星期四

匈牙利命名法 (For reference)

匈牙利命名法
變數名稱 = 屬性+類型+描述
屬性
" g_ 全域變數
" c_ 常數
" m_ 成員變數
類型
" n/ui int/unsigned int
" l/ ul long/unsigned long
" sh/us short/unsigned short
" f float
" d double
" ld long double
" ch char
" b boolean
" p pointer
" h handle
" str String
" w/dw WORD/DWORD
" b byte/unsigned char
" bl BOOL
描述
" Custom 自訂
" Src 來源
" Dst 目的
" Tmp 暫時

Other Reference:

Prefix

Data Type

Prefix

Data Type

c

char, TCHAR

bt

TBYTE, BYTE,

uc

UCHAR



s

short

us

USHORT

w

WORD

n

int, INT

u

UINT

l

LONG, long

dw

DWORD

ul

ULONG

fl

float

db

double

b

BOOL

f

bitwise flag fields

sz

ANSI string, terminated with a \0 character.

psz

PSTR

h

HANDLE

hmem

HGLOBAL, HLOCAL

hwnd

HWND

hfile

HFILE

hdc

HDC

hpen

HPEN

hfont

HFONT

hbmp

HBITMAP

hpal

HPALETTE

hmenu

HMENU

hicon

HICON

hinst

HINSTANCE

hcur

HCURSOR

hbr

HBRUSH

pt

POINT

rc

RECT

tm

TEXTMETRIC

lf

LOGFONT

bmp

BITMAPINFO

pal

PALETTEENTRY

cls

WNDCLASS

msg

MSG

rgb

RGBQUAD

clr

COLORREF

of

OFSTRUCT

ps

PAINTSTRUCT

cb

count of bytes

cx, cy

length in pixels

p

added for pointer to any type, e.g., ps, pdw, phicon, pof, ..., etc.

a

added for array of any type, e.g., as, adw, auc, ...

C

a big C in front of all C++ class names, the rest of the class name is a mix of big and small letters

m_

added in front of all C++ class member variables.

str

string



st

structure




2009年8月3日 星期一

張茂松牧師 - 打造一個精品、塑造一個達人

新店行道會張茂松牧師 - 打造一個精品、塑造一個達人
1. 熟記
2. 思想
3. 禱告
4. 遵行

讀聖經時, 常常問為什麼?

如何預備被祝福?(汝矣島純福音教會主任牧師趙鏞基妻子 金聖惠總長)
1. 正向思考
2. 有異象, 異夢
3. 盡力去做
4. 倚靠聖靈