버그 잡이/리눅스 코어 파일 분석 가이드 3

메모리 alignment

요약 : 구조체의 메모리 크기는 구조체 변수의 최대 자료형의 크기를 기준으로정렬된다 http://ikpil.com/359 자료 구조 순서에 따라 바뀌는 구조체 메모리 크기다음 블로그에 설명 잘되어 있음 요약 : 메모리 할당후 빈공간에 연속적으로 메모리 할당이 가능하냐 않하냐에 따라 메모리 할당 크기가 변하게 된다. 상세 내용은 다음 링크를 참조 구조체 메모리 저장방식 #pragma pack

gdb에서 메모리 덤프

gdb에서 메모리 덤프 뜨기 [메모리 덤프]dump memory ./dump_file 0x1003033 0x2040204명령어 설명: - 명령어 : dump - 매개 변수: memory - 결과 파일 : ./dump_file - 덤프 시작 주소 : 0x1003033 - 덤프 끝 주소 : 0x2040204 결과 : 현재 디렉토리에 ./dump_file이란 파일로 0x1003033을 시작으로 0x2040204 까지의 메모리 내용디 덤프 떠진다. 관련되서 유용한 정보 [프로세스와 맵핑된 메모리 정보]/proc/pid/maps[root@localhost]# cat /proc/`pidof crond`/maps7fb0b3d33000-7fb0b3d3e000 r-xp 00000000 08:01 38102 /lib64/..

dmesg의 Segfault 분석 방법

dmesg의 Segfault Error 분석 방법$ dmesg foo[1234]: segfault at 2a ip 0000000000400511 sp 00007fffe00a3260 error 4 in foo[400000+1000] These are some hints in dmesg output:foo is the executable name1234 is the process ID2a is the faulty address in hexadecimalthe value after ip is the instruction pointerthe value after sp is the stack pointererror 4 is an error codethe string at the end is the name of ..