160 likes | 378 Views
HW-889P. Advanced driver code analysis techniques Tips and tricks to develop more secure & reliable drivers. Dave Sielaff Principal Software Development Engineer Microsoft Corporation. Motivation. Customers want reliable products Some bugs are tough to find by debugging
E N D
HW-889P Advanced driver code analysis techniquesTips and tricks to develop more secure & reliable drivers Dave Sielaff Principal Software Development Engineer Microsoft Corporation
Motivation • Customers want reliable products • Some bugs are tough to find by debugging • Finding potential crashes earlier is always good
Agenda • Introducing the Source Code Annotation Language (SAL) • Understanding Visual Studio Code Analysis warnings • Adding SAL to existing driver Afterwards, you will have examples of how to • Fix bugs using Code Analysis warnings • Annotate parameters and shared variable access
Introducing SAL • Microsoft Source Code Annotation Language • Describes important aspects of code intent • Like using ASSERT on function declarations • Readable by humans and tools • Declaring locking behavior • Finding potential race conditions, deadlocks • Describing parameter behavior • Finding potential null dereferences, uninitialized memory use
Describing locking behavior • Which functions acquire/release locks? • _Acquires_lock_(lock) • _Releases_lock_(lock) • Does a function depend on a lock being held prior to call? • _Requires_lock_held_(lock) • Which variables are guarded by which lock? • _Guarded_by_(lock)
demo Concurrency Annotation Usage
Basic SAL parameter concepts • Input • Data is passed to called function, treated as read-only • Input/Output • Data is passed into function and potentially modified • Output • Caller only provides space for called function to write to • Called function writes data into that space • Output Pointers • Like Output, where value returned by called function is pointer
Basic SAL parameter concepts (continued) • Required • Pointer parameter that must be non-NULL • Optional • Pointer parameter that can be NULL
demo Parameter Annotation Usage
Using Code Analysis and SAL • Code Analysis can find valuable bugs right out of the box • Adding SAL to your code makes Code Analysis even more effective • Think of SAL as compile-time ASSERT system • No need to annotate your code all at once • Annotating incrementally gets you incremental value, immediately and over time as your code evolves
For more information RELATED SESSIONS DOCUMENTATION & ARTICLES • TOOL-100T: Improving software quality using Visual Studio 11 C++ Code Analysis • Driver Development Tools • Windows Hardware DevCenter • Windows DevCenter • Visual Studio Code Analysis and SAL
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.