]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: Print invocation on ICE
authorNathan Sidwell <nathan@acm.org>
Sun, 2 Nov 2025 00:02:47 +0000 (20:02 -0400)
committerNathan Sidwell <nathan@acm.org>
Tue, 20 Jan 2026 17:31:28 +0000 (12:31 -0500)
Print the compiler's invocation upon ICE. Particularly useful on LTO
crashes.

gcc/
* diagnostics/context.cc (context::action_after_output): Print
invocation on ICE.

gcc/diagnostics/context.cc

index 9cb13acc52035e92bf1858a353230c4c6a289637..03d570665843dde5a5d05b6b9058803f75c2f8fc 100644 (file)
@@ -1003,10 +1003,11 @@ context::action_after_output (enum kind diag_kind)
        /* Attempt to ensure that any outputs are flushed e.g. that .sarif
           files are written out.
           Only do it once.  */
-       static bool finishing_due_to_ice = false;
-       if (!finishing_due_to_ice)
+       static char **saved_argv = nullptr;
+       if (!saved_argv)
          {
-           finishing_due_to_ice = true;
+           saved_argv = m_original_argv;
+           m_original_argv = nullptr;
            finish ();
          }
 
@@ -1021,6 +1022,12 @@ context::action_after_output (enum kind diag_kind)
        if (m_abort_on_error)
          real_abort ();
 
+       bool space = false;
+       for (auto *argv = saved_argv; *argv; space = true)
+         fnotice (stderr, &" %s"[1 - space], *argv++);
+       fnotice (stderr, "\n");
+       freeargv (saved_argv);
+
        if (m_report_bug)
          fnotice (stderr, "Please submit a full bug report, "
                   "with preprocessed source.\n");