Skip to content

sonar.cxx.drmemory.reportPaths

guwirth edited this page Mar 10, 2021 · 7 revisions

Overview

Sensor to read reports from the Dr. Memory tool. Dr. Memory is a memory monitoring tool capable of identifying memory-related programming errors such as accesses of uninitialized memory, accesses to unaddressable memory (including outside of allocated heap units and heap underflow and overflow), accesses to freed memory, double frees, memory leaks, and (on Microsoft Windows) handle leaks, GDI API usage errors, and accesses to un-reserved thread local storage slots.

Note: The cxx plugin itself does not run the tool, you have to do that yourself beforehand. The sensor only reads the report generated by the tool!

Supported versions

  • Link to the tool page: http://drmemory.org/
  • The sensor supports rules from Dr. Memory with version 1.8.

Create report

In order to run Dr. Memory and generate a fitting report, make sure:

  • to call it from the projects root directory, so that the paths in the report fit
  • that the parameter matches the sonar.sources list in sonar-project.properties

Sample command lines:

Launch your program with Dr. Memory. The actual call should look something like this:

drmemory.exe -logdir c:/logs -- c:/path/to/my/app

Example of a report file

If the tool was executed successfully, a report like the example below should be generated:

Dr. Memory version 1.8.0 build 8 built on Sep  9 2014 16:27:02
Dr. Memory results for pid 3144: "Mask.Acceptance.Tests.exe"
Application cmdline: "Mask.Acceptance.Tests.exe"
Recorded 108 suppression(s) from default C:\Program Files (x86)\Dr. Memory\bin\suppress-default.txt

Error #733: LEAK 7300 direct bytes 0x028365b8-0x0283823c + 48336 indirect bytes
# 0 replace_calloc                                                [d:\drmemory_package\common\alloc_replace.c:2413]
# 1 gdCalloc                                                      [d:\sample\nonnugetlib\libgd-2.1.1\src\gdhelpers.c:69]
# 2 gdImageCreate                                                 [d:\sample\nonnugetlib\libgd-2.1.1\src\gd.c:173]
# 3 WinGraphics::Initialize                                       [d:\sample\sources\maskcpp\core\rendering\graphics\net\netgraphics.cpp:165]
# 4 GraphicsDrawing<>::Initialiser                                [d:\sample\sources\maskcpp\core\rendering\graphicsdrawing.h:54]
# 5 BitmapGeneratorHelper::Generer                                [d:\sample\sources\maskcpp\core\bitmapgeneratorhelper.cpp:13]
# 6 BitmapGenerator::Generate                                     [d:\sample\sources\maskcpp\core\bitmapgenerator.cpp:27]
# 7 BitmapGenerationConfiguration::AndGetResultAsBmpContent       [d:\sample\sources\maskcpp\factory\maskfactory.h:73]
# 8 MaskAcceptanceTest::LaunchTest                                [d:\sample\tests\acceptance\acceptancetestexecutor.cpp:78]
# 9 zoom::Zoom_ReportWithWidthSpecified_Test::TestBody            [d:\sample\tests\acceptance\zoomtest.cpp:20]
#10 testing::internal::HandleSehExceptionsInMethodIfSupported<>   [d:\sample\packages\external.google-test.1.6.2-dev\sources\src\gtest.cc:2075]
#11 testing::internal::HandleExceptionsInMethodIfSupported<>      [d:\sample\packages\external.google-test.1.6.2-dev\sources\src\gtest.cc:2126]

Configure cxx plugin

  1. First check if the file extensions read in by the cxx plugin are set (sonar.cxx.file.suffixes).
  2. The rules for which you want to generate issue must be activated in the Quality Profile of your project. You can find instructions on how to do this under Manage Quality Profiles.
  3. Set the analysis parameter sonar.cxx.drmemory.reportPaths in the configuration file sonar-project.properties of your project. The Report Paths link describes the configuration options.
  4. Normally the File Encoding is UTF-8. Use the parameter sonar.cxx.drmemory.encoding to use another one.
  5. Execute the SonarScanner to transfer the project with the report to the SonarQube Server.

Sample for sonar-project.properties:

sonar.cxx.drmemory.encoding=UTF-8
sonar.cxx.drmemory.reportPaths=c:/logs/**/results.txt

Troubleshooting

Clone this wiki locally