From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 14189385E01D for ; Tue, 7 Jun 2022 15:10:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14189385E01D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.91,284,1647331200"; d="scan'208";a="76913645" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 Jun 2022 07:10:20 -0800 IronPort-SDR: xgaZ8CzZ8uWs48pGtqo+ppNMcV7UxJ60MSP+mTUCI7PqrvdCoUPzHgMmtk5ULrjlbNVpAbFe/i bWGFNNSF5bkgwG0Vw4Ni5OQm38ZelbfTsGFmItFIDJwIEsRnFJd4Z7vUtnVd3LzJmhAn/2lsv0 BsVpL7HSvRrDmpfQDL/nZn0fJFtgMqPlrx7GLTzBMYJsG50iDsE5fFkUt3Y8BPyrCyJg+BSJy3 8qWDI4MyYWk6ifhRomMQmO8V8MgZQw5PeDNcoAlFhrSnr75AwaerNItGP1FxP78TqnTHxbfAlc Zok= From: Thomas Schwinge To: David Malcolm CC: , Markus Schordan Subject: Re: [committed] diagnostics: add SARIF output format In-Reply-To: <20220602194620.843787-1-dmalcolm@redhat.com> References: <20220602194620.843787-1-dmalcolm@redhat.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Tue, 7 Jun 2022 17:10:07 +0200 Message-ID: <87ilpcqzlc.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2022 15:10:25 -0000 Hi David, and Markus! On 2022-06-02T15:46:20-0400, David Malcolm via Gcc-patches wrote: > This patch adds support to gcc's diagnostic subsystem for emitting > diagnostics in SARIF, aka the Static Analysis Results Interchange Format: > https://sarifweb.azurewebsites.net/ > by extending -fdiagnostics-format=3D to add two new options: > -fdiagnostics-format=3Dsarif-stderr > and: > -fdiagnostics-format=3Dsarif-file > > The patch targets SARIF v2.1.0 Now that's "funny": on that very day that you pushed to GCC "diagnostics: add SARIF output format", I'd been attending at ISC 2022 the "Compiler-assisted Correctness Checking and Performance Optimization for HPC" (C3PO) workshop, , where in his interesting keynote "On the Benefits of Software Verification Competitions for HPC", Markus Schordan (in CC just for your information) had a number of generally positive :-) mentions of GCC's Static Analyzer -- just also did comment that it doesn't support the standard SARIF output format. Seems that issue is now resolved. :-) He generally also covered other fundamental aspects, such as the difference between "sound" vs. "complete" analysis. See "What is soundness (in static analysis)?", or "Soundness and completeness: with precision", for example. As I remember, it was stated that it's unclear which one GCC's Static Analyzer strives for; may want to clarify that, in the manual: , I suppose? Plus, probably a few more things relevant for GCC's Static Analyzer, that I don't currently remember; I didn't take notes. Maybe Markus is going to upload his presentation on , or would like to make it available to you in another way? Note that I'm really just relaying information here, but other than general interest, I'm myself not too familiar with the details of Static Analysis. Just thought that you would appreciate hearing about GCC's Static Analyzer "spotted in the wild". Gr=C3=BC=C3=9Fe Thomas > This is a JSON-based format suited for capturing the results of static > analysis tools (like GCC's -fanalyzer), but it can also be used for plain > GCC warnings and errors. > > SARIF supports per-event metadata in diagnostic paths such as > ["acquire", "resource"] and ["release", "lock"] (specifically, the > threadFlowLocation "kinds" property: SARIF v2.1.0 section 3.38.8), so > the patch extends GCC"s diagnostic_event subclass with a "struct meaning" > with similar purpose. The patch implements this for -fanalyzer so that > the various state-machine-based warnings set these in the SARIF output. > > The heart of the implementation is in the new file > diagnostic-format-sarif.cc. Much of the rest of the patch is interface > classes, isolating the diagnostic subsystem (which has no knowledge of > e.g. tree or langhook) from the "client" code in the compiler proper > cc1 etc). > > The patch adds a langhook for specifying the SARIF v2.1.0 > "artifact.sourceLanguage" property, based on the list in > SARIF v2.1.0 Appendix J. > > The patch adds automated DejaGnu tests to our testsuite via new > scan-sarif-file and scan-sarif-file-not directives (although these > merely use regexps, rather than attempting to use a proper JSON parser). > > I've tested the patch by hand using the validator at: > https://sarifweb.azurewebsites.net/Validation > and the react-based viewer at: > https://microsoft.github.io/sarif-web-component/ > which successfully shows most of the information (although not paths, > and not CWE IDs), and I've fixed all validation errors I've seen (though > bugs no doubt remain). > > I've also tested the generated SARIF using the VS Code extension linked > to from the SARIF website; I'm a novice with VS Code, but it seems to be > able to handle my generated SARIF files (e.g. showing the data in the > SARIF tab, and showing squiggly underlines under issues, and when I > click on them, it visualizes the events in the path inline within the > source window). > > Has anyone written an Emacs mode for SARIF files? (pretty please) > > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. > Pushed to trunk as r13-967-g6cf276ddf22066. > > [...] ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955