|
|
 |

 |
|
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 continued
N
4NT utility, 768
naked calls
convention for, 480-482
x86 calls, 317, 319
names
decorated, 498
Name property (Thread class), 240
text aliasing (WinDBG), 379
threads, in native code, 276
Nasarre, Christophe, 54
Nathan, Adam, 764
native C++ applications. See also native code
assertions in, 113-142
types of assertions, 118-142
VERIFY macro, 116
tracing, 148
native code. See also managed code
advanced breakpoints, 269-280
conditional expressions, 274-275
data breakpoints, 277-280
system and exported functions, 271-274
calling methods in Watch windows, 230-233
character limit on debugging information, 291
compiler and linker switches for debugging, 59-65
debugging DLL at source level, 246-247
debugging injected code, 295
detaching from Windows 2000 processes, 299
dump files, 299-301
exception monitoring, 296-298
hit counts on location breakpoints, 224
Memory window, 295
walking the stack manually, 346-347
remote debugging, 291-294
symbol handling, 298. See also symbols
thread names, setting, 276
warnings in, 48-51
Watch windows, 280-291, 350
autoexpanding types, 283-291
formatting data and expression evaluation, 280-283
pseudoregisters, 283
timing code, 283
where DLLs load, 52-57
WinDBG debugger, 353-404
basic issues, 356-359
breakpoints, 379-382
command parameters, 362
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, 398-403
getting help, 361-362
processes and threads, 366-371
SOS extension support, 396-403
symbol handling, 357, 362-366
x86 assembly language, 269-302
calling conventions, 316-322
common constructs, 336-337
complete example, 339-341
debugging tips and tricks, 349-351
Disassembly window, using, 341-345, 346-347
instruction format and memory addressing, 307-309
instructions, list of, 310-316, 327-336
registers, 303-307, 350
variables and parameters, 322-326
navigating disassembled code, 342
NDoc utility, 416
NEG instruction (x86), 327
Nelson, Mark, 765
.NET Framework. See also Visual Studio .NET debugger
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 add-in, 444-452
SuperSaver add-in, 438-444
tool windows, creating, 430-432
toolbar button issues, 429-430
advanced breakpoints (Visual Studio .NET Debugger), 214-228
Breakpoints dialog box, 217-222
Breakpoints window, 215
child breakpoints, 222
conditional expressions, 226-227, 236-240, 274-275
location breakpoint modifiers, 224-227
multiple on single line, 227-228
native code, 269-280
per-thread breakpoints, 240
quickly breaking on functions, 217-224
setting in dynamically loaded DLLs, 301
tips on setting, 215-217
applications
assertions in, 95-103
tracing, 144-146
ASP.NET applications
assertions in, 103-113
tracing, 146-148
Visual Studio .NET Debugger with, 233
CLR debugging, 160, 257
debug symbols, turning on, 42
debuggers, 158
Demeanor for .NET utility, 251, 768
development resources, 761-769
exception handling, 475-477
inline assembler (Visual C++ .NET), 309-310
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
Reflector utility, 266
tracing, 144-146
wizards, 408
!net_send extension command (WinDBG), 392
new operator, DCRT library tracking, 671-674
newarr instruction (ILDASM), 264
NEW_INLINE_WORKAROUND macro, 673-674
newobj instruction (ILDASM), 264
NGEN.EXE, 469
Nilsson, Jimmy, 765
/noconfig switch (C# compiler), 58
/NODEFAULTLIB switch (LINK.EXE), 63
noninvasive process attaching (WinDBG), 370-371
nonsampling, 456
NOP instruction (x86), 310
_NORMAL_BLOCK identifier, 679
NOT instruction (x86), 327
Notenboom, Leo, 434
notserv parameter, 569
NTOSKRNL.EXE debugger, 162
NTSD debugger, 354
null-terminated strings, handling, 713
O
obfuscators for intellectual property protection, 250
object lifetime tracking code, 524
.OCOMMAND command (WinDBG), 386
OCXs (ActiveX controls), where they load, 52-57
OnConnection method, 428
Onions, Julian, 502
Open Dump File command (WinDBG), 396
Open Executable dialog (WinDBG), 360
Open HTML Help File command (WinDBG), 362
Open Log File command (WinDBG), 375
OpenDeadlockDetection function, 599
.OPENDUMP command (WinDBG), 396
operating systems
heap checking, 697-699
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
understanding, 20
operational flow, viewing, 244, 479, 484-488
Optimization property, 61
Optimize For Windows98 property, 63
Options dialog, adding managed property pages to, 433-436
Options registry key, 433
/OPT:NOWIN98 switch (LINK.EXE), 63
OR instruction (x86), 327
order file (SWS utility), 732-733
/ORDER option (LINK.EXE), 725
/ORDER switch (LINK.EXE), 64
Osterlund, Russ, 769
OutputDebugString function, 602
OUTPUT_DEBUG_STRING_EVENT event, 176
overrun checking (/RTCs switch), 708
overruns, memory, 701-707
P
P command (WinDBG), 374
/P switch (CL.EXE), 59
packing functions 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
page faults, 309
minimizing, 61, 723-747
SWS utility, 727-747
future of, 747
how to use, 728-733
implementing, 734-746
PageHeap utility, 701-707
parameters
asserting, 89
macro, 410-411
viewing on stack (disassembled code), 342
WinDBG commands, 362
x86 assembly language, 322-326
PC command (WinDBG), 374
PDB (Program Database), 42, 200, 201, 494
CrashFinder utility, 502-511
generating MAP files from, 499-501
PDB2MAP utility, 499-501
/PDBSTRIPPED switch (LINK.EXE), 65
PE file format, 210
_penter function (SWS utility), 734-738
performance, 6
of BUGSLAYERUTIL.DLL, 678
critical sections, spinning, 587-588
data breakpoints, 277-280
default memory manager, 589-590
exception monitoring in native code, 296-298
exceptions, when to use, 475
logging depth and, 66
mixed-mode debugging, 247
multithreaded programming 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
operating system heap checking, 697
relocated DLLs, 54
server application tracing, 718-722
smoke test benchmark, 69
timing code in Watch window, 283
tools, 27
working set tuning, 723-747
SWS utility, 727-747
WST utility, 726
per-thread breakpoints, 240
Peters, Rich, 502
Petzold, Charles, 766
Pietrek, Matt, 57, 210, 465, 603, 699, 767
Pike, Rob, 257, 763
pipes for remote native code debugging, 292-294
planning
automatic unit tests, 629, 634. See also unit tests
debugging/testing, 18
projects, 9-13
resources for developers, 761-769
training to avoid bugs, 13, 20
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
pointer verification (/RTCs switch), 708
pooled COM objects, uncommitted transactions with, 624
POP instruction (x86), 311
POPAD instruction (x86), 312
PostMessage function, 593
Poulin, Franois, 149
#pragma directives
comment, 63
init_seg, 693
pack, 60
warning, 49
precompiling headers, 675
preprocessing source files, 59
Presedo, Pablo, 502
.PRF files (SWS utility), 732-733
printf-style debugging (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
PrivateAssemblies directory, 436
proactive coding, 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
process critical section, 594
Process Explorer utility, 53, 574, 576-578
Process Status command (WinDBG), 367
processes under WinDBG, 366-371
attaching to and detaching from, 369-371
creating in Command window, 369
debugging child processes, 366-367
viewing in Command window, 367-369
ProcessFunctionComment function (XmlDocument), 419
process-related bugs, 8-17
ProcessSpy utility, 54
ProfilerLib, 465-467
profiling, 455-465
in-process debugging, 469-474
ProfilerLib, 465-467
Profiling API, 455-465
flow tracing, 479, 484-488
hooking functions in, 479-484
enter and leave notifications, 480
FunctionIDMapper function, 483-484
implementing functions, 480-482
inlining, 482-483, 484
in-process debugging, 469-474
ProgId attribute (Connect class), 427
Program Database (PDB), 200, 201, 494
CrashFinder utility, 502-511
generating MAP files from, 499-501
programming language, knowledge of, 20
projects
building debugging systems, 41-66
debug symbols, 42-46
lightweight diagnostics for release builds, 65-66
managed code warnings, 46-48
native code warnings, 48-51
builds
breaking, 67
debug builds, 67, 70
frequency of, 67-68
full debugging symbols in, 42-46
lightweight diagnostics for release builds, 65-66
organizing build settings, 444-452
reproducing, 38
symbol servers, building, 71-81
projects
GUID strings, 412
knowledge of, 19
object models, 412-413
planning, 9-13, 18
tracking changes, 33-40
bug tracking, 38-40
full memory tracking (BUGSLAYERUTIL), 678
version control, 33-38, 40
labeling, 37
when to make changes, 36-37
prolog, function, 313
property evaluation, turning off, 230
Prosise, Jeff, 764, 766
protecting Win32 programs from debugger access, 160
pseudoregisters, 274, 283, 373
PublicAssemblies directory, 436
Purify utility, 669
PUSH instruction (x86), 311
PUSHAD instruction (x86), 312
Q
Q command (WinDBG), 371
quality, commitment to, 15-17
QueueUserWorkItem functions, 582
quick break keys, 165
Quit command (WinDBG), 371
Quit Command Prompt command (WinDBG), 385
R
R command (WinDBG), 369, 379
RaiseException function, 516, 520
reading debugger memory (WDBG), 192-195
reading MAP files, 493-501
extracting information from, 498-499
PDB2MAP utility, 499-501
understanding contents of, 495-498
ReadProcessMemory function, 176, 192
Reagan, Ronald, 84
REBASE.EXE utility, 54-57
rebasing DLLs, 52, 54-57
Record Focus Changes With Mouse Clicks And Double Clicks (Tester), 636
Recorder application, 628
recording Tester scripts, 635-638
Rector, Brent, 767
Red Time, 36
Reflector utility, 768
registers, x86 assembly language, 303-307, 350
Registers command (WinDBG), 369, 379
RegisterServiceCtrlHandlerEx function, 567
Registry changes for add-ins, 426
regular commands, WinDBG, 361
release builds
breaking, 67
debug builds, 67, 70
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
/RELEASE switches (LINK.EXE), 64
release vs. debug CRT libraries, 677-678
.RELOAD command (WinDBG), 364, 395
Reload Module command (WinDBG), 364, 395
relocated DLLs, 53
remote debugging
managed code, 247-249
native applications, 291-294
Remote Desktop Connection and Debugger.Launch, 107-108
Remove( ) (TraceListener classes), 100
REP instruction (x86), 334
REPE instruction (x86), 334
REPNE instruction (x86), 334
repeating bug occurrences, 24
reproducing builds, 38
requirements
documenting, 9-13
for debugging, 19-22
_resetstkoflw function, 527
resetting hit count, 226
resource leaks, 7
checking for, without utilities, 727
MemDumperValidator extension, 678-694
resources for developers, 761-769
ResumeDeadlockDetection function, 600
RET instruction (x86), 315-316
rethrowing exceptions, 476
return values
asserting, 90
for error conditions, 41
_ReturnAddress function, 557, 613
reverse engineering, 22
Anakrino utility, 266
ILDASM (Microsoft Intermediate Language Disassembler), 249-266
alternative tools, 266
important instructions, list of, 259-265
tree output descriptions, 251
.NET Reflector utility, 266
reviewing code, 15, 36
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
what to assert, 86-95
heap checking, 697-699
integer underflow/overflow checking, 58
memory leak checking, 7
checking for, 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
Richter, Jeffrey, 475, 517, 764, 767
Ritchie, Dennis M., 765
Roeder, Lutz, 266
/rootsuffix switch, 437
Rosenberg, Jonathan B., 210, 764
round-trip disassemblers, 254
_RPTFn macro (DCRT), 668
_RPTn macro (DCRT), 668
/RTC switch (CL.EXE), 61
/RTCx switches, 707-713
run time, working set tuning and, 744-746
Run To Cursor option (Visual Basic .NET Debugger), 217
run-time checking, 61
run-time error check switches, 707-713
Russinovich, Mark, 53, 97, 143, 168, 389, 574, 575, 576, 766, 769
S
/01 switch (CL.EXE), 61
S command (WinDBG), 367
sampling, 456
SatelliteDllName registry key, 427
SatelliteDllPath registry key, 427
SCAS instruction (x86), 333
scheduling
automatic unit tests, 634. See also unit tests
to avoid bugs, 8
installation program, building, 70
project planning, 9-13
time to build debugging systems, 41-66
debug symbols, 42-46
lightweight diagnostics for release builds, 65-66
managed code warnings, 46-48
native code warnings, 48-51
training to avoid bugs, 13, 20
SCM (Service Control Manager), 567, 575
SDK, Debugging Tools for Windows, 354
Seconds To Wait Before Inserting SLEEP Statements option (Tester), 637
security
buffer overrun checks, 61
buffer security check switch, 714
intellectual property protection, 250
preventing debugger access to Win32 programs, 160
string processing, debugging, 713
windows services, 568
segment registers, x86 CPU, 304
SEH (structured exception handling), 514-518
SEH frame, creating/destroying, 336
Sells, Chris, 491, 767
SendMessage function, 593
SendMessageTimeOut function, 593
server application tracing (FastTrace), 148, 717-722
implementation, 721-722
merging trace logs, 720-721
Service Control Manager (SCM), 567, 575
service identity, setting, 571
services, Web (XML)
assertions in, 103-113
documentation comments, 415-423
physical access to binaries, 250
timeout exceptions, 249
tracing, 146-148
services, Windows
basic characteristics, 566-568
API functions, 566-567
security, 568
debugging, 568-575
Allow Service To Interact With Desktop, 570
attaching to processes, 571-575
core code, 569
service identity, setting, 571
startup code, 575
Set Alias command (WinDBG), 379
Set Current Process/Thread command (WinDBG), 367
Set Exception commands (WinDBG), 382
Set Local Context command (WinDBG), 372
Set Locale command (WinDBG), 385
Set Next Statement command, 232-233, 345
SetBreakpoint function, 196
SetCrashHandlerFilter function, 549
SetCriticalSectionAndSpinCount function, 588
SetDeadlockDetectionOptions function, 599
SetEnterLeaveFunctionHooks method (ICorProfilerInfo), 480
SetEventMask method (ICorProfilerInfo), 458, 469
SetFastTraceOptions function (FastTrace), 719
SetFunctionIDMapper method (ICorProfilerInfo), 483
SetServiceStatus function, 567
_set_se_translator API, 524-525
SetSingleStep function, 198
setting breakpoints (Visual Studio .NET Debugger), 214-228
Breakpoints dialog box, 217-222
Breakpoints window, 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 in dynamically loaded DLLs, 301
tips on, 215-217
setting breakpoints (WDBG), 195-200
setting breakpoints (WinDBG), 379-382
Breakpoint Disable command (WinDBG), 380
Breakpoint Enable command (WinDBG), 380
Breakpoint List command (WinDBG), 380
memory access breakpoints, 381-382
SettingsMaster add-in, 444-452
SetUnhandledExceptionFilter function, 525-527
Shanholtz, Jeff, 502
.SHELL command (WinDBG), 385
.SHELL_QUIT command (WinDBG), 385
SHL instruction (x86), 328
short deadlines, 8
Show Includes property, 62
Show Number Formats command (WinDBG), 385
Show Progress property, 64
/showincludes switch (CL.EXE), 62
SHR instruction (x86), 328
Shutdown method (ICorProfilerCallback), 458, 460
single stepping (WDBG), 195-200
skills required for debugging, 19-22
skip count modifiers (location breakpoints), 224-226
Smaller Type Check property, 61
smoke tests, 68-70
Smooth Working Set (SWS) utility, 62, 727-747
future of, 747
how to use, 728-733
order file, 732-733
running applications with, 731-732
setting up SWS compiles, 729-731
implementing, 734-746
file format and symbol enumeration, 738-744
_penter function, 734-738
run time, 744-746
SnapCurrentProcessMiniDump function, 556, 590
SnapFastTraceFiles function (FastTrace), 720
SOAPscope utility, 768
SoftICE debugger, 163-164
Solitaire, replacing boss's mail program with, 170
Solomon, David A., 389, 766
Son of Strike (SOS) support, 235, 396-403
source files
DCRT library, 669
extracting from MAP files, 498-499, 504
Source Insight utility, 768
spinning critical sections, 587-588
SplitParams function, 411
Spool, Jared, 12
Stack Back Trace section (Dr. Watson), 757
stacks
checking (/RTCs switch), 707
infinite recursion and, 527
stack frames, 313, 324
Stack Walking section (SUPERASSERT), 125
StackTrace class, 98
StackWalk64 API, 202, 208
walking (WDBG), 208
StackTrace class, 98
StackWalk64 API, 202, 208
Standard Template Library (STL), 49, 51, 374, 589
starg instruction (ILDASM), 261
StartDebugging function, 92
starting automatically in debuggers, 168-170
StartPoint property (code elements), 418
StartServiceCtrlDispatcher function, 567
startup code, services, 575
static versions of CRT libraries, 677-678
__stdcall call (x86), 317, 318
stelem instruction (ILDASM), 261
Step command (WinDBG), 374
Step Into/Over/Out (WDBG), 209-210
Step to Next Call command (WinDBG), 374
stepping through code
DebuggerStepThroughAttribute attribute, 245
SetSingleStep function, 198
WDBG debugger
basic functionality, 209-210
breakpoints and single stepping, 195-200
stack walking, 200-208
WinDBG debugger, 373-378
stepping through the stack, 346-347
stfld instruction (ILDASM), 262
STL (Standard Template Library), 49, 51, 374, 589
store instructions (ILDASM), 261-262
STOS instruction (x86), 333
STRESS.EXE program, 694
stressing applications, 694-697
string manipulation instructions (x86), 333-336
string processing, 713
Strip Private Symbols property, 64, 65
STRSAFE library, 713
Struct Member Alignment property, 60
structure references (x86), 338
structured exception handling (SEH), 514-518
SUB instruction (x86), 312
subexpression breakpoints, 217
Sullivan, Ed, 762
SUPERASSERT macro, 121-142, 299-301
implementation highlights, 127-142
SuperSaver add-in, 438-444
SuspendDeadlockDetection function, 600
Swift, Jonathan, 350
SWS (Smooth Working Set) utility, 62, 727-747
future of, 747
how to use, 728-733
order file, 732-733
running applications with, 731-732
setting up SWS compiles, 729-731
implementing, 734-746
file format and symbol enumeration, 738-744
_penter function, 734-738
run time, 744-746
SX commands (WinDBG), 382
!sym extension command (WinDBG), 365
SymbolEngine project, 203
symbols
debugging, 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
building symbol server, 357
SYMSRV.DLL file, 73
SYMSTORE.EXE utility, 78
synchronization 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
System account, 568, 571
system DLLs, breakpoints on, 271-274
System.Exception class, 41
T
T command (WinDBG), 374
tailcall exit function, 480
Tanenbaum, Andrew S., 767
Task Manager, 573, 727
TC command (WinDBG), 374
TCP/IP for remote native code debugging, 292-294
TEB (thread environment block), 368
technologies, understanding, 20
terminating MemBumperValidator in C++, 692-693
Terminal Services, Remote Desktop Connection and Debugger.Launch, 107-108
test apps (unit tests), 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, 634
future of, 665
recording, 635-638
requirements for, 629
test harness. See unit tests
TEST instruction (x86), 329
Tester utility (user interface testing)
implementing, 638-665
keystroke and mouse recording, 653-665
notification and playback, 638-653
manual, 627-628
scheduling tests, 634
scripts for, 630-635
debugging scripts for, 634
future of, 665
recording scripts for, 635-638
requirements for, 629
testers, role of, 84
testing
code verification, 84, 151-153
multithreaded applications, 592. See also threading
plans for, 18
smoke tests, 68-70
user interface tests, 35, 84, 151-153, 627-665
future of, 665
implementing, 638-665
manual, 627-628
requirements of, 629
scheduling, 634
scripts for, 630-635
verifying bug fixes, 28
x86 instructions, 329
text aliasing (WinDBG), 379
TextWriterTraceListener class, 97
this call (x86), 317, 319
thread environment block (TEB), 368
thread identifiers, obtaining, 240
thread information block (TIB), 304, 336, 368
thread local storage, accessing, 337, 485
thread names, setting in native code, 276
Thread Status command (WinDBG), 368
threading (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
WinDBG, 366-371
!threads extension command (WinDBG), 398
!threadtoken extension command (WinDBG), 388
throw keyword, 518
TIB (thread information block), 304, 336, 337, 368
time intervals, WST and, 739
timeout exceptions, XML web services, 249
TimeOut property (web services), 249
timing code in Watch window, 283
.TLIST command (WinDBG), 369
TLIST.EXE utility, 355, 574
Toggle Source Line Support command (WinDBG), 374
!token extension command (WinDBG), 388
tool windows, add-ins, 430-432
toolbar buttons in add-ins, 429-430
tools, understanding your own, 20
tools for debugging, 27
bug tracking systems, 33, 38-40
version control systems, 33-38, 40
labeling, 37
when to make changes, 36-37
Trace and Watch Data command (WinDBG), 374-378
Trace class (System.Diagnostic), 95-96, 144-146
Trace command (WinDBG), 374
TRACE macro, 148
Trace to Next Call command (WinDBG), 374
TraceContext.Trace class, 146-148
TraceListener class, 96-103, 144
TraceSwitch class, 145-146
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
TraceSwitch class, 145-146
web services, 146-148
WinDBG debugger, 373-378
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
training to avoid bugs, 13, 20
translating EXCEPTION_POINTERS structures, 551-553
trimming white space from files, 438-444
trust-and-verify approach, 84, 151-153
try keyword, 518
__try/__except statements, 514
__try/__finally statements, 514
TuneModule function (SWS), 744
tuning (performance), 6
of BUGSLAYERUTIL.DLL, 678
critical sections, spinning, 587-588
data breakpoints, 277-280
default memory manager, 589-590
exception monitoring in native code, 296-298
exceptions, when to use, 475
logging depth and, 66
mixed-mode debugging, 247
multithreaded programming 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
operating system heap checking, 697
relocated DLLs, 54
server application tracing, 718-722
smoke test benchmark, 69
timing code in Watch window, 283
tools, 27
working set tuning, 723-747
SWS utility, 727-747
WST utility, 726
types, expanding automatically (Watch window)
managed code, 241-243
native code, 283-291
U
UI testing, 35, 84, 151-153, 627-665
implementing automatic, 638-665
keystroke and mouse recording, 653-665
notification and playback, 638-653
manual, 627-628
scheduling, 634
scripts for, 630-635
debugging, 634
future of, 665
recording, 635-638
requirements for, 629
UMDH.EXE utility, 355
unbox instruction (ILDASM), 265
uncommitted transactions with pooled COM objects, 624
underrun checking (/RTCs switch), 708
Unicode strings in WinDBG, 385
uninitialized memory writes, 700-701
unit tests, 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, 634
future of, 665
recording, 635-638
requirements for, 629
.UNLOAD command (WinDBG), 387
Unload Extension DLL command (WinDBG), 387
UNLOAD_DLL_DEBUG_EVENT event, 176
unmanaged code. See native code
Unsupported Tools add-ins, 425
unwinding exceptions, 515
Use Full Page Heap option (AppVerifier), 704
Use IntelliSense To Verify Breakpoints option, 217
user expectations, 6
user interface testing, 35, 84, 151-153, 627-665
implementing automatic, 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
user interfaces, inconsistent, 5
UserDebuggerHotKey value (AeDebug key), 164-165
user-mode debuggers, 159-160
using statement, 477
V
VALIDATEALLBLOCKS macro, 688
validation function (MemDumperValidator), 687-688
variable usage checking (/RTCu switch), 708
variables
changing values of (Watch windows), 228-233
calling methods in, 230-232
expanding types automatically, 241-243, 283-291
native code, 280-291, 350
Set Next Statement command, 232-233
evaluating with WinDBG, 372-373
x86 assembly language, 322-326
vectored exception handling, 517
/VERBOSE switches (LINK.EXE), 64
VERIFY macro, 116
verifying bug fixes, 28
verifying code, 84, 151-153
version control systems, 33-38, 40
labeling, 37
when to make changes, 36-37
versions of CRT libraries, 678
$VFRAME pseudoregister, 283
virtual machines, debugging environment, 160
VirtualProtect function, 176
VirtualProtectEx function, 193
VirtualQueryEx function, 193
Visual Assist utility, 768
Visual Basic .NET projects, turning on debug symbols, 42
Visual C++ .NET inline assembler, 309-310
Visual Studio Debugger Proxy (DbgProxy), 159
Visual Studio .NET
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 add-in, 444-452
SuperSaver add-in, 438-444
tool windows, creating, 430-432
toolbar button issues, 429-430
applications
assertions in, 95-103
tracing, 144-146
ASP.NET applications
assertions in, 103-113
tracing, 146-148
Visual Studio .NET Debugger with, 233
CLR debugging, 160, 257
debug symbols, turning on, 42
debuggers, 158
Demeanor for .NET utility, 251, 768
development resources, 761-769
exception handling, 475-477
inline assembler (Visual C++ .NET), 309-310
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
Reflector utility, 266
tracing, 144-146
wizards, 408
Visual Studio .NET Add-In Wizard, 426-429
Visual Studio .NET debugger, 213-234
advanced breakpoints (Visual Studio .NET Debugger), 214-228
Breakpoints dialog box, 217-222
Breakpoints window, 215
child breakpoints, 222
conditional expressions, 226-227, 236-240, 274-275
location breakpoint modifiers, 224-227
multiple on single line, 227-228
native code, 269-280
per-thread breakpoints, 240
quickly breaking on functions, 217-224
setting in dynamically loaded DLLs, 301
tips on setting, 215-217
ASP Web applications, 233
Disassembly window, 341-345
garbage code, 350
walking the stack manually, 346-347
Memory window, 295, 346
Watch windows, 228-233
calling methods in, 230-232
expanding types automatically, 241-243, 283-291
native code, 280-291, 350
Set Next Statement command, 232-233
VSVARS32.BAT file, 397
W
WaitForDebugEvent function, 172
WaitForSingleObject function, 585, 594-595
Walk Stack button (SUPERASSERT), 124
walking the stack
manually (disassembled code), 346-347
Stack Walking section (SUPERASSERT), 125
WDBG, symbols and, 200-208
Warn( ) (TraceContext.Trace), 146
Warning glyph (Breakpoints window), 216
warnings
managed code, 46-48
native code, 48-51
Watch windows (Visual Studio .NET debugger), 228-233
calling methods in, 230-232
expanding types automatically, 241-243, 283-291
native code, 280-291, 350
autoexpanding types, 283-291
formatting data and expression evaluation, 280-283
pseudoregisters, 283
timing code, 283
Set Next Statement command, 232-233
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
WDBG.EXE subsystem (WDBG), 192
web services, XML
assertions in, 103-113
physical access to binaries, 250
timeout exceptions, 249
tracing, 146-148
white space, trimming off files, 438-444
Whole Program Optimizations setting, 62
wild writes (memory), 700-701
Win32 Debugging API, 159
WinDBG (Microsoft Windows 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
window placement, 359
Windows 2000 processes, detaching from, 299
Windows debuggers, 159-164
kernel-mode, 161-164
KD (kernel debugger), 162
SoftICE, 163-164
WinDBG (Windows Debugger). See WinDBG
MinDBG debugger, 171-190
user-mode debuggers, 159-160
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
writing your own, 210-211
Windows development resources, 761-769
Windows Forms
assertions, 95-103
tracing, 144-146
Windows Me, implementing DeadlockDetection, 603-604
Windows operating system heap checking, 697-699
Windows services
basic characteristics, 566-568
API functions, 566-567
security, 568
debugging, 568-575
Allow Service To Interact With Desktop, 570
attaching to processes, 571-575
core code, 569
service identity, setting, 571
startup code, 575
wizards, 408
Woodring, Mike, 764
working set tuning, 723-747
SWS utility, 727-747
future of, 747
how to use, 728-733
implementing, 734-746
WST utility, 726
/Wp64 switch (CL.EXE), 60
Write( ) (Trace), 144, 146
WriteIf( ) (Trace), 144
WriteLine( ) (Trace), 144
WriteLineIf( ) (Trace), 144
WriteProcessMemory function, 176
writing debuggers, 210-211
writing to debugger memory (WDBG), 192-195
WST (Working Set Tuner) utility, 726
wt command (CORDBG.EXE), 244, 479
WT command (WinDBG), 374-378
X
X command (WinDBG), 365
/X switch (CL.EXE), 60
x86 assembly language, 269-302
calling conventions, 316-322
common constructs, 336-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
XML documentation comments, 415-423
XML web services
assertions in, 103-113
physical access to binaries, 250
timeout exceptions, 249
tracing, 146-148
XmlDocument class, 419
XOR instruction (x86), 327
XPExceptMon project, 517
Y
Yellow Time, 36
Z
/Zi switch (C++), 43
/Zp switch (CL.EXE), 60
Previous
Last Updated: March 11, 2003
|