blob: ddae7911254160565f7c286adde7bdc6b1657454 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2019-2023,2024 Thomas E. Dickey *
3.\" Copyright 2000-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
5.\" Permission is hereby granted, free of charge, to any person obtaining a *
6.\" copy of this software and associated documentation files (the *
7.\" "Software"), to deal in the Software without restriction, including *
8.\" without limitation the rights to use, copy, modify, merge, publish, *
9.\" distribute, distribute with modifications, sublicense, and/or sell *
10.\" copies of the Software, and to permit persons to whom the Software is *
11.\" furnished to do so, subject to the following conditions: *
12.\" *
13.\" The above copyright notice and this permission notice shall be included *
14.\" in all copies or substantial portions of the Software. *
15.\" *
16.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23.\" *
24.\" Except as contained in this notice, the name(s) of the above copyright *
25.\" holders shall not be used in advertising or otherwise to promote the *
26.\" sale, use or other dealings in this Software without prior written *
27.\" authorization. *
28.\"***************************************************************************
29.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_trace.3x,v 1.50 2024/04/20 21:24:19 tom Exp $
31.TH curs_trace 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32.ie \n(.g \{\
33.ds `` \(lq
34.ds '' \(rq
35.\}
36.el \{\
37.ie t .ds `` ``
38.el .ds `` ""
39.ie t .ds '' ''
40.el .ds '' ""
41.\}
42.
Steve Kondikae271bc2015-11-15 02:50:53 +010043.de bP
micky3879b9f5e72025-07-08 18:04:53 -040044.ie n .IP \(bu 4
45.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010046..
micky3879b9f5e72025-07-08 18:04:53 -040047.
48.de dS \" Start unfilled display.
49.nr aD \n(.j
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053050.na
micky3879b9f5e72025-07-08 18:04:53 -040051..
52.
53.de dE \" End unfilled display.
54.ad \n(.j
55.rr aD
56..
57.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040059\fB\%curses_trace\fP,
60\fB\%trace\fP,
61\fB\%_tracef\fP,
62\fB\%_traceattr\fP,
63\fB\%_traceattr2\fP,
64\fB\%_tracecchar_t\fP,
65\fB\%_tracecchar_t2\fP,
66\fB\%_tracechar\fP,
67\fB\%_tracechtype\fP,
68\fB\%_tracechtype2\fP,
69\fB\%_nc_tracebits\fP,
70\fB\%_tracedump\fP,
71\fB\%_tracemouse\fP \-
72\fIcurses\fR debugging routines
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053073.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040074.nf
75\fB#include <curses.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053076.PP
micky3879b9f5e72025-07-08 18:04:53 -040077\fBunsigned curses_trace(const unsigned \fItrace-mask\fP);
78.PP
79\fBvoid _tracef(const char *\fIformat\fP, ...);
80.PP
81\fBchar *_traceattr(attr_t \fIattr\fP);
82\fBchar *_traceattr2(int \fIbuffer\fP, chtype \fIch\fP);
83\fBchar *_tracecchar_t(const cchar_t *\fIstring\fP);
84\fBchar *_tracecchar_t2(int \fIbuffer\fP, const cchar_t *\fIstring\fP);
85\fBchar *_tracechar(int \fIc\fP);
86\fBchar *_tracechtype(chtype \fIch\fP);
87\fBchar *_tracechtype2(int \fIbuffer\fP, chtype \fIch\fP);
88.PP
89\fBvoid _tracedump(const char *\fIlabel\fP, WINDOW *\fIwin\fP);
90\fBchar *_nc_tracebits(void);
91\fBchar *_tracemouse(const MEVENT *\fIevent\fP);
92.PP
93\fI/* deprecated */\fP
94\fBvoid trace(const unsigned int \fItrace-mask\fP);
95.fi
96.SH DESCRIPTION
97The \fIcurses trace\fP routines are used for debugging the
98\fI\%ncurses\fP libraries,
99as well as applications which use the \fI\%ncurses\fP libraries.
100Some limitations apply:
101.bP
102Aside from \fBcurses_trace\fP,
103the other functions are normally available only with the debugging library
104e.g., \fBlibncurses_g.a\fP.
105.IP
106All of the trace functions may be compiled into any model (shared, static,
107profile) by defining the symbol \fBTRACE\fP.
108.bP
109Additionally, the functions which use \fBcchar_t\fP
110are only available with the wide-character configuration of the libraries.
111.SS Functions
Steve Kondikae271bc2015-11-15 02:50:53 +0100112The principal parts of this interface are
113.bP
micky3879b9f5e72025-07-08 18:04:53 -0400114\fBcurses_trace\fP, which selectively enables different tracing features, and
Steve Kondikae271bc2015-11-15 02:50:53 +0100115.bP
micky3879b9f5e72025-07-08 18:04:53 -0400116\fB_tracef\fP, which writes formatted data to the \fItrace\fP file.
117.IP
118The other functions either return a pointer to a string-area
119(allocated by the corresponding function), or return no value
120(such as \fB_tracedump\fP,
121which implements the screen dump for \fBTRACE_UPDATE\fP).
122The caller should not free these strings,
123since the allocation is reused on successive calls.
124To work around the problem of a single string-area per function,
125some use a buffer-number parameter, telling the library to allocate
126additional string-areas.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530127.PP
micky3879b9f5e72025-07-08 18:04:53 -0400128The \fBcurses_trace\fP function is always available,
129whether or not the other trace functions are available:
130.bP
131If tracing is available,
132calling \fBcurses_trace\fP with a nonzero parameter
133updates the trace mask,
134and returns the previous trace mask.
135.IP
136When the trace mask is nonzero,
137\fI\%ncurses\fP creates the file \*(``trace\*('' in the current directory for output.
138If the file already exists, no tracing is done.
139.bP
140If tracing is not available, \fBcurses_trace\fP returns zero (0).
141.SS "Trace Parameter"
142The trace parameter is formed by OR'ing
143values from the list of \fBTRACE_\fIxxx\fR definitions in \fB<curses.h>\fR.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530144These include:
145.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100146.B TRACE_DISABLE
micky3879b9f5e72025-07-08 18:04:53 -0400147turn off tracing by passing a zero parameter.
148.IP
149The library flushes the output file,
150but retains an open file-descriptor to the trace file
151so that it can resume tracing later if a nonzero parameter is passed
152to the \fBcurses_trace\fP function.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530153.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100154.B TRACE_TIMES
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155trace user and system times of updates.
156.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100157.B TRACE_TPUTS
micky3879b9f5e72025-07-08 18:04:53 -0400158trace \fBtputs\fP(3X) calls.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530159.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100160.B TRACE_UPDATE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530161trace update actions, old & new screens.
162.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100163.B TRACE_MOVE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530164trace cursor movement and scrolling.
165.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100166.B TRACE_CHARPUT
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530167trace all character outputs.
168.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100169.B TRACE_ORDINARY
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530170trace all update actions.
171The old and new screen contents are written to the trace file
172for each refresh.
173.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100174.B TRACE_CALLS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530175trace all curses calls.
176The parameters for each call are traced, as well as return values.
177.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100178.B TRACE_VIRTPUT
micky3879b9f5e72025-07-08 18:04:53 -0400179trace virtual character puts, i.e., calls to \fBaddch\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530180.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100181.B TRACE_IEVENT
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530182trace low-level input processing, including timeouts.
183.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100184.B TRACE_BITS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530185trace state of TTY control bits.
186.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100187.B TRACE_ICALLS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530188trace internal/nested calls.
189.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100190.B TRACE_CCALLS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530191trace per-character calls.
192.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100193.B TRACE_DATABASE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530194trace read/write of terminfo/termcap data.
195.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100196.B TRACE_ATTRS
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530197trace changes to video attributes and colors.
198.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100199.B TRACE_MAXIMUM
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530200maximum trace level, enables all of the separate trace features.
201.PP
micky3879b9f5e72025-07-08 18:04:53 -0400202Some tracing features are enabled whenever the \fBcurses_trace\fP parameter
Steve Kondikae271bc2015-11-15 02:50:53 +0100203is nonzero.
204Some features overlap.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530205The specific names are used as a guideline.
micky3879b9f5e72025-07-08 18:04:53 -0400206.SS "Command-line Utilities"
207The command-line utilities such as \fBtic\fP(1) provide a verbose option
208which extends the set of messages written using the \fBcurses_trace\fP function.
209Both of these (\fB\-v\fP and \fBcurses_trace\fP)
210use the same variable (\fB_nc_tracing\fP),
211which determines the messages which are written.
Steve Kondikae271bc2015-11-15 02:50:53 +0100212.PP
micky3879b9f5e72025-07-08 18:04:53 -0400213Because the command-line utilities may call initialization functions
214such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
215some of their debugging output may be directed to the \fItrace\fP file
216if the \fI\%NCURSES_TRACE\fP environment variable is set:
217.bP
218messages produced in the utility are written to the standard error.
219.bP
220messages produced by the underlying library are written to \fItrace\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100221.PP
micky3879b9f5e72025-07-08 18:04:53 -0400222If \fI\%ncurses\fP is built without tracing,
223none of the latter are produced,
224and fewer diagnostics are provided by the command-line utilities.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530225.SH RETURN VALUE
226Routines which return a value are designed to be used as parameters
micky3879b9f5e72025-07-08 18:04:53 -0400227to the \fB_tracef\fP routine.
228.SH ENVIRONMENT
229.SS NCURSES_TRACE
230A positive integral value stored in this variable causes the following
231functions to enable the tracing feature as if
232.B \%curses_trace
233were called.
234.PP
235.dS
236.RS 4
237\fB\%filter\fP,
238\fB\%initscr\fP,
239\fB\%new_prescr\fP,
240\fB\%newterm\fP,
241\fB\%nofilter\fP,
242\fB\%restartterm\fP,
243\fB\%ripoffline\fP,
244\fB\%setupterm\fP,
245\fB\%slk_init\fP,
246\fB\%tgetent\fP,
247\fB\%use_env\fP,
248\fB\%use_extended_names\fP,
249\fB\%use_tioctl\fP
250.RE
251.dE
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530252.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400253These functions are not part of the X/Open Curses interface.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530254Some other curses implementations are known to
micky3879b9f5e72025-07-08 18:04:53 -0400255have similar features,
256but they are not compatible with \fI\%ncurses\fP:
257.bP
258SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
259to control whether debugging information was written
260to the \*(``trace\*('' file.
261While the functions were always available,
262this feature was only enabled
263if \fBDEBUG\fP was defined when building the library.
264.IP
265The SVr4 tracing feature is undocumented.
266.bP
267PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
268which (like SVr4) are always available,
269and enable tracing
270to the \*(``trace\*('' file
271only when a debug-library is built.
272.IP
273PDCurses has a short description of these functions,
274with a note that they are not present in X/Open Curses,
275\fI\%ncurses\fP or NetBSD.
276It does not mention SVr4,
277but the functions' inclusion in a header file section
278labeled \*(``Quasi-standard\*('' hints at the origin.
279.bP
280NetBSD does not provide functions for enabling/disabling traces.
281It uses environment variables
282\fI\%CURSES_TRACE_MASK\fP and
283\fI\%CURSES_TRACE_FILE\fP to determine what is traced,
284and where the results are written.
285This is available only when a debug-library is built.
286.IP
287The NetBSD tracing feature is undocumented.
288.PP
289A few \fI\%ncurses\fP functions are not provided when symbol versioning
290is used:
291.RS 4
292.PP
293_nc_tracebits,
294_tracedump,
295_tracemouse
296.RE
297.PP
298The original \fBtrace\fP routine was deprecated because
299it often conflicted with application names.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530300.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400301\fB\%curses\fP(3X)