Hello everyone,
Could anyone show me a sample about how to use these two commands in Windbg please? I read the document in debugger.chm, but confused. I did search in Google and MSDN, but not find an easy to learn sample.
thanks in advance, George
Hello everyone,
Could anyone show me a sample about how to use these two commands in Windbg please? I read the document in debugger.chm, but confused. I did search in Google and MSDN, but not find an easy to learn sample.
thanks in advance, George
Think in terms of function levels as per the following pseudo-code:
1 x = 0
2 y = 0
3 call 8
4 x = 5
5 y = 7
6 call 8
7 halt
8 print x
9 print y
10 call 12
11 return
12 print x + y
13 print x * y
14 return
The commands are basically "run until an event occurs". The event causes the debugger to break (stop execution and await your command).
The "gu
" command runs until it goes up to the next highest stack level. If you're on lines 8, 9, 10 or 11, you'll end up at 4 or 7 depending on which "call 8
" has called that code. If you're on lines 12, 13 or 14, you'll break at 11.
Think of this as running until you've moved up the stack. Note that if you first go down, you'll have to come up twice.
The "pc
" command runs until the next call so, if you're on line 1, it will break at line 3. This is sort of opposite to "gu
" since it halts when you're trying to go down a stack level.
There is something wrong from Windbg output -- "Can't continue completed step". Here is the related output from Windbg and source code, any ideas?
(I set a breakpoint in main, then step next using p command twice and then use gc command -- then error happens.)
(204.18c0): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:
0000000077ef2aa0 cc int 3
0:000> bp main
0:000> g
Breakpoint 0 hit
TestDebug1!main:
00000001
40001090 4057 push rdi
0:000> p
TestDebug1!main+0x1a:
00000001400010aa c7442424c8000000 mov dword ptr [rsp+24h],0C8h ss:00000000
0012feb4=cccccccc
0:000> p
TestDebug1!main+0x22:
00000001`400010b2 488d442424 lea rax,[rsp+24h]
0:000> gc
Can't continue completed step
using namespace std;
int foo() { int b = 300;
return b;
}
int goo() { int a = 400;
return a;
}
int main() { int a = 200;
int* b = &a;
foo();
a = 400;
goo();
return 0;
}