{"id":3998,"date":"2022-12-20T17:28:39","date_gmt":"2022-12-20T20:28:39","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/groff_trace-man7\/"},"modified":"2022-12-20T17:28:39","modified_gmt":"2022-12-20T20:28:39","slug":"groff_trace-man7","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/groff_trace-man7\/","title":{"rendered":"GROFF_TRACE (man7)"},"content":{"rendered":"<h1 align=\"center\">GROFF_TRACE<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#PROBLEMS\">PROBLEMS<\/a><br \/> <a href=\"#FILES\">FILES<\/a><br \/> <a href=\"#ENVIRONMENT\">ENVIRONMENT<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">groff_trace \u2212 groff macro package trace.tmac<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"21%\">\n<p style=\"margin-top: 1em\"><b>groff \u2212m trace<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"44%\">\n<p style=\"margin-top: 1em\">[<i>option<\/i> &#8230;] [<i>input-file<\/i> &#8230;]<\/p>\n<\/td>\n<td width=\"22%\"> <\/td>\n<\/tr>\n<\/table>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>trace<\/i> macro package of <b>groff<\/b>(1) can be a valuable tool for debugging documents written in the roff formatting language. A call stack trace is protocolled on standard error, this is, a diagnostic message is emitted on entering and exiting of a macro call. This greatly eases to track down an error in some macro.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This tracing process is activated by specifying the groff or troff command-line option <b>\u2212m\u00a0trace<\/b>. This works also with the <b>groffer<\/b>(1) viewer program. A finer control can be obtained by including the macro file within the document by the groff macro call <b>.mso\u00a0trace.tmac<\/b>. Only macros that are defined after this line are traced.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the command-line option <b>\u2212r\u00a0trace-full=1<\/b> is given (or if this register is set in the document), number and string register assignments together with some other requests are traced also.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If some other macro package should be traced as well it must be specified after <b>\u2212m\u00a0trace<\/b> on the command line.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The macro file <b>trace.tmac<\/b> is unusual because it does not contain any macros to be called by a user. Instead, the existing macro definition and appending facilities are modified such that they display diagnostic messages.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">In the following examples, a roff fragment is fed into groff via standard input. As we are only interested in the diagnostic messages (standard error) on the terminal, the normal formatted output (standard output) is redirected to the nirvana device <i>\/dev\/null<\/i>. The resulting diagnostic messages are displayed directly below the corresponding example.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Command line option<\/b> <br \/> Example:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>sh#<\/i> echo &#8216;. <br \/> > .de test_macro <br \/> > .. <br \/> > .test_macro <br \/> > .test_macro some dummy arguments <br \/> > &#8216; | groff \u2212m trace > \/dev\/null<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">*** .de test_macro <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr de trace enter: .test_macro <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr trace exit: .test_macro <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr de trace enter: .test_macro &#8220;some&#8221; &#8220;dummy&#8221; &#8220;arguments&#8221; <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr trace exit: .test_macro &#8220;some&#8221; &#8220;dummy&#8221; &#8220;arguments&#8221;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The entry and the exit of each macro call is displayed on the terminal (standard output) \u2014 together with the arguments (if any).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Nested macro calls<\/b> <br \/> Example:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>sh#<\/i> echo &#8216;. <br \/> > .de child <br \/> > .. <br \/> > .de parent <br \/> > .child <br \/> > .. <br \/> > .parent <br \/> > &#8216; | groff \u2212m trace > \/dev\/null<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">*** .de child <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr .de parent <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr de trace enter: .parent <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr de trace enter: .child <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr trace exit: .child <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr trace exit: .parent<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This shows that macro calls can be nested. This powerful feature can help to tack down quite complex call stacks.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Activating with .mso<\/b> <br \/> Example:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>sh#<\/i> echo &#8216;. <br \/> > .de before <br \/> > .. <br \/> > .mso trace.tmac <br \/> > .de after <br \/> > .. <br \/> > .before <br \/> > .after <br \/> > .before <br \/> > &#8216; | groff > \/dev\/null<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">*** de trace enter: .after <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr trace exit: .after<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Here, the tracing is activated within the document, not by a command-line option. As tracing was not active when macro <i>before<\/i> was defined, no call of this macro is protocolled; on the other hand, the macro <i>after<\/i> is fully protocolled.<\/p>\n<h2>PROBLEMS <a name=\"PROBLEMS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Because <b>trace.tmac<\/b> wraps the <b>.de<\/b> request (and its cousins), macro arguments are expanded one level more. This causes problems if an argument contains four backslashes or more to prevent too early expansion of the backslash. For example, this macro call<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">.foo \\\\n[bar]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">normally passes \u2018\\n[bar]\u2019 to macro \u2018.foo\u2019, but with the redefined <b>.de<\/b> request it passes \u2018n[bar]\u2019 instead.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The solution to this problem is to use groff\u2019s <b>E<\/b> escape which is an escape character not interpreted in copy mode, for example<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">.foo En[bar]<\/p>\n<h2>FILES <a name=\"FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>trace<\/i> macros are kept in the file <b>trace.tmac<\/b> located in the <i>tmac directory<\/i>; see <b>groff_tmac<\/b>(5) for details.<\/p>\n<h2>ENVIRONMENT <a name=\"ENVIRONMENT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>GROFF_TMAC_PATH<\/i><\/p>\n<p style=\"margin-left:22%;\">A colon-separated list of additional tmac directories in which to search for macro files; see <b>groff_tmac<\/b>(5) for details.<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>trace<\/i> macro packages was written by James Clark. This document was written by <a href=\"mailto:groff-bernd.warken-72@web.de\">Bernd Warken<\/a>.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Groff: The GNU Implementation of troff<\/i>, by Trent A. Fisher and Werner Lemberg, is the primary <i>groff<\/i> manual. You can browse it interactively with \u201cinfo groff\u201d. <b><br \/> groff<\/b>(1)<\/p>\n<p style=\"margin-left:22%;\">An overview of the groff system.<\/p>\n<p style=\"margin-left:11%;\"><b>troff<\/b>(1)<\/p>\n<p style=\"margin-left:22%;\">For details on option <b>\u2212m<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>groffer<\/b>(1)<\/p>\n<p style=\"margin-left:22%;\">A viewer program for all kinds of roff documents.<\/p>\n<p style=\"margin-left:11%;\"><b>groff_tmac<\/b>(5)<\/p>\n<p style=\"margin-left:22%;\">A general description of groff macro packages.<\/p>\n<p style=\"margin-left:11%;\"><b>groff<\/b>(7)<\/p>\n<p style=\"margin-left:22%;\">A short reference for the groff formatting language.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  groff_trace \u2212 groff macro package trace.tmac <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[971],"tags":[973,1086,972],"class_list":["post-3998","post","type-post","status-publish","format-standard","hentry","category-7-miscelanea","tag-973","tag-groff_trace","tag-man7"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3998"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3998\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}