SlideShare a Scribd company logo
PVS-Studio Now Supports Any Build 
System under Windows and Any Compiler. 
Easy and Right Out of the Box. 
Author: Evgeniy Ryzhkov 
Date: 28.03.2014 
We're currently preparing a bomb in PVS-Studio! 
The next PVS-Studio version 5.15 will be able to analyze projects built by absolutely any build system: 
Makefile, Visual Studio Project, user-made build systems based on Python, Bash or whatever else... It will 
allow you to simply "watch" compiler calls and collect all the necessary information to run the analyzer in 
automatic mode. Moreover, it works with any (sensible) C/C++ compiler under Windows. Want to know 
more? 
The working principles and the limitations of the Visual Studio plugin 
PVS-Studio was originally developed as a plugin for Microsoft Visual C++. Interaction between the tool and 
the development environment is manifested in two aspects: first, tool integration with the user interface, 
for it is more convenient to work with it from the environment you are used to; second, collecting file 
compilation parameters for a correct analysis. 
Let me remind the working principles of code analyzers (PVS-Studio in particular) to those who are not quite 
familiar with them. Before you can carry out an analysis of source files, you need to preprocess them, i.e. 
expand all the #include's and #define's. This is first of all necessary for the analyzer to know additional 
information about the data types used in the code. 
Until recently, the PVS-Studio plugin used to collect compilation parameters with the help of Visual Studio's 
API and run preprocessing automatically. Now we have learned how to track compilation parameters when 
the compiler is called and "reproduce" this call with the "perform preprocessing" switch – and only then call
the analyzer itself. It doesn't make any difference for the plugin, and it still retains the original mechanism. 
However, this mechanism couldn't be used with certain projects earlier (even some native Visual C++ 
projects). What are these cases? 
First, the cases when you have a Makefile-project built, for example, with nmake. In this case, Visual 
Studio's API didn't allow the plugin to get the compilation parameters and call the preprocessor. True, you 
could embed a PVS-Studio's call into Makefile, but let's admit that it is far from an elegant solution. We do 
have users who handle PVS-Studio this way, of course, but most were scared off by it. 
Second, when you have a self-made build system that calls the compiler from scripts, it only theoretically 
looks like Makefile. In practice, however, it is usually only the author of this system who can modify it, and 
he is not always easily accessible, so trying PVS-Studio on such a project may appear almost impossible. 
In other words, it was not a rare problem when you had a project well compilable by Visual C++ and you felt 
like trying PVS-Studio on it but could not do this, and your zest gradually grew weaker and weaker... 
How have we solved it? 
We have developed a special utility to monitor compiler calls. It works with all the basic compilers under 
Windows, but we mainly focused on Visual C++ users, as usual. 
The monitoring tool simply taps all the compiler calls and then launches the compiler once again with the 
"perform file preprocessing" parameter. After that, it calls the analyzer. The nicest thing is that the entire 
procedure is absolutely transparent for the user and anyone can do it. 
Moreover, we offer two different techniques to work with this mechanism. 
Technique 1 – Monitoring through the graphic interface 
Imagine that you have got access to Unreal Engine 4's source files. You open the solution in Visual Studio 
and see an nmake-based project which can't be checked by the PVS-Studio plugin. No problem. You just 
need to do the following: 
1. Run PVS-Studio Standalone. 
2. Click "Compiler Monitoring" and choose the x64 platform for monitoring, for you want to build a 64- 
bit version of Unreal Engine 4.
3. Click "Start Monitoring" to turn on the compiler call monitoring mode. 
4. Now you switch to Visual Studio and click Build to start building the project. While the build is 
running, you will see the status in the monitoring window indicating that compiler calls are being 
tapped. Notice that it is the number of tapped calls which is indicated there, not the number of 
source files. The reason is that the compiler is often launched with several files as its arguments, so 
the number of compiler calls is less than or equal to the number of files. 
5. Once Visual Studio is finished with the build, click Stop Monitoring. After that, PVS-Studio will be 
launched. The files will be preprocessed and analyzed, and the diagnostic messages will be 
displayed in PVS-Studio Standalone's window. You can start working with them from there right 
away. However, I recommend that you wait until the analysis is over, save the analysis report as the 
UE4.plog file, then close PVS-Studio Standalone, open the UE4.plog file from within the Visual 
Studio environment through the PVS-Studio menu and handle the results from there. Why? Because 
you will be able to use IntelliSense inside Visual Studio, which will make it much easier to navigate 
through the code, track macros' values, search for variable declarations, and so on. You can also do 
it all from PVS-Studio Standalone of course, but let's be honest – our tool is far not as convenient as 
Visual Studio yet. 
This simple technique will allow you to easily check projects exploiting the monitoring graphic interface in 
PVS-Studio. But sometimes it may be more convenient to launch monitoring from the command line. The 
next section will tell you how to do that. 
Technique 2 – Monitoring through the command line interface 
The graphic interface is not always convenient for monitoring. Imagine you want to check Qt 5.2. To do this, 
we need to download the distribution package in the archive and unpack it. Then we launch Visual Studio 
2012 Command Promt (to set up the environment correctly), go to the folder with Qt and do the following: 
1. Turn on the monitoring mode: 
"C:Program Files (x86)PVS-StudioCLMonitor.exe" monitor 
The program will terminate right away but it will leave a "tracking module" running in background. 
2. Run configure.exe – this is a program from the Qt package which prepares a build script. 
3. Run nmake – and now settle back into your chair waiting for the Qt to finish with the build. 
4. Once it is done, you need to tell the monitoring module to stop tapping and start analysis (and save 
the results into a log file for the Win32 platform): 
"C:Program Files (x86)PVS-StudioCLMonitor.exe" analyze C:Qt5.plog Win32 
5. Once the analysis is over, the report will be saved into a log file. I do not recommend you to handle 
the log directly. It is better to open it in PVS-Studio Standalone as it is much more convenient to 
view and handle it from there. 
As you can see, checking projects built by any build system from the command line is as easy as through the 
user interface – the algorithm includes the same 5 simple steps.
Known issues and limitations 
We haven't revealed (yet?) any fundamental problems in the monitoring mechanism, but there are certain 
nuances you should know about. 
First, the monitoring module taps every single compiler call. It means that if you run several different build 
processes at once, each of them will be tapped – and analyzed. That is, you will get a mess of analysis 
results for the project you need and some wrong project. Keep that in mind and be sure not to run any 
other build processes while the monitoring module is active. 
Second, you may sometimes face subtle issues with precompiled headers. It is not a rare thing when the 
path to the precompiled headers is absent from the list of include folders. While the compiler can find these 
headers, the preprocessor (which is a part of the compiler!) cannot. The solution is a simple one – you just 
need to explicitly specify the path to certain include files in the list of include folders. 
Trial Mode 
And finally, a small bug in the butter. PVS-Studio has a trial mode which sets a limited number of clicks you 
can make in the list of diagnostic messages. However, when using PVS-Studio in the monitoring mode from 
the command line, file names are not shown at all. Instead, the messages "Trial Restriction" are displayed. 
However, you can still study the compiler monitoring while in the trial mode by using the PVS-Studio 
Standalone UI application (the 'Tools -> Analyze your files..' menu item).

More Related Content

PDF
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Andrey Karpov
 
PDF
Static Analysis: From Getting Started to Integration
Andrey Karpov
 
PDF
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
Andrey Karpov
 
PPTX
Containerize your Blackbox tests
Kevin Beeman
 
PDF
First steps with selenium rc
Dang Nguyen
 
PDF
Static analysis is most efficient when being used regularly. We'll tell you w...
PVS-Studio
 
PDF
Selenium With Spices
Nikolajs Okunevs
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Andrey Karpov
 
Static Analysis: From Getting Started to Integration
Andrey Karpov
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
Andrey Karpov
 
Containerize your Blackbox tests
Kevin Beeman
 
First steps with selenium rc
Dang Nguyen
 
Static analysis is most efficient when being used regularly. We'll tell you w...
PVS-Studio
 
Selenium With Spices
Nikolajs Okunevs
 

What's hot (20)

PDF
PVS-Studio Has Finally Got to Boost
Andrey Karpov
 
DOCX
Selenium notes
wholcomb
 
PDF
Selenium XPath Performance Problems in IE
Clever Moe
 
DOCX
CodeShip
Bryan Reinbolt
 
PDF
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Andrey Karpov
 
PPTX
XPDays-2018
Yegor Maksymchuk
 
PDF
How the PVS-Studio Team Improved Unreal Engine's Code
PVS-Studio
 
PDF
San Jose Selenium Meet-up PushToTest TestMaker Presentation
Clever Moe
 
PDF
We continue checking Microsoft projects: analysis of PowerShell
PVS-Studio
 
PDF
Coordinated Testing with a Test-Server
ESUG
 
ODP
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
ODP
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
PDF
Selenium Tutorial
prad_123
 
DOCX
Testing Guide
Santosh Kiran Beyagudem
 
PPT
Presentation_C++UnitTest
Raihan Masud
 
PDF
Advanced Selenium Workshop
Clever Moe
 
PDF
Aikau testing tech talk live 83 20150204
David Webster
 
PDF
Creating selenium remote control tests
Dang Nguyen
 
PPTX
Any point on mac
Manav Prasad
 
PPTX
SKILLWISE_SELENIUM
Skillwise Consulting
 
PVS-Studio Has Finally Got to Boost
Andrey Karpov
 
Selenium notes
wholcomb
 
Selenium XPath Performance Problems in IE
Clever Moe
 
CodeShip
Bryan Reinbolt
 
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Andrey Karpov
 
XPDays-2018
Yegor Maksymchuk
 
How the PVS-Studio Team Improved Unreal Engine's Code
PVS-Studio
 
San Jose Selenium Meet-up PushToTest TestMaker Presentation
Clever Moe
 
We continue checking Microsoft projects: analysis of PowerShell
PVS-Studio
 
Coordinated Testing with a Test-Server
ESUG
 
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
Oscon2008 Qa Leak Testing Latest Slides
ctalbert
 
Selenium Tutorial
prad_123
 
Presentation_C++UnitTest
Raihan Masud
 
Advanced Selenium Workshop
Clever Moe
 
Aikau testing tech talk live 83 20150204
David Webster
 
Creating selenium remote control tests
Dang Nguyen
 
Any point on mac
Manav Prasad
 
SKILLWISE_SELENIUM
Skillwise Consulting
 
Ad

Viewers also liked (20)

PDF
과제4 주변 임베디드 설계
UGenie
 
PDF
임베디드 시스템 찾기 ver.13-11-22
지호 이
 
PDF
임베디드 시스템 찾기
석화 강
 
PPTX
원통형 냉장고(공모전)
younhoon kim
 
PDF
주변의 임베디드 최종
bbangg
 
PPTX
임베디드 시스템 찾기1
YS Shin
 
PPTX
1192034임수빈(임베디드시스템설계)
SuBinL
 
PPTX
0992029양대현
DaeHyeon Yang
 
PDF
주변의 임베디드(수정)
정원 서
 
PPTX
임베디드 시스템 찾기3
YS Shin
 
PPTX
임베디드 시스템 찾기2
YS Shin
 
PDF
임베디드시스템찾기2차
SuBinL
 
PPTX
임베디드 소스 리뷰
Kunyoung Sin
 
PPTX
임베디드
래선 김
 
PPTX
임베디드 시스템 찾기4
YS Shin
 
PPTX
임베디드 시스템 찾기 Final
shinminkyung
 
PPTX
임베디드시스템설계
DaeHyeon Yang
 
PPTX
임베디드버그찾기
DaeHyeon Yang
 
PPTX
임베디드 시스템 찾기 3
shinminkyung
 
PPT
임베디드시스템과시장
Minsuk Lee
 
과제4 주변 임베디드 설계
UGenie
 
임베디드 시스템 찾기 ver.13-11-22
지호 이
 
임베디드 시스템 찾기
석화 강
 
원통형 냉장고(공모전)
younhoon kim
 
주변의 임베디드 최종
bbangg
 
임베디드 시스템 찾기1
YS Shin
 
1192034임수빈(임베디드시스템설계)
SuBinL
 
0992029양대현
DaeHyeon Yang
 
주변의 임베디드(수정)
정원 서
 
임베디드 시스템 찾기3
YS Shin
 
임베디드 시스템 찾기2
YS Shin
 
임베디드시스템찾기2차
SuBinL
 
임베디드 소스 리뷰
Kunyoung Sin
 
임베디드
래선 김
 
임베디드 시스템 찾기4
YS Shin
 
임베디드 시스템 찾기 Final
shinminkyung
 
임베디드시스템설계
DaeHyeon Yang
 
임베디드버그찾기
DaeHyeon Yang
 
임베디드 시스템 찾기 3
shinminkyung
 
임베디드시스템과시장
Minsuk Lee
 
Ad

Similar to PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy and Right Out of the Box. (20)

PDF
The Development History of PVS-Studio for Linux
PVS-Studio
 
PPTX
PVS-Studio static analyzer: advanced features
Andrey Karpov
 
PDF
PVS-Studio confesses its love for Linux
PVS-Studio
 
PDF
Trying to Sell PVS-Studio to Google, or New Bugs in Chromium
Andrey Karpov
 
PDF
R&D on PVS-Studio
PVS-Studio
 
PPTX
PVS-Studio for Linux (CoreHard presentation)
Andrey Karpov
 
PDF
PVS-Studio for Visual C++
Andrey Karpov
 
PDF
Information sheet PVS-Studio
PVS-Studio
 
PDF
War of the Machines: PVS-Studio vs. TensorFlow
PVS-Studio
 
PDF
PVS-Studio for Visual C++
PVS-Studio
 
PDF
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio
 
PDF
PVS-Studio advertisement - static analysis of C/C++ code
Andrey Karpov
 
PDF
HPX and PVS-Studio
PVS-Studio
 
PDF
Bugs Found by LibreOffice in PVS-Studio
PVS-Studio
 
PDF
New Year PVS-Studio 6.00 Release: Scanning Roslyn
PVS-Studio
 
PDF
What's the Difference Between Static Analysis and Compiler Warnings?
Andrey Karpov
 
PDF
Bugs found in GCC with the help of PVS-Studio
PVS-Studio
 
PDF
Checking the Source SDK Project
Andrey Karpov
 
PDF
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
PVS-Studio
 
PDF
Visual Studio Ceases Support of Add-Ins in Community Previews 14
Andrey Karpov
 
The Development History of PVS-Studio for Linux
PVS-Studio
 
PVS-Studio static analyzer: advanced features
Andrey Karpov
 
PVS-Studio confesses its love for Linux
PVS-Studio
 
Trying to Sell PVS-Studio to Google, or New Bugs in Chromium
Andrey Karpov
 
R&D on PVS-Studio
PVS-Studio
 
PVS-Studio for Linux (CoreHard presentation)
Andrey Karpov
 
PVS-Studio for Visual C++
Andrey Karpov
 
Information sheet PVS-Studio
PVS-Studio
 
War of the Machines: PVS-Studio vs. TensorFlow
PVS-Studio
 
PVS-Studio for Visual C++
PVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
Andrey Karpov
 
HPX and PVS-Studio
PVS-Studio
 
Bugs Found by LibreOffice in PVS-Studio
PVS-Studio
 
New Year PVS-Studio 6.00 Release: Scanning Roslyn
PVS-Studio
 
What's the Difference Between Static Analysis and Compiler Warnings?
Andrey Karpov
 
Bugs found in GCC with the help of PVS-Studio
PVS-Studio
 
Checking the Source SDK Project
Andrey Karpov
 
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
PVS-Studio
 
Visual Studio Ceases Support of Add-Ins in Community Previews 14
Andrey Karpov
 

More from Andrey Karpov (20)

PDF
60 антипаттернов для С++ программиста
Andrey Karpov
 
PDF
60 terrible tips for a C++ developer
Andrey Karpov
 
PPTX
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Andrey Karpov
 
PDF
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
PDF
PVS-Studio in 2021 - Feature Overview
Andrey Karpov
 
PDF
PVS-Studio в 2021 - Примеры ошибок
Andrey Karpov
 
PDF
PVS-Studio в 2021
Andrey Karpov
 
PPTX
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Andrey Karpov
 
PPTX
Best Bugs from Games: Fellow Programmers' Mistakes
Andrey Karpov
 
PPTX
Does static analysis need machine learning?
Andrey Karpov
 
PPTX
Typical errors in code on the example of C++, C#, and Java
Andrey Karpov
 
PPTX
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
Andrey Karpov
 
PPTX
Game Engine Code Quality: Is Everything Really That Bad?
Andrey Karpov
 
PPTX
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
PPTX
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
Andrey Karpov
 
PPTX
Static Code Analysis for Projects, Built on Unreal Engine
Andrey Karpov
 
PPTX
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Andrey Karpov
 
PPTX
The Great and Mighty C++
Andrey Karpov
 
PPTX
Static code analysis: what? how? why?
Andrey Karpov
 
PDF
Zero, one, two, Freddy's coming for you
Andrey Karpov
 
60 антипаттернов для С++ программиста
Andrey Karpov
 
60 terrible tips for a C++ developer
Andrey Karpov
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Andrey Karpov
 
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
PVS-Studio in 2021 - Feature Overview
Andrey Karpov
 
PVS-Studio в 2021 - Примеры ошибок
Andrey Karpov
 
PVS-Studio в 2021
Andrey Karpov
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Andrey Karpov
 
Best Bugs from Games: Fellow Programmers' Mistakes
Andrey Karpov
 
Does static analysis need machine learning?
Andrey Karpov
 
Typical errors in code on the example of C++, C#, and Java
Andrey Karpov
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
Andrey Karpov
 
Game Engine Code Quality: Is Everything Really That Bad?
Andrey Karpov
 
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
Andrey Karpov
 
Static Code Analysis for Projects, Built on Unreal Engine
Andrey Karpov
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Andrey Karpov
 
The Great and Mighty C++
Andrey Karpov
 
Static code analysis: what? how? why?
Andrey Karpov
 
Zero, one, two, Freddy's coming for you
Andrey Karpov
 

Recently uploaded (20)

PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Activate_Methodology_Summary presentatio
annapureddyn
 

PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy and Right Out of the Box.

  • 1. PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy and Right Out of the Box. Author: Evgeniy Ryzhkov Date: 28.03.2014 We're currently preparing a bomb in PVS-Studio! The next PVS-Studio version 5.15 will be able to analyze projects built by absolutely any build system: Makefile, Visual Studio Project, user-made build systems based on Python, Bash or whatever else... It will allow you to simply "watch" compiler calls and collect all the necessary information to run the analyzer in automatic mode. Moreover, it works with any (sensible) C/C++ compiler under Windows. Want to know more? The working principles and the limitations of the Visual Studio plugin PVS-Studio was originally developed as a plugin for Microsoft Visual C++. Interaction between the tool and the development environment is manifested in two aspects: first, tool integration with the user interface, for it is more convenient to work with it from the environment you are used to; second, collecting file compilation parameters for a correct analysis. Let me remind the working principles of code analyzers (PVS-Studio in particular) to those who are not quite familiar with them. Before you can carry out an analysis of source files, you need to preprocess them, i.e. expand all the #include's and #define's. This is first of all necessary for the analyzer to know additional information about the data types used in the code. Until recently, the PVS-Studio plugin used to collect compilation parameters with the help of Visual Studio's API and run preprocessing automatically. Now we have learned how to track compilation parameters when the compiler is called and "reproduce" this call with the "perform preprocessing" switch – and only then call
  • 2. the analyzer itself. It doesn't make any difference for the plugin, and it still retains the original mechanism. However, this mechanism couldn't be used with certain projects earlier (even some native Visual C++ projects). What are these cases? First, the cases when you have a Makefile-project built, for example, with nmake. In this case, Visual Studio's API didn't allow the plugin to get the compilation parameters and call the preprocessor. True, you could embed a PVS-Studio's call into Makefile, but let's admit that it is far from an elegant solution. We do have users who handle PVS-Studio this way, of course, but most were scared off by it. Second, when you have a self-made build system that calls the compiler from scripts, it only theoretically looks like Makefile. In practice, however, it is usually only the author of this system who can modify it, and he is not always easily accessible, so trying PVS-Studio on such a project may appear almost impossible. In other words, it was not a rare problem when you had a project well compilable by Visual C++ and you felt like trying PVS-Studio on it but could not do this, and your zest gradually grew weaker and weaker... How have we solved it? We have developed a special utility to monitor compiler calls. It works with all the basic compilers under Windows, but we mainly focused on Visual C++ users, as usual. The monitoring tool simply taps all the compiler calls and then launches the compiler once again with the "perform file preprocessing" parameter. After that, it calls the analyzer. The nicest thing is that the entire procedure is absolutely transparent for the user and anyone can do it. Moreover, we offer two different techniques to work with this mechanism. Technique 1 – Monitoring through the graphic interface Imagine that you have got access to Unreal Engine 4's source files. You open the solution in Visual Studio and see an nmake-based project which can't be checked by the PVS-Studio plugin. No problem. You just need to do the following: 1. Run PVS-Studio Standalone. 2. Click "Compiler Monitoring" and choose the x64 platform for monitoring, for you want to build a 64- bit version of Unreal Engine 4.
  • 3. 3. Click "Start Monitoring" to turn on the compiler call monitoring mode. 4. Now you switch to Visual Studio and click Build to start building the project. While the build is running, you will see the status in the monitoring window indicating that compiler calls are being tapped. Notice that it is the number of tapped calls which is indicated there, not the number of source files. The reason is that the compiler is often launched with several files as its arguments, so the number of compiler calls is less than or equal to the number of files. 5. Once Visual Studio is finished with the build, click Stop Monitoring. After that, PVS-Studio will be launched. The files will be preprocessed and analyzed, and the diagnostic messages will be displayed in PVS-Studio Standalone's window. You can start working with them from there right away. However, I recommend that you wait until the analysis is over, save the analysis report as the UE4.plog file, then close PVS-Studio Standalone, open the UE4.plog file from within the Visual Studio environment through the PVS-Studio menu and handle the results from there. Why? Because you will be able to use IntelliSense inside Visual Studio, which will make it much easier to navigate through the code, track macros' values, search for variable declarations, and so on. You can also do it all from PVS-Studio Standalone of course, but let's be honest – our tool is far not as convenient as Visual Studio yet. This simple technique will allow you to easily check projects exploiting the monitoring graphic interface in PVS-Studio. But sometimes it may be more convenient to launch monitoring from the command line. The next section will tell you how to do that. Technique 2 – Monitoring through the command line interface The graphic interface is not always convenient for monitoring. Imagine you want to check Qt 5.2. To do this, we need to download the distribution package in the archive and unpack it. Then we launch Visual Studio 2012 Command Promt (to set up the environment correctly), go to the folder with Qt and do the following: 1. Turn on the monitoring mode: "C:Program Files (x86)PVS-StudioCLMonitor.exe" monitor The program will terminate right away but it will leave a "tracking module" running in background. 2. Run configure.exe – this is a program from the Qt package which prepares a build script. 3. Run nmake – and now settle back into your chair waiting for the Qt to finish with the build. 4. Once it is done, you need to tell the monitoring module to stop tapping and start analysis (and save the results into a log file for the Win32 platform): "C:Program Files (x86)PVS-StudioCLMonitor.exe" analyze C:Qt5.plog Win32 5. Once the analysis is over, the report will be saved into a log file. I do not recommend you to handle the log directly. It is better to open it in PVS-Studio Standalone as it is much more convenient to view and handle it from there. As you can see, checking projects built by any build system from the command line is as easy as through the user interface – the algorithm includes the same 5 simple steps.
  • 4. Known issues and limitations We haven't revealed (yet?) any fundamental problems in the monitoring mechanism, but there are certain nuances you should know about. First, the monitoring module taps every single compiler call. It means that if you run several different build processes at once, each of them will be tapped – and analyzed. That is, you will get a mess of analysis results for the project you need and some wrong project. Keep that in mind and be sure not to run any other build processes while the monitoring module is active. Second, you may sometimes face subtle issues with precompiled headers. It is not a rare thing when the path to the precompiled headers is absent from the list of include folders. While the compiler can find these headers, the preprocessor (which is a part of the compiler!) cannot. The solution is a simple one – you just need to explicitly specify the path to certain include files in the list of include folders. Trial Mode And finally, a small bug in the butter. PVS-Studio has a trial mode which sets a limited number of clicks you can make in the list of diagnostic messages. However, when using PVS-Studio in the monitoring mode from the command line, file names are not shown at all. Instead, the messages "Trial Restriction" are displayed. However, you can still study the compiler monitoring while in the trial mode by using the PVS-Studio Standalone UI application (the 'Tools -> Analyze your files..' menu item).