没有合适的资源?快使用搜索试试~ 我知道了~
首页Klocwork_Tuning_Analysis_C_C++.pdf
资源详情
资源推荐
Tuning Klocwork
Analysis for C/C++
Software release 8.0 SR1
Document version 4.0
Copyright © 1998-2008 Klocwork Inc.
All rights reserved
This document, as well as the software described in it, is furnished under license and may only be
used or copied in accordance with the terms of such license. The information contained herein is the
property of Klocwork Inc. and is confidential between Klocwork Inc. and the client and remains the
exclusive property of Klocwork Inc. No part of this documentation may be copied, translated, stored
in a retrieval system, or transmitted in any form or by any means, electronic, mechanical,
photocopying, recording or otherwise without the prior written permission of Klocwork Inc.
If you find any problems in the documentation, please report them to us in writing. Klocwork Inc.
does not warrant that this document is error-free.
Klocwork Inc. and Klocwork are registered trademarks and Klocwork Insight, Klocwork Solo, Klocwork Insight Architect, Klocwork Insight
Review, Klocwork Source Cross-Reference, Klocwork Management Console, Klocwork Developer for Java in Eclipse, Klocwork for C/C++,
Klocwork for Java, Klocwork Extensibility Interface, and Klocwork Stack Overflow Analyzer are trademarks of Klocwork Inc.
Copyright notices for third-party software are contained in the file “3rdparty_copyright_notices.txt”, located in the Klocwork installation
directory.
Adobe®, Adobe Acrobat, Acrobat Exchange, Acrobat Reader, and PostScript are either registered trademarks or trademarks of Adobe Systems
Incorporated in the United States and/or other countries. Rational ClearCase is a registered trademark of IBM Corporation. Linux is a registered
trademark of Linus Torvalds. FLEXlm is a registered trademark of Macrovision Corporation. Microsoft®, Microsoft Word, Microsoft Excel,
Microsoft Office, Internet Explorer, Windows®, Windows NT®, Windows® 2000, Windows® 2000 Server, Windows® Server 2003, Windows®
XP, MS-DOS™, Microsoft Visual Studio®, Microsoft .NET, and Microsoft Visual C++ are trademarks of Microsoft Corporation. Pentium® is a
registered trademark of Intel Corporation. Red Hat is a trademark of Red Hat, Inc., in the United States and other countries. Sun, Sun
Microsystems, the Sun Logo, Solaris, Forte, Java, JRE and all Java-related trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc. in the United States and other countries. All SPARC trademarks are used under license and are trademarks or registered
trademarks of SPARC International, Inc. in the United States and other countries. Products bearing SPARC trademarks are based upon an
architecture developed by Sun Microsystems, Inc. MySQL is a registered trademark of MySQL AB in the USA and other countries. InstallShield
is a service mark and is either a registered trademark or trademark of InstallShield Software Corporation in the United States and/or other
countries. IntelliJ IDEA is either a trademark or a registered trademark of JetBrains, Inc. Java Service Wrapper is a trademark of Tanuki Software.
WinCVS, Krusader and SourceForge are trademarks of OSTG Open Source Technology Group, All Rights Reserved. Apache TomCat is a
trademark of the Apache Software Foundation. Green Hills is a registered trademark of Green Hills Software, Inc. Metrowerks is a registered
trademark of Freescale Semiconductor, Inc. Wind River is a registered trademark of Wind River Systems, Inc. yEd is a trademark of yWorks
GmbH. JBuilder is a registered trademark of Borland Software Corporation. BEA WebLogic is a registered trademark of BEA Systems, Inc.
Klocwork Inc.
Toll-free telephone (North America):
1-866-556-2967
E-mail:
sales@klocwork.com
support@klocwork.com
Web site: http://www.klocwork.com
In the U.S.:
8 New England Executive Park, Suite 180
Burlington, Massachusetts 01803 USA
In Canada:
30 Edgewater Street, Suite 114
Ottawa, Ontario
Canada K2L 1V8
iii
Contents
Chapter 1 Getting started 5
Who should use this book ............................................................................................................................. 5
Why tune Klocwork analysis? ...................................................................................................................... 5
Documentation conventions ......................................................................................................................... 6
Help and support ........................................................................................................................................... 6
Chapter 2 Using macro simplification to tune Klocwork analysis 9
Overriding macro definitions ........................................................................................................................ 9
#kw_override ..................................................................................................................................... 9
#kw_nodef ....................................................................................................................................... 12
Using the __KLOCWORK__ macro .......................................................................................................... 12
Ignoring default macro definitions .............................................................................................................. 13
Changing default macro definitions ............................................................................................................ 13
Example: Dealing with NPD false positives caused by custom asserts ...................................................... 14
Chapter 3 Using knowledge base files to tune Klocwork analysis 17
Introduction ................................................................................................................................................ 17
Creating and applying a knowledge base file ............................................................................................. 18
Creating a knowledge base file ........................................................................................................ 18
Using your knowledge base in Klocwork analysis .......................................................................... 18
Examples .................................................................................................................................................... 18
Tuning the memory leak checker .................................................................................................... 18
Tuning the NPD checker ................................................................................................................. 24
Tuning the Resource Leak checker .................................................................................................. 29
Appendix A Knowledge base specification 33
Knowledge base syntax for C/C++ ............................................................................................................. 33
About records and fields .................................................................................................................. 33
Common syntax elements in the Specification field ........................................................................ 37
Specification fields for default record kinds ............................................................................................... 41
ACQUIRE ....................................................................................................................................... 41
ALLOC ............................................................................................................................................ 44
BAA ................................................................................................................................................ 46
BPS .................................................................................................................................................. 48
CHECKRET .................................................................................................................................... 48
CONDNORET ................................................................................................................................ 49
DMEM............................................................................................................................................. 50
FREE ............................................................................................................................................... 52
IAA .................................................................................................................................................. 52
LOCK .............................................................................................................................................. 53
NORET ............................................................................................................................................ 54
NPD ................................................................................................................................................. 54
NPD.SRC ........................................................................................................................................ 55
iv Contents
R ...................................................................................................................................................... 57
RELEASE ....................................................................................................................................... 59
RET ................................................................................................................................................. 60
RETARG ......................................................................................................................................... 61
SAFE_FREE ................................................................................................................................... 62
SLEEP ............................................................................................................................................. 62
TaintedIntData ................................................................................................................................. 63
TSFMTsink ..................................................................................................................................... 63
TSprop ............................................................................................................................................. 64
TSsrc ................................................................................................................................................ 64
UNLOCK ........................................................................................................................................ 65
UnsafeAllocSizeAccepter ................................................................................................................ 65
UnsafeArrayIndexAccepter ............................................................................................................. 66
UnsafeLoopBoundAccepter ............................................................................................................ 66
W ..................................................................................................................................................... 66
xNPD ............................................................................................................................................... 67
xRET ............................................................................................................................................... 67
5
In This Chapter
Who should use this book .................................................. 5
Why tune Klocwork analysis? ........................................... 5
Documentation conventions ............................................... 6
Help and support ................................................................ 6
Who should use this book
Tuning Klocwork Analysis explains how to increase the accuracy of
Klocwork code issue detection. You can cause Klocwork to find code issues
that would otherwise go undetected, or reduce the number of issues that
Klocwork reports incorrectly in the context of your source code. The results
of your changes will appear in Klocwork Review and in the Klocwork
developer tools after a Klocwork analysis.
You should be at the expert level with Klocwork and your organization's
software to tune Klocwork analysis.
Why tune Klocwork analysis?
Klocwork analysis uses two sources of information for issue detection: your
source code, and the Klocwork knowledge base. The Klocwork knowledge
base is a repository of information about how functions interact in a software
system. This information lets Klocwork assess apparent code issues in
context to determine if they are true code issues. With this knowledge,
Klocwork is able to find code issues that would otherwise go undetected.
For example, knowledge base entries can help identify how a function uses
parameters passed to it, or whether a function is a part of a memory
allocation/deallocation pair. Native system function behavior is specified in
the default knowledge bases. Manually adding knowledge base entries can
significantly increase the accuracy of issue detection and improve the
productivity of Klocwork users, particularly when third-party libraries are
used.
C HAPTER 1
Getting started
剩余69页未读,继续阅读
stephegn
- 粉丝: 9
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功