| www.delorie.com/gnu/docs/gdb/gdbint_22.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The functions described below produce output for the actual data items, or fields, which contain information about the object.
Choose the appropriate function accordingly to your particular needs.
printf-like format string. The optional argument fldname
supplies the name of the field. The data items themselves are
supplied as additional arguments after format.
This generic function should be used only when it is not possible to use one of the specialized versions (see below).
int variable. It uses the
"%d" output conversion specification. fldname specifies
the name of the field.
"%s" conversion
specification.
Sometimes, there's a need to compose your output piece by piece using
functions that operate on a stream, such as value_print or
fprintf_symbol_filtered. These functions accept an argument of
the type struct ui_file *, a pointer to a ui_file object
used to store the data stream used for the output. When you use one
of these functions, you need a way to pass their results stored in a
ui_file object to the ui_out functions. To this end,
you first create a ui_stream object by calling
ui_out_stream_new, pass the stream member of that
ui_stream object to value_print and similar functions,
and finally call ui_out_field_stream to output the field you
constructed. When the ui_stream object is no longer needed,
you should destroy it and free its memory by calling
ui_out_stream_delete.
ui_stream object which uses the
same output methods as the ui_out object whose pointer is
passed in uiout. It returns a pointer to the newly created
ui_stream object.
ui_stream object specified by
streambuf.
streambuf->stream and outputs it like
ui_out_field_string does. After a call to
ui_out_field_stream, the accumulated data no longer exists, but
the stream is still valid and may be used for producing more fields.
Important: If there is any chance that your code could bail
out before completing output generation and reaching the point where
ui_out_stream_delete is called, it is necessary to set up a
cleanup, to avoid leaking memory and other resources. Here's a
skeleton code to do that:
struct ui_stream *mybuf = ui_out_stream_new (uiout); struct cleanup *old = make_cleanup (ui_out_stream_delete, mybuf); ... do_cleanups (old); |
If the function already has the old cleanup chain set (for other kinds of cleanups), you just have to add your cleanup to it:
mybuf = ui_out_stream_new (uiout); make_cleanup (ui_out_stream_delete, mybuf); |
Note that with cleanups in place, you should not call
ui_out_stream_delete directly, or you would attempt to free the
same buffer twice.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |