autoconf
[Top][All Lists]
Advanced

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

Re: a debugging trick: how to peek into m4's processing


From: Eric Blake
Subject: Re: a debugging trick: how to peek into m4's processing
Date: Sat, 25 Jul 2009 09:46:46 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 7/25/2009 8:40 AM:
>> +$ @kbd{cat <<\EOF > foo.m4}
>> +m4_init
>> +m4_errprintn([try one: m4_dquote is ]m4_defn([m4_dquote]))
>> +m4_divert([0])dnl
>> +m4_errprintn([try two: m4_dquote is ]m4_defn([m4_dquote]))dnl
>> +m4_dquote([hi])
>> +EOF
>> +$ @kbd{autom4te --language=m4sugar foo.m4}
>> +try one: m4_dquote is [$@@]
>> +try two: m4_dquote is [$@@]
>> +$ @kbd{cat foo}
>> +[hi]
> 
> In this second example, the file 'foo' is never being created, since autom4te
> is not being passed the options "-o foo".

Oops.  Definitely needs fixing (or deletion - read on).

> 
> More importantly, your example shows m4_errprintn only in the context of
> "autom4te --language=m4sugar". But it's more powerful than that: it also
> works from inside an 'autoconf' run (with is more often what the user wants
> to debug).
> 
> Here is a proposed patch to
>   - show m4_errprintn in the context of autoconf,
>   - separate the two techniques (m4_errprintn and diversions) into separate
>     examples,

Using diversions is not a technique.  Rather, it is an additional reason
(beyond postprocessing) why outputting to anything except stderr or
separate files is problematic, because diversions can be discarded or
rearranged - ultimately, all diversions except for KILL (-1) go to
standard out.  So I'm just dropping the autom4te --language=m4sugar
example altogether.

>   - Tweak the output so that it fits in 79 columns (in 'info' output).
> 
> 
> 2009-07-25  Bruno Haible  <address@hidden>
> 
>       Clarify autom4te debugging tips.
>       * doc/autoconf.texi (Debugging via autom4te): Clarify that the two
>       techniques are independent.

Git did not like your patch - I could not apply it with either 'git am' or
'git apply', so I had to do more work to get it into good shape to play
with it.  Here's the followup I'm using:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkprKOYACgkQ84KuGfSFAYB+ggCfdrWGVrYUbce9yBlsXOgRUXn1
wqAAn0s0JqvV+FEqvoTVgytnj3ZmgZdd
=QjwU
-----END PGP SIGNATURE-----
From bd9c233305b0abc867eea1deddde55be9b8a6857 Mon Sep 17 00:00:00 2001
From: Bruno Haible <address@hidden>
Date: Sat, 25 Jul 2009 09:38:39 -0600
Subject: [PATCH] Clarify autom4te debugging tips.

* doc/autoconf.texi (Debugging via autom4te): Fix example from
previous commit, and add clarification.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    6 ++++++
 doc/autoconf.texi |   48 +++++++++++++++++-------------------------------
 2 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4ed5149..4ecd0d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-25  Bruno Haible  <address@hidden>
+
+       Clarify autom4te debugging tips.
+       * doc/autoconf.texi (Debugging via autom4te): Fix example from
+       previous commit, and add clarification.
+
 2009-07-25  Eric Blake  <address@hidden>

        Document some autom4te debugging tips.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 0b61e35..39286fd 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12454,39 +12454,25 @@ Debugging via autom4te
 version is 2.63b.95-3963
 @end example

-Another trick is using @code{m4_errprintn} to output debugging messages
-to standard error with no further m4 expansion, and without interfering
-with the post-processing done to standard output.  For example, contrast
-these two attempts to learn how @code{m4_dquote} is implemented:
+Another trick is to print out the expansion of various m4 expressions to
+standard error or to an independent file, with no further m4 expansion,
+and without interfering with diversion changes or the post-processing
+done to standard output.  @code{m4_errprintn} shows a given expression
+on standard error.  For example, if you want to see the expansion of an
+autoconf primitive or of one of your autoconf macros, you can do it like
+this:

address@hidden
-$ @kbd{cat <<\EOF > foo.m4}
-m4_init
-try one: [m4_dquote is ]m4_defn([m4_dquote])
-m4_divert([0])dnl
-try two: [m4_dquote is ]m4_defn([m4_dquote])
-m4_dquote([hi])
-EOF
-$ @kbd{autom4te --language=m4sugar -o foo foo.m4}
-foo.m4:2: error: possibly undefined macro: m4_dquote
-      If this token and others are legitimate, please use m4_pattern_allow.
-      See the Autoconf documentation.
-$ @kbd{cat foo}
-try two: m4_dquote is [$@@]
-[hi]
-$ @kbd{cat <<\EOF > foo.m4}
-m4_init
-m4_errprintn([try one: m4_dquote is ]m4_defn([m4_dquote]))
-m4_divert([0])dnl
-m4_errprintn([try two: m4_dquote is ]m4_defn([m4_dquote]))dnl
-m4_dquote([hi])
address@hidden
+$ @kbd{cat <<\EOF > configure.ac}
+AC_INIT
+m4_errprintn([The definition of AC_DEFINE_UNQUOTED:])
+m4_errprintn(m4_defn([AC_DEFINE_UNQUOTED]))
+AC_OUTPUT
 EOF
-$ @kbd{autom4te --language=m4sugar foo.m4}
-try one: m4_dquote is [$@@]
-try two: m4_dquote is [$@@]
-$ @kbd{cat foo}
-[hi]
address@hidden smallexample
+$ @kbd{autoconf}
address@hidden definition of AC_DEFINE_UNQUOTED:
address@hidden([], $@@)
address@hidden example

 @node Programming in M4sh
 @chapter Programming in M4sh
-- 
1.6.3.3.334.g916e1


reply via email to

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