[[TableOfContents]] == 일반 == === 명령 === ==== Commands (Windows Debuggers) MSDN ==== http://msdn.microsoft.com/en-us/library/windows/hardware/ff539170(v=vs.85).aspx ==== 주요 명령 ==== {{{#!folding 펼치기 attachment:WinDbg/140812_02.png }}} ==== 자주 사용하는 명령 ==== * Thread 관련 * ~ : thread 목록 보기 * ~#s: #번째 thread로 focus(?) 변경 * ~#k: #번째 thread의 스택 상황 보기 * Breakpoint 관련 * bu: 심볼에 breakpoint 설정 -- bu module!symbol name * ex) bu USER32!MessageBoxW * bl: 설정된 브레이크포인트 목록 보기 * bc: 주어진 번호(bl로 봤을때..)의 브레이크포인트를 제거 * ba: address에 breakpoint 걸기 -- ba Access Size [Address] * ex) ba e1 0xXXXXXXXX -> e는 execute이고 e일때 Size는 반드시 1이어야 함. * Disassemble 관련 * uf: symbol을 disassemble * ex) uf win!WndProc+0x19b * u: address를 disassemble * ex) u 0xXXXXXX [L(-)#] -- #만큼 이후(이전) 코드 disassemble * Memory 관련 * du: unicode 문자열 * da: ASCII 문자열 * Symbols 관련 * lm: 현재 로드된 심볼의 목록 * lmvm: 특정 모듈 자세히 보기 * ex) lmvm mydll * ld, .reload: 심볼 load/unload관련 * ex) ld ntdll * x: 심볼 목록 보기 * ex) x USER32!Message* -- Message로 시작되는 User32의 모든 심볼 목록 보기 * Debugging 관련 * k: 현재 스레드의 callstack 보기 * kf: 현재 스레드의 callstack 과 커널 스택 사용량 보기 * r: 현재 스레드의 register상태 보기 ==== 기타 명령 ==== * .tlist: 현재 실행중인 모든 프로세스를 출력. -v 자세히. === 심볼 설정 === - MS 기호 서버 경로 [[code(http://msdl.microsoft.com/download/symbols)]] - 웹 심볼 [[code(SRV*로컬저장위치*URL)]] - 추가 경로는 [[code(;)]] 로 구분 - [[code(.pd_)]] 와 같이 compressing된 심볼 파일 경로는 로컬 위치도 [[code(SRV*)]]를 사용한다. - 닷넷 프레임 워크 [[code(.ni.dll)]] 기호가 없을 때: [https://docs.microsoft.com/en-us/dotnet/framework/tools/ngen-exe-native-image-generator Ngen.exe (Native Image Generator)]을 이해해야 한다. [[code(processor-specific machine code)]] 를 기억하면 된다. [https://blogs.msdn.microsoft.com/devops/2012/12/10/creating-ngen-pdbs-for-profiling-reports/] 심볼 설정 예 {{{ SRV*D:\ossymbols*http://msdl.microsoft.com/download/symbols;SRV*D:\mysymbolserver;D:\mysymbols }}} .reload === 디버거 연결 변경 === attachment:140812.PNG {{| HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug |}} ||Name||Type||Data|| ||Auto||REG_SZ||1 / 0|| ||Debugger||REG_SZ||"C:\Program Files (x86)\Debugging Tools for Windows\windbg.exe" -p %ld %e -%ld -g|| -p %ld: 크래시 난 프로세스의 PID -e %ld: 크래시가 발생되어 처리할 디버그 이벤트 -g: 디버거가 실행되는 순간 대기 없이 계속 디버기를 수행할 것 == 기타 == === ["윈도우 커널 패닉 유형 Minidump"] === === 좀 더 간단한 디버거 DbgDiag === [http://www.microsoft.com/en-us/download/details.aspx?id=49924 DbgDiag from Microsoft] WinDbg 수준에는 미치지 못하지만 간단한 덤프 디버깅 분석 도구. 복잡한 설정이 필요없기 때문에 비 개발자나 End User 대상일 때 유용할 수 있다. 문제를 파악 할 수 있는 수준에서 일반적인 오류 분석이 가능하나 더 정확한 분석은 WinDbg가 필요할 수 있음. Quick Start * Launch the "DebugDiag Analysis" application * Select the "CrashHangAnalysis" checkbox on the main page * Drag-and-drop your dump into the "Data files" pane on the main page * Click "Start Analysis" ---- CategoryDev