• AVR Freaks

Hot!Code coverage and static analysis tools supported by MP LAB X IDE

Author
manjubhargavi.narravula@medtronic.com
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/09/11 02:07:54
  • Location: 0
  • Status: offline
2019/09/12 08:14:19 (permalink)
0

Code coverage and static analysis tools supported by MP LAB X IDE

Hi all,
Could you share the details of Code coverage and static analysis tools supported by MP LAB X IDE
#1

9 Replies Related Threads

    mlp
    boots too small
    • Total Posts : 825
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/09/12 10:08:51 (permalink)
    +1 (1)
    MPLAB X is based on NetBeans, so anything that works with NetBeans should be worth a try.

    Mark (this opinion available for hire)
    #2
    crosland
    Super Member
    • Total Posts : 1696
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/09/12 11:18:13 (permalink)
    #3
    katela
    Super Member
    • Total Posts : 1468
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/09/12 14:25:26 (permalink)
    +1 (1)
    If you could specify the kind of tools you are inquiring about, you could get a better response.
     

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #4
    oliverb
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/10 05:47:12 (permalink)
    0
    Well it is a reasonable question I think.
     
    The main supported system appears to be PC-Lint plus, from Gimpel software. As I understand it the MPLAB X Plugin just interfaces to the package.
     
    I've been looking for free alternatives.
     
    I tried out the 2010 release of "splint", but it would just keep reporting a "parse error", with little clue as to what code feature it actually objected to. I get the impression that C standards have moved on a little. I worked out I had to pass it the include paths in order for it to find XC.h, but it might be choking on something in XC.h?
     
    I've tried compiling the source of splint (much newer than the binary) using Cygwin. I also tried Visual Studio but I need to configure flex/bison to handle "L" and "Y" files, and it is so much easier with Cygwin. I haven't tried it out yet.
     
    I've looked at "clang-tidy", but can't work out how to run it on a MPLAB project. The LLVM package appears to be a compiler, with the analysis tool written to support that compiler.
    post edited by oliverb - 2019/11/14 04:31:23
    #5
    oliverb
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/14 08:15:28 (permalink)
    0
    Observations on splint, now I have the August 4 version compiled: It really doesn't like unsigned char variables, it seems as if numbers should never be smaller than int?
     
    Incidentally after compiling in Cygwin it is possible to compile in Visual Studio as the generated c and h files will now be present.
     
    Also it seems to object to declaring variables inside a "for" statement, but that probably isn't standard C anyway?
    I've managed to get it to segfault, but I don't know how to make a bug report as it needs several files to make it happen.
     
    post edited by oliverb - 2019/11/14 10:56:08
    #6
    flotischu
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2017/09/27 06:53:30
    • Location: 0
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/14 08:29:13 (permalink)
    0
    oliverb
    I've looked at "clang-tidy", but can't work out how to run it on a MPLAB project. The LLVM package appears to be a compiler, with the analysis tool written to support that compiler.

     
    I've tried to get "clang-tidy" working too, since I've read this:
    https://microchipdeveloper.com/swtools:static-analyzers
    Unfortunately there is no explanation how to setup this tool sad: sad
    #7
    1and0
    Access is Denied
    • Total Posts : 10005
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/14 08:35:31 (permalink)
    +1 (1)
    oliverb
    Also it seems to object to declaring variables inside a "for" statement, but that probably isn't standard C anyway?

    That is a syntax introduced in the C99 Standard, where local variable declarations can be intermingled with the code.
    #8
    oliverb
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/14 11:10:31 (permalink)
    0
    Hmm possible progress: clang-tidy lcdx.c -- -I"C:\Program Files (x86)\Microchip\xc8\v1.45\include"
     
    Error while processing C:\Users\Oliver\Documents\MPLAB\rfg_fpa.X\lcdx.c.error: too many errors emitted, stopping now [clang-diagnostic-error]C:\Program Files (x86)\Microchip\xc8\v1.45\include\__size_t.h:4:18: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long long') [clang-diagnostic-error]typedef unsigned        size_t;         /* type yielded by sizeof */
    lcdx is one file of my project. Now I think I have to feed it a PIC type in order to generate valid symbols for ports, tris etc.
     
    clang-tidy lcdx.c -- -I"C:\Program Files (x86)\Microchip\xc8\v1.45\include" -D__XC -D__XC8 -D__XC__ -D__XC8__  -D__18F4520 -D__18F4520__ -D_18F4520 -D__XC -D__XC8 -D__PICC18__ -D_MPC_ -D_PIC18
     
    pic18f4520.h:50:46: error: expected ';' after top level declarator [clang-diagnostic-error]
    extern volatile unsigned char           PORTA               @ 0xF80;
     
    So now it is choking on the at sign. It also doesn't like a whole bunch of types, but they can probably be hidden by defining them
     
    Further to the above I've installed CPPCHECK. It has a GUI, so it is relatively easy to set up.
     
    I would recommend putting the CPPCHECK project in the folder above the actual project. Despite the name it appears to test C code as well, and it appears to ignore undefined symbols so you can run it on PIC C code without having to tweak it to process the header. I presume the assumption is that it won't check for basic errors that any compiler would pick up.
     
    post edited by oliverb - 2019/11/23 11:14:50
    #9
    oliverb
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Code coverage and static analysis tools supported by MP LAB X IDE 2019/11/19 12:35:43 (permalink)
    0
    Well if anyone is interested: I tried copying the include folder to another location c:\microchip\include and modifying it. By taking out the addresses, and adding defines to substitute for __bit and __nonreentrant I got it to go beyond all the "errors" in the header and parse the program.
     
    clang-tidy lcdx.c -- -I"C:\Microchip\include" -D__XC -D__XC8 -D__XC__ -D__XC8__  -D__18F4520 -D__18F4520__ -D_18F4520 -D__XC -D__XC8 -D__PICC18__ -D_MPC_ -D_PIC18 -D__bit=char -D__nonreentrant=
     
    So now it has spotted a signed/unsigned char mixup and is complaining about using an assignment in a condition (which I actually want to do), so it is sort of parsing the code, but it seems to need custom headers in order to do it.
     
    it doesn't like "short long":
     
    C:\Microchip\include\pic18f4520.h:6836:32: error: cannot combine with previous 'short' declaration specifier [clang-diagnostic-error]
    extern volatile unsigned short long     TBLPTR              ;
     
     
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5