16
PC-LINT PLUGIN 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 1 Table of Contents Chapter 1. Gimpel PC-lint/MISRA Plug-in 1.1 Introduction ..................................................................................................... 3 1.2 About Gimpel PC-lint/MISRA ......................................................................... 3 1.3 Gimpel PC-LINT/MISRA Installation .............................................................. 3 1.4 Plug-In Installation .......................................................................................... 5 1.5 Example of Use .............................................................................................. 6 Chapter 2. PC-Lint Plugin Function Summary 2.1 Introduction ................................................................................................... 11 2.2 PCLint Tab ................................................................................................... 11 2.3 Context Menu Items ..................................................................................... 12 About This Help File ................................................................................................... 13 Index ............................................................................................................................. 15

Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-LINT PLUGIN

Table of Contents

Chapter 1. Gimpel PC-lint/MISRA Plug-in1.1 Introduction ..................................................................................................... 31.2 About Gimpel PC-lint/MISRA ......................................................................... 31.3 Gimpel PC-LINT/MISRA Installation .............................................................. 31.4 Plug-In Installation .......................................................................................... 51.5 Example of Use .............................................................................................. 6

Chapter 2. PC-Lint Plugin Function Summary2.1 Introduction ................................................................................................... 112.2 PCLint Tab ................................................................................................... 112.3 Context Menu Items ..................................................................................... 12

About This Help File ................................................................................................... 13

Index ............................................................................................................................. 15

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 1

Page 2: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

DSxxxxxxxxA-page 2 2006-2016 Microchip Technology Inc.

Page 3: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-LINT PLUGIN

Chapter 1. Gimpel PC-lint/MISRA Plug-in

1.1 INTRODUCTION

The Gimpel PC-lint/MISRA plug-in provides a LINT and MISRA standard check on C source files created in MPLAB X IDE. This plug-in sets the PC-lint installation path, compiler configuration, command line argument, log file creation and selection of source files.

To check the source code, the plug-in will invoke the Gimpel PC-lint/MISRA executable file with the appropriate command line argument. The output of the Gimpel PC-lint/MISRA analysis will be redirected to the MPLAB X IDE output window. The out-put will contain the file name(s) and line number(s) in which linting found inconsisten-cies. Double clicking an output line will open the corresponding file at the line number in the MPLAB X IDE editor window.

• About Gimpel PC-lint/MISRA

• Gimpel PC-LINT/MISRA Installation

• Plug-In Installation

• Example of Use

1.2 ABOUT GIMPEL PC-LINT/MISRA

PC-lint will check your C/C++ source code and find bugs, glitches, inconsistencies, non-portable constructs, redundant code, and much more using the K&R and ANSI standards for C (style of coding). The purpose of linting your program is to determine potential problems prior to integration or porting, or to reveal unusual constructs that may be a source of subtle errors. PC-lint often finds problems that the compiler alone cannot. It is much fussier about details than the compiler. The C compiler cannot always detect each and every potential problem in your source files. This is where PC-lint comes in. PC-lint can be configured to complain a lot or a little.

1.3 GIMPEL PC-LINT/MISRA INSTALLATION

Begin by installing Gimpel PC-lint Software. Go to the Gimpel web site to acquire this product and update to the latest patch:

http://www.gimpel.com/html/pcl.htm

On Windows, running the setup program will copy the PC-lint files onto your hard drive. Running the configuration wizard (config.exe) will configure PC-lint (lint-nt.exe) for your compiler, libraries, editors and IDEs. It may be run multiple times if you have multiple configurations for which you need support. It will build a batch file for calling PC-lint (lin.bat) and will invoke the appropriate PC-lint configuration files (*.lnt) for your environment.

PC-lint error messages may be found in the file msg.txt.

Important Gimpel PC-lint/MISRA plug-in files are listed below.

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 3

Page 4: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

1.3.1 lint-nt.exe

PC-lint executable to process the C source file(s) for linting.

1.3.2 config.exe

Configuration wizard for PC-lint. This wizard creates a file that contains options to allow PC-lint to process the source code, i.e., using this utility you will be able to select your desired Microchip C compiler.

1.3.3 co-xcnn.lnt

The co-xcnn.lnt files are included with PC-lint and contain options for using the respective MPLAB XC C compiler with PC-lint.

Currently, for PC-lint to support MPLAB XC C compilers, you will need to follow the instructions in the co-xc8.lnt, co-xc16.lnt and co-xc32.lnt files for editing lint-cmac.h and include-path.lnt files.

For example, co-xc8.lnt for MPLAB XC8 has:

// Before you start using this file, please follow the directions to perform these// simple steps:// 1- include the path(s) to your header files// - run xc8 with -v option and copy any -I argument from the output to// include-path.lnt (in the same directory where co-xc8.lnt exists).// don't forget to use the -i lint option. ex: -i"include-path".// Note that any other include directories should be added explicitly.

// 2- Now include the preprocessor macro definitions specific to the chip you are// using:// - From the output you get in step one, copy all arguments starting with -D// to "lint-cmac.h" in the same directory as co-xc8.lnt.// - Edit the file to have the form:// #define macro_name value // each definition on a separate line

1.3.4 msg.txt

An ASCII rendition of PC-lint messages for MPLAB X IDE use. PC-lint message types are shown in Table 1-1

1.3.5 lin.bat

Batch file for invoking lint-nt.exe.

TABLE 1-1: PC-LINK MESSAGES

Type C C++ Warning Level

Syntax Errors 1 - 199 1001 - 1199 1

Internal Errors 200 - 299 0

Fatal Errors 300 - 399 0

Warnings 400 - 699 1400 - 1699 2

Informational 700 - 899 1700 - 1899 3

Elective Notes 900 - 999 1900 - 1999 4

DSxxxxxxxxA-page 4 2006-2016 Microchip Technology Inc.

Page 5: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

Gimpel PC-lint/MISRA Plug-in

1.4 PLUG-IN INSTALLATION

To install the plug-in into MPLAB X IDE:

1. Select Tools>Plugins.

2. In the Plugins window, click on Available Plugins.

3. Check “Install” in front of “PCLint” and then click the Install button.

4. Follow the instructions to install the plugin. You may need to restart MPLAB X IDE when you are done.

If you do not see the PC-lint or any other plugins here, you will need to configure the Microchip Update Center under the Settings tab. See MPLAB X IDE Help for informa-tion on how to do this.

FIGURE 1-1: AVAILABLE PLUGINS

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 5

Page 6: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

1.5 EXAMPLE OF USE

First follow the instructions under:

• Section 1.3 “Gimpel PC-LINT/MISRA Installation”

• Section 1.4 “Plug-In Installation”

Then read the following sections.

1.5.1 Get the latest config files for check

Update or get the latest configuration (config) files for the check you want to run. For this example, the MISRA2012 check is used. You will need these config files:

1. au-misra3.lnt - MISRA checks to run

2. co-xc8.lnt - MPLAB XC8 C compiler config files

If you updated to the latest PC-lint patch, you will have the latest versions of these files.

1.5.2 Create a user options file

Create a userOptions file that basically contains:

1. the path to the check config-file - au-misra3.lnt

2. the path to the compiler config file - co-xc8.lnt

For example, userOptions.lnt contains:

// Microchip MPLAB XC8 C, -si4 -sp4, // Standard lint options//-SL-3.3.16: how-to from Mekala and based on his input setup this cfgC:\lint\configSL\au-misra3.lntC:\lint\configSL\co-xc8.lnt//C:\lint\options.lnt -si4 -sp4-i"C:\Program Files (x86)\Microchip\xc8\v1.36\include"

1.5.3 Configure PC-lint in MPLAB X IDE

To configure PC-lint in MPLAB X IDE, select Tools>Options>Embedded>PCLint (Figure 1-2). Then set:

1. "Location" - Enter the path to your PC-lint executable file lint-nt.exe.

2. "Options" - Select “UserOptionFile”.

3. "User Option File:Path" - Select the path to your userOptions file.

4. "Standards" - Select MISRA2012.

DSxxxxxxxxA-page 6 2006-2016 Microchip Technology Inc.

Page 7: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

Gimpel PC-lint/MISRA Plug-in

FIGURE 1-2: PC-LINT TAB

1.5.4 Create config files according to header

Create two more config files as described in the header of the co-xc8.lnt file (see Section 1.3.3 “co-xcnn.lnt”). Both files contain the information that is usually passed via the compiler options -i xxx (include-path.lnt) and -D xxx (lint-cmac.h). For this example both files are empty, BUT they need to exist (as referenced in the co-xc8.lnt file).

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 7

Page 8: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

1.5.5 Generate dependency files for MPLAB XC compilers

For MPLAB XC Compilers, PC-lint requires include-path.lnt and lint-cmac.h for linting. These two files can be generated from the MPLAB X IDE project context menu item “Generate PCLint Dependency Files”. Selecting this item will add both dependency files to the c:\pclint\lint\lnt folder.

FIGURE 1-3: GENERATE PCLINT DEPENDENCY FILES

DSxxxxxxxxA-page 8 2006-2016 Microchip Technology Inc.

Page 9: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

Gimpel PC-lint/MISRA Plug-in

1.5.6 Lint the files in a project

Right-click on the project you wish to lint in the MPLAB X IDE Project window and select "Lint this Project" (see Figure 1-4). You should get a output as shown in Figure 1-5.

FIGURE 1-4: LINT THIS PROJECT

FIGURE 1-5: PC-LINT OUTPUT

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 9

Page 10: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

DSxxxxxxxxA-page 10 2006-2016 Microchip Technology Inc.

Page 11: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-LINT PLUGIN

Chapter 2. PC-Lint Plugin Function Summary

2.1 INTRODUCTION

Once the Gimpel PC-lint/MISRA plug-in is installed, the following items will be added to MPLAB XIDE:

• PCLint Tab

• Context Menu Items

2.2 PCLINT TAB

The PCLint tab will be created under Tools>Options, Embedded.

FIGURE 2-1: PCLINT TAB

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11

Page 12: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

2.3 CONTEXT MENU ITEMS

A “Lint this File/Project” menu option will be added to the respective context menu.

Clicking the menu item will lint the files and present the output in the Output window on a tab named PCLint. The output will contain the hyperlink with file name(s) and line number(s) in which the lint tool found inconsistencies. Clicking on the hyperlink will open the corresponding file at the specified line number.

2.3.1 File Context Menu

A “Lint this File” menu option will be added to the file context menu. To open this context menu, right click on a source file in the Source Files folder of a project in the Projects window.

Multiple files may also be selected for linting, but be sure to set the project as “main” before performing this operation.

2.3.2 Project Context Menu

“Lint this Project” and “Generate PCLint Dependency Files” menu options will be added to the project context menu. To open this context menu, right click on a project name in the Projects window. Before performing this operation be sure to set the project as “main”.

2.3.3 Editor Context Menu

A “Lint this File” menu option will be added to the editor context menu. To open this con-text menu, right click in the Editor window.

TABLE 2-1: PCLINT TAB OPTIONS

Option Description

Location The name and location of the PC-lint executable file. By default the execut-able name will be lint-nt.exe located under the Gimpel PC-lint/MISRA installation folder.

Cmd Options Enter custom command line arguments for the Gimpel PC-lint/MISRA exe-cutable.

Log File Select this option to create a log file with the selected file name. The results of Gimpel PC-lint/MISRA linting will be output to this file.

Options Select the type of options file (.lnt):StandardOptionFile: Use the PC-lint stardard option file (not compiler spe-cific)UserOptionFile: Use your own options fileCompilerOptionFile: Use the Microchip compiler options file

User Option File Path

If UserOptionFile is selected above, specify the path to the file here.

Standards Select a MISRA standard:NOSTANDARD: Do not perform a MISRA checkMISRA 1998: Check for MISRA 1998 conformanceMISRA 2004: Check for MISRA 2004 conformanceFor details, see http://www.misra.org.uk/.

DSxxxxxxxxA-page 12 2006-2016 Microchip Technology Inc.

Page 13: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-LINT PLUGIN

About This Help File

These topics contain general information that will be useful to know before using Chapter Name. Items discussed include:

• Conventions Used

• Recommended Reading

CONVENTIONS USED

The following conventions may appear in this documentation:

DOCUMENTATION CONVENTIONS

Description Represents Examples

Arial font:

Italic Referenced books MPLAB X IDE User’s Guide

Emphasized text ...is the only compiler...

Initial caps A window the Output window

A dialog the Settings dialog

A menu selection select Enable Programmer

Quotes A field name in a window or dialog

“Save project before build”

Underlined, italic with right angle bracket

A menu path File>Save

Bold characters A dialog button Click OK

A tab Click the Power tab

Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>

Courier New font:

Plain Sample source code #define START

Filenames autoexec.bat

File paths c:\mcc18\h

Keywords _asm, _endasm, static

Command-line options -Opa+, -Opa-

Bit values 0, 1

Constants 0xFF,’A’

Italic A variable argument file.o, where file can be any valid filename

Square brackets [ ] Optional arguments mpasmwin [options] file [options]

Curly brackets and pipe character: { | }

Choice of mutually exclusive arguments; an OR selection

errorlevel {0|1}

Ellipses... Replaces repeated text var_name [, var_name...]

Represents code supplied by user

void main (void){ ...}

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 13

Page 14: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

RECOMMENDED READING

This help file describes how to use the PC-Lint plugin. Other useful documents are listed below. The following documents are available and recommended as supplemen-tal reference resources.

PCLint Documentation

Go to the Gimpel web site for documentation:

http://www.gimpel.com/html/pcl.htm

MPLAB X IDE Documentation

MPLAB X IDE documentation includes tutorials, functional descriptions and reference material. See the MPLAB X IDE webpage:

http://www.microchip.com/mplabx

Device Data Sheets and Family Reference Manuals

See the Microchip web site for complete and updated versions of device (PIC MCU and dsPIC DSC) data sheets and related device family reference manuals. See the Micro-chip website:

http://www.microchip.com/

DSxxxxxxxxA-page 14 2006-2016 Microchip Technology Inc.

Page 15: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-LINT PLUGIN

Index

CCommand Options, PC-lint ...................................... 12config files .................................................................. 6config.exe - PC-lint..................................................... 4

DDocumentation

Conventions...................................................... 13

EExample of Use.......................................................... 6

GGenerate PCLint Dependency Files........................... 8Gimpel PC-lint/MISRA................................................ 3

Iinclude-path.lnt........................................................7, 8Installation

Gimpel PC-lint/MISRA ........................................ 3PC-Lint Plug-In ................................................... 5

Llin.bat - PC-lint ........................................................... 4Lint this File.............................................................. 12Lint this Project .....................................................9, 12lint-cmac.h...............................................................7, 8lint-nt.exe - PC-lint ..................................................... 4Location of PC-Lint Plugin ....................................... 12Log File, PC-lint ....................................................... 12

MMISRA Standards .................................................... 12msg.txt - PC-lint ......................................................... 4

OOptions Files, PC-lint ............................................... 12

PPCLint Tab ............................................................6, 11

RReading, Recommended ......................................... 14

UUser Options File ....................................................... 6

2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 15

Page 16: Table of Contentsww1.microchip.com/downloads/opensource/docs/pclint_xhelp.pdf · 2006-2016 Microchip Technology Inc. DSxxxxxxxxA-page 11 Chapter 2. PC-Lint Plugin Function Summary

PC-Lint Plugin

DSxxxxxxxxA-page 16 2006-2016 Microchip Technology Inc.