|
|
 |

 |
|
Debugging Applications for Microsoft® .NET and Microsoft Windows®
|
|
|
Author
|
|
John Robbins (Wintellect Collection)
|
|
|
Pages
|
848
|
|
Disk
|
1 Companion CD(s)
|
|
Level
|
All Levels
|
|
Published
|
03/26/2003
|
|
ISBN
|
9780735615366
|
|
Price
|
$59.99
To see this book's discounted price, select a reseller below.
|
|
|
|
|
 |
|
|
Index
Symbols & Numbers
| command (WinDBG), 367
? command (WinDBG), 361
?? command (WinDBG), 373
~ command (WinDBG), 368
/01 switch (CL.EXE), 61
4NT utility, 768
64-bit portability, 60
A
Abort Program button (SUPERASSERT), 123
AboutBoxIcon registry key, 427
accessing symbols information, 202
ACT (Application Compatibility Toolkit), 702
ActiveX controls (OCXs), where they load, 52-57
AD command (WinDBG), 379
Add( ) (TraceListener classes), 100
ADD instruction (x86), 313
AddCrashHandlerLimitModule function, 550
add-ins for Visual Studio .NET, 408, 424-436
fixing Add-In Wizard output, 426-429
in managed code, debugging, 423
managed property pages, creating, 433-436
SettingsMaster, 444-452
SuperSaver, 438-444
tool windows, creating, 430-432
toolbar button issues, 429-430
Additional Mini Dump Information section (SUPERASSERT), 125
AddVectoredExceptionHandler function, 517
advanced breakpoints (Visual Studio .NET Debugger), 214-228
Breakpoints dialog box, 217-222
Breakpoints window, 215
child breakpoints, 222
in dynamically loaded DLLs, 301
four tips on setting, 215-217
location breakpoint modifiers, 224-227
conditional expressions, 226-227, 236-240, 274-275
hit counts, 224-226
multiple on single line, 227-228
native code, 269-280
conditional expressions, 274-275
data breakpoints, 277-280
system and exported functions, 271-274
per-thread breakpoints, 240
quickly breaking on functions, 217-224
setting in dynamically loaded DLLs, 301
advanced breakpoints (WDBG), 195-200
advanced breakpoints (WinDBG), 379-382
Breakpoint Disable command (WinDBG), 380
Breakpoint Enable command (WinDBG), 380
Breakpoint List command (WinDBG), 380
memory access breakpoints, 381-382
AeDebug key, 164
AL command (WinDBG), 379
aliasing, WinDBG, 379
AllocationHook function (MemStress), 695-697
Allow Service To Interact With Desktop, 570
Anakrino utility, 266, 768
!analyze extension command (WinDBG), 388
AND instruction (x86), 327
Angel, Dave, 115
AppDomain-wide breakpoints, 222-223
Append Log File command (WinDBG), 375
Application Compatibility Toolkit (ACT), 702
application crashes, 7
application stressing, 694-697
AppVerifier utility, 702-707
AS command (WinDBG), 379
_ASSERT macro (C run-time library), 119-120
_ASSERTE macro (C run-time library), 119-120
ASM files, learning from, 351
__asm keyword, 310
ASP.NET applications
assertions in, 103-113
tracing, 146-148
Visual Studio .NET Debugger with, 233
ASPTraceListener class, 104-107
assembly language (x86), 269-302
calling conventions, 316-322
common constructs, 336-337
structure and class references, 338
complete example, 339-341
debugging tips and tricks, 349-351
Disassembly window, using, 341-345
garbage code, 350
walking the stack manually, 346-347
instruction format and memory addressing, 307-309
instructions, list of, 310-316, 327-336
comparing and testing, 329
data manipulation, 327-329
jumping and branching, 329
looping, 332
string manipulation, 333-336
registers, 303-307, 350
variables and parameters, 322-326
Assert( ) (Debug, Trace classes), 95-97, 103-104
assert macro (C run-time library), 119-120
AssertControl control (example), 105-108
AssertHttpApplication class, 104
assertions, 85-142
ASP.NET applications and services, 103-113
checking assumptions, 90. See also condition checking
DCRT assertion support, 668
how to assert, 88-89
ignoring, 126-127
native C++ applications, 113-142
types of assertions, 118-142
VERIFY macro, 116
.NET applications, 95-103
what to assert, 86-95
ASSERT_KINDOF macro (MFC), 120-121
ASSERT_VALID macro (MFC), 120-121
.ATTACH command (WinDBG), 369
Attach to Process command (WinDBG), 369
attaching to processes
services, 571-575
WinDBG, 369-371
auto memory evaluation, 295
Auto value (AeDebug key), 164
autoexpanding types (Watch window)
managed code, 241-243
native code, 283-291
AUTOEXP.DAT file, 284-286
automatic debugging, 168-170
automatic user interface testing, 35, 84, 151-153, 627-665
implementing, 638-665
keystroke and mouse recording, 653-665
notification and playback, 638-653
manual, 627-628
scheduling, 634
scripts for, 630-635
debugging scripts for, 634
future of, 665
recording scripts for, 635-638
requirements for, 629
B
64-bit portability, 60
BA command (WinDBG), 381
background automatic save to IDE, 438-444
Balena, Francesco, 764
base addresses, 57
Basic Runtime Checks property, 61
BD command (WinDBG), 380
BE command (WinDBG), 380
BeginInprocDebugging method (ICorProfilerInfo), 470
_beginthreadex function, 588
beq instruction (ILDASM), 263
beta 1 (feature complete), 68
bgt instruction (ILDASM), 263
Bilas, Scott, 122
binaries, packing functions into (working set tuning), 723-747
SWS utility, 62, 727-747
future of, 747
how to use, 728-733
implementing, 734-746
WST utility, 726
binary images, CrashFinder with, 502-511
binary manipulation instructions (x86), 328
bit sets, WST and, 739
bit-shift operators (x86), 328
BL command (WinDBG), 380
Black, Rex, 764
Blake, Russ, 727, 739
ble instruction (ILDASM), 263
Bloom, Scott, 502
blt instruction (ILDASM), 263
bne instruction (ILDASM), 263
books for developers, 762-767
BoundsChecker utility, 669
Box, Don, 766
box instruction (ILDASM), 264
BP command (WinDBG), 379
br instruction (ILDASM), 263
branch instructions
ILDASM, 263
x86, 329
Break Into Debugger button (SUPERASSERT), 123
break keys, 165
Break On Access command (WinDBG), 381
BREAKIN.EXE utility, 355
breaking the build, 67
breaking the smoke test, 69
breakpoints (Visual Studio .NET Debugger), 214-228
Breakpoints dialog box (Visual Studio .NET debugger), 217-222
Breakpoints window (Visual Studio .NET debugger), 215
child breakpoints, 222
in dynamically loaded DLLs, 301
location breakpoint modifiers, 224-227
conditional expressions, 226-227, 236-240, 274-275
hit counts, 224-226
multiple on single line, 227-228
native code, 269-280
conditional expressions, 274-275
data breakpoints, 277-280
system and exported functions, 271-274
per-thread breakpoints, 240
quickly breaking on functions, 217-224
setting, 215-217
in dynamically loaded DLLs, 301
problems using C# or J#, 220-221
breakpoints (WDBG), 195-200
breakpoints (WinDBG), 379-382
Breakpoint Disable command (WinDBG), 380
Breakpoint Enable command (WinDBG), 380
Breakpoint List command (WinDBG), 380
memory access breakpoints, 381-382
brfalse instruction (ILDASM), 263
brtrue instruction (ILDASM), 263
Brown, Keith, 568, 767
BSMDVINFO structure, 686
BU command (WinDBG), 379
buffer security check switch, 61, 714
bugs
caused by inadequate processes, 8-17
defined, 4-7
descriptions, 25
tracking systems, 33, 38-40
version control, 33-38, 40
labeling, 37
when to make changes, 36-37
BUGSLAYERUTIL.DLL
DLL versions of CRT libraries, 678
full memory tracking, 678
MemDumperValidator extension, 678-694
deep validations, 687-688
implementing, 691-694
using with C, 686-687
using with C++, 685-686
MemStress extension, 694-697
builds
breaking, 67
debug, 67, 70
debugging systems, building, 41-66
debug symbols, 42-46
lightweight diagnostics for release builds, 65-66
managed code warnings, 46-48
native code warnings, 48-51
frequency of, 67-68
full debugging symbols in, 42-46
handlers, scheduling time for, 41-66
lightweight diagnostics for release builds, 65-66
organizing build settings, 444-452
reproducing, 38
symbol servers, building, 71-81
Burns, Robert, 207
C
C++
assertions in C++ applications, 113-142
types, 118-142
VERIFY macro, 116
debug symbols in projects, 43
decorated names, 498
exception handling, 514, 518-525
catch (...) construct, 520-524
_set_se_translator API, 524-525
tracing, 148
C#
compiler errors, 46-48
compiler options, 58
documentation comments, 415-423
turning on debug symbols, 42
C7 (CodeView) format, 201
CAB files, compressing WinDBG dumps into, 394, 396
call instruction (ILDASM), 265
CALL instruction (x86), 315-316
Call Stack window (Visual Basic .NET Debugger), 216
call stacks, 65
calling conventions (x86), 316-322
calling methods in Watch windows, 230-233
callvirt instruction (ILDASM), 265
catch blocks, 476
catch (...) construct, 520-524
catch keyword, 518
CBreakpoint class, 280
C-Cover utility, 768
CDB.EXE utility, 355
__cdecl call (x86), 317, 318
ceq instruction (ILDASM), 262
CFTL approach, 9-10
cgt instruction (ILDASM), 262
.CHAIN command (WinDBG), 387
character limit on debugging information, 291
Check For Arithmetic Overflow/Underflow property, 58
/checked switch (C# compiler), 58
checking (reviewing) code, 15, 36
assertions, 90. See also condition checking
heap checking, 697-699
integer underflow/overflow checking, 58
memory leak checking, 7
without utilities, 727
MemDumperValidator extension, 678-694
memory overruns, 701-707
multithreaded programming, 591. See also threading
operating system heap checking, 697-699
run-time checking, 61
CheckNotification method, 633
child breakpoints, 222
child processes, debugging (WinDBG), 366-367
Choose Breakpoints dialog box (Visual Studio .NET debugger), 220-221
CL.EXE switches, 59-62
Clark, Jason D., 767
class references (x86), 338
ClassDumper method, 686
Clear Screen command (WinDBG), 385
_CLIENT_BLOCK identifier, 679
Close Log File command (WinDBG), 375
CLR debugging, 160, 257
!clrstack extension command (WinDBG), 399
.CLS command (WinDBG), 385
clt instruction (ILDASM), 262
CMP instruction (x86), 329
CMPS instruction (x86), 333
code, profiling, 455-465
flow tracing, 479, 484-488
in-process debugging, 469-474
ProfilerLib, 465-467
Profiling API, 455-465
code, tracing, 142-148
ASP.NET applications, 146-148
DCRT library assertion support, 668
Event Tracing system, 66
EventLogTraceListener class, 97
FastTrace utility, 717-722
implementation, 721-722
merging trace logs, 720-721
flow tracing (Profiler API), 479, 484-488
native C++ applications, 148
.NET applications, 144-146
performance of, 718-719
TraceListener class, 96-103, 144
web services, 146-148
WinDBG debugger, 373-378
code, tracking
bugs, 38-40
heap memory (DCRT library), 667-676
features of, 668-669
new operator, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
object lifetime, 524
version control, 33-38, 40
labeling, 37
when to make changes, 36-37
code, writing
code coverage, 27, 152-153
code elements in macros, 413-415
"Code First, Think Later" approach, 9-10
code freeze, 36, 38
defensively (proactive coding), 83-154
assertions, 85-142
commenting, 85, 149-150
tracing, 142-148
unit testing, 35, 84, 151-153, 627-665
reviewing code, 15, 36
assertions, 85-142
heap checking, 697-699
integer underflow/overflow checking, 58
memory leak checking, 7, 727, 678-694
memory overruns, 701-707
multithreaded programming, 591. See also threading
operating system heap checking, 697-699
run-time checking, 61
stepping through
DebuggerStepThroughAttribute attribute, 245
SetSingleStep function, 198
WDBG debugger, 195-210
WinDBG debugger, 373-378
Code Model property, 412
CodeView (C7) format, 201
COFF (Common Object File Format), 201
Cogswell, Bryce, 168, 574, 769
Cohen, Danny, 350
COM+ services, debugging, 569
Command Help command (WinDBG), 361
Command Shell command (WinDBG), 385
Command window, WinDBG, 360
executing macros from, 410. See also entries at macros
processes, creating, 369
processes and threads, viewing, 367-369
CommandPreload registry key, 426
commands, WinDBG, 360-362
CommenTater macro, 415-423
commenting, 149-150
assertions as documentation, 85
CommenTater macro, 415-423
commitment to quality, 15-17
Common Object File Format (COFF), 201
comparison instructions
ILDASM, 262
x86, 329
compilers
compiler option (#pragma init_seg), 693
errors, 46-48
switches for debugging native code, 59-62
condition checking (assertions), 85-142
ASP.NET applications and services, 103-113
DCRT assertion support, 668
how to assert, 88-89
ignoring, 126-127
native C++ applications, 113-142
types of assertions, 118-142
VERIFY macro, 116
.NET applications, 95-103
what to assert, 86-95
conditional command execution, WinDBG, 381
conditional expressions. See also condition checking
assertion methods, 90
constants in conditional statements, 142
location breakpoints, 226-227, 236-240
native code, 274-275
WinDBG command execution, 381
conditionally compiled assertion methods, 90
console applications
assertions, 95-103
tracing, 144-146
constants, placement in conditional statements, 142
ContinueDebugEvent function, 172
conv instruction (ILDASM), 263
Copy to Clipboard button (SUPERASSERT), 123
CORDBG.EXE debugger, wt command, 244, 479
core code of services, debugging, 569
core dumps (dump files), 71
compressing WinDBG dumps into CAB files, 394, 396
full dumps, 393
MemDumperValidator extension (BUGSLAYERUTIL.DLL), 678-694
C classes, 686-687
C++ classes, 685-686
deep validations, 687-688
implementing, 691-694
initialization and termination in C++, 692-693
minidumps, 71, 300
Create Mini Dump button (SUPERASSERT), 123, 299-301
deadlock dumps in the field, 590
garbage code (disassembled code), 350
MiniDumpFilterMemory function, 555
MiniDumpFilterMemoryPaths function, 555
MiniDumpWithHandleData function, 555
MiniDumpWriteDump function, 554-563
SnapCurrentProcessMiniDump function, 556, 590
WinDBG debugger, 358, 394
writing, 394, 553-563
native code, 299-301
SOS (Son of Strike), 235, 396-403
WinDBG debugger, handling with, 393-396
creating dump files, 393-394
debugging dump files, 396
extension commands, 400-402
opening dump files, 395-396
Cor_Enable_Profiling environment variable, 463
Cor_Profiler environment variable, 463
corrupt data, 7
CPU basics, 21, 303
crash address, using, 491-512
CrashFinder utility, 502-511
MAP files, 63
creating and reading, 493-501
extracting information from, 498-499
PDB2MAP utility, 499-501
understanding contents of, 495-498
crash dumps. See core dumps
crash handlers, 513-564
CrashFinder utility, 502-511
CrashHandler API, 527-551
EXCEPTION_POINTERS structures, translating, 551-553
minidumps, 71, 300
Create Mini Dump button (SUPERASSERT), 123, 299-301
deadlock dumps in the field, 590
garbage code (disassembled code), 350
MiniDumpFilterMemory function, 555
MiniDumpFilterMemoryPaths function, 555
MiniDumpWithHandleData function, 555
MiniDumpWriteDump function, 554-563
SnapCurrentProcessMiniDump function, 556, 590
WinDBG debugger, 358, 394
writing, 394, 553-563
SetUnhandledExceptionFilter function, 525-527
crashes, 7. See also crash handlers
DLL base addresses, knowing, 52-54
dumps. See core dumps
minidumps. See minidumps
starting debugger at, 166-168
using the crash address, 491-512
CrashFinder utility, 502-511
MAP files, 493-501
CrashFinder utility, 502-511
CrashHandler API, 527-551
.CREATE command (WinDBG), 369
Create Dump File CAB command (WinDBG), 396
Create Dump File command (WinDBG), 393-394
Create Mini Dump button (SUPERASSERT), 123, 299-301
Create Process command (WinDBG), 369
CreateProcess function, 171
CREATE_PROCESS_DEBUG_EVENT event, 173
CreateRemoveThread function, 199
CreateThread function, not using, 588-589
CREATE_THREAD_DEBUG_EVENT event, 174
creative bug hunting, 26-27
critical sections, spinning, 587-588
!critsecextension command (WinDBG), 388
CRT libraries, comparison of, 677-678
_CRT_BLOCK identifier, 679
_CrtCheckMemory function, 675
_CRTDBG flags, 670
_CrtIsMemoryBlock function, 675
_CrtIsValidHeapPointer function, 675
_CrtIsValidPointer function, 675
_CrtMemBlockHeader structure, 691
_CrtMemDifference function, 676
_CrtMemDumpStatistics function, 676
CSC.RSP file, ignoring, 58
CUseCriticalSection class, 583, 586
custom debuggers, writing, 210-211
D
daily builds, 67-68
data breakpoints, 277-280
data corruption, 7
data manipulation instructions (x86), 327-329
data truncation assignment checking (/RTCc switch), 708
DBG files, 201
DBGCHOOSER (Debugger Chooser), 166-168
DBGHELP.DLL file, 202
CrashFinder with, 505
MiniDumpWriteDump function, 554-563
DBGPROXY service, 159, 299
DCOM project, uncommitted transactions with, 624
DCRT (debug C run-time) library, 667-676
features of, 668-669
new operator with, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
DeadDetExt (DeadlockDetection extension), 598, 610
deadlines responsible for bugs, 8
DeadlockDetection utility, 595-624
DeadDetExt extension, 598, 610
future of, 624
high-level issues, 596-598
how to use, 598-601
implementing, 601-624
highlights of, 610-624
hooking imported functions, 601-610
requirements for, 595-596
deadlocks and multithreaded programming, 581-626
CreateThread and ExitThread functions, 588-589
DeadlockDetection utility, 595-624
DeadDetExt extension, 598, 610
future of, 624
high-level issues, 596-598
how to use, 598-601
implementing, 601-624
requirements for, 595-596
local storage, accessing, 337, 485
low-level multithreading, 583-587
multiprocessor machines, 592
names of threads, setting in native code, 276
obtaining thread identifiers, 240
TEB (thread environment block), 368
TIB (thread information block), 304, 336, 368
tips and tricks, 581-592
code reviews, 591
deadlock dumps in the field, 590
default memory manager, 589-590
discrete pieces, using, 583
minimizing amount of multithreading, 582
spinning critical sections, 587-588
testing on multiprocessor machines, 592
tracing performance, 718-719
debug builds, 67
installation programs for, 70
testing with, 70
debug C run-time (DCRT) library, 667-676
features of, 668-669
new operator with, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
Debug class (System.Diagnostic), 95-97, 103-104
Debug Interface Access (DIA) SDK, 202
debug registers, 277
debug symbols, 42-46
native debugging, 298. See also native code
SWS utility, enumerating, 738-744
symbol servers, building, 71-81
symbol tables and engines (WDBG), 200-208
SymbolEngine project, 203
Watch window formatting, 280-283
WinDBG debugger, 357, 362-366
debug think, 603-604
DebugBreak function, 168, 573
debuggee, defined, 158
Debugger Chooser (DGBCHOOSER), 166-168
debugger proxy service, 299
Debugger value (AeDebug key), 164, 165
DEBUGGER.CHM help files, 356, 362
DebuggerHiddenAttribute attribute, 245
Debugger.Launch( ), 107
-108
debuggers
automatically starting in, 168-170
debug registers, 277
debug symbols, 42-46
native debugging, 298. See also native code
SWS utility, enumerating, 738-744
symbol servers, building, 71-81
symbol tables and engines (WDBG), 200-208
SymbolEngine project, 203
Watch window formatting, 280-283
WinDBG debugger, 357, 362-366
debuggee, defined, 158
Dr. Watson, 493, 751-760
JIT (just-in-time) debugging, 164-168
crashing into debugger, 166-168
quick break keys, 165
.NET debuggers, 158
NTSD debugger, 354
proxy service for, 299
Visual Studio .NET debugger, 213-234
advanced breakpoints, 214-228
for ASP Web applications, 233
Disassembly window, 341-345
expanding types automatically, 241-243, 283-291
Memory window, 295, 346
native code, 269-291, 350
setting breakpoints in dynamically loaded DLLs, 301
Watch windows, 228-233, 280-283
WDBG debugger, 190-210
breakpoints and single stepping, 195-200
debug symbols, 357, 362-366
future of, 211-212
reading and writing memory, 192-195
stepping functionality, 209-210
symbols and stack walking, 200-208
WinDBG (Windows Debugger), 162, 353-404, 556
basic issues, 356-359
breakpoints, 379-382
command parameters, 362
command-line arguments, changing, 360
commands, types of, 361
control commands, 385-386
dump files, handling, 393-396
evaluating variables, 372-373
exceptions and events, 382-384
executing, stepping, tracing, 373-378
extension commands, 386-393
getting help, 361-362
processes and threads, 366-371
SOS extension support, 396-403
symbol handling, 357, 362-366
Windows debuggers, 159-164
kernel-mode, 161-164
MinDBG, 171-190
user-mode, 159-160
WDBG, 190-210, 211-212
writing your own, 210-211
DebuggerStepThroughAttribute attribute, 245
debugging. See also debuggers
during coding (proactive programming), 83-154
assertions, 85-142
commenting, 149-150
tracing, 142-148
unit testing, 35, 84, 151-153, 627-665
memory, with DCRT library, 667-676. See also memory
features of, 668-669
new operator with, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
memory, with MemDumperValidator extension, 678-694. See also memory
C classes, 686-687
C++ classes, 685-686
deep validations, 687-688
implementing, 691-694
memory, with MemStress extension, 694-697. See also memory
mixed-mode, 246-247
plans for, 18
policies, 41
requirements for, 19-22
server applications with FastTrace, 148, 717-722
implementation, 721-722
merging trace logs, 720-721
step-by-step process of, 22-30
string processing, 713
tools for, 20, 27, 33-40, 354-355
windows services, 568-575
Allow Service To Interact With Desktop, 570
attaching to processes, 571-575
core code, 569
service identity, setting, 571
startup code, 575
Debugging Tools for Windows package, 354-355
DebugView utility, 143, 575
DEC instruction (x86), 328
DECLARE_MEMDEBUG macro, 685
decorated names, 498
deep validations, MemDumperValidator extension, 687-688
default memory manager, 589-590
default workspace, WinDBG, 358
DefaultTraceListener class, 96-100
defensive (proactive) programming, 83-154
assertions, 85-142
ASP.NET applications and web services, 103-113
how to assert, 88-89
ignoring, 126-127
native C++ applications, 113-142
.NET applications, 95-103
what to assert, 86-87, 89-95
commenting, 149-150
assertions as documentation, 85
tracing, 142-148
ASP.NET applications and web services, 146-148
DCRT library assertion support, 668
Event Tracing system, 66
EventLogTraceListener class, 97
FastTrace utility, 717-722
flow tracing (Profiler API), 479, 484-488
native C++ applications, 148
.NET applications, 144-146
performance of, 718-719
TraceListener class, 96-103, 144
WinDBG debugger, 373-378
unit testing, 35, 84, 151-153, 627-665
implementing, 638-665
manual, 627-628
scripts for, 630-635
scheduling, 634
Delete Alias command (WinDBG), 379
Demeanor for .NET utility, 251, 768
descriptions, bug, 25
.DETACH command (WinDBG), 370
Detach from Process command (WinDBG), 370
detaching from processes
WinDBG, 370
Windows 2000, 299
Detect 64-Bit Portability Issues setting, 60
developers
resources for, 761-769
role of, 84
DevPartner utility, 768
DIA (Debug Interface Access) SDK, 202
Dilascia, Paul, 766
disassembler, writing, 210
Disassembly window (Visual Studio .NET debugger), 341-345
garbage code, 350
walking the stack manually, 346-347
Display Local Variables command (WinDBG), 372-373
Display Stack Backtrace command (WinDBG), 372
Display Type command (WinDBG), 373
Display Variables command (WinDBG), 366
DIV instruction (x86), 328
divide-and-conquer approach, 25
DllMain function, 594
DLLs
CRT libraries, DLL versions of, 677-678
determining which come into address space, 576
knowing where they load, 52-57
rebasing, 52, 54-57
Do Child Focus Attempt In Scripts option (Tester), 636
DocComment property (code elements), 417
docking tool windows (add-ins), 430
documentation
assertions as, 85
commenting code, 149-150
comments, macro for, 415-423
dot (meta) commands, WinDBG, 361, 385-386. See also specific commands by name
Dotfuscator utility, 250
Douglas, Frank, 763
Dr. Watson, 493, 751-760
!dreg extension command (WinDBG), 392
DT command (WinDBG), 373
.DUMP command (WinDBG), 393-394
dump files (core dumps), 71
compressing WinDBG dumps into CAB files, 394, 396
full dumps, 393
MemDumperValidator extension (BUGSLAYERUTIL.DLL), 678-694
C classes, 686-687
C++ classes, 685-686
deep validations, 687-688
implementing, 691-694
initialization and termination in C++, 692-693
minidumps, 71, 300
Create Mini Dump button (SUPERASSERT), 123, 299-301
deadlock dumps in the field, 590
garbage code (disassembled code), 350
MiniDumpFilterMemory function, 555
MiniDumpFilterMemoryPaths function, 555
MiniDumpWithHandleData function, 555
MiniDumpWriteDump function, 554-563
SnapCurrentProcessMiniDump function, 556, 590
WinDBG debugger, 358, 394
writing, 394, 553-563
native code, 299-301
SOS (Son of Strike), 235, 396-403
WinDBG debugger, handling with, 393-396
creating dump files, 393-394
debugging dump files, 396
extension commands, 400-402
opening dump files, 395-396
.DUMPCAB command (WinDBG), 396
!dumpclass extension command (WinDBG), 401
!dumpmodule extension command (WinDBG), 401
!dumpmt extension command (WinDBG), 400
!dumpobj extension command (WinDBG), 401
!dumpstack extension command (WinDBG), 400
!dumpstackobjects extension command (WinDBG), 402
Duncan, Christopher, 762
duplicating bugs, 24
DV command (WinDBG), 366, 372-373
dynamically loaded DLLs, breakpoints in, 301
E
EditPoint property (code elements), 418
EEAddIn (Expression Evaluator Add-In), 286-291
effective address display, 308
EFLAGS (x86 CPU flags register), 304
e-mail, preventing from boss, 170
Email Assertion button (SUPERASSERT), 123
Enable Unicode Display command (WinDBG), 385
.ENABLE_UNICODE command (WinDBG), 385
endians, 349
EndInprocDebugging method (ICorProfilerInfo), 470
engineer ignorance, 13
enter notifications, requesting (Profiling API), 480
EnterCriticalSection function, 587, 595
EnumerateChains method (ICorDebug), 471
EnumLocalVariables method, 206
/EP switch (CL.EXE), 59
epilog, function, 313
errors
assertions with error handling, 87
debug symbols, 42-46
native debugging, 298. See also native code
SWS utility, enumerating, 738-744
symbol servers, building, 71-81
symbol tables and engines (WDBG), 200-208
SymbolEngine project, 203
Watch window formatting, 280-283
WinDBG debugger, 357, 362-366
detection tools, 27
managed code warnings as, 46-48
native code warnings as, 48-51
run-time error check switches, 707-713
scheduling time to build handlers, 41-66
lightweight diagnostics for release builds, 65-66
managed code warnings, 46-48
native code warnings, 48-51
Esposito, Dino, 765
Evaluate C++ Expression command (WinDBG), 373
events
Event Filters dialog (WinDBG), 382
Event Tracing system, 66
EventLogTraceListener class, 97
logging, 66
WinDBG handling, 382-384
__except blocks, 514
EXCEPTION_DEBUG_EVENT event, 174
ExceptionMon utility, 467-474
managed exception monitoring, 455-477
in-process debugging, 469-474
ProfilerLib, 465-467
Profiling API, 455-465
EXCEPTION_POINTERS structures, translating, 551, 553
exceptions, 41
C++ exception handling, 514, 518-525
catch (...) construct, 520-524
_set_se_translator API, 524-525
EXCEPTION_DEBUG_EVENT event, 174
ExceptionMon utility, 467-474
EXCEPTION_POINTERS structures, translating, 551, 553
handling in .NET, 475-477
managed exception monitoring, 455-477
ProfilerLib, 465-467
Profiling API, 455-465
monitoring in native code, 296-298
SetUnhandledExceptionFilter function, 525-527
structured exception handling (SEH), 514-518
WinDBG debugger, 382-384
wizard-generated add-ins, 428
!exchain extension command (WinDBG), 392
Exchange Server services, 569
executable image path, WinDBG, 358, 395
Execute If-Else command (WinDBG), 381
ExitProcess function, 623
EXIT_PROCESS_DEBUG_EVENT event, 175
ExitThread function, not using, 588-589
EXIT_THREAD_DEBUG_EVENT event, 175
_exitthreadex function, 588
Expand Arrays checkbox (SUPERASSERT), 124
expanding types automatically (Watch window)
managed code, 241-243
native code, 283-291
Expect Commands from Target command (WinDBG), 386
expectations of users, 6
exported functions, breakpoints on, 271-274
Expression Evaluator Add-In (EEAddIn), 286-291
extending Visual Studio .NET, 407-453
add-ins, 408, 424-436
fixing Add-In Wizard output, 426-429
in managed code, debugging, 423
managed property pages, creating, 433-436
SettingsMaster, 444-452
SuperSaver, 438-444
tool windows, creating, 430-432
toolbar button issues, 429-430
macros, 407, 409-415
code elements, 413-415
CommenTater macro, 415-423
executing from Command window, 410
macro parameters, 410-411
in managed code, debugging, 423
project object models, 412-413
wizards, 408
Extensibility Browser add-in, 425
extension commands, WinDBG, 361, 386-393
loading and controlling, 387-388
with SOS (Son of Strike), 398-403
extracting information from MAP files, 498-499, 504
F
__fastcall call (x86), 317, 318
FastTrace utility, 148, 717-722
implementation, 721-722
merging trace logs, 720-721
feature complete (beta 1), 68
file formats, SWS utility, 738-744
Filter Command dialog (WinDBG), 384
finally blocks, 476, 514
Find combo box (Visual Basic .NET Debugger), 223-224
FindAssertControl( ) (ASPTraceListener), 107
first chance exception, 296
fixed-name aliases (WinDBG), 379
flags register (EFLAGS), x86 CPU, 304
floating point instructions, 303
flow of operation, viewing, 244, 479, 484-488
FlowTrace utility, 479, 484-488
FlushFastTraceFiles function (FastTrace), 720
FlushInstructionCache function, 176
!for_each_frame extension command (WinDBG), 393
.FORMATS command (WinDBG), 385
formatting symbols for Watch windows, 280-283
FPU (floating-point unit), 303
.FRAME command (WinDBG), 372
_FREE_BLOCK identifier, 680
frequency of builds, 67-68
FS register access (x86), 336
full dumps, WinDBG, 393
FuncEnter method (CFlowTrace), 481
function name, extracting from MAP files, 498-499, 504
Function Order property, 64
FunctionIDMapper function, 483-484
functions, packing into binaries (working set tuning), 723-747
SWS utility, 62, 727-747
future of, 747
how to use, 728-733
implementing, 734-746
WST utility, 726
G
G command (WinDBG), 373
GAC (global assembly cache), installing into, 436
garbage code (disassembled code), 350
General Protection Faults (GPFs), 309
general-purpose registers, x86 CPU, 303
Generate ICO Data for Extensibility add-in, 425
Generate MAP File property, 63
Generate Preprocessed File property, 59
Gershnik, Eugene, 518
GetCurrentException method (ICorDebug), 470
GetDeadlockDetectionOptions function, 599
GetEventMask method (ICorProfilerInfo), 458
GetExceptionCode function, 515
GetExceptionInformation function, 516
GetFaultReason function, 551
GetFirstStackTraceString function, 552-553
GetImprocInspectionInspection method (ICorProfilerInfo), 470
GetImprocInspectionThisThread method (ICorProfilerInfo), 470
GetModuleInfo method (ICorProfilerInfo), 458
GetNextStackTraceString function, 552-553
GetObjectType function, 114
GetProcAddress function, 623
GetRegisterString function, 551
GFLAGS.EXE utility, 170, 698
/GL switch (CL.EXE), 62
Gladstone, Ken, 502
global assembly cache (GAC), installing into, 436
global memory breakpoints, 277-280
global variables (x86), 322-326
GlobalUnlock function, 347-349
Go command (WinDBG), 373
GPFs (General Protection Faults), 309
Graham, Neill, 765
Green Time, 36
Greenspun, Philip, 763
Grove, Andy, 151
/GS switch (CL.EXE), 61, 714
GUID settings for projects, 412
H
!handle extension command (WinDBG), 388, 390
HandleOutput( ) (ASPTraceListener), 106
$HANDLES pseudoregister, 283
Has Changed evaluation, 226
!heap extension command (WinDBG), 392
heap memory, tracking (DCRT library), 667-676
features of, 668-669
new operator with, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
HeapCreate API function, 697
heaps, operating system, 697-699
heavy vs. light debugging, 27
.help command (WinDBG), 361
.hh command (WinDBG), 362
HISTORY.TXT file, 80
hit count modifiers (location breakpoints), 224-226
HITInlining notification, 482
HookImportedFunctionsByName function, 604-610
hooking functions in Profiling API, 479-484
enter and leave notifications, 480
FunctionIDMapper function, 483-484
implementing functions, 480-482
inlining, 482-483, 484
hooking imported functions in DeadlockDetection, 601-610
HookOrdinalExport function, 604
host shim control, 431
Howard, Michael, 568, 763
HRESULT values, custom, 285
I
.I files, 59
I386CPUHELP.DLL file (WDBG), 192
ICorDebug interface, 470
ICorProfilerCallback interface, 457-461
ICorProfilerInfo interface, 461, 469
IDiaSymbol interface, 203
IDIV instruction (x86), 328
IDTToolsOptionsPage interface, 433
Ierardi, Peter, 9, 624
ignorance as cause of bugs, 13
-14
Ignore All Default Libraries property, 63
Ignore Assertion Always button (SUPERASSERT), 124
Ignore Once button (SUPERASSERT), 123
Ignore Standard Include Path property, 60
_IGNORE_BLOCK identifier, 680
ignoring assertions, 126-127
ILDASM (Microsoft Intermediate Language Disassembler), 249-266
alternative tools, 266
important instructions, list of, 259-265
branch, 263
comparison, 262
load, 260-261
store, 261-262
tree output descriptions, 251
ILT (Incremental Link Table), 735
image file execution options, 168-170
IMetaDataEmit interface, 461
IMetaDataImport interface, 461
!imgreloc extension command (WinDBG), 391
IMPLEMENT_MEMDEBUG macro, 685
impossible deadlines, 8
improper training
as cause of bugs, 13
knowing one's own tools, 20
IMUL instruction (x86), 328
in-process debugging and ExceptionMon utility, 469-474
INC instruction (x86), 328
INCLUDE environment variable, ignoring, 60
include files, listing, 62
Include Information in MAP File properties, 63
inconsistencies in user interface, 5
Incremental Link Table (ILT), 735
infinite recursion, 527
Initialize method (ICorProfilerCallback), 458-460
InitializeComponent method, 245
InitializeCriticalSectionAndSpinCount function, 588
initializing MemBumperValidator in C++, 692-693
injected code, debugging, 295
inline assembler, Visual C++ .NET, 309-310
inlining, 482-483, 484
in-process debugging and ExceptionMon utility, 469-474
installation program, 70
installing into GAC (global assembly cache), 436
instruction format, x86 CPUs, 307-309
instructions, x86 assembly language, 269-302
calling conventions, 316-322
common constructs, 336-337
structure and class references, 338
complete example, 339-341
debugging tips and tricks, 349-351
Disassembly window, using, 341-345
garbage code, 350
walking the stack manually, 346-347
format and memory addressing, 307-309
list of, 310-316, 327-336
comparing and testing, 329
data manipulation, 327-329
jumping and branching, 329
looping, 332
string manipulation, 333-336
registers, 303-307, 350
variables and parameters, 322-326
INT 3 instruction (x86), 313
integer underflow/overflow checking, 58
intellectual property protection, 250
IntelliSense, verifying breakpoints, 217
InterlockedIncrement function, 740
ISAPI filters and extensions, 569, 573-575
IsBad* functions, 114
IsDebuggerPresent function, 159, 160
IsWindow function, 114
J
J command (WinDBG), 381
JE instruction (x86), 330
JG instruction (x86), 330
JGE instruction (x86), 330
JIT (just-in-time) debugging, 164-168
crashing into debugger, 166-168
quick break keys, 165
JL instruction (x86), 330
JLE instruction (x86), 330
JMP instruction (x86), 329
JNE instruction (x86), 330
jump instructions (x86), 329
just-in-time (JIT) debugging, 164-168
crashing into debugger, 166-168
quick break keys, 165
K
K command (WinDBG), 372
KD (kernel debugger), 162
Keep Comments option, 59
kernel-mode debuggers, 161-164
KD (kernel debugger), 162
SoftICE, 163-164
WinDBG (Windows Debugger), 162, 556
Kernighan, Brian W., 257, 763, 765
keystroke recording, Tester utility, 653-662
KILL.EXE utility, 355
Kim, Frank, 568
Knuth, Donald, 150
Krug, Steve, 763
Kwok, Ching Ming, 502
L
labeling, version control, 37
language, knowledge of, 20
Launch( ) (Debugger), 107
LD command (WinDBG), 363
ldarg instruction (ILDASM), 260
ldarga instruction (ILDASM), 260
ldc instruction (ILDASM), 260
ldelem instruction (ILDASM), 261
ldfld instruction (ILDASM), 260
ldlen instruction (ILDASM), 261
ldloc instruction (ILDASM), 260
ldloca instruction (ILDASM), 260
ldsfld instruction (ILDASM), 260
LEA instruction (x86), 314
learning from your bugs, 3, 30
LEAVE instruction (x86), 313
leave notifications, requesting (Profiling API), 480
LeBlanc, David, 568, 763
Lidin, Serge, 765
light vs. heavy debugging, 27
line number, extracting from MAP files, 498-499, 504
.LINES command (WinDBG), 374
linker switches for debugging native code, 59, 63-65
LINK.EXE switches, 63-65
/ORDER option, 725
List Aliases command (WinDBG), 379
List Debugger Extensions command (WinDBG), 387
List Loaded Modules command (WinDBG), 362-365, 395
List Process IDs command (WinDBG), 369
LIST.EXE utility, 355
little endian CPUs, 349
LM command (WinDBG), 362-365, 395
load addresses, specifying for DLLs, 55
.LOAD command (WinDBG), 387
load conflicts in DLLs, 52
Load Extension DLL command (WinDBG), 387
load instructions (ILDASM), 260-261
Load Symbols command (WinDBG), 363
LoadBehavior registry key, 426
LOAD_DLL_DEBUG_EVENT event, 175
LoadLibrary function, 599
LOCALASSIST.DLL file (WDBG), 192
LOCALDEBUG.DLL file (WDBG), 192
.LOCALE command (WinDBG), 385
Locals Depth list (SUPERASSERT), 124
LocalSystem account, 571
location breakpoints. See also breakpoints (Visual Studio .NET Debugger)
modifiers, 224-227
conditional expressions, 226-227, 236-240, 274-275
hit counts, 224-226
native code, 269-280
conditional expressions, 274-275
data breakpoints, 277-280
system and exported functions, 271-274
setting, 214-215
LOCK prefix (x86), 328
!locks extension command (WinDBG), 388
.LOGAPPEND command (WinDBG), 375
.LOGCLOSE command (WinDBG), 375
LOGGER.EXE utility, 355
logging
bug descriptions, 25
bugs, defined, 4-7
Dr. Watson log files, reading, 751-760
execution flow, 66
LOGGER.EXE utility, 355
tracing, 142-148
ASP.NET applications, 146-148
DCRT library assertion support, 668
Event Tracing system, 66
EventLogTraceListener class, 97
FastTrace utility, 717-722
flow tracing (Profiler API), 479, 484-488
native C++ applications, 148
.NET applications, 144-146
performance of, 718-719
TraceListener class, 96-103, 144
web services (XML), 146-148
WinDBG debugger, 373-378
tracking changes, 33-40
bug tracking, 38-40
full memory tracking (BUGSLAYERUTIL), 678
tracking heap memory (DCRT library), 667-676
features of, 668-669
new operator, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
tracking object lifetime, 524
version control, 33-38, 40
labeling, 37
when to make changes, 36-37
logical operators (x86), 327
.LOGOPEN command (WinDBG), 375
LOGVIEWER.EXE utility, 355
LOOP instruction (x86), 332
looping instruction (x86), 332
Loosley, Chris, 763
low-level multithreading, 583-587. See also multithreaded programming
/LTCG switch (LINK.EXE), 64
M
Macro Explorer, 409
macros (various)
C run-time library, 119-120
CommenTater macro, 415-423
DCRT, 668
DECLARE_MEMDEBUG macro, 685
IMPLEMENT_MEMDEBUG macro, 685
MakeAddinFromMacroProj macro, 409
MEMSTRESSINIT macro, 695
MFC, 120-121
NEW_INLINE_WORKAROUND macro, 673-674
SUPERASSERT macro, 121-142, 299-301
implementation highlights, 127-142
TRACE macro, 148
VALIDATEALLBLOCKS macro, 688
VERIFY macro, 116
macros, Visual Studio .NET, 407, 409-415
code elements, 413-415
CommenTater macro, 415-423
executing from Command window, 410
macro parameters, 410-411
in managed code, debugging, 423
project object models, 412-413
Maguire, Steve, 762, 764
MakeAddinFromMacroProj macro, 409
managed code
C# compiler options for debugging, 58
calling properties, 231
flow of operation, viewing, 244, 479, 484-488
hit counts on location breakpoints, 224
macros and add-ins in, debugging, 423
quick breakpoints, 221
SOS (Son of Strike), 235, 396-403
tips and tricks, 245-249
warnings in, 46-48
managed exception monitoring, 455-477
ExceptionMon utility, 467-474
ProfilerLib, 465-467
Profiling API, 455-465
managed modules, 57
managed property pages, add-ins, 433-436
managed tool windows, add-ins, 430-432
MAP files, 63
creating and reading, 493-501
extracting information from, 498-499, 504
PDB2MAP utility, 499-501
understanding contents of, 495-498
/MAP switch (LINK.EXE), 63
/MAPINFO switch (LINK.EXE), 63
McCarthy, Jim, 67, 762
McConnell, Steve, 18, 150, 762
McKay, Everett N., 764
Mem Usage column (Task Manager), 723
MemDumperValidator extension, 678-694
deep validations, 687-688
implementing, 691-694
initialization and termination in C++, 692-693
using with C, 686-687
using with C++, 685-686
memory, 667-715
access breakpoints, WinDBG, 381-382
block identifiers, 679
DCRT (debug C run-time) library, 667-676
features of, 668-669
new operator with, 671-674
release CRT library vs., 677-678
turning on, 670
useful functions, 675-676
debugging with MemDumperValidator extension, 678-694
C classes, 686-687
C++ classes, 685-686
deep validations, 687-688
implementing, 691-694
debugging with MemStress extension, 694-697
default memory manager, 589-590
global memory breakpoints, 277-280
/GS switch, 714
hunting down problems, 699-707
memory overruns, finding, 701-707
uninitialized memory writes, 700-701
leaks, 7
checking for, without utilities, 727
finding with MemDumperValidator extension, 678-694
operating system heap checking, 697-699
overruns, finding, 701-707
page faults, minimizing, 61. See also SWS utility
relocated DLLs, 54
/RTCx switches, 707-713
working set tuning, 723-747
SWS utility, 727-747
WST utility, 726
x86 CPU addressing, 307-309
walking the stack manually, 346-347
memory access breakpoints, WinDBG, 381-382
memory block identifiers, 679
memory leaks, 7. See also memory
checking for, without utilities, 727
MemDumperValidator extension, 678-694
C classes, 686-687
C++ classes, 685-686
deep validations, 687-688
implementing, 691-694
memory overruns, finding, 701-707
Memory window (Visual Studio .NET debugger), 295
walking the stack manually, 346-347
MemStress extension, 694-697
MEMSTRESSINIT macro, 695
MemTouch program, 382
merging trace logs, 720-721
message boxes with assertions, avoiding, 101
Messmer, Hans-Peter, 767
meta (dot) commands, WinDBG, 361, 385-386. See also specific commands by name
Meta-command Help command (WinDBG), 361
methods. See also specific methods by name
calling in Watch windows, 230-233
parameters, asserting, 89
return values, asserting, 90
Microsoft Intermediate Language (MSIL), 250-251, 258-259
Microsoft Intermediate Language Disassembler (ILDASM), 249-266
alternative tools, 266
important instructions, list of, 259-265
branch, 263
comparison, 262
load, 260-261
store, 261-262
tree output descriptions, 251
Microsoft WinDBG debugger, 162, 353-404, 556
basic issues, 356-359
setting up, 357-359
unusual behaviors, 359
breakpoints, 379-382
memory access breakpoints, 381-382
command parameters, 362
command-line arguments, changing, 360
commands, types of, 361
control commands, 385-386
dump files, handling, 393-396
creating, 393-394
debugging, 396
opening, 395-396
evaluating variables, 372-373
exceptions and events, 382-384
executing, stepping, tracing, 373-378
extension commands, 386-393
loading and controlling, 387-388
with SOS (Son of Strike), 398-403
getting help, 361-362
processes and threads, 366-371
attaching to and detaching from processes, 369-371
creating processes in Command window, 369
debugging child processes, 366-367
viewing in Command window, 367-369
SOS extension support, 396-403
symbol handling, 357, 362-366
MinDBG debugger, 171-190
MiniDumpFilterMemory function, 555
MiniDumpFilterMemoryPaths function, 555
minidumps, 71, 300
Create Mini Dump button (SUPERASSERT), 123, 299-301
deadlock dumps in the field, 590
garbage code (disassembled code), 350
MiniDumpFilterMemory function, 555
MiniDumpFilterMemoryPaths function, 555
MiniDumpWithHandleData function, 555
MiniDumpWriteDump function, 554-563
WinDBG debugger, 358, 394
writing, 394, 553-563
MiniDumpWithHandleData function, 555
MiniDumpWriteDump function, 554-563
Minimum Pixels To Drag Before Generating (Tester), 636
misunderstood project requirements, 12-13
mixed mode debugging, 246-247
MNUMDT (Magic Ninja Uninitialized Memory Debugging Technique), 700
module parameters, asserting, 89
ModuleLoadFinished method (ICorProfilerCallback), 458
Modules window, 52
monitoring exceptions, 455-477
ExceptionMon utility, 467-474
in-process debugging, 469-474
ProfilerLib, 465-467
Profiling API, 455-465
Morearty, Mike, 280, 381
mouse recording, Tester utility, 653, 662-665
MOV instruction (x86), 312
MOVS instruction (x86), 333
MOVSX instruction (x86), 329
MOVZX instruction (x86), 329
MS-DOS window in WinDBG, 385
MSIL (Microsoft Intermediate Language), 250-251, 258-259
MSVCMON.EXE, 292-294
MUL instruction (x86), 328
multiple breakpoints on single line, 227-228
multiprocessor machines, testing multithreading applications on, 592
multithreaded programming, 581-626
CreateThread and ExitThread functions, 588-589
DeadlockDetection utility, 595-624
DeadDetExt extension, 598, 610
future of, 624
high-level issues, 596-598
how to use, 598-601
implementing, 601-624
requirements for, 595-596
local storage, accessing, 337, 485
low-level multithreading, 583-587
multiprocessor machines, 592
names of threads, setting in native code, 276
obtaining thread identifiers, 240
TEB (thread environment block), 368
TIB (thread information block), 304, 336, 368
tips and tricks, 581-592
code reviews, 591
deadlock dumps in the field, 590
default memory manager, 589-590
discrete pieces, using, 583
minimizing amount of multithreading, 582
spinning critical sections, 587-588
testing on multiprocessor machines, 592
tracing performance, 718-719
Munyan, Steve, 36
Next
Last Updated: March 11, 2003
|