autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: Stack traces


From: Akim Demaille
Subject: FYI: Stack traces
Date: Fri, 22 Aug 2003 15:40:40 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

There is one thing that remains not satisfying: an m4 script that
issues warnings and then an m4_fatal will not see the warnings, since
they are processed after a _successful_ run of m4.  The alternative
would be to also delay the m4_fatal to autom4te, but then it means
that we try to continue processing a script that can be monstrously
broken, triggering tons of cryptic messages.

I don't know.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Output stack traces in warnings.

        * lib/m4sugar/m4sugar.m4 (_m4_warn): New.
        Replace the former...
        (m4_warn): Pass the call stack to _m4_warn.
        * bin/autom4te.in: Adjust to output the call stack.
        * tests/m4sugar.at (m4@&address@hidden): Adjust.

Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.88
diff -u -u -r1.88 autom4te.in
--- bin/autom4te.in 22 Aug 2003 08:09:12 -0000 1.88
+++ bin/autom4te.in 22 Aug 2003 13:35:03 -0000
@@ -78,7 +78,7 @@
 # FIXME: What about `sinclude'?
 my @preselect = ('include',
                 'm4_pattern_allow', 'm4_pattern_forbid',
-                'm4_warn');
+                '_m4_warn');
 
 # M4 include path.
 my @include;
@@ -993,11 +993,23 @@
 
 # Issue the warnings each time autom4te was run.
 handle_traces ($req, "$tmp/warnings",
-              ('m4_warn' => "\$1::\$f:\$l::\$2\n\n"));
+              ('_m4_warn' => "\$1::\$f:\$l::\$2::\$3\n\n"));
+# Warnings are separated by 2 \n.
 for (split (/\n{2,}/, contents ("$tmp/warnings")))
 {
-  my ($cat, $loc, $msg) = split '::';
+  # The message looks like:
+  # | syntax::input.as:5::ouch
+  # | ::input.as:4: baz is expanded from...
+  # | input.as:2: bar is expanded from...
+  # | input.as:3: foo is expanded from...
+  # | input.as:5: the top level
+  my ($cat, $loc, $msg, $stacktrace) = split ('::', $_, 4);
   msg $cat, $loc, "warning: $msg";
+  for (split /\n/, $stacktrace)
+    {
+      my ($loc, $trace) = split (': ', $_, 2);
+      msg $cat, $loc, $trace;
+    }
 }
 
 # Now output...
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.74
diff -u -u -r2.74 m4sugar.m4
--- lib/m4sugar/m4sugar.m4 21 Aug 2003 17:25:31 -0000 2.74
+++ lib/m4sugar/m4sugar.m4 22 Aug 2003 13:35:05 -0000
@@ -201,17 +201,29 @@
        [m4_fatal([assert failed: $1], [$2])])])
 
 
+
 ## ------------- ##
 ## 3. Warnings.  ##
 ## ------------- ##
 
 
+# _m4_warn(CATEGORY, MESSAGE, STACK-TRACE)
+# ----------------------------------------
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.
+# This is for traces only.
+# The STACK-TRACE is a \n-separated list of "LOCATION: MESSAGE".
+m4_define([_m4_warn], [])
+
+
 # m4_warn(CATEGORY, MESSAGE)
 # --------------------------
-# Report a MESSAGE to the autoconf user if the CATEGORY of warnings
-# is requested (in fact, not disabled).  This is for traces only.
-m4_define([m4_warn], [])
-
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.
+m4_define([m4_warn],
+[_m4_warn([$1], [$2],
+m4_ifdef([m4_expansion_stack],
+         [m4_defn([m4_expansion_stack])
+m4_location[: the top level]]))
+])
 
 
 
Index: tests/m4sugar.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/m4sugar.at,v
retrieving revision 1.23
diff -u -u -r1.23 m4sugar.at
--- tests/m4sugar.at 21 Aug 2003 17:25:31 -0000 1.23
+++ tests/m4sugar.at 22 Aug 2003 13:35:05 -0000
@@ -42,29 +42,38 @@
 # warnings.  But maybe autom4te should handle that by itself?
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_warn([obsolete],  [obsolete])
-m4_warn([cross],  [cross])
+[[m4_init
+m4_defun([cross_warning],
+[m4_warn([cross],  [cross])
+])
+
+m4_warn([obsolete],  [obsolete])
+cross_warning
 m4_warn([syntax], [syntax])
 ]])
 
 AT_CHECK_M4SUGAR([-o-], 0, [],
-[script.4s:3: warning: syntax
+[script.4s:8: warning: syntax
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
-[script.4s:1: warning: obsolete
-script.4s:2: warning: cross
-script.4s:3: warning: syntax
+[script.4s:6: warning: obsolete
+script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
+script.4s:8: warning: syntax
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [],
-[script.4s:2: warning: cross
+[script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wnone,cross,error -f], 1, [],
-[[script.4s:2: error: cross
-script.4s:2: the top level
-autom4te: m4 failed with exit status: 1
+[[script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
 ]])
 
 AT_CLEANUP





reply via email to

[Prev in Thread] Current Thread [Next in Thread]