curs_trace(3X)
β¨ curs_trace β the ncurses debugging girlies β¨
okay bestie, gather round, because today we're talking about the curses_trace family from curs_trace(3X) β the whole little squad is: curses_trace, trace, _tracef, _traceattr, _traceattr2, _tracecchar_t, _tracecchar_t2, _tracechar, _tracechtype, _tracechtype2, _nc_tracebits, _tracedump, _tracemouse. that's the curses debugging routines lineup. π
πΈ SYNOPSIS πΈ
#include <curses.h>
unsigned curses_trace(const unsigned trace-mask);
void _tracef(const char *format, ...);
char *_traceattr(attr_t attr);
char *_traceattr2(int buffer, chtype ch);
char *_tracecchar_t(const cchar_t *string);
char *_tracecchar_t2(int buffer, const cchar_t *string);
char *_tracechar(int c);
char *_tracechtype(chtype ch);
char *_tracechtype2(int buffer, chtype ch);
void _tracedump(const char *label, WINDOW *win);
char *_nc_tracebits(void);
char *_tracemouse(const MEVENT *event);
/* deprecated */
void trace(const unsigned int trace-mask);
π¦ DESCRIPTION π¦
so these curses trace routines exist for debugging the ncurses libraries, and also for debugging applications that use ncurses. it's giving backstage pass energy. but bestie, there are limitations, and we respect them:
- aside from
curses_trace, the other functions are normally only available with the debugging library, e.g.libncurses_g.a.
all of the trace functions may be compiled into any model (shared, static, profile) by defining the symbol TRACE. iconic.
- additionally, the functions which use
cchar_tare only available with the wide-character configuration of the libraries. no wide chars, no vibes. π
π Functions π
the principal parts of this interface are literally just two:
curses_trace, which selectively enables different tracing features, and_tracef, which writes formatted data to the trace file.
the other functions either return a pointer to a string-area (allocated by the corresponding function), or return no value at all β like _tracedump, which implements the screen dump for TRACE_UPDATE.
the caller should NOT free these strings, because the allocation is reused on successive calls. so hands off, bestie. π«Ά
and to work around the whole "only one string-area per function" situation, some of them take a buffer-number parameter, which tells the library to allocate additional string-areas. slay, honestly.
now: the curses_trace function is always available, whether or not the other trace functions are available:
- if tracing is available, calling
curses_tracewith a nonzero parameter updates the trace mask, and returns the previous trace mask.
when the trace mask is nonzero, ncurses creates the file trace in the current directory for output. if the file already exists, no tracing is done. periodt.
- if tracing is not available,
curses_tracereturns zero (0). sad girl hours.
π Trace Parameter π
the trace parameter is formed by logically "or"-ing values from the list of TRACE_xxx definitions in <curses.h>. these include:
TRACE_DISABLEβ turn off tracing by passing a zero parameter.
the library flushes the output file, but retains an open file-descriptor to the trace file so that it can resume tracing later if a nonzero parameter is passed to the curses_trace function. she's keeping the door open, iykyk.
TRACE_TIMESβ trace user and system times of updates.TRACE_TPUTSβ tracetputs(3X)calls.TRACE_UPDATEβ trace update actions, old & new screens.TRACE_MOVEβ trace cursor movement and scrolling.TRACE_CHARPUTβ trace all character outputs.TRACE_ORDINARYβ trace all update actions. the old and new screen contents are written to the trace file for each refresh.TRACE_CALLSβ trace all curses calls. the parameters for each call are traced, as well as return values.TRACE_VIRTPUTβ trace virtual character puts, i.e., calls toaddch.TRACE_IEVENTβ trace low-level input processing, including timeouts.TRACE_BITSβ trace state of TTY control bits.TRACE_ICALLSβ trace internal/nested calls.TRACE_CCALLSβ trace per-character calls.TRACE_DATABASEβ trace read/write ofterminfo/termcapdata.TRACE_ATTRSβ trace changes to video attributes and colors.TRACE_MAXIMUMβ maximum trace level, enables all of the separate trace features. the full send. π
some tracing features are enabled whenever the curses_trace parameter is nonzero. some features overlap. the specific names are used as a guideline β it's giving "close enough" but make it library design.
π Command-line Utilities π
the command-line utilities such as tic(1) provide a verbose option which extends the set of messages written using the curses_trace function. both of these (-v and curses_trace) use the same variable (_nc_tracing), which determines the messages which are written. shared brain cell energy.
because the command-line utilities may call initialization functions such as setupterm, tgetent or use_extended_names, some of their debugging output may be directed to the trace file if the NCURSES_TRACE environment variable is set:
- messages produced in the utility are written to the standard error.
- messages produced by the underlying library are written to
trace.
if ncurses is built without tracing, none of the latter are produced, and fewer diagnostics are provided by the command-line utilities. π
π RETURN VALUE π
routines which return a value are designed to be used as parameters to the _tracef routine. that's the whole assignment bestie.
π ENVIRONMENT π
NCURSES_TRACE
a positive integral value stored in this variable causes the following functions to enable the tracing feature as if curses_trace were called:
filter, initscr, new_prescr, newterm, nofilter, restartterm,
ripoffline, setupterm, slk_init, tgetent, use_env,
use_extended_names, use_tioctl
π PORTABILITY π
these functions are not part of the X/Open Curses interface. some other curses implementations are known to have similar features, but they are not compatible with ncurses:
- SVr4 provided
traceonandtraceoff, to control whether debugging information was written to thetracefile. while the functions were always available, this feature was only enabled ifDEBUGwas defined when building the library.
the SVr4 tracing feature is undocumented. π
- PDCurses provides
traceonandtraceoff, which (like SVr4) are always available, and enable tracing to thetracefile only when a debug-library is built.
PDCurses has a short description of these functions, with a note that they are not present in X/Open Curses, ncurses or NetBSD. it does not mention SVr4, but the functions' inclusion in a header file section labeled Quasi-standard hints at the origin. the archaeology of it all.
- NetBSD does not provide functions for enabling/disabling traces. it uses environment variables
CURSES_TRACE_MASKandCURSES_TRACE_FILEto determine what is traced, and where the results are written. this is available only when a debug-library is built.
the NetBSD tracing feature is undocumented.
a few ncurses functions are not provided when symbol versioning is used:
_nc_tracebits, _tracedump, _tracemouse
the original trace routine was deprecated because it often conflicted with application names. rest in peace queen, you were too real for this namespace. π
β SEE ALSO β
curses(3X)
and that's the whole page, bestie β no cap. this was the curs_trace(3X) man page from ncurses 6.6, dated 2025-01-18, and you absolutely ate it. go enable TRACE_MAXIMUM and watch the trace file pop off. mwah π π«Άβ¨
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2019-2024,2025 Thomas E. Dickey
- Copyright 2000-2016,2017 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms