From patchwork Mon Nov 4 16:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 2006303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=YAzV6xJX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhxQ42WDyz1xyD for ; Tue, 5 Nov 2024 03:15:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 833F53857022 for ; Mon, 4 Nov 2024 16:15:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 3E7E03857011 for ; Mon, 4 Nov 2024 16:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E7E03857011 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3E7E03857011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730736731; cv=none; b=Jfi0/BtM4kuo+gtU4nFBnL0cEy5Paq2g4Wlyqb3DokcF1TojJ2+fxE82KuYtkxgBAqS/nYIaf0BdfS2DV39iAi/o/KPzSIH/ok5nJ/0hol1EipCRyJQTY24z1hTt31MltWfevbU0jfzn8lsy5X+mgi5K55Y7kRWUTPHg8VxNFCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730736731; c=relaxed/simple; bh=oXf+GnLlYofE/WO0/croihESWJxLtalE4MARkCFmfkg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dybFV80ZUCPLnMDwz2Qy7NCGeuL5t5PpNlciMv35BfGOyxnbM7M2INg1G/1ezoUGnTeUAvLIFbXxeKLBcSAo2qtzWYwn+znjFAS3Ar4rjA73/BS77cQs3++8g/2rO9u2QCria3kl0TnEbCQHSegcFRWjsyg0xkpP59y8Q3DhnuU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-37f52925fc8so2734242f8f.1 for ; Mon, 04 Nov 2024 08:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1730736702; x=1731341502; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U1eTBVzRsNW1mUdALK/4eKF9eZ20cddkQ0pDverAmWg=; b=YAzV6xJX5lfoZcVVxWcjNuxdn8NtWctsfj+Zv4iZDce7T+TCKpk+GL3PArxmiwNL/Z Wa9E7gYhOz7LEc5sPxK3XfQjHAtiSd8vlGv26nzVEUGDkZTgznZlMapR5uyypHEDX3md bclGFB83o20pVy4C2ISKkgPKJ2oc2ecvYiSHucUoDyeWECffPFyLMzy1CAIy0BJYHSPZ ocp/4Pgu1Ix8A5BmJi2HQ/CI3uzMX3Ydwk0Y2z3+/RcoK+h6hLl3TXJrDp0xbX99oxOJ twb257o7oSu/TIbElJiiF5biqU+5qX6msohbIowKZN/rSHs0827AlfFoOofeFt+sS2C/ QjGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730736702; x=1731341502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U1eTBVzRsNW1mUdALK/4eKF9eZ20cddkQ0pDverAmWg=; b=oROTIUA1M/aV4ekO9U5tRfrH8LBMfWNCAmLSNmDPH/hEK9Wnv/aOngF7WcidjpIp5J UUfS9xo/C+A90Xk+zRNi8/i+h2J0Ow71INj+vJzzs8QGr3Rq8IhhIU8XiE+dyqWEA0UY RU1KoqW5hvX7gisE6x27vulZ1nnxZFhWA0RiRpEWTVfkucscumWWcysBZbJAzgJYPKNR aEy88xBn2u5wN4+p4GMWnAdnEEk6LsBiSnIkkCPQMmbFDt6ijcSxLqG1gGMkDj/xbFMG ERoHWPqCq2+oB43qpv2Yz/nu95QeWvUppEqs9T/vZ1pRkoYuiMPNSaI/sPaBAd4buyS9 pJdA== X-Gm-Message-State: AOJu0Ywv2+l7/ipya7GY3625Q9rHyvTJA3WwKfbBm4UYhI09iz+WKs+m VYknEIR8YGLRPueczm/JQ+AfHja5Qy06AO/00PdPsmCXrwE/SRKDHqgQ1sXm1rns0vbk7vl5AUo = X-Google-Smtp-Source: AGHT+IGc4ahvr4ne1nAEgzWHUWN6CVouLA/IrRNyAICaUS0eXDENRtXH3rKTE8bBBTvMQi7iGtjLDA== X-Received: by 2002:a05:6000:1a8a:b0:37d:4a7b:eeb2 with SMTP id ffacd0b85a97d-381c7a6d600mr9789310f8f.35.1730736701897; Mon, 04 Nov 2024 08:11:41 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e747csm13574463f8f.64.2024.11.04.08.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 08:11:41 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 20/38] ada: Add Invocation node to the SARIF report Date: Mon, 4 Nov 2024 17:10:55 +0100 Message-ID: <20241104161116.1431659-20-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104161116.1431659-1-poulhies@adacore.com> References: <20241104161116.1431659-1-poulhies@adacore.com> MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Viljar Indus Add an invocation node to the SARIF report that contains the command line use to activate gnat and whether the execution was successful or not. gcc/ada/ChangeLog: * diagnostics-sarif_emitter.adb (Print_Runs): Add printing for the invocation node that consists of a single invocations that is composed of the commandLine and executionSuccessful attributes. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/diagnostics-sarif_emitter.adb | 81 ++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/gcc/ada/diagnostics-sarif_emitter.adb b/gcc/ada/diagnostics-sarif_emitter.adb index fe251f9754d..b6035c2970d 100644 --- a/gcc/ada/diagnostics-sarif_emitter.adb +++ b/gcc/ada/diagnostics-sarif_emitter.adb @@ -28,6 +28,10 @@ with Diagnostics.JSON_Utils; use Diagnostics.JSON_Utils; with Gnatvsn; use Gnatvsn; with Output; use Output; with Sinput; use Sinput; +with Lib; use Lib; +with Namet; use Namet; +with Osint; use Osint; +with Errout; use Errout; package body Diagnostics.SARIF_Emitter is @@ -94,6 +98,19 @@ package body Diagnostics.SARIF_Emitter is -- ... -- ] + procedure Print_Invocations; + -- Print an invocations node that consists of + -- * a single invocation node that consists of: + -- * commandLine + -- * executionSuccessful + -- + -- "invocations": [ + -- { + -- "commandLine": , + -- "executionSuccessful": ["true"|"false"], + -- } + -- ] + procedure Print_Artifact_Change (A : Artifact_Change); -- Print an ArtifactChange node -- @@ -573,6 +590,63 @@ package body Diagnostics.SARIF_Emitter is Write_Char (']'); end Print_Fixes; + ----------------------- + -- Print_Invocations -- + ----------------------- + + procedure Print_Invocations is + + function Compose_Command_Line return String; + -- Composes the original command line from the parsed main file name and + -- relevant compilation switches + + function Compose_Command_Line return String is + Buffer : Bounded_String; + begin + Append (Buffer, Get_First_Main_File_Name); + for I in 1 .. Compilation_Switches_Last loop + declare + Switch : constant String := Get_Compilation_Switch (I).all; + begin + if Buffer.Length + Switch'Length + 1 <= Buffer.Max_Length then + Append (Buffer, ' ' & Switch); + end if; + end; + end loop; + + return +Buffer; + end Compose_Command_Line; + + begin + Write_Str ("""" & "invocations" & """" & ": " & "["); + Begin_Block; + NL_And_Indent; + + Write_Char ('{'); + Begin_Block; + NL_And_Indent; + + -- Print commandLine + + Write_String_Attribute ("commandLine", Compose_Command_Line); + Write_Char (','); + NL_And_Indent; + + -- Print executionSuccessful + + Write_String_Attribute + ("executionSuccessful", + (if Compilation_Errors then "false" else "true")); + + End_Block; + NL_And_Indent; + Write_Char ('}'); + + End_Block; + NL_And_Indent; + Write_Char (']'); + end Print_Invocations; + ------------------ -- Print_Region -- ------------------ @@ -1052,6 +1126,12 @@ package body Diagnostics.SARIF_Emitter is Write_Char (','); NL_And_Indent; + -- A run consists of an invocation + Print_Invocations; + + Write_Char (','); + NL_And_Indent; + -- A run consists of results Print_Results (Diags); @@ -1076,7 +1156,6 @@ package body Diagnostics.SARIF_Emitter is ------------------------ procedure Print_SARIF_Report (Diags : Diagnostic_List) is - begin Write_Char ('{'); Begin_Block;