GDB has several user interfaces. Although the command-line interface is the most common and most familiar, there are others.
GDB´Â ¸î¸î »ç¿ëÀÚ ÀÎÅÍÆäÀ̽º¸¦ °¡Áö°í ÀÖ´Ù. ºñ·Ï ¸í·É¾î ¶óÀÎ ÀÎÅÍÆäÀ̽º°¡ °¡Àå ÀϹÝÀûÀÌ°í ´ëºÎºÐ Àͼ÷ÇÏ´Ù ÇÒÁö¶óµµ, ±×¿Ü ´Ù¸¥ °Íµéµµ ÀÖ´Ù.
The command interpreter in GDB is fairly simple. It is designed to allow for the set of commands to be augmented dynamically, and also has a recursive subcommand capability, where the first argument to a command may itself direct a lookup on a different command list.
GDB³» ¸í·É¾î Çؼ®±â´Â ²Ï °£´ÜÇÑ´Ù. ±×°ÍÀº µ¿ÀûÀ¸·Î ÀÎÀÚµéÀ» ¸í·É¾î ÁýÇÕ¿¡ Çã¿ëÇϵµ·Ï µðÀÚÀεǾúÀ¸¸ç ¶ÇÇÑ ¸í·É¾î¿¡ ´ëÇÑ Ã¹ ÀÎÀÚ´Â ´Ù¸¥ ¸í·É¾î ¸®½ºÆ®¸¦ Á÷Á¢ ãÀ»¼ö ÀÖ´Â °¡´ÉÇÑ Àç±ÍÀûÀÎ ÇÏÀ§ ¸í·É¾î¸¦ °¡Áö°í ÀÖ´Ù.
For instance, the `set' command just starts a lookup on the
setlist
command list, while `set thread' recurses
to the set_thread_cmd_list
.
¿¹¸¦ µé¾î, `set' ¸í·É¾î´Â setlist
¸í·É¾î ¸®½ºÆ®¸¦ ã±â ½ÃÀÛÇϸç,
¹Ý¸é¿¡ `set thread'´Â set_thread_cmd_list
¸¦ Àç±ÍÀûÀ¸·Î ã±â ½ÃÀÛÇÑ´Ù.
To add commands in general, use add_cmd
. add_com
adds to
the main command list, and should be used for those commands. The usual
place to add commands is in the _initialize_xyz
routines at
the ends of most source files.
ÀϹÝÀûÀ¸·Î ¸í·É¾î¸¦ Ãß°¡Çϱâ À§ÇØ, add_cmd
¸¦ Ãß°¡Çضó. add_com
´Â
ÁÖ ¸í·É¾î ¸®½ºÆ®¿¡ Ãß°¡ÇÏ°í ÀÌµé ¸í·É¾î¸¦ À§ÇØ »ç¿ëµÇ¾î¾ß ÇÑ´Ù. ¸í·É¾î¸¦ Ãß°¡ÇÒ ½ÇÁ¦ À§Ä¡´Â
´ëºÎºÐÀÇ ¼Ò½º ÆÄÀÏ ³¡¿¡¼ _initialize_xyz
·çƾ ³»ÀÌ´Ù.
Before removing commands from the command set it is a good idea to
deprecate them for some time. Use deprecate_cmd
on commands or
aliases to set the deprecated flag. deprecate_cmd
takes a
struct cmd_list_element
as it's first argument. You can use the
return value from add_com
or add_cmd
to deprecate the
command immediately after it is created.
¸í·É¾î ÁýÇÕ¿¡¼ ¸í·É¾î¸¦ Á¦°ÅÇϱâ Àü¿¡ °¡²û ±×°ÍµéÀ» ´Ù½Ã »ý°¢ÇÏ´Â °ÍÀº ÁÁÀº »ý°¢ÀÌ´Ù.
¸í·É¾î¿¡¼ deprecate_cmd
¸¦ »ç¿ëÇϰųª deprecated flag ¼³Á¤À» ¾ó¶óÀ̽ÌÇؼ
»ç¿ëÇضó. deprecate_cmd
´Â ù ÀÎÀڷνá struct cmd_list_element
¸¦
°¡Á®¶ó. ¿©·¯ºÐÀº »ý¼ºµÈÈÄ Áï½Ã ¸í·É¾î¸¦ ´Ù½Ã »ý°¢ÇϱâÀ§ÇØ add_com
³ª add_cmd
¿¡¼ ¹Ýȯ °ªÀ» »ç¿ëÇÒ¼ö ÀÖ´Ù.
The first time a comamnd is used the user will be warned and offered a
replacement (if one exists). Note that the replacement string passed to
deprecate_cmd
should be the full name of the command, i.e. the
entire string the user should type at the command line.
¸í·É¾î°¡ »ç¿ëµÇ´Â ùÀ½¿¡ »ç¿ëÀÚ´Â °æ°íµÇ°í ´ëü(Á¸ÀçÇÑ´Ù¸é)¸¦ Á¦°øÇÑ´Ù.
deprecate_cmd
¿¡ Àü´ÞµÇ´Â ´ëü ¹®ÀÚ¿Àº ¸í·É¾îÀÇ ¿ÏÀüÇÑ À̸§À̾î¾ß ÇÑ´Ù.
Áï, ¸í·É¾î ¶óÀο¡¼ »ç¿ëÀÚ°¡ ŸÀÔÇؾßÇÏ´Â Àüü ¹®ÀÚ¿.
ui_out
Functionsui_out
ÇÔ¼ö
The ui_out
functions present an abstraction level for the
GDB output code. They hide the specifics of different user
interfaces supported by GDB, and thus free the programmer
from the need to write several versions of the same code, one each for
every UI, to produce output.
ui_out
ÇÔ¼ö´Â GDB Ãâ·Â Äڵ带 À§ÇØ Ãß»óÈ ´Ü°è¸¦ Á¦°øÇÑ´Ù.
GDB´Â GDB°¡ Áö¿øÇÏ´Â ¿©·¯°¡Áö »ç¿ëÀÚ ÀÎÅÍÆäÀ̽º¸¦ ¼û±â¸ç ¸ðµç UI ¸¶´Ù, Ãâ·ÂÀ» ¸¸µé±â À§ÇØ °°Àº ÄÚµåÀÇ ¸î¸î ¹öÀüÀ» ¾µ ÇÊ¿ä°¡ ÀÖ´Â ÇÁ·Î±×·¡¸Ó¸¦ ÀÚÀ¯½º·´°Ô ÇÑ´Ù.
ui_out
In general, execution of each GDB command produces some sort of output, and can even generate an input request.
ÀϹÝÀûÀ¸·Î, °¢ GDB ¸í·É¾îÀÇ ½ÇÇàÀº ÀϺΠÁ¤·ÄµÈ Ãâ·ÂÀ» ¸¸µé¸ç ÀÔ·Â ¿ä±¸¸¦ ¸¸µé¼öµµ ÀÖ´Ù.
Output can be generated for the following purposes: Ãâ·ÂÀº ´ÙÀ½ ¸ñÀûÀ» À§ÇØ »ý¼ºµÉ¼ö ÀÖ´Ù:
ÀÛµ¿ÀÇ °á°ú¸¦ Ãâ·ÂÇϱâ À§ÇØ;
info¸¦ ¾Ë¸®°Å³ª ¿ä±¸µÈ ÀÛµ¿ÀÇ ¿ªÈ¿°ú¸¦ ¸¸µé±â À§ÇØ;
ºñµ¿±âÀû À̺¥Æ®(´Ã¾î³ ºñµ¿±â ÀÛµ¿ÀÇ ÁøÇà Áö½Ã¸¦ Æ÷ÇÔÇÏ¿©)ÀÇ ¾Ë¸²À» Á¦°øÇϱâ À§ÇØ;
¿¡·¯ ¸Þ¼¼Áöµé(°æ°í Æ÷ÇÔ)À» Ãâ·ÂÇϱâ À§ÇØ;
µ¥ÀÌŸ µð¹ö±×¸¦ º¸¿©ÁÖ±â À§ÇØ;
ÀÔ·Â(Ưº°ÇÑ °æ¿ì)À» À§ÇØ »ç¿ëÀÚ¸¦ ÁúÀÇÇϰųª ÇÁ·ÒÇÁÆ®Çϱâ À§ÇØ.
This section mainly concentrates on how to build result output, although some of it also applies to other kinds of output.
ÀÌ ¼½¼ÇÀº ºñ·Ï ÀϺΰ¡ ´Ù¸¥ Á¾·ùÀÇ Ãâ·Â¿¡ Àû¿ëµÈ´Ù ÇÒÁö¶óµµ, ÁÖ·Î °á°ú Ãâ·ÂÀ» ¸¸µå´Â ¹æ¹ý¿¡ ´ëÇØ ÁýÁßÇÑ´Ù.
Generation of output that displays the results of an operation involves one or more of the following:
ÀÛµ¿ÀÇ °á°ú¸¦ º¸¿©ÁÖ´Â Ãâ·Â »ý¼ºÀº ´ÙÀ½ÀÇ Çϳª ¶Ç´Â ±× ÀÌ»ó°ú °ü·ÃÀÌ ÀÖ´Ù;
½ÇÁ¦ µ¥ÀÌÅÍÀÇ Ãâ·Â
»ç¶÷ÀÌ ½±°Ô ÀÐÀ»¼ö ÀÖµµ·Ï Çϱâ À§ÇØ Àû´çÇÑ ÄÜ¼Ö Ãâ·Âó·³ Çü½ÄÈµÈ Ãâ·Â
¸Ó½Å ±â¹Ý Çü½Ä--GDB Ãâ·ÂÀ» Àд ÇÁ·Î±×·¥ÀÌ ½±°Ô ÆĽÌÇϵµ·Ï ÇÏ´Â ´õ °£°áÇÑ Çü½Ä
Ãâ·Â¿¡¼ Èï¹Ì·Î¿î ºÎºÐÀ» ½Äº°Çϱâ À§ÇØ GUI(GDBTK³ª Emacs°°Àº)¸¦ µµ¿ÍÁÖ´Â ¸ñÀûÀÇ ÁÖ¼®
The ui_out
routines take care of the first three aspects.
Annotations are provided by separate annotation routines. Note that
use of annotations for an interface between a GUI and GDB is
deprecated.
ui_out
·çƾÀº ù ¼¼ ºÎºÐÀ» ´Ù·é´Ù.
ÁÖ¼®Àº ºÐ¸®µÈ ÁÖ¼® ·çƾÀ¸·Î Á¦°øµÈ´Ù. GUI¿Í GDB »çÀÌÀÇ ÀÎÅÍÆäÀ̽º¸¦ À§ÇØ ÁÖ¼®À» »ç¿ëÇϴ°ÍÀº
°í·ÁÇؾßÇÒ ºÎºÐÀÌ´Ù.
Output can be in the form of a single item, which we call a field; a list of fields; or a table, which is a list of fields with a header. In a BNF-like form:
Ãâ·ÂÀº ´ÜÀÏ ¾ÆÀÌÅÛÀÇ Çü½Ä¿¡ ÀÖÀ»¼ö ÀÖÀ»¼ö ÀÖÀ¸¸ç, ¿ì¸®´Â field¸¦ È£ÃâÇÑ´Ù; ÇʵåÀÇ list; ¶Ç´Â Çì´õ¸¦ °¡Áö°í ÀÖ´Â ÇʵåÀÇ ¸®½ºÆ®ÀÎ table. BNF °°Àº Çü½ÄÀ¸·Î:
<field> ::= any single item of data kept by gdb ;; <list> ::= { <field> } ;; <table> ::= <header> { <list> } ;; <header> ::= { <column> } ;; <column> ::= <width> <alignment> <title> ;;
All ui_out
routines currently are of type void
, except
for ui_out_stream_new
which returns a pointer to the newly
created object.
ÇöÀç ¸ðµç ui_out
ÇÔ¼öµéÀº »õ·Î »ý¼ºµÈ ŸÀÔÀÇ °´Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦
¹ÝȯÇÏ´Â ui_out_stream_new
¸¦ Á¦¿ÜÇÏ°í´Â void
ŸÀÔÀÌ´Ù.
The first parameter is always the ui_out
vector object, a
pointer to a struct ui_out
.
óÀ½ ÀÎÀÚ´Â Ç×»ó ui_out
º¤ÅÍ °´Ã¼À̸ç, struct ui_out
¿¡ ´ëÇÑ
Æ÷ÀÎÅÍÀÌ´Ù.
The format parameter is like in printf
family of
functions. When it is present, there is usually also a variable list
of arguments used to satisfy the %
specifiers in the supplied
format.
format ÆĶó¹ÌÅÍ´Â printf
°è¿ÀÇ ÇÔ¼ö °°´Ù.
±×°ÍÀÌ Á¸ÀçÇϸé, Á¦°øµÈ Çü½Ä³» %
ÁöÁ¤ÀÚ¸¦ ¸¸Á·ÇÏ´Â °¡º¯ÀÎÀÚ ¸®½ºÆ®°¡ ÀÖ´Ù.
When a character string argument is not used in a ui_out
function call, a NULL
pointer has to be supplied instead.
¹®ÀÚ¿ ÀÎÀÚ°¡ ui_out
ÇÔ¼ö È£Ãâ½Ã »ç¿ëµÇÁö ¾Ê´Â´Ù¸é, NULL
Æ÷ÀÎÅÍ°¡
´ë½Å Á¦°øµÈ´Ù.
This section introduces ui_out
routines for building lists and
tables. The routines to output the actual data items (fields) are
presented in the next section.
ÀÌ ¼½¼ÇÀº ¸®½ºÆ®¿Í Å×ÀÌºí ºôµùÀ» À§ÇØ ui_out
·çƾÀ» ¼Ò°³ÇÑ´Ù.
½ÇÁ¦ µ¥ÀÌÅÍ ¾ÆÀÌÅÛ(Çʵå)¸¦ Ãâ·ÂÇÏ´Â ·çƾÀº ´ÙÀ½Àå¿¡ ÀÖ´Ù.
To recap: A list is a sequence of fields with information about an object; a table is a list of lists, each on a separate line, prefixed by a header line with the column titles.
Àç»ýÇϱâ À§ÇØ: list´Â °´Ã¼¿¡ °üÇÑ Á¤º¸¸¦ °¡Áö´Â ¿¬¼ÓÀûÀÎ fieldsÀÌ´Ù.; tableÀº ºÐ¸®µÈ ¶óÀδç Ä®·³ titles¸¦ °¡Áö´Â header ¶óÀο¡ ÀÇÇØ Á¢µÎ»ç¸¦ ºÙÀÎ ¸®½ºÆ®µéÀÇ ¸®½ºÆ®ÀÌ´Ù.
Use the table functions if your output is composed of a list of fields for several objects and the console output should have a header. Use this even when you are listing just one object but you still want the header.
¸¸ÀÏ Ãâ·ÂÀÌ ¸î¸î °´Ã¼¸¦ À§ÇÑ ÇÊµå ¸®½ºÆ®·Î ÀÌ·ç¾îÁ³´Ù¸é Å×À̺í ÇÔ¼ö¸¦ »ç¿ëÇضó. ±×¸®°í ÄÜ¼Ö Ãâ·ÂÀº Çì´õ¸¦ °¡Á®¾ß¸¸ ÇÑ´Ù. ¿©·¯ºÐÀÌ ´ÜÁö ÇϳªÀÇ °´Ã¼¸¦ ¸®½ºÆÃÇÒ¶§µµ ÀÌ°ÍÀ» »ç¿ëÇضó. ±×·¯³ª ¿©ÀüÈ÷ Çì´õ´Â ¿øÇÑ´Ù.
Use the list functions for the output of each object of a table or if your output consists of a single list of fields.
Å×ÀÌºí °¢ °´Ã¼ÀÇ Ãâ·ÂÀ» À§Çؼ³ª ¸¸ÀÏ Ãâ·ÂÀÌ ´ÜÀÏ ¸®½ºÆ® Çʵå·Î ÀÌ·ç¾î Á® ÀÖ´Ù¸é ¸®½ºÆ® ÇÔ¼ö¸¦ »ç¿ëÇضó.
You can nest a list into a table, but not the other way around.
±ÙóÀÇ ´Ù¸¥ ¹æ¹ýÀÌ ¾Æ´Ï¶ó ¸®½ºÆ®¸¦ Å×À̺í·Î ÁßøÇÒ¼ö ÀÖ´Ù.
Lists can also be nested: some of your fields may be lists or
tuples--{name,value}
pairs. The maximum
nesting level is currently 4.
list´Â ÁßøµÉ¼ö ÀÖ´Ù. ÇʵåÁß ÀϺδ ¸®½ºÆ®³ª tuplesÀÌ´Ù--
{name,value}
½Ö. ÃÖ´ë Áßø ·¹º§Àº ÇöÀç 4ÀÌ´Ù.
The overall structure of the table output code is something like this:
Å×À̺í Ãâ·Â ÄÚµåÀÇ Àüü ±¸Á¶´Â ´ÙÀ½°ú °°´Ù:
ui_out_table_begin ui_out_table_header ... ui_out_table_body ui_out_list_begin ui_out_field_* ... ui_out_list_end ... ui_out_table_end
Here's the description of table- and list-related ui_out
functions:
¿©±â¿¡ Å×À̺íÀÇ ±â¼ú°ú ui_out
ÇÔ¼ö °ü·Ã ¸®½ºÆ®°¡ ÀÖ´Ù.
ui_out_table_begin
marks the beginning of the
output of a table. It should always be called before any other
ui_out
function for a given table. nbrofcols is the
number of columns in the table, and tblid is an optional string
identifying the table. The string pointed to by tblid is copied
by the implementation of ui_out_table_begin
, so the application
can free the string if it was malloc
ed.
ÇÔ¼ö ui_out_table_begin
´Â Å×À̺í Ãâ·ÂÀÇ ½ÃÀÛÀ» Ç¥½ÃÇÑ´Ù.
ÁÖ¾îÁø ´Ù¸¥ Å×À̺íÀ» À§ÇØ ´Ù¸¥ ui_out
ÇÔ¼ö¸¦ È£ÃâÇϱ⿡ Àü¿¡
Ç×»ó È£ÃâµÇ¾î¾ß ÇÑ´Ù. nbrofcols´Â Å×ÀÌºí³» Ä®·³ÀÇ ¼öÀ̸ç,
tblid´Â Å×À̺íÀ» ½Äº°ÇÏ´Â ¼±ÅÃÀûÀÎ ¹®ÀÚ¿ÀÌ´Ù. tblid°¡ °¡¸®Å°´Â ¹®ÀÚ¿Àº ui_out_table_begin
¼öÇà½Ã º¹»çµÈ´Ù. ±×·¡¼ ÀÀ¿ë ÇÁ·Î±×·¥Àº ¸¸ÀÏ malloc
À̶ó¸é ¹®ÀÚ¿À» ÇØÁ¦ÇÑ´Ù.
The companion function ui_out_table_end
, described below, marks
the end of the table's output.
¾Æ·¡ ±â¼úÇÑ ½ÖÀÎ ÇÔ¼ö ui_out_table_end
´Â Å×À̺íÀÇ Ãâ·ÂÀÇ ³¡À»
Ç¥½ÃÇÑ´Ù.
ui_out_table_header
provides the header information for a
single table column. You call this function several times, one each
for every column of the table, after ui_out_table_begin
, but
before ui_out_table_body
.
ui_out_table_header
´Â ´ÜÀÏ Å×À̺í Ä®·³À» À§ÇÑ Çì´õ Á¤º¸¸¦ Á¦°øÇÑ´Ù.
¿©·¯ºÐÀº ui_out_table_begin
¿Í ui_out_table_body
»çÀÌ¿¡
Å×À̺íÀÇ ¸ðµç Ä®·³¿¡ Çѹø¾¿ ¿©·¯ºÐ ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.
The value of width gives the column width in characters. The
value of alignment is one of left
, center
, and
right
, and it specifies how to align the header: left-justify,
center, or right-justify it. colhdr points to a string that
specifies the column header; the implementation copies that string, so
column header strings in malloc
ed storage can be freed after
the call.
width °ªÀº ¹®ÀÚ³» Ä®·³ÀÇ ÆøÀ» ÁØ´Ù. alignment °ªÀº left
, center
, right
Áß ÇϳªÀ̸ç Çì´õ¸¦ Á¤·ÄÇÏ´Â
¹æ¹ýÀ» ÁöÁ¤ÇÑ´Ù.; left, center, rigth ¼±ÅÃ.
colhdr´Â Ä®·³ Çì´õ¸¦ ÁöÁ¤ÇÏ´Â ¹®ÀÚ¿¿¡ ´ëÇÑ Æ÷ÀÎÅÍÀÌ´Ù.;
¼öÇàÀº ¹®ÀÚ¿À» º¹»çÇϸç malloc
µÈ ½ºÅ丮Áö³» Ä®·³ Çì´õ ¹®ÀÚ¿Àº
È£ÃâµÚ ÇØÁ¦µÉ¼ö ÀÖ´Ù.
ÀÌ ÇÔ¼ö´Â Çì´õ Á¤º¸ÀÇ ³¡°ú Å×ÀÌºí ¹Ùµð Ãâ·ÂÀÇ ½ÃÀÛÀ» Ç¥½ÃÇÑ´Ù. ÀÌ ÇÔ¼ö´Â ¾î¶² µ¥ÀÌÅÍ Ãâ·ÂÀ» ÀÚüÀûÀ¸·Î ¸¸µéÁö ¾Ê´Â´Ù.; ±×°ÍÀº ¸®½ºÆ®¿Í ¾Æ·¡ ±â¼úÇÑ Çʵå Ãâ·Â ÇÔ¼ö°¡ ÇÑ´Ù.
ÀÌ ÇÔ¼ö´Â Å×À̺í Ãâ·ÂÀÇ ³¡À» ¾Ë·ÁÁØ´Ù. ÀÌ ÇÔ¼ö´Â Å×ÀÌºí ¹Ùµð°¡ ¸®½ºÆ®¿Í Çʵå Ãâ·Â ÇÔ¼ö¿¡ ÀÇÇØ ¸¸µé¾îÁøÈÄ È£ÃâµÇ¾î¾ß ÇÑ´Ù.
There should be exactly one call to ui_out_table_end
for each
call to ui_out_table_begin
, otherwise the ui_out
functions will signal an internal error.
ui_out_table_begin
È£Ãâ´ç ui_out_table_end
¸¦ Á¤È®È÷
Çѹø È£ÃâÇØ¾ß ÇÑ´Ù. ±×·¸Áö ¾ÊÀ¸¸é ui_out
ÇÔ¼ö´Â ³»ºÎ ¿¡·¯¸¦
¾Ë¸°´Ù.
The output of the lists that represent the table rows must follow the
call to ui_out_table_body
and precede the call to
ui_out_table_end
. You produce the lists by calling
ui_out_list_begin
and ui_out_list_end
, with suitable
calls to functions which actually output fields between them.
Å×À̺í Row¸¦ ³ªÅ³»´Â ¸®½ºÆ® Ãâ·ÂÀº ui_out_table_body
È£Ãâ ´ÙÀ½À̸ç
ui_out_table_end
È£Ãâ ÀüÀÌ´Ù.
¿©·¯ºÐÀº ÀÌ ÇÔ¼öµé »çÀÌÀÇ ½ÇÁ¦ Ãâ·Â ÇʵåÀÎ ÇÔ¼ö¸¦ ¾Ë¸Â°Ô È£ÃâÇÏ¿©,
ui_out_list_begin
¿Í ui_out_list_end
È£ÃâÇÏ¿© ¸®½ºÆ®¸¦ È£ÃâÇÒ¼ö ÀÖ´Ù.
malloc
ed storage can be
freed after the call.
ÀÌ ÇÔ¼ö´Â ½ÃÀÛ°ú ¸®½ºÆ® Ãâ·ÂÀ» Ç¥½ÃÇÑ´Ù.
lstid´Â ¸®½ºÆ®¸¦ ½Äº°ÇÏ´Â ¼±ÅÃÀûÀÎ ¹®ÀÚ¿¿¡ ´ëÇÑ Æ÷ÀÎÅÍÀÌ´Ù.;
ÀÌ°ÍÀº ¼öÇà½Ã º¹»çµÇ¸ç malloc
µÈ ½ºÅ丮Áö³» ¹®ÀÚ¿À» È£ÃâµÚ
ÇØÁ¦ÇÒ¼ö ÀÖ´Ù.
ui_out_list_end
for each call to
ui_out_list_begin
, otherwise an internal GDB error
will be signaled.
ÀÌ ÇÔ¼ö´Â ¸®½ºÆ® Ãâ·ÂÀÇ ³¡À» ¾Ë¸°´Ù. ui_out_list_begin
È£Ãâ´ç
ui_out_list_end
¸¦ Á¤È®È÷ Çѹø¸¸ È£ÃâÇØ¾ß ÇÑ´Ù. ±×·¸Áö ¾ÊÀ¸¸é
³»ºÎ GDB ¿¡·¯°¡ ³¯¾Æ¿Â´Ù.
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.
ÀÌ°ÍÀº °¡Àå ÀϹÝÀûÀÎ Ãâ·Â ÇÔ¼öÀÌ´Ù. ÀÌ ÇÔ¼ö´Â printf
°°Àº
Çü½Ä ¹®Àڿó·³, format³» Çü½ÄÈµÈ ÁöÁ¤¿¡ µû¶ó °¡º¯ ÀÎÀÚ ¸®½ºÆ®³»
µ¥ÀÌÅÍ Ç¥ÇöÀ» ¸¸µç´Ù. ¼±Åà ÀÎÀÚ fldname´Â ÇʵåÀÇ À̸§À» Á¦°øÇÑ´Ù.
µ¥ÀÌÅÍ ¾ÆÀÌÅÛÀº 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.
ÀÌ ÇÔ¼ö´Â int
º¯¼öÀÇ °ªÀ» Ãâ·ÂÇÑ´Ù.
"%d"
Ãâ·Â º¯È¯ ÁöÁ¤ÀÚ¸¦ »ç¿ëÇضó. fldname´Â ÇʵåÀÇ À̸§À» ÁöÁ¤ÇÑ´Ù.
ÀÌÇÔ¼ö´Â ÁÖ¼Ò¸¦ Ãâ·ÂÇÑ´Ù.
"%s"
conversion
specification.
ÀÌ ÇÔ¼ö´Â "%s"
º¯È¯ ÁöÁ¤ÀÚ¸¦»ç¿ëÇÏ¿© ¹®ÀÚ¿À» Ãâ·ÂÇÑ´Ù.
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
.
°¡²û, value_print
³ª fprintf_symbol_filtered
ó·³,
½ºÆ®¸²¿¡¼ ÀÛµ¿ÇÏ´Â ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© Á¶°¢´ÜÀ§·Î Ãâ·ÂÀ» ÀÌ·çµµ·Ï ÇÒ ÇÊ¿ä°¡
ÀÖ´Ù. À̵é ÇÔ¼ö´Â struct ui_file *
ŸÀÔÀÇ ÀÎÀÚ¿Í Ãâ·Â½Ã »ç¿ëÇÏ´Â
µ¥ÀÌÅÍ ½ºÆ®¸²À» ÀúÀåÇϱâ À§ÇÑ ui_file
°´Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦
¹Þ´Â´Ù.
À̵é ÇÔ¼öµéÁß Çϳª¸¦ »ç¿ëÇÒ¶§, ¿©·¯ºÐÀº ui_file
°´Ã¼¿¡ ÀúÀåµÈ
°á°ú¸¦ ui_out
ÇÔ¼ö¿¡ Àü´ÞÇϱâ À§ÇÑ ¹æ¹ýÀÌ ÇÊ¿äÇÏ´Ù.
ÀÌ·¯ÇÑ ¸ñÀûÀ» À§ÇØ, ¿©·¯ºÐÀº ¿ì¼± ui_out_stream_new
¸¦ È£ÃâÇÏ¿©
ui_stream
°´Ã¼¸¦ ¸¸µé°í, ui_stream
°´Ã¼ÀÇ
stream
¸â¹ö¸¦ value_print
¿Í ºñ½ÁÇÑ ÇÔ¼öµé¿¡°Ô
Àü´ÞÇÏ°í, ¸¶Áö¸·À¸·Î ¿©·¯ºÐÀÌ ¸¸µç Çʵ带 Ãâ·ÂÇϱâ À§ÇØ
ui_out_field_stream
¸¦ È£ÃâÇضó.
ui_stream
°´Ã¼°¡ ´õÀÌ»ó ÇÊ¿äÇÏÁö ¾ÊÀ»¶§, ¿©·¯ºÐÀº ¿ì¼± °´Ã¼¸¦
Æı«ÇÏ°í 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.
ÀÌ ÇÔ¼ö´Â uiout¿¡ ´ëÇÑ Æ÷ÀÎÅÍ·Î Àü´ÞÇÏ´Â ui_out
°´Ã¼¿Í °°Àº Ãâ·Â ¹æ¹ýÀ» »ç¿ëÇÏ´Â »õ·Î¿î ui_stream
°´Ã¼¸¦ ¸¸µç´Ù.
ÀÌ ÇÔ¼ö´Â »õ·Î »ý¼ºµÈ ui_stream
°´Ã¼¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ¹ÝȯÇÑ´Ù.
ui_stream
object specified by
streambuf.
ÀÌ ÇÔ¼ö´Â streambuf°¡ ÁöÁ¤ÇÏ´Â ui_stream
°´Ã¼¸¦
Æı«ÇÑ´Ù.
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.
ÀÌ ÇÔ¼ö´Â streambuf->stream
¿¡ ½ÎÀÎ ¸ðµç µ¥ÀÌÅ͸¦ ¼ÒºñÇÏ°í
ui_out_field_string
°¡ Çϴ°Íó·³ Ãâ·ÂÇÑ´Ù.
ui_out_field_stream
È£ÃâÈÄ, ½×ÀÎ µ¥ÀÌÅÍ´Â ´õÀÌ»ó Á¸ÀçÇÏÁö ¾Ê´Â´Ù.
±×·¯³ª ½ºÆ®¸²Àº ¿©ÀüÈ÷ À¯È¿ÇÏ¸ç ´õ ¸¹Àº ÇʵåµéÀ» ¸¸µé±â À§ÇØ »ç¿ëµÈ´Ù.
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:
Áß¿ä: ¸¸ÀÏ ¿©·¯ºÐÀÇ Äڵ尡 Ãâ·Â »ý¼ºÀ» ³¡³»°í ui_out_stream_delete
°¡ È£ÃâµÇ´Â ½ÃÁ¡¿¡ µµ´ÞÇϱâ Àü¿¡ ³¡³¯ °¡´É¼ºÀÌ ÀÖ´Ù¸é,
¸Þ¸ð¸®¿Í ´Ù¸¥ ÀÚ¿øÀÌ ¸¯µÇ´Â °ÍÀ» ÇÇÇϱâ À§ÇØ cleanupÀ» ¼³Á¤ÇÒ ÇÊ¿ä°¡
ÀÖ´Ù.
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:
¸¸ÀÏ ÇÔ¼ö°¡ ÀÌ¹Ì ¿¡Àü cleanup cahin set(´Ù¸¥ Á¾·ùÀÇ cleanup)À» °¡Áö°í ÀÖ´Ù¸é, ¿©·¯ºÐÀº ¿©·¯ºÐÀÇ cleanup¸¸ Ãß°¡ÇÏ¸é µÈ´Ù.
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.
cleanupÀ» ÇÒ¶§, ¿©·¯ºÐÀº ui_out_stream_delete
¸¦ Á÷Á¢ È£ÃâÇϰųª
°°Àº ¹öÆÛ¸¦ ÇØÁ¦Çϱâ À§ÇØ µÎ¹ø ½ÃµµÇؼ´Â ¾ÈµÈ´Ù.
ÀÌ ÇÔ¼ö´Â Å×ÀÌºí³» Çʵ带 °Ç³Ê¶è´Ù. ¸¸ÀÏ ¿©·¯ºÐÀÌ Å×À̺í Á¤·Ä ºÐ¿¾øÀÌ ºó Çʵ带 ³²±æ·Á¸é ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇضó. fldname ÀÎÀÚ´Â (ÀÒ¾î¹ö¸°)Çʵ带 À§ÇÑ À̸§À» ÁöÁ¤ÇÑ´Ù.
ÀÌ ÇÔ¼ö´Â »ç¶÷ÀÌ Àб⠽±°Ô ¸¸µé±â À§ÇÑ ¹æ¹ýÀ¸·Î string³» ÅؽºÆ®¸¦ Ãâ·ÂÇÑ´Ù. ¿¹¸¦ µé¾î, ÀÌ ¹æ¹ýÀÇ ÄÜ¼Ö ¼öÇàÀº ½ºÅ©¸°ÀÇ ºñÁÖ¾óÇÑ ºÎºÐÀÇ ½ºÅ©·ÑÀ» ¸·±â À§ÇØ ³»Àå ÆäÀÌÀú¸¦ ÅëÇØ ÀÌ ÅؽºÆ®¸¦ ÇÊÅ͸µÇÑ´Ù.
Use this function for printing relatively long chunks of text around
the actual field data: the text it produces is not aligned according
to the table's format. Use ui_out_field_string
to output a
string field, and use ui_out_message
, described below, to
output short messages.
½ÇÁ¦ ÇÊµå µ¥ÀÌÅͳ» ÅؽºÆ®ÀÇ ±ä chunkÀ» Ãâ·ÂÇϱâ À§ÇØ ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇضó.;
¸¸µå´Â ÅؽºÆ®´Â Å×À̺í Çü½Ä¿¡ µû¶ó Á¤·ÄµÇÁö ¾Ê´Â´Ù. ¹®ÀÚ¿ Çʵ带 Ãâ·ÂÇϱâ
À§ÇØ ui_out_field_string
¸¦ »ç¿ëÇÏ°í °£´ÜÇÑ ¸Þ¼¼Áö¸¦ Ãâ·ÂÇϱâ
À§ÇØ ¾Æ·¡ ±â¼úÇÑ, ui_out_message
¸¦ »ç¿ëÇضó.
ui_out_text
with the rest of the table or
list.
ÀÌ ÇÔ¼ö´Â nspaces ½ºÆäÀ̽º¸¦ Ãâ·ÂÇÑ´Ù. Å×À̺íÀ̳ª ¸®½ºÆ®ÀÇ ³ª¸ÓÁö¸¦
°¡Áö°í ui_out_text
°¡ ¸¸µç ÅؽºÆ®¸¦ Á¤·ÄÇϱ⠽±´Ù.
ÀÌ ÇÔ¼ö´Â ÇöÀç verbosity ·¹º§ÀÌ verbosity¿¡ ÀÇÇØ ÁÖ¾îÁø °Í¸¸Å Ä¿´Ù¶õ Çü½ÄÈµÈ ¸Þ¼¼Áö¸¦ ¸¸µç´Ù. ÇöÀç verbosity ·¹º§Àº `set verbositylevel' ¸í·É¾î·Î »ç¿ëÀÚ°¡ ÁöÁ¤ÇÑ´Ù. (1)
NULL
, is the string to
be printed to indent the wrapped text on the next line; it must remain
accessible until the next call to ui_out_wrap_hint
, or until an
explicit newline is produced by one of the other functions. If
indent is NULL
, the wrapped text will not be indented.
ÀÌ ÇÔ¼ö´Â ÄÜ¼Ö Ãâ·Â ÇÊÅÍ(ÆäÀÌ¡ ÇÊÅÍ)¸¦ ÁØ´Ù.
¸ðµç ´Ù¸¥ Ãâ·Â ¼ÒºñÀÚ¸¦ ¹«½ÃÇÑ´Ù. ¸¸ÀÏ NULL
ÀÌ ¾Æ´Ï¶ó¸é,
indent´Â ´ÙÀ½ ¶óÀÎÀÇ ·¹ÇÎµÈ ÅؽºÆ®¸¦ µé¿©¾²±â À§ÇØ Ãâ·ÂÇϱâ À§ÇÑ
¹®ÀÚ¿ÀÌ´Ù.; ÀÌ ÇÔ¼ö´Â ui_out_wrap_hint
¿¡ ´ëÇÑ ´ÙÀ½ È£ÃâÀ̳ª
¸í¹éÇÑ newlineÀÌ ´Ù¸¥ ÇÔ¼öÁß Çϳª°¡ ¸¸µé¶§±îÁö Á¢±ÙÇÒ¼ö ÀÖµµ·Ï ³²¾Æ ÀÖ¾î¾ß
ÇÑ´Ù. ¸¸ÀÏ indent°¡ NULL
À̶ó¸é, ·¹ÇÎµÈ ÅؽºÆ®´Â
µé¿©¾²¿©ÁöÁö ¾Ê´Â´Ù.
¸¸ÀÏ UI°¡ Ãß·ÂÀ» ¹öÆÛÇÑ´Ù¸é, ÀÌ ÇÔ¼ö´Â Ãâ·ÂÀÌ Áö±Ý±îÁö ½Î¿©Àִ°ÍÀº ¸ðµÎ flushÇÑ´Ù.
ui_out
functionsui_out
ÇÔ¼öÀÇ »ç¿ë ¿¹Á¦
This section gives some practical examples of using the ui_out
functions to generalize the old console-oriented code in
GDB. The examples all come from functions defined on the
`breakpoints.c' file.
ÀÌ ¼½¼ÇÀº GDB³» ¿¹Àü ÄÜ¼Ö ±â¹Ý Äڵ带 ÀϹÝÈÇϱâ À§ÇÑ ui_out
ÇÔ¼öÀÇ Æ¯º°ÇÑ ½ÇÁ¦ÀûÀÎ »ç¿ë ¿¹Á¦À» º¸¿©ÁØ´Ù.
This example, from the breakpoint_1
function, shows how to
produce a table.
breakpoint_1
ÇÔ¼ö¿¡¼ ÀÌ ¿¹Á¦´Â Å×À̺íÀ» ¸¸µå´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.
The original code was:
¿ø·¡ ÄÚµå´Â:
if (!found_a_breakpoint++) { annotate_breakpoints_headers (); annotate_field (0); printf_filtered ("Num "); annotate_field (1); printf_filtered ("Type "); annotate_field (2); printf_filtered ("Disp "); annotate_field (3); printf_filtered ("Enb "); if (addressprint) { annotate_field (4); printf_filtered ("Address "); } annotate_field (5); printf_filtered ("What\n"); annotate_breakpoints_table (); }
Here's the new version:
»õ·Î¿î ¹öÀüÀº:
if (!found_a_breakpoint++) { annotate_breakpoints_headers (); if (addressprint) ui_out_table_begin (ui, 6); else ui_out_table_begin (ui, 5); annotate_field (0); ui_out_table_header (ui, 4, left, "Num"); annotate_field (1); ui_out_table_header (ui, 15, left, "Type"); annotate_field (2); ui_out_table_header (ui, 5, left, "Disp"); annotate_field (3); ui_out_table_header (ui, 4, left, "Enb"); if (addressprint) { annotate_field (4); ui_out_table_header (ui, 11, left, "Address"); } annotate_field (5); ui_out_table_header (ui, 40, left, "What"); ui_out_table_body (ui); annotate_breakpoints_table (); }
This example, from the print_one_breakpoint
function, shows how
to produce the actual data for the table whose structure was defined
in the above example. The original code was:
print_one_breakpoint
ÇÔ¼ö¿¡¼, ÀÌ ¿¹Á¦´Â À§ ¿¹Á¦¿¡¼
Á¤ÀÇµÈ ±¸Á¶Ã¼³» Å×À̺íÀ» À§ÇÑ ½ÇÁ¦ ´ëÀÌÅ͸¦ ¸¸µå´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.
annotate_record (); annotate_field (0); printf_filtered ("%-3d ", b->number); annotate_field (1); if ((int)b->type > (sizeof(bptypes)/sizeof(bptypes[0])) || ((int) b->type != bptypes[(int) b->type].type)) internal_error ("bptypes table does not describe type #%d.", (int)b->type); printf_filtered ("%-14s ", bptypes[(int)b->type].description); annotate_field (2); printf_filtered ("%-4s ", bpdisps[(int)b->disposition]); annotate_field (3); printf_filtered ("%-3c ", bpenables[(int)b->enable]);
This is the new version: ÀÌ°ÍÀÌ »õ ¹öÀüÀÌ´Ù:
annotate_record (); ui_out_list_begin (uiout, "bkpt"); annotate_field (0); ui_out_field_int (uiout, "number", b->number); annotate_field (1); if (((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0]))) || ((int) b->type != bptypes[(int) b->type].type)) internal_error ("bptypes table does not describe type #%d.", (int) b->type); ui_out_field_string (uiout, "type", bptypes[(int)b->type].description); annotate_field (2); ui_out_field_string (uiout, "disp", bpdisps[(int)b->disposition]); annotate_field (3); ui_out_field_fmt (uiout, "enabled", "%c", bpenables[(int)b->enable]);
This example, also from print_one_breakpoint
, shows how to
produce a complicated output field using the print_expression
functions which requires a stream to be passed. It also shows how to
automate stream destruction with cleanups. The original code was:
print_one_breakpoint
¿¡¼, ÀÌ ¿¹Á¦´Â ½ºÆ®¸² Àü´ÞÀ» ¿ä±¸ÇÏ´Â
print_expression
ÇÔ¼ö¸¦ »ç¿ëÇÏ´Â º¹ÀâÇÑ Ãâ·Â Çʵ带 ¸¸µé±â À§ÇÑ
¹æ¹ýÀ» º¸¿©ÁØ´Ù. ÀÌ ÇÔ¼ö´Â ½ºÆ®¸² Æı«¸¦ ÀÚµ¿ÈÇϱâ À§ÇÑ ¹æ¹ýÀ» Á¦°øÇÑ´Ù.
¿ø·¡ ÄÚµå´Â :
annotate_field (5); print_expression (b->exp, gdb_stdout);
The new version is:
»õ ¹öÀüÀº:
struct ui_stream *stb = ui_out_stream_new (uiout); struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb); ... annotate_field (5); print_expression (b->exp, stb->stream); ui_out_field_stream (uiout, "what", local_stream);
This example, also from print_one_breakpoint
, shows how to use
ui_out_text
and ui_out_field_string
. The original code
was:
print_one_breakpoint
¿¡¼, ÀÌ ¿¹Á¦´Â ui_out_text
¿Í
ui_out_field_string
¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀ» Á¦°øÇÑ´Ù.
¿ø·¡ ÄÚµå´Â:
annotate_field (5); if (b->dll_pathname == NULL) printf_filtered ("<any library> "); else printf_filtered ("library \"%s\" ", b->dll_pathname);
It became:
´ÙÀ½°ú °°´Ù:
annotate_field (5); if (b->dll_pathname == NULL) { ui_out_field_string (uiout, "what", "<any library>"); ui_out_spaces (uiout, 1); } else { ui_out_text (uiout, "library \""); ui_out_field_string (uiout, "what", b->dll_pathname); ui_out_text (uiout, "\" "); }
The following example from print_one_breakpoint
shows how to
use ui_out_field_int
and ui_out_spaces
. The original
code was:
print_one_breakpoint
¿¡¼ ´ÙÀ½ ¿¹Á¦´Â
ui_out_field_int
°ú ui_out_spaces
¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀ»
º¸¿©ÁØ´Ù.
¿ø·¡ ÄÚµå´Â:
annotate_field (5); if (b->forked_inferior_pid != 0) printf_filtered ("process %d ", b->forked_inferior_pid);
It became:
´ÙÀ½°ú °°´Ù:
annotate_field (5); if (b->forked_inferior_pid != 0) { ui_out_text (uiout, "process "); ui_out_field_int (uiout, "what", b->forked_inferior_pid); ui_out_spaces (uiout, 1); }
Here's an example of using ui_out_field_string
. The original
code was:
ÀÌ°ÍÀº ui_out_field_string
ÀÇ »ç¿ë ¿¹Á¦ÀÌ´Ù.
¿ø·¡ ÄÚµå´Â:
annotate_field (5); if (b->exec_pathname != NULL) printf_filtered ("program \"%s\" ", b->exec_pathname);
It became: ´ÙÀ½°ú °°´Ù:
annotate_field (5); if (b->exec_pathname != NULL) { ui_out_text (uiout, "program \""); ui_out_field_string (uiout, "what", b->exec_pathname); ui_out_text (uiout, "\" "); }
Finally, here's an example of printing an address. The original code:
¸¶Áö¸·À¸·Î, ¿©±â¿¡ ÁÖ¼Ò Ãâ·Â ¿¹Á¦°¡ ÀÖ´Ù. ¿ø·¡ ÄÚµå´Â:
annotate_field (4); printf_filtered ("%s ", local_hex_string_custom ((unsigned long) b->address, "08l"));
It became:
´ÙÀ½°ú °°´Ù:
annotate_field (4); ui_out_field_core_addr (uiout, "Address", b->address);
libgdb
was an abortive project of years ago. The theory was to
provide an API to GDB's functionality.
libgdb
´Â ¸î³âÀü ½ÇÆÐÇÑ ÇÁ·ÎÁ§Æ®ÀÌ´Ù. ÀÌ ÀÌ·ÐÀº GDB ±â´ÉÀ» À§ÇÑ
API¸¦ Á¦°øÇÑ´Ù.
Go to the first, previous, next, last section, table of contents.