How do I restart the debuggee without erasing all my breakpoints?
Asked Answered
P

2

8

Each time I do a .restart (because I accidentally pressed F10 one too many times), WinDBG erases all my breakpoints. Is it possible to have it leave the breakpoints in place when restarting the debuggee?

Paperboard answered 30/1, 2016 at 8:21 Comment(5)
save the workspace? does it store the breakpoints?Damocles
It saves bu breakpoints but not bp breakpoints, so the solution is use bu and save the workspace.Cawnpore
I don't even know what the workspace is :)Paperboard
See here: msdn.microsoft.com/en-us/library/windows/hardware/… and this classic post: blogs.msdn.com/b/ntdebugging/archive/2010/05/07/…Cawnpore
Second link is broken, can use this archived version instead: web.archive.org/web/20190112003614/https://…Echelon
C
7

If you set breakpoints using bu rather than with bp breakpoints they are saved in the workspace. So do that, save the workspace, and that should to the trick.

Cawnpore answered 31/1, 2016 at 1:36 Comment(2)
I'm making breakpoints by clicking a source code line. Does that use bu or bp?Paperboard
Those are unresolved breakpoints (bu). See here (last paragraph): msdn.microsoft.com/en-us/library/windows/hardware/… You can verify this using .bpcmds which displays the commands used to set the current breakpoints.Cawnpore
L
2

this requires awk in path which i normally have in my setup

will work if it is windbg cdb or kd dont have to remember saying yes no always to questions

0:000> .shell -ci "bl" awk "{print \"bp \" $7}" >> c:\breaks.txt
.shell: Process exited

0:000> .restart
CommandLine: C:\Windows\System32\calc.exe

774e04f6 cc              int     3
0:000> bl

0:000> $$>a< c:\breaks.txt

0:000> bl
 0 e 00fb1635     0001 (0001)  0:**** calc!WinMain
 1 e 75eaea11     0001 (0001)  0:**** USER32!MessageBoxA
 2 e 774855c8     0001 (0001)  0:**** ntdll!NtCreateFile

also if there is no aslr saving the command history can help you restart the session in its full glory

.write_cmd_hist c:\foo.txt 

edit

i just checked the clickety history is not part of the command history neither f9 key press nor clicking the hand icon in windbg provides a history event

0:000> bl
 0 e 00a11022     0001 (0001)  0:**** helloworld!main+0x22
 1 e 00a11016     0001 (0001)  0:**** helloworld!main+0x16
0:000> .bpcmds
bu0 @@masm(`helloworld!c:\test\helloworld\helloworld.cpp:6+`);
bu1 @@masm(`helloworld!c:\test\helloworld\helloworld.cpp:5+`);
windbg> .write_cmd_hist c:\foo.txt
Wrote command history to 'c:\foo.txt'
0:000> .shell - type c:\foo.txt
Unknown option ' '
.write_cmd_hist c:\foo.txt
.bpcmds
bl
.cls
t <----- neither f8 ,f10 nor f5 gets recorded in the history
.echo foo
g helloworld!main
.shell: Process exited
Press ENTER to continue
<.shell waiting 1 second(s) for process>
<.shell process may need input>
Lampyrid answered 31/1, 2016 at 16:39 Comment(3)
Does .write_cmd_hist do anything for breakpoints set by clicking source lines? I'm not typing any commands in to set such breakpoints, I'm just clicking the appropriate source code line.Paperboard
doesn't seem to be the caseLampyrid
And what about remote debugging? .shell runs on the target machine. Do we need to have awk on all the machines we debug? There is a builtin solution in WinDbg. Trying to reinvent the wheel just for the sake of reinventing it seems... uncalled for.Cawnpore

© 2022 - 2024 — McMap. All rights reserved.