]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_trace.3x
ncurses 6.4 - patch 20230923
[ncurses.git] / man / curs_trace.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 2000-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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 .\"
30 .\" $Id: curs_trace.3x,v 1.37 2023/09/23 20:53:33 tom Exp $
31 .TH curs_trace 3X 2023-09-23 "ncurses 6.4" "Library calls"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fB\%curses_trace\fP,
42 \fB\%trace\fP,
43 \fB\%_tracef\fP,
44 \fB\%_traceattr\fP,
45 \fB\%_traceattr2\fP,
46 \fB\%_tracecchar_t\fP,
47 \fB\%_tracecchar_t2\fP,
48 \fB\%_tracechar\fP,
49 \fB\%_tracechtype\fP,
50 \fB\%_tracechtype2\fP,
51 \fB\%_nc_tracebits\fP,
52 \fB\%_tracedump\fP,
53 \fB\%_tracemouse\fP \-
54 \fIcurses\fR debugging routines
55 .SH SYNOPSIS
56 .nf
57 \fB#include <curses.h>\fP
58 .PP
59 \fBunsigned curses_trace(const unsigned \fIparam\fB);\fR
60 .PP
61 \fBvoid _tracef(const char *\fIformat\fB, ...);\fR
62 .PP
63 \fBchar *_traceattr(attr_t \fIattr\fB);\fR
64 \fBchar *_traceattr2(int \fIbuffer\fB, chtype \fIch\fB);\fR
65 \fBchar *_tracecchar_t(const cchar_t *\fIstring\fB);\fR
66 \fBchar *_tracecchar_t2(int \fIbuffer\fB, const cchar_t *\fIstring\fB);\fR
67 \fBchar *_tracechar(int \fIch\fB);\fR
68 \fBchar *_tracechtype(chtype \fIch\fB);\fR
69 \fBchar *_tracechtype2(int \fIbuffer\fB, chtype \fIch\fB);\fR
70 .PP
71 \fBvoid _tracedump(const char *\fIlabel\fB, WINDOW *\fIwin\fB);\fR
72 \fBchar *_nc_tracebits(void);\fP
73 \fBchar *_tracemouse(const MEVENT *\fIevent\fB);\fR
74 .PP
75 /* deprecated */
76 \fBvoid trace(const unsigned int \fIparam\fB);\fR
77 .fi
78 .SH DESCRIPTION
79 The \fIcurses trace\fP routines are used for debugging the ncurses libraries,
80 as well as applications which use the ncurses libraries.
81 Some limitations apply:
82 .bP
83 Aside from \fBcurses_trace\fP,
84 the other functions are normally available only with the debugging library
85 e.g., \fBlibncurses_g.a\fP.
86 .IP
87 All of the trace functions may be compiled into any model (shared, static,
88 profile) by defining the symbol \fBTRACE\fP.
89 .bP
90 Additionally, the functions which use \fBcchar_t\fP
91 are only available with the wide-character configuration of the libraries.
92 .SS Functions
93 The principal parts of this interface are
94 .bP
95 \fBcurses_trace\fP, which selectively enables different tracing features, and
96 .bP
97 \fB_tracef\fP, which writes formatted data to the \fItrace\fP file.
98 .IP
99 The other functions either return a pointer to a string-area
100 (allocated by the corresponding function), or return no value
101 (such as \fB_tracedump\fP,
102 which implements the screen dump for \fBTRACE_UPDATE\fP).
103 The caller should not free these strings,
104 since the allocation is reused on successive calls.
105 To work around the problem of a single string-area per function,
106 some use a buffer-number parameter, telling the library to allocate
107 additional string-areas.
108 .PP
109 The \fBcurses_trace\fP function is always available,
110 whether or not the other trace functions are available:
111 .bP
112 If tracing is available,
113 calling \fBcurses_trace\fP with a nonzero parameter
114 updates the trace mask,
115 and returns the previous trace mask.
116 .IP
117 When the trace mask is nonzero,
118 ncurses creates the file \*(``trace\*('' in the current directory for output.
119 If the file already exists, no tracing is done.
120 .bP
121 If tracing is not available, \fBcurses_trace\fP returns zero (0).
122 .SS Trace Parameter
123 The trace parameter is formed by OR'ing
124 values from the list of \fBTRACE_\fIxxx\fR definitions in \fB<curses.h>\fR.
125 These include:
126 .TP 5
127 .B TRACE_DISABLE
128 turn off tracing by passing a zero parameter.
129 .IP
130 The library flushes the output file,
131 but retains an open file-descriptor to the trace file
132 so that it can resume tracing later if a nonzero parameter is passed
133 to the \fBcurses_trace\fP function.
134 .TP 5
135 .B TRACE_TIMES
136 trace user and system times of updates.
137 .TP 5
138 .B TRACE_TPUTS
139 trace \fBtputs\fP(3X) calls.
140 .TP 5
141 .B TRACE_UPDATE
142 trace update actions, old & new screens.
143 .TP 5
144 .B TRACE_MOVE
145 trace cursor movement and scrolling.
146 .TP 5
147 .B TRACE_CHARPUT
148 trace all character outputs.
149 .TP 5
150 .B TRACE_ORDINARY
151 trace all update actions.
152 The old and new screen contents are written to the trace file
153 for each refresh.
154 .TP 5
155 .B TRACE_CALLS
156 trace all curses calls.
157 The parameters for each call are traced, as well as return values.
158 .TP 5
159 .B TRACE_VIRTPUT
160 trace virtual character puts, i.e., calls to \fBaddch\fP.
161 .TP 5
162 .B TRACE_IEVENT
163 trace low-level input processing, including timeouts.
164 .TP 5
165 .B TRACE_BITS
166 trace state of TTY control bits.
167 .TP 5
168 .B TRACE_ICALLS
169 trace internal/nested calls.
170 .TP 5
171 .B TRACE_CCALLS
172 trace per-character calls.
173 .TP 5
174 .B TRACE_DATABASE
175 trace read/write of terminfo/termcap data.
176 .TP 5
177 .B TRACE_ATTRS
178 trace changes to video attributes and colors.
179 .TP 5
180 .B TRACE_MAXIMUM
181 maximum trace level, enables all of the separate trace features.
182 .PP
183 Some tracing features are enabled whenever the \fBcurses_trace\fP parameter
184 is nonzero.
185 Some features overlap.
186 The specific names are used as a guideline.
187 .SS Initialization
188 These functions check the \fBNCURSES_TRACE\fP environment variable,
189 to set the tracing feature as if \fBcurses_trace\fP was called:
190 .RS 4
191 .PP
192 filter,
193 initscr,
194 new_prescr,
195 newterm,
196 nofilter,
197 restartterm,
198 ripoffline,
199 setupterm,
200 slk_init,
201 tgetent,
202 use_env,
203 use_extended_names,
204 use_tioctl
205 .RE
206 .SS Command-line Utilities
207 The command-line utilities such as \fBtic\fP(1) provide a verbose option
208 which extends the set of messages written using the \fBcurses_trace\fP function.
209 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
210 use the same variable (\fB_nc_tracing\fP),
211 which determines the messages which are written.
212 .PP
213 Because the command-line utilities may call initialization functions
214 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
215 some of their debugging output may be directed to the \fItrace\fP file
216 if the \fBNCURSES_TRACE\fP environment variable is set:
217 .bP
218 messages produced in the utility are written to the standard error.
219 .bP
220 messages produced by the underlying library are written to \fItrace\fP.
221 .PP
222 If ncurses is built without tracing, none of the latter are produced,
223 and fewer diagnostics are provided by the command-line utilities.
224 .SH RETURN VALUE
225 Routines which return a value are designed to be used as parameters
226 to the \fB_tracef\fP routine.
227 .SH PORTABILITY
228 These functions are not part of the XSI interface.
229 Some other curses implementations are known to
230 have similar features,
231 but they are not compatible with ncurses:
232 .bP
233 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
234 to control whether debugging information was written
235 to the \*(``trace\*('' file.
236 While the functions were always available,
237 this feature was only enabled
238 if \fBDEBUG\fP was defined when building the library.
239 .IP
240 The SVr4 tracing feature is undocumented.
241 .bP
242 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
243 which (like SVr4) are always available,
244 and enable tracing
245 to the \*(``trace\*('' file
246 only when a debug-library is built.
247 .IP
248 PDCurses has a short description of these functions,
249 with a note that they are not present in X/Open Curses,
250 ncurses or NetBSD.
251 It does not mention SVr4,
252 but the functions' inclusion in a header file section
253 labeled \*(``Quasi-standard\*('' hints at the origin.
254 .bP
255 NetBSD does not provide functions for enabling/disabling traces.
256 It uses environment variables
257 \fBCURSES_TRACE_MASK\fP and
258 \fBCURSES_TRACE_FILE\fP to determine what is traced,
259 and where the results are written.
260 This is available only when a debug-library is built.
261 .IP
262 The NetBSD tracing feature is undocumented.
263 .PP
264 A few ncurses functions are not provided when symbol versioning is used:
265 .RS 4
266 .PP
267 _nc_tracebits,
268 _tracedump,
269 _tracemouse
270 .RE
271 .PP
272 The original \fBtrace\fP routine was deprecated because
273 it often conflicted with application names.
274 .SH SEE ALSO
275 \fBcurses\fP(3X).