Abhinav
Abhinav

Reputation: 1490

Windbg console logging

Is it possible to log certain things in Windbg console conditionally or unconditionally. I can change my source code and do but that is a tedious due to various resons including checkout cerain files, editing code, building and deploying. Which is seriously tedious and non-productive. I am looking for certain things like conditional breakpoint for eg.

bp module!Class::funcname+0x0ff5E1 ".if(cond) {exp1;exp2 } .else {gc}" 

to log to windbg console based on the cond (maybe cond=1 for always). I have used ?? command to print values whuile debugging but is it possible to automate as i need many values and doing it 1 by 1 takes toime and thats not formatted too! I am ;ooking something like above conditional breakpoint or any other way to do so. Any tutorial/sample will be certainly helpful.

Edit: well, one way i figured out to do this might be

bp module!Class::Func+0x0FF5E1 ".if(cond) {.echo The value of variable ALPHA is; ?? ALPHA;gc} .else {.echo SomeOtherTextIfNeeded; gc;}:"

this might be lengthy but is good as we will have to add equivalent lines in code too to display these log messages in the log; And here we dont change the code. There will certainly be other ways i am interested to see here :)

Another may be use the formatted output; on top of that if it format and variables name can be read from file, it would be great!!

Upvotes: 3

Views: 1471

Answers (1)

EdChum
EdChum

Reputation: 393863

You can open and close a logfile programmatically reusing the same log

bp module!Class::funcname+0x0ff5E1 ".if(cond) {.logappend c:\mylog.txt;exp2;.logclose;gc; } .else {gc}" 

Upvotes: 4

Related Questions