windows 디버거 사용하기
DESCRIPTION
Windows 디버거 사용하기. 그대가 있기에 외롭지 않아 !. Advanced Windows Debugging Chapter.2 2008.06.16 안준석. 개 요. 디버거의 역할과 활용에 대해 알아본다 . 디버거의 기능을 완전하게 사용하기 위한 환경 설정법을 익힌다 . 기본적인 디버거 명령어를 공부하고 어떤 작업을 할 수 있는지 알아본다. 디버거 살짝 맛 보기 !. 순 서. 아하 ! 디버거 ! Prerequisite Debugger Basic - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/1.jpg)
Windows 디버거 사용하기
Advanced Windows Debugging Chapter.2<NHN 게임서비스플래폼팀 >
2008.06.16 안준석
그대가 있기에 외롭지 않아 !
![Page 2: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/2.jpg)
개요• 디버거의 역할과 활용에 대해 알아본다 .
• 디버거의 기능을 완전하게 사용하기 위한 환경 설정법을 익힌다 .
• 기본적인 디버거 명령어를 공부하고 어떤 작업을 할 수 있는지 알아본다 .
디버거 살짝 맛 보기 !
![Page 3: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/3.jpg)
순서• 아하 ! 디버거 !• Prerequisite• Debugger Basic• Basic Debugger Tasks• Remote Debugging• 마무리
![Page 4: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/4.jpg)
아하 ! 디버거 !디버거는 내 친구
디버거 사용 메타포
![Page 5: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/5.jpg)
• 디버거는 내 친구• 삽질 할 때 옆에
있어주지요 ..
디버거는 내 친구 ?
• 디버거는 내 친구• 가끔 구렁텅이에
빠뜨리기도 하지요 ..
왜 !
![Page 6: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/6.jpg)
출시 전 디버깅
• 프로그램 작동 시나리오 예상• 브레이크 포인트 설정• 호출 스택 (Call Stack) 확인• 변수 값 확인 (Watch)
![Page 7: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/7.jpg)
출시 그리고 디버깅• 버전이 안 맞아요• 윈도우 ME 에서 안되요• 모르겠어요 안되요 안되 !
가벼운 Exe• 파
일 크기
• 보안
분리 된
심볼과
소스
부작용 ? 해결책 ?
잘 설정한 디버거가 약이죠 !
• 저 버전의 심볼이 필요해 !• 저 버전의 소스가 필요해 !• OS 도 똑같이 !
![Page 8: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/8.jpg)
디버거 설정
문제 탐색
상태 고치기
디버거 사용 메타포
심볼과 소스 경로
함수 , 파라미터 ,변수
스택 그리고 레지스터
![Page 9: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/9.jpg)
Prerequisite프로시저와 스택
복귀 주소로컬 변수파라미터
※ 이번 섹션의 예제 대부분은 『 Windows 구조와 원리 :OS 를 관통하는 프로그래밍의 원리 2th - 정덕영』
에서 발췌 됐습니다 .
![Page 10: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/10.jpg)
LOCAL 변수
프로시저와 스택
이전의 EBP
복귀 주소
파라미터 #1
파라미터 #2
힙은 위로스택은 아래로
높은 주소
낮은 주소
현재 EBP
EBP + 0x04
EBP + 0x08
EBP + 0x0C
EBP - xx
![Page 11: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/11.jpg)
main(){
A();
}
int A(){
B();
}
int B(){
}
스택과 복귀 주소
B() 복귀주소
A() 복귀주소
main() 복귀주소
현재 ESP
![Page 12: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/12.jpg)
main(){
int local1;
A();}
A(){
int local2;
}
스택과 로컬 변수
local2
A() 복귀주소
local1
main() 복귀주소
현재 ESP
![Page 13: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/13.jpg)
main(){
sum(1, 2)}
int sum(int a, int b){
return a + b;}
스택과 파라미터
main:push 2push 1call sum
sum :…
스택에 데이터가 Push
되면 ?
ESP 만으로는 역부족 !
![Page 14: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/14.jpg)
스택 프레임
eax
이전의 EBP
sum() 복귀주소
1
2
main() 복귀주소 main(){
sum(1, 2)}
int sum(int a, int b){
return a + b;}
EBP
EBP – 0x04
EBP + 0x10
EBP + 0x08
EBP + 0x0C
EBP + 0x04
![Page 15: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/15.jpg)
Debugger Basic분류
명령어설정
리다이렉션
![Page 16: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/16.jpg)
분류• User Mode– 단일 유저 모드 프로세스 대상– Cdb.exe, ntsd.exe, windbg.exe
• Kernel Mode– 시스템 전체 대상– Kd.exe, windbg.exe
![Page 17: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/17.jpg)
명령어• Built-in Commands– kP
• Meta Commands– .help
• Extension Commands– !teb, !thread
![Page 18: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/18.jpg)
사용 설정• User Mode Debugger– 완벽한 동작을 위해 두 가지 필요
• 타겟 이미지와 연관 된 심볼
• Kernel Mode Debugger– 두 대의 컴퓨터– OS 버전이 달라도 된다– OS 에 기능이 통합되어 있다– Boot.ini 에서 설정 !
![Page 19: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/19.jpg)
리다이렉션
User Mode
Kernel Mode
![Page 20: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/20.jpg)
Basic Debugger Tasks
설정명령어
예
![Page 21: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/21.jpg)
디버거 설정
문제 탐색
상태 고치기
디버거 사용하기
![Page 22: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/22.jpg)
설정
Symbol Source
![Page 23: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/23.jpg)
심볼 설정• Symbol• Symbol Path• Symbol Server• Symbol Cache• Reloading the Symbols• Validating Symbols• Using Symbols
우리 팀도 심볼 서버 만들죠 !
![Page 24: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/24.jpg)
소스 설정• Source
![Page 25: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/25.jpg)
명령어• Exploratory Commands
• Other Exploratory Commands
• Context-Changing Commands
찾아서
탐색과 고치기 명령 !
고친다 !
![Page 26: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/26.jpg)
Exploratory Commands
• Why Did the Debugger Stop?
• What Is the Target System?
• What are the Current Register Values?
• What Code Is the Processor Executing Now?
• What Is the Current Call Stack?
• Setting a Code Breakpoint
• What Are the Variable Values?
• How Do You Inspect Memory?
• Setting a Breakpoint on Access
• What does That memory Location Contain?
명령어는 책에서 !
![Page 27: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/27.jpg)
Context-Changing Commands
• Tracing Code Execution• Stepping Over a Function Execution• Continuing Code Execution• Tracing and Watching a Function Execution• Changing the Context
![Page 28: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/28.jpg)
Remote DebuggingOverview
![Page 29: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/29.jpg)
마무리Reference
![Page 30: Windows 디버거 사용하기](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568131d9550346895d983e90/html5/thumbnails/30.jpg)
Reference
• Advanced Windows Debugging p.29~p.121
• Windows 구조와 원리 2th• 뇌를 자극하는 윈도우 시스템 프로그래밍• Advanced Windows Programming
4th