본문 바로가기

@@나도이것저것또는머리아팠는데문제해결

Windbg 명령어

자주 쓰는 일반 명령어
r : 레지스터 상태 보기 / 변경
d : 메모리 내용 보기
e : 메모리 내용 변경
bp : 브레이크 포인트 걸기
p, t : 브레이크 포인트가 걸린 다음 명령들을 한 줄씩 수행
대표적 일반 명령어
A(Assemble), U(Unassemble)
BL(Breakpoint List), BC(Breakpoint Clear)
BD(Breakpoint Disable), BE(Breakpoint Enable)
BA(Break on Access)
BP, BU(Set Breakpoint)
D, DA, DB, DW, DD(Display Memory)
Dds(Display Words and Symbols)
DL(Display Linked List) LIST_ENTRY or SINGLE_LIST_ ...
DS, Ds(Display String)
DT(Display Type)
DV(Display Local Variable)
K, KB, KD, KP, KV (Display Stack Backtrace

E, EA, EB, Ed, EW, EU (Enter Values)
S(Search Memory)
R(Register)
LD(Load Symbol)
LM(List Loaded Symbols)
LN(List Nearest Symbols)
G(Go), P(Step), PC(Step to Next Call)
T(Trace), TB(Trace to Next Branch), TC(Trace to Next Call)
WT(Trace and Watch Data)


2. 메타 명령 (대부분 디버거 자체를 제어) (.으로 시작)

자주 쓰는 명령어
.attach : WinDbg를 특정 프로세스에 붙여서 그 프로세스를 디버깅할 때 사용
.cls : WinDbg 명령 창에 출력된 모든 내용을 지우기
.sympath : 현재 WinDbg에 설정된 심볼 경로 확인 / 설정
.reload : 심볼 경로를 설정한 후에 WinDbg가 심볼을 다시 로드하게 하기
대표적 메타 명령어
.bugcheck (Display Bug Check Data)
.cls (Clear Screen)
.ofilter (Filter Target Output)
.enable_unicode (Enable Unicode Display)
.crash (Force System Crash)
.dump (Create Dump File)
.reboot (Reboot Target Computer)
.cxr (Display Context Record)
.exr (Display Exception Record)
.ecxr (Display Exception Context Record)
.trap (Display Trap Frame)
.exepath (Set Executable Path)
.srcpath (Set Source Path)
.sympath (Set Symbol Store Path)
.symfix (Set Symbol Store Path)
.reload (Reload Module)
.context (Set User-Mode Address Context)
.process (Set Process Context)
.thread (Set Register Context)
.tss (Display Task State Segment)
.load (Load Extension DLL)


3. 확장 명령
온갖 종류의 명령을 많이 포함하고 있지만 굳이 성격을 구분하자면 윈도우 운영체제에 종속적인 정보를 다루는 명령들이 많다. 특정 정보를 자세히 보여주거나 해석해서 보여줘 디버깅을 편리하게 도와주는 기능을 가지는 것들도 있다.
확장 명령은 !로 시작하는 이름 형식을 가지고 있고 사용자가 직접 만들 수 있다. (자세한 것은 65page or 6장)

<DIV style="BORDER-BOTTOM: #9fd331 1px dashed; BORDER-LEFT: #9fd331 1px dashed; PADDING-BOTTOM: 10px; BACKGROUND-COLOR: #e7fdb5; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; BORDER-TOP: #9fd331 1px dashed; BORDER-RIGHT: #9fd331 1px dashed; PADDING-TOP: 10px" class=txc-textbox>자주 쓰는 확장 명령어
!process : 현재 프로세스의 정보를 보거나 현재 윈도우 운영체제에서 실행 중인 모든 프로세스의 정보를 보여주는 명령
!gle : GetLastError의 약자로 Win32 API인 GetLastError()와 같이 마지막으로 설정된 Win32 Code를 보여주는 명령이다.
!error : Win32 Error Code나 NTSTATUS Code를 해석해 문자열로 보여주는 명령이다.
!analyze : 덤프 파일을 열었을 때 자동으로 분석을 하는 데 사용하는 명령이다.
대표적인 확장 명령어
!analyze : displays information about the current bug check
!cpuid : displays information about the processors on the system
!error : decodes and displays information about an error value
!gle : displays the last error value for the current thread
!obja : displays the attributes of an object in the object manager
!peb : displays a formatted view of the information in the process environment block(PEB)
!teb : displays a formatted view of the information in the thread environment block (TEB)
!token : displays a formatted view of a security token object
!process : displays information about the specified process or all
!stacks : displays information about the current kernel stacks
!thread : displays summary information about a thread
!zombies : displays all dead ("zombie") processes or threads
!drivers : displays a list of all drivers loaded
!devnode : displays information about a node in the device tree
!devobj : displays detailed information about a DEVICE_OBJECT
!devstack : displays a formatted view of the device stack
!drvobj : displays detailed information about a DRIVER_OBJECT


유저모드 명령줄
0:000
0은 프로세스 번호이고 000은 스레드 번호이다.
커널모드 명령줄

프로세스나 스레드 정보 표시가 없으므로 현재 어떤 프로세스의 어떤 스레드인지 확인하려면 !process, !thread 명령으로 직접 확인해봐야 한다.
멀티 프로세서는 현재 프로세서 번호를 포함해 아래처럼 나온다.

 

하이퍼스레딩을 지원하는 프로세서 하나는 두 개의 프로세서가 존재하는 것으로 나온다.
듀얼 코어 프로세서 하나는 2개의 프로세서로 나온다.
하이퍼스레딩을 지원하면서 듀얼 프로세서이면 4개로 나온다. 이러한 프로세서를 두 개 사용하면 8개의 프로세서로 나타난다.

 

출처

문헌 : WinDbg로 쉽게 배우는&nbsp;Windows Debugging
http://tiktoor.tistory.com/25