From 663e698786aea976d2a0b4210821c6a6f87e5266 Mon Sep 17 00:00:00 2001 From: Ivan Galkin Date: Mon, 16 Apr 2018 12:56:38 +0200 Subject: [PATCH] CxxValgrindSensor: allow multiple nodes #1440 * proper parsing of multiple s and s see https://github.com/pathscale/valgrind-mmt/blob/master/docs/internals/xml-output.txt Each stackstrace of Valgrind will be stored as a separate NewIssue. The reason is missing formatting for error messages (even line breaks are not allowed). Error messages with one stack trace are already hard to read. * revisit Valgrind*::equals() and Valgrind*::hashCode() implementation a. equals() shouldn not be implemented through hashCode() because there could be hash collisions and unequal objects could return true b. perform equals()/hashCode() over all fields I believe that SonarQube has to show the Valgrind's report as-is. There should be no filtering or obfuscation --- .../sensors/valgrind/CxxValgrindSensor.java | 26 +- .../cxx/sensors/valgrind/ValgrindError.java | 67 +++-- .../cxx/sensors/valgrind/ValgrindFrame.java | 68 +++-- .../valgrind/ValgrindReportParser.java | 19 +- .../cxx/sensors/valgrind/ValgrindStack.java | 25 +- .../valgrind/CxxValgrindSensorTest.java | 12 +- .../sensors/valgrind/ValgrindErrorTest.java | 21 +- .../valgrind/ValgrindReportParserTest.java | 38 ++- ...AMPLE.xml => valgrind-result-SAMPLE_1.xml} | 0 .../valgrind-result-SAMPLE_2.xml | 254 ++++++++++++++++++ .../valgrind-result-SAMPLE_3.xml | 72 +++++ 11 files changed, 502 insertions(+), 100 deletions(-) rename cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/{valgrind-result-SAMPLE.xml => valgrind-result-SAMPLE_1.xml} (100%) create mode 100644 cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_2.xml create mode 100644 cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_3.xml diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java index 160dcfc551..ff93fb4a02 100644 --- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java +++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java @@ -68,14 +68,28 @@ protected void processReport(final SensorContext context, File report) saveErrors(context, parser.processReport(report)); } + private static String createErrorMsg(ValgrindError error, ValgrindStack stack, Integer stackNr) { + StringBuilder errorMsg = new StringBuilder(); + errorMsg.append(error.getText()); + if (error.getStacks().size() > 1) { + errorMsg.append(" (Stack ").append(stackNr).append(")"); + } + errorMsg.append("\n\n").append(stack); + return errorMsg.toString(); + } + void saveErrors(SensorContext context, Set valgrindErrors) { for (ValgrindError error : valgrindErrors) { - ValgrindFrame frame = error.getLastOwnFrame(context.fileSystem().baseDir().getPath()); - if (frame != null) { - saveUniqueViolation(context, CxxValgrindRuleRepository.KEY, - frame.getPath(), frame.getLine(), error.getKind(), error.toString()); - } else { - LOG.warn("Cannot find a project file to assign the valgrind error '{}' to", error); + Integer stackNr = 0; + for (ValgrindStack stack : error.getStacks()) { + ValgrindFrame frame = stack.getLastOwnFrame(context.fileSystem().baseDir().getPath()); + if (frame != null) { + String errorMsg = createErrorMsg(error, stack, stackNr); + saveUniqueViolation(context, CxxValgrindRuleRepository.KEY, frame.getPath(), frame.getLine(), error.getKind(), errorMsg); + } else { + LOG.warn("Cannot find a project file to assign the valgrind error '{}' to", error); + } + ++stackNr; } } } diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java index e38acb96be..928cb35f50 100644 --- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java +++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java @@ -19,6 +19,9 @@ */ package org.sonar.cxx.sensors.valgrind; +import java.util.List; + +import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; /** @@ -29,54 +32,78 @@ class ValgrindError { private final String kind; private final String text; - private final ValgrindStack stack; + private final List stacks; /** * Constructs a ValgrindError out of the given attributes * * @param kind The kind of error, plays the role of an id * @param text Description of the error - * @param stack The associated call stack + * @param stacks One or more associated call stacks */ - public ValgrindError(String kind, String text, ValgrindStack stack) { + public ValgrindError(String kind, String text, List stacks) { this.kind = kind; this.text = text; - this.stack = stack; + this.stacks = stacks; } + + /** + * For debug prints only; SonarQube cannot deal with long/multi-line error + * messages. Formats like Markdown or HTML are not supported. + * + * For the sake of readability each ValgrindStack will be saved as a separate NewIssue. + * + * See NewIssueLocation::message() + */ @Override public String toString() { - return text + "\n\n" + stack; + StringBuilder sb = new StringBuilder(); + sb.append("ValgrindError [kind=").append(kind).append(", text=").append(text).append(", stacks=["); + for (ValgrindStack stack : stacks) { + sb.append(" ValgrindStack=[").append(stack).append("] "); + } + sb.append("] ]"); + return sb.toString(); } + @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) return true; - } - if (o == null || getClass() != o.getClass()) { + if (obj == null) return false; - } - ValgrindError other = (ValgrindError) o; - return hashCode() == other.hashCode(); + if (getClass() != obj.getClass()) + return false; + ValgrindError other = (ValgrindError) obj; + return new EqualsBuilder() + .append(kind, other.kind) + .append(text, other.text) + .append(stacks, other.stacks) + .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder() - .append(kind) - .append(stack) - .toHashCode(); + .append(kind) + .append(text) + .append(stacks) + .toHashCode(); } String getKind() { return this.kind; } - /** - * @see ValgrindStack#getLastFrame - */ - public ValgrindFrame getLastOwnFrame(String basedir) { - return stack.getLastOwnFrame(basedir); + public String getText() { + return text; + } + + public List getStacks() { + return stacks; } + } diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java index fe098e07d1..bde8fc8b2a 100644 --- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java +++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java @@ -22,7 +22,9 @@ import java.io.File; import javax.annotation.Nullable; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.ObjectUtils; /** * Represents a stack frame. Overwrites equality. Has a string serialization @@ -30,12 +32,12 @@ */ class ValgrindFrame { - private String ip = "???"; - private String obj = ""; - private String fn = "???"; - private String dir = ""; - private String file = ""; - private String line = ""; + private String ip; + private String obj; + private String fn; + private String dir; + private String file; + private String line; /** * Constructs a stack frame with given attributes. Its perfectly valid if some @@ -43,24 +45,12 @@ class ValgrindFrame { */ public ValgrindFrame(@Nullable String ip, @Nullable String obj, @Nullable String fn, @Nullable String dir, @Nullable String file, @Nullable String line) { - if (ip != null) { - this.ip = ip; - } - if (obj != null) { - this.obj = obj; - } - if (fn != null) { - this.fn = fn; - } - if (dir != null) { - this.dir = FilenameUtils.normalize(dir); - } - if (file != null) { - this.file = file; - } - if (line != null) { - this.line = line; - } + this.ip = (ip != null) ? ip : "???"; + this.obj = (obj != null) ? obj : ""; + this.fn = (fn != null) ? fn : "???"; + this.dir = (dir != null) ? FilenameUtils.normalize(dir) : ""; + this.file = (file != null) ? file : ""; + this.line = (line != null) ? line : ""; } @Override @@ -77,25 +67,33 @@ public String toString() { @Override public boolean equals(Object o) { - if (this == o) { + if (this == o) return true; - } - if (o == null || getClass() != o.getClass()) { + if (o == null) + return false; + if (getClass() != o.getClass()) return false; - } ValgrindFrame other = (ValgrindFrame) o; - return hashCode() == other.hashCode(); + return new EqualsBuilder() + .append(ip, other.ip) + .append(obj, other.obj) + .append(fn, other.fn) + .append(dir, other.dir) + .append(file, other.file) + .append(line, other.line) + .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder() - .append(obj) - .append(fn) - .append(dir) - .append(file) - .append(line) - .toHashCode(); + .append(ip) + .append(obj) + .append(fn) + .append(dir) + .append(file) + .append(line) + .toHashCode(); } String getPath() { diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java index cf820bd917..52ed5e6979 100644 --- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java +++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java @@ -20,8 +20,12 @@ package org.sonar.cxx.sensors.valgrind; import java.io.File; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.Stack; + import javax.xml.stream.XMLStreamException; import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; @@ -93,7 +97,8 @@ private static ValgrindError parseErrorTag(SMInputCursor error) throws XMLStream String kind = null; String text = null; - ValgrindStack stack = null; + List details = new ArrayList<>(); + List stacks = new ArrayList<>(); while (child.getNext() != null) { String tagName = child.getLocalName(); if ("kind".equalsIgnoreCase(tagName)) { @@ -102,17 +107,23 @@ private static ValgrindError parseErrorTag(SMInputCursor error) throws XMLStream text = child.childElementCursor("text").advance().getElemStringValue(); } else if ("what".equalsIgnoreCase(tagName)) { text = child.getElemStringValue(); + } else if ("auxwhat".equalsIgnoreCase(tagName)) { + details.add(child.getElemStringValue()); } else if ("stack".equalsIgnoreCase(tagName)) { - stack = parseStackTag(child); + stacks.add(parseStackTag(child)); } } - if (text == null || kind == null || stack == null) { + if (text == null || kind == null || stacks.isEmpty()) { String msg = "Valgrind error is incomplete: we require all of 'kind', '*what.text' and 'stack'"; child.throwStreamException(msg); } - return new ValgrindError(kind, text, stack); + if (!details.isEmpty()) { + text = text + ": " + String.join("; ", details); + } + + return new ValgrindError(kind, text, stacks); } /** diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java index c40eb1a7d6..80f3cf9e4f 100644 --- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java +++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java @@ -23,6 +23,7 @@ import java.util.List; import javax.annotation.Nullable; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; /** @@ -53,23 +54,23 @@ public String toString() { @Override public int hashCode() { - HashCodeBuilder builder = new HashCodeBuilder(); - for (ValgrindFrame frame : frames) { - builder.append(frame); - } - return builder.toHashCode(); + return new HashCodeBuilder() + .append(frames) + .toHashCode(); } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) return true; - } - if (o == null || getClass() != o.getClass()) { + if (obj == null) return false; - } - ValgrindStack other = (ValgrindStack) o; - return hashCode() == other.hashCode(); + if (getClass() != obj.getClass()) + return false; + ValgrindStack other = (ValgrindStack) obj; + return new EqualsBuilder() + .append(frames, other.frames) + .isEquals(); } /** diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensorTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensorTest.java index cd8aa1d5ef..3d98947d2f 100644 --- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensorTest.java +++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensorTest.java @@ -19,6 +19,7 @@ */ package org.sonar.cxx.sensors.valgrind; +import java.util.Collections; import java.util.HashSet; import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; @@ -81,18 +82,21 @@ public void sensorDescriptor() { DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); sensor.describe(descriptor); - SoftAssertions softly = new SoftAssertions(); + SoftAssertions softly = new SoftAssertions(); softly.assertThat(descriptor.name()).isEqualTo(language.getName() + " ValgrindSensor"); softly.assertThat(descriptor.languages()).containsOnly(language.getKey()); softly.assertThat(descriptor.ruleRepositories()).containsOnly(CxxValgrindRuleRepository.KEY); softly.assertAll(); } - + private ValgrindError mockValgrindError(boolean inside) { + ValgrindStack stack = mock(ValgrindStack.class); + ValgrindFrame frame = inside ? generateValgrindFrame() : null; + when(stack.getLastOwnFrame(anyString())).thenReturn(frame); + ValgrindError error = mock(ValgrindError.class); when(error.getKind()).thenReturn("valgrind-error"); - ValgrindFrame frame = inside == true ? generateValgrindFrame() : null; - when(error.getLastOwnFrame((anyString()))).thenReturn(frame); + when(error.getStacks()).thenReturn(Collections.singletonList(stack)); return error; } diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindErrorTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindErrorTest.java index 5f057252db..54d8fe8ff0 100644 --- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindErrorTest.java +++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindErrorTest.java @@ -19,6 +19,7 @@ */ package org.sonar.cxx.sensors.valgrind; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -34,9 +35,9 @@ public class ValgrindErrorTest { @Before public void setUp() { - error = new ValgrindError("kind", "text", new ValgrindStack()); - equalError = new ValgrindError("kind", "text", new ValgrindStack()); - otherError = new ValgrindError("otherkind", "othertext", new ValgrindStack()); + error = new ValgrindError("kind", "text", Collections.singletonList(new ValgrindStack())); + equalError = new ValgrindError("kind", "text", Collections.singletonList(new ValgrindStack())); + otherError = new ValgrindError("otherkind", "othertext", Collections.singletonList(new ValgrindStack())); } @Test @@ -68,21 +69,9 @@ public void errorHashWorksAsExpected() { assertThat(error.hashCode() != otherError.hashCode()).isTrue(); } - @Test - public void stringRepresentationShouldResembleValgrindsStandard() { - Map ioMap = new HashMap<>(); - - ioMap.put("\n\n", new ValgrindError("", "", new ValgrindStack())); - ioMap.put("description\n\n", new ValgrindError("kind", "description", new ValgrindStack())); - - for (Map.Entry entry : ioMap.entrySet()) { - assertEquals(entry.getKey(), entry.getValue().toString()); - } - } - @Test public void getKindWorks() { String KIND = "kind"; - assertEquals(new ValgrindError(KIND, "", new ValgrindStack()).getKind(), KIND); + assertEquals(new ValgrindError(KIND, "", Collections.singletonList(new ValgrindStack())).getKind(), KIND); } } diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParserTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParserTest.java index 4b0e7ac722..ff2f127997 100644 --- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParserTest.java +++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParserTest.java @@ -39,9 +39,41 @@ public void setUp() { @Test public void shouldParseCorrectNumberOfErrors() throws javax.xml.stream.XMLStreamException { File absReportsProject = TestUtils.loadResource("/org/sonar/cxx/sensors/reports-project").getAbsoluteFile(); - File absReportFile = new File(absReportsProject, "valgrind-reports/valgrind-result-SAMPLE.xml"); + File absReportFile = new File(absReportsProject, "valgrind-reports/valgrind-result-SAMPLE_1.xml"); Set valgrindErrors = parser.processReport(absReportFile); - assertEquals(6, valgrindErrors.size()); + assertEquals(13, valgrindErrors.size()); + } + + @Test + public void parseAnErrorWithMultipleStacks() throws javax.xml.stream.XMLStreamException { + File absReportsProject = TestUtils.loadResource("/org/sonar/cxx/sensors/reports-project").getAbsoluteFile(); + File absReportFile = new File(absReportsProject, "valgrind-reports/valgrind-result-SAMPLE_2.xml"); + Set valgrindErrors = parser.processReport(absReportFile); + // single + assertEquals(1, valgrindErrors.size()); + + ValgrindError error = valgrindErrors.iterator().next(); + // merge and + assertEquals("Invalid write of size 4: Address 0xd820468 is 0 bytes after a block of size 40 alloc'd", error.getText()); + // contains two entries + assertEquals(2, error.getStacks().size()); + } + + @Test + public void parseAnErrorWithMultipleAuxwhat() throws javax.xml.stream.XMLStreamException { + File absReportsProject = TestUtils.loadResource("/org/sonar/cxx/sensors/reports-project").getAbsoluteFile(); + File absReportFile = new File(absReportsProject, "valgrind-reports/valgrind-result-SAMPLE_3.xml"); + Set valgrindErrors = parser.processReport(absReportFile); + // single + assertEquals(1, valgrindErrors.size()); + + ValgrindError error = valgrindErrors.iterator().next(); + // merge , and one more + // see PROTOCOL for version 3 + // https://github.com/pathscale/valgrind-mmt/blob/master/docs/internals/xml-output.txt + assertEquals("Invalid write of size 4: Details0; Details1", error.getText()); + // contains one entry + assertEquals(1, error.getStacks().size()); } @Test(expected = javax.xml.stream.XMLStreamException.class) @@ -49,7 +81,7 @@ public void shouldThrowWhenGivenAnIncompleteReport_1() throws javax.xml.stream.X File absReportsProject = TestUtils.loadResource("/org/sonar/cxx/sensors/reports-project").getAbsoluteFile(); File absReportFile = new File(absReportsProject, "valgrind-reports/incorrect-valgrind-result_1.xml"); - // error contains no kind-tag + // error contains no kind-tag parser.processReport(absReportFile); } diff --git a/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE.xml b/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_1.xml similarity index 100% rename from cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE.xml rename to cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_1.xml diff --git a/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_2.xml b/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_2.xml new file mode 100644 index 0000000000..c85bf1f1fe --- /dev/null +++ b/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_2.xml @@ -0,0 +1,254 @@ + + + + +4 +memcheck + + + Memcheck, a memory error detector + Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. + Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info + Command: /home/user/bin/64/debug/MODULE_TU_d /home/user/code/modules/MODULE/cppunit_output_dbg.xml + + +20112 +20111 +memcheck + + + + /usr/bin/valgrind.bin + --leak-check=yes + --xml=yes + --xml-file=/home/user/code/modules/MODULE/valgrind_output.xml + + + /home/user/bin/64/debug/MODULE_TU_d + /home/user/code/modules/MODULE/cppunit_output_dbg.xml + + + + + RUNNING + + + + + 0x0 + 1 + InvalidWrite + Invalid write of size 4 + + + 0x511DF59 + /home/user/bin/64/debug/libMODULE_d.so.1.0.0 + ns::Clazz::method(float) + /home/user/code/modules/MODULE/src/MODULE + Clazz.cpp + 114 + + + 0x427181 + /home/user/bin/64/debug/MODULE_TU_d + _Clazz::method(float) + /home/user/code/tu/MODULE_TU/include/MODULE_TU + ClazzTest.h + 12 + + + 0x427847 + /home/user/bin/64/debug/MODULE_TU_d + ClazzTest::method() + /home/user/code/tu/MODULE_TU/include/MODULE_TU + ClazzTest.h + 31 + + + 0x4296D3 + /home/user/bin/64/debug/MODULE_TU_d + CppUnit::TestCaller<ClazzTest>::runTest() + /home/user/code/externals/ThirdParty/include/cppunit + TestCaller.h + 166 + + + 0x4EA97B5 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestCaseMethodFunctor::operator()() const + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestCase.cpp + 32 + + + 0x4E9AB98 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + DefaultProtector.cpp + 15 + + + 0x4EA43F6 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::ProtectorChain::ProtectFunctor::operator()() const + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + ProtectorChain.cpp + 20 + + + 0x4EA4286 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + ProtectorChain.cpp + 77 + + + 0x4EB5602 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestResult.cpp + 178 + + + 0x4EA9226 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestCase::run(CppUnit::TestResult*) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestCase.cpp + 92 + + + 0x4EA9E85 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestComposite.cpp + 64 + + + 0x4EA9D07 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestComposite::run(CppUnit::TestResult*) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestComposite.cpp + 23 + + + Address 0xd820468 is 0 bytes after a block of size 40 alloc'd + + + 0x4C2E80F + /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so + operator new[](unsigned long) + + + 0x511DF1A + /home/user/bin/64/debug/libMODULE_d.so.1.0.0 + ns::Clazz::method(float) + /home/user/code/modules/MODULE/src/MODULE + Clazz.cpp + 110 + + + 0x427181 + /home/user/bin/64/debug/MODULE_TU_d + _Clazz::method(float) + /home/user/code/tu/MODULE_TU/include/MODULE_TU + ClazzTest.h + 12 + + + 0x427847 + /home/user/bin/64/debug/MODULE_TU_d + ClazzTest::method() + /home/user/code/tu/MODULE_TU/include/MODULE_TU + ClazzTest.h + 31 + + + 0x4296D3 + /home/user/bin/64/debug/MODULE_TU_d + CppUnit::TestCaller<ClazzTest>::runTest() + /home/user/code/externals/ThirdParty/include/cppunit + TestCaller.h + 166 + + + 0x4EA97B5 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestCaseMethodFunctor::operator()() const + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestCase.cpp + 32 + + + 0x4E9AB98 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + DefaultProtector.cpp + 15 + + + 0x4EA43F6 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::ProtectorChain::ProtectFunctor::operator()() const + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + ProtectorChain.cpp + 20 + + + 0x4EA4286 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + ProtectorChain.cpp + 77 + + + 0x4EB5602 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestResult.cpp + 178 + + + 0x4EA9226 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestCase::run(CppUnit::TestResult*) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestCase.cpp + 92 + + + 0x4EA9E85 + /home/user/bin/64/debug/libcppunit_d.so.1.12.1 + CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) + /home/user/code/externals/ThirdParty/cppunit/sources/src/cppunit + TestComposite.cpp + 64 + + + + + + + FINISHED + + + + + + 1 + 0x0 + + + + + + + diff --git a/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_3.xml b/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_3.xml new file mode 100644 index 0000000000..e5458bb2eb --- /dev/null +++ b/cxx-sensors/src/test/resources/org/sonar/cxx/sensors/reports-project/valgrind-reports/valgrind-result-SAMPLE_3.xml @@ -0,0 +1,72 @@ + + + + +4 +memcheck + + + Memcheck, a memory error detector + Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. + Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info + Command: /home/user/bin/64/debug/MODULE_TU_d /home/user/code/modules/MODULE/cppunit_output_dbg.xml + + +20112 +20111 +memcheck + + + + /usr/bin/valgrind.bin + --leak-check=yes + --xml=yes + --xml-file=/home/user/code/modules/MODULE/valgrind_output.xml + + + /home/user/bin/64/debug/MODULE_TU_d + /home/user/code/modules/MODULE/cppunit_output_dbg.xml + + + + + RUNNING + + + + + 0x0 + 1 + InvalidWrite + Invalid write of size 4 + + + 0x511DF59 + /home/user/bin/64/debug/libMODULE_d.so.1.0.0 + ns::Clazz::method(float) + /home/user/code/modules/MODULE/src/MODULE + Clazz.cpp + 114 + + + Details0 + Details1 + + + + + FINISHED + + + + + + 1 + 0x0 + + + + + + +