Go to the first, previous, next, last section, table of contents.


Symbol Handling

½Éº¼ Çڵ鸵

Symbols are a key part of GDB's operation. Symbols include variables, functions, and types.

½Éº¼Àº GDB ÀÛµ¿¿¡¼­ Áß¿äÇÑ ºÎºÐÀÌ´Ù. ½Éº¼Àº º¯¼ö, ÇÔ¼ö ±×¸®°í ŸÀÔÀ» Æ÷ÇÔÇÑ´Ù.

Symbol Reading

½Éº¼ Àбâ

GDB reads symbols from symbol files. The usual symbol file is the file containing the program which GDB is debugging. GDB can be directed to use a different file for symbols (with the `symbol-file' command), and it can also read more symbols via the `add-file' and `load' commands, or while reading symbols from shared libraries.

GDB´Â symbol files¿¡¼­ ½Éº¼À» Àд´Ù. ÀϹÝÀûÀÎ ½Éº¼ ÆÄÀÏÀº GDB°¡ µð¹ö±ëÇÏ´Â ÇÁ·Î±×·¥À» Æ÷ÇÔÇÑ ÆÄÀÏÀÌ´Ù. GDB´Â ½Éº¼(`symbol-file' ¸í·É¾î·Î)À» À§ÇØ ´Ù¸¥ ÆÄÀÏÀ» »ç¿ëÇϵµ·Ï Áö½ÃÇÒ¼ö ÀÖÀ¸¸ç `add-file'¿Í `load' ¸í·É¾î¸¦ ÅëÇØ ´õ ¸¹Àº ½Éº¼À» ÀÐÀ»¼ö ÀÖÀ¸¸ç ¶Ç °øÀ¯ ¶óÀ̺귯¸®¿¡¼­ ½Éº¼À» ÀÐÀ»¼ö ÀÖ´Ù.

Symbol files are initially opened by code in `symfile.c' using the BFD library (see section Support Libraries). BFD identifies the type of the file by examining its header. find_sym_fns then uses this identification to locate a set of symbol-reading functions.

½Éº¼ ÆÄÀÏÀº BFD ¶óÀ̺귯¸®(Support Libraries ¼½¼ÇÀ» ÂüÁ¶Çضó.)¸¦ »ç¿ëÇÏ´Â `symfile.c'³» Äڵ忡 ÀÇÇØ ¿­¸°´Ù. BFD´Â Çì´õ¸¦ °Ë»çÇÏ¿© ÆÄÀÏÀÇ Å¸ÀÔÀ» ½Äº°ÇÑ´Ù. ±×¸®°í find_sym_fns´Â ½Éº¼-Àд ÇÔ¼ö ÁýÇÕÀ» À§Ä¡½ÃÅ°±â À§ÇØ ÀÌ ½Äº°À» »ç¿ëÇÑ´Ù.

Symbol-reading modules identify themselves to GDB by calling add_symtab_fns during their module initialization. The argument to add_symtab_fns is a struct sym_fns which contains the name (or name prefix) of the symbol format, the length of the prefix, and pointers to four functions. These functions are called at various times to process symbol files whose identification matches the specified prefix.

½Éº¼-Àб⠸ðµâÀº ¸ðµâ ÃʱâÈ­µ¿¾È add_symtab_fns¸¦ È£ÃâÇÏ¿© GDB¿¡¼­ ±×°ÍµéÀ» ½Äº°ÇÑ´Ù. add_symtab_fns¿¡ ´ëÇÑ ÀÎÀÚ´Â ½Éº¼ Çü½ÄÀÇ À̸§, Á¢µÎ»çÀÇ ±æÀÌ, ±×¸®°í ³× ÇÔ¼ö¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ Æ÷ÇÔÇÏ´Â struct sym_fnsÀÌ´Ù. À̵é ÇÔ¼ö´Â ÁöÁ¤µÈ Á¢µÎ»ç¿Í ÀÏÄ¡ÇÏ¿© ½Äº°µÈ ½Éº¼ ÆÄÀÏÀ» ó¸®Çϱâ À§ÇØ ¿©·¯¹ø È£ÃâµÈ´Ù.

The functions supplied by each module are:

°¢ ¸ðµâÀÌ Á¦°øÇÏ´Â ÇÔ¼ö´Â:

xyz_symfile_init(struct sym_fns *sf)
Called from symbol_file_add when we are about to read a new symbol file. This function should clean up any internal state (possibly resulting from half-read previous files, for example) and prepare to read a new symbol file. Note that the symbol file which we are reading might be a new "main" symbol file, or might be a secondary symbol file whose symbols are being added to the existing symbol table.

»õ ½Éº¼ ÆÄÀÏÀ» ÀÐÀ»¶§ symbol_file_add¿¡¼­ È£ÃâµÈ´Ù. ÀÌ ÇÔ¼ö´Â ³»ºÎ »óÅÂ(¿¹¸¦ µé¾î half-read Àü ÆÄÀÏÀÇ °á°ú)¸¦ ºñ¿ì°í »õ ½Éº¼ ÆÄÀÏÀ» ÀÐÀ» Áغñ¸¦ ÇÑ´Ù. ¿ì¸®°¡ Àд ½Éº¼ ÆÄÀÏÀº »õ·Î¿î "main" ½Éº¼ ÆÄÀÏÀ̰ųª Á¸ÀçÇÏ´Â ½Éº¼ Å×ÀÌºí¿¡ Ãß°¡µÈ ÀÌÂ÷ ½Éº¼ ÆÄÀÏÀÌ´Ù. The argument to xyz_symfile_init is a newly allocated struct sym_fns whose bfd field contains the BFD for the new symbol file being read. Its private field has been zeroed, and can be modified as desired. Typically, a struct of private information will be malloc'd, and a pointer to it will be placed in the private field. There is no result from xyz_symfile_init, but it can call error if it detects an unavoidable problem.

xyz_symfile_init¿¡ ´ëÇÑ ÀÎÀÚ´Â »õ·Î Ç×´çµÈ struct sym_fns À̸ç bfd´Â Àд »õ·Î¿î ½Éº¼ ÆÄÀÏÀ» À§ÇØ BFD¸¦ Æ÷ÇÔÇÑ´Ù. private Çʵå´Â 0ÀÌ¸ç ¿øÇÏ¸é ¼öÁ¤ÇÒ¼ö ÀÖ´Ù. ÀüÇüÀûÀ¸·Î °³ÀÎ Á¤º¸ ±¸Á¶´Â mallocµÇ¸ç ÀÌ°Í¿¡ ´ëÇÑ Æ÷ÀÎÅÍ´Â private Çʵ忡 ³õÀδÙ. xyz_symfile_initÀÇ °á°ú´Â ¾Æ´ÏÁö¸¸ ¸¸ÀÏ ÇÇÇÒ¼ö ¾ø´Â ¹®Á¦°¡ ¹ß°ßµÈ´Ù¸é error¸¦ È£ÃâÇÑ´Ù.

xyz_new_init()
Called from symbol_file_add when discarding existing symbols. This function needs only handle the symbol-reading module's internal state; the symbol table data structures visible to the rest of GDB will be discarded by symbol_file_add. It has no arguments and no result. It may be called after xyz_symfile_init, if a new symbol table is being read, or may be called alone if all symbols are simply being discarded.

Á¸ÀçÇÏ´Â ½Éº¼À» ¹ö¸±¶§ symbol_file_add¿¡¼­ È£ÃâµÈ´Ù. ÀÌ ÇÔ¼ö´Â ½Éº¼-Àд ¸ðµâÀÇ ³»ºÎ »óŸ¦ ó¸®ÇÒ¶§¸¸ ÇÊ¿äÇÏ´Ù.; GDB ³ª¸ÓÁö¸¦ ºñÁÖ¾óÇÏ°Ô ÇÏ´Â ½Éº¼ Å×ÀÌºí µ¥ÀÌÅÍ ±¸Á¶´Â symbol_file_add¿¡ ÀÇÇØ ¹ö·ÁÁø´Ù. ÀÎÀÚµµ ¾ø°í ¹Ýȯ°ªµµ ¾ø´Ù. ¸¸ÀÏ »õ·Î¿î ½Éº¼ Å×À̺íÀ» Àд´ٸé xyz_symfile_init ´ÙÀ½¿¡ È£ÃâµÇ°Å³ª, ¸¸ÀÏ ¸ðµç ½Éº¼ÀÌ ´Ü¼øÈ÷ ¹ö·ÁÁø´Ù¸é È£ÃâµÈ´Ù.

xyz_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline)
Called from symbol_file_add to actually read the symbols from a symbol-file into a set of psymtabs or symtabs. sf points to the struct sym_fns originally passed to xyz_sym_init for possible initialization. addr is the offset between the file's specified start address and its true address in memory. mainline is 1 if this is the main symbol table being read, and 0 if a secondary symbol file (e.g. shared library or dynamically loaded file) is being read.

½Éº¼ ÆÄÀÏÀÇ psymtabÀ̳ª symtab ÁýÇÕ¿¡¼­ ½Éº¼À» Àбâ À§ÇØ symbol_file_add¿¡¼­ È£ÃâµÈ´Ù. sf´Â °¡´ÉÇÑ ÃʱâÈ­¸¦ À§ÇØ xyz_sym_init¿¡ Àü´ÞµÇ´Â struct sym_fns¿¡ ´ëÇÑ Æ÷ÀÎÅÍÀÌ´Ù. addr´Â ÆÄÀÏÀÌ ÁöÁ¤ÇÑ ½ÃÀÛÁÖ¼Ò¿Í ¸Þ¸ð¸®³» ½ÇÁ¦ ÁÖ¼Ò »çÀÌÀÇ offsetÀÌ´Ù. mainline´Â ¸¸ÀÏ ÀÌ°ÍÀÌ ÀÐÀº ¸ÞÀÎ ½Éº¼ Å×À̺íÀ̶ó¸é 1, ¸¸ÀÏ 2Â÷ ½Éº¼ ÆÄÀÏ(Áï, °øÀ¯ ¶óÀ̺귯¸®³ª µ¿ÀûÀ¸·Î ·ÎµùµÈ ÆÄÀÏ)ÀÌ Àоú´Ù¸é 0 ÀÌ´Ù.

In addition, if a symbol-reading module creates psymtabs when xyz_symfile_read is called, these psymtabs will contain a pointer to a function xyz_psymtab_to_symtab, which can be called from any point in the GDB symbol-handling code.

°Ô´Ù°¡ ¸¸ÀÏ ½Éº¼ Àд ¸ðµâÀÌ xyz_symfile_read°¡ È£ÃâµÉ¶§ psymtabsÀ» ¸¸µç´Ù¸é, À̵é psymtabsÀº GDB ½Éº¼ Çڵ鸵 Äڵ峻 ¾î¶² Æ÷ÀÎÆ®¿¡¼­ È£ÃâµÇ´Â ÇÔ¼ö xyz_psymtab_to_symtab¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ Æ÷ÇÔÇÑ´Ù.

xyz_psymtab_to_symtab (struct partial_symtab *pst)
Called from psymtab_to_symtab (or the PSYMTAB_TO_SYMTAB macro) if the psymtab has not already been read in and had its pst->symtab pointer set. The argument is the psymtab to be fleshed-out into a symtab. Upon return, pst->readin should have been set to 1, and pst->symtab should contain a pointer to the new corresponding symtab, or zero if there were no symbols in that part of the symbol file.

¸¸ÀÏ psymtabÀÌ ÀÌ¹Ì ÀÐÇôÁöÁö ¾Ê°í pst->symtab Æ÷ÀÎÅÍ ÁýÇÔÀ» °¡Áö°í ÀÖ´Ù¸é psymtab_to_symtab(¶Ç´Â PSYMTAB_TO_SYMTAB ¸ÅÅ©·Î)¿¡¼­ È£ÃâµÈ´Ù. ÀÎÀÚ´Â symtab°ú ÀÏÄ¡ÇÏÁö ¾Ê°Ô Çϱâ À§ÇÑ psymtabÀÌ´Ù. ¹Ýȯ½Ã, pst->readin´Â 1·Î ¼³Á¤µÇ¾î¾ß Çϸç pst->symtab´Â »õ·Î¿î ÇØ´ç symtab¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ Æ÷ÇÔÇØ¾ß Çϸç, ¸¸ÀÏ ½Éº¼ ÆÄÀÏÀÇ ÀϺκп¡ ½Éº¼ÀÌ ¾ø´Ù¸é, 0À» Æ÷ÇÔÇØ¾ß ÇÑ´Ù.

Partial Symbol Tables

ºÎºÐÀûÀÎ ½Éº¼ Å×À̺í

GDB has three types of symbol tables:

GDB´Â ¼¼ ŸÀÔÀÇ ½Éº¼ Å×À̺íÀ» °¡Áö°í ÀÖ´Ù:

This section describes partial symbol tables.

ÀÌ ¼½¼ÇÀº ºÎºÐÀûÀÎ ½Éº¼ Å×À̺íÀ» ±â¼úÇÑ´Ù.

A psymtab is constructed by doing a very quick pass over an executable file's debugging information. Small amounts of information are extracted--enough to identify which parts of the symbol table will need to be re-read and fully digested later, when the user needs the information. The speed of this pass causes GDB to start up very quickly. Later, as the detailed rereading occurs, it occurs in small pieces, at various times, and the delay therefrom is mostly invisible to the user.

psymtabÀº ½ÇÇà ÆÄÀÏ µð¹ö±ë Á¤º¸¸¦ ¸Å¿ì ºü¸£°Ô Àü´ÞµÇµµ·Ï ¸¸µé¾î Á³´Ù. ÀÛÀº ¾çÀÇ Á¤º¸´Â ÀϺΠ½Éº¼ Å×À̺íÀ» ´Ù½Ã ÀÐÀ» ÇÊ¿ä°¡ ÀÖ´Ù´Â °ÍÀ» ¾Ë¾Æ³½´Ù. ±×¸®°í »ç¿ëÀÚ°¡ Á¤º¸°¡ ÇÊ¿äÇÒ¶§ ³ªÁß¿¡ ¿ÏÀüÈ÷ ¼ÒÈ­µÈ´Ù. Àü´Þ ¼Óµµ´Â GDB°¡ ¸Å¿ì ºü¸£°Ô ½ÃÀÛÇϵµ·Ï ¾ß±âÇÑ´Ù. ³ªÁß¿¡, ¼¼ºÎÀûÀ¸·Î ´Ù½Ã ÀбⰡ ¹ß»ýÇÑ´Ù¸é, ¿©·¯¹ø ÀÛÀº ´ÜÀ§·Î ÀϾ¸ç ±×·¯ÇÑ µô·¹ÀÌ´Â »ç¿ëÀÚµéÀÌ °¡Àå º¼¼ö ¾ø´Â°ÍÀÌ´Ù.

The symbols that show up in a file's psymtab should be, roughly, those visible to the debugger's user when the program is not running code from that file. These include external symbols and types, static symbols and types, and enum values declared at file scope.

ÆÄÀÏÀÇ psymtab¿¡¼­ º¸¿©ÁÖ´Â ½Éº¼Àº ÇÁ·Î±×·¥ÀÌ ÇØ´ç ÆÄÀÏ¿¡¼­ µ¹¾Æ°¡´Â Äڵ尡 ¾Æ´Ò¶§ µð¹ö°Å »ç¿ëÀÚ¿¡°Ô À̰͵éÀ» º¸¿©Áà¾ß ÇÑ´Ù. À̰͵éÀº ¿ÜºÎ ½Éº¼°ú ŸÀÔ, Á¤Àû ½Éº¼°ú ŸÀÔ, ±×¸®°í ÆÄÀÏ ¹üÀ§³» ¼±¾ðµÈ enum º¯¼ö¸¦ Æ÷ÇÔÇÑ´Ù.

The psymtab also contains the range of instruction addresses that the full symbol table would represent.

psymtabÀº Àüü ½Éº¼ Å×À̺íÀÌ ³ªÅ¸³»´Â ¸í·É¾î ÁÖ¼ÒÀÇ ¹üÀ§¸¦ Æ÷ÇÔÇÑ´Ù.

The idea is that there are only two ways for the user (or much of the code in the debugger) to reference a symbol:

idea´Â ½Éº¼À» ÂüÁ¶Çϱâ À§ÇØ »ç¿ëÀÚ(¶Ç´Â µð¹ö°Å³» ¸¹Àº ÄÚµå)¿¡°Ô´Â 2°¡ÁöÀÇ ¹æ¹ýÀÌ ÀÖ´Ù´Â °ÍÀÌ´Ù.

The only reason that psymtabs exist is to cause a symtab to be read in at the right moment. Any symbol that can be elided from a psymtab, while still causing that to happen, should not appear in it. Since psymtabs don't have the idea of scope, you can't put local symbols in them anyway. Psymtabs don't have the idea of the type of a symbol, either, so types need not appear, unless they will be referenced by name.

psymtabÀÌ Á¸ÀçÇÏ´Â À¯ÀÏÇÑ ÀÌÀ¯´Â Àû´çÇÑ ¼ø°£¿¡ symtabÀ» Àеµ·Ï ¾ß±âÇÏ´Â °ÍÀÌ´Ù. psymtab¿¡¼­ »ý·«µÉ¼ö ÀÖ´Â ½Éº¼Àº ³ªÅ¸³ªµµ·Ï ¾ß±âÇÏ´Â µ¿¾È¿¡µµ, ±×°÷¿¡¼­ ³ªÅ¸³ª¼­´Â ¾ÈµÈ´Ù. psymtabÀº ¹üÀ§¿¡ ´ëÇÑ ¾ÆÀ̵ð¾î¸¦ °¡Áö°í ÀÖÁö¸¸, ¿©·¯ºÐÀº ¾î¶µç Áö¿ª ½Éº¼À» ³õÀ»¼ö ¾ø´Ù. psymtabÀº ½Éº¼ ŸÀÔ¿¡ ´ëÇÑ ¾ÆÀ̵ð¾î¸¦ °¡Áö°í ÀÖÁö ¾Ê´Ù. ±×·¡¼­ À̸§À¸·Î ÂüÁ¶ÇѴٴ°ÍÀ» Á¦¿ÜÇÑ´Ù¸é ŸÀÔÀº ³ªÅ¸³¯ ÇÊ¿ä°¡ ¾ø´Ù.

It is a bug for GDB to behave one way when only a psymtab has been read, and another way if the corresponding symtab has been read in. Such bugs are typically caused by a psymtab that does not contain all the visible symbols, or which has the wrong instruction address ranges.

psymtabÀÌ Àп©Áú¶§ ÇÏ´Â Çൿ°ú »óÀÀÇÏ´Â symtabÀÌ ÀÐÇôÁú¶§ ´Ù¸¥ ¹æ¹ýÀ¸·Î ÇൿÇÏ´Â °ÍÀº GDB ¹ö±×ÀÌ´Ù. ±×·± ¹ö±×´Â ÀüÇüÀûÀ¸·Î psymtabÀÌ ¸ðµç ºñÁ®ºí ½Éº¼À» Æ÷ÇÔÇÏÁö ¾Ê¾Æ¼­°Å³ª À߸øµÈ ¸í·É¾î ÁÖ¼Ò ¹üÀ§¸¦ °¡Áö±â ¶§¹®ÀÌ´Ù.

The psymtab for a particular section of a symbol file (objfile) could be thrown away after the symtab has been read in. The symtab should always be searched before the psymtab, so the psymtab will never be used (in a bug-free environment). Currently, psymtabs are allocated on an obstack, and all the psymbols themselves are allocated in a pair of large arrays on an obstack, so there is little to be gained by trying to free them unless you want to do a lot more work.

½Éº¼ ÆÄÀÏ(objfile)ÀÇ Æ¯Á¤ ¼½¼ÇÀ» À§ÇÑ psymtabÀº symtabÀÌ ÀÐÇôÁøÈÄ ¹ö·ÁÁø´Ù. symtabÀº Ç×»ó psymtabÀü¿¡ °Ë»öµÇ¸ç, ±×·¡¼­ psymtabÀº °áÄÚ »ç¿ë(buf-free environment)µÇÁö ¾Ê´Â´Ù. ÇöÀç, psymtabÀº obstack¿¡¼­ ÇÒ´çµÇ¸ç ¸ðµç psymbolÀº obstack³» Ä¿´Ù¶õ ¹è¿­½ÖÀ¸·Î ÇÒ´çµÈ´Ù. ±×·¡¼­ ¸¸ÀÏ ¿©·¯ºÐÀÌ ´õ ¸¹ÀÌ ÀÏÇÏ±æ ¿øÇÏÁö ¾Ê´Â´Ù¸é ±×°ÍµéÀ» ÇØÁ¦ÇÒ·Á°í ½ÃµµÇÏ¿© ¾ò´Â °ÍÀº °ÅÀÇ ¾ø´Ù.

Types

ŸÀÔ

Fundamental Types (e.g., FT_VOID, FT_BOOLEAN).

±âº» ŸÀÔ(e.g., FT_VOID, FT_BOOLEAN).

These are the fundamental types that GDB uses internally. Fundamental types from the various debugging formats (stabs, ELF, etc) are mapped into one of these. They are basically a union of all fundamental types that GDB knows about for all the languages that GDB knows about.

À̰͵éÀº GDB°¡ ³»ºÎÀûÀ¸·Î »ç¿ëÇÏ´Â ±âº» ŸÀÔÀÌ´Ù. ´Ù¾çÇÑ µð¹ö±ë Çü½Ä(stab, ELF µî)¿¡¼­ ±âº» ŸÀÔÀº À̰͵éÁß Çϳª·Î ´ëÀÀµÈ´Ù. ±×µéÀº ±âº»ÀûÀ¸·Î GDB°¡ ¾Ë°í ÀÖ´Â ¸ðµç ¾ð¾î¿¡ °üÇØ GDB°¡ ¾Ë°í ÀÖ´Â ¸ðµç ±âº» ŸÀÔ°ú °áÇÕÇÑ´Ù.

Type Codes (e.g., TYPE_CODE_PTR, TYPE_CODE_ARRAY).

ŸÀÔ ÄÚµå (e.g., TYPE_CODE_PTR, TYPE_CODE_ARRAY).

Each time GDB builds an internal type, it marks it with one of these types. The type may be a fundamental type, such as TYPE_CODE_INT, or a derived type, such as TYPE_CODE_PTR which is a pointer to another type. Typically, several FT_* types map to one TYPE_CODE_* type, and are distinguished by other members of the type struct, such as whether the type is signed or unsigned, and how many bits it uses.

GDB´Â ¸Å¹ø ³»ºÎ ŸÀÔÀ» ¸¸µé¸ç, ÀÌ°ÍÀº À̵é ŸÀÔÁß Çϳª·Î Ç¥½ÃµÈ´Ù. ŸÀÔÀº TYPE_CODE_INT°°Àº ±âº» ŸÀÔÀ̰ųª Ÿ¸¥ ŸÀÔÀ» Æ÷ÀÎÅÍÇÏ´Â TYPE_CODE_PTR °°Àº ÆÄ»ý ŸÀÔÀÌ´Ù. ÀüÇüÀûÀ¸·Î, ¸î¸î FT_* ŸÀÔÀº TYPE_CODE_* ŸÀÔÀ¸·Î ´ëÀÀÇÏ¸ç ¾î¶² ŸÀÔÀÌ signÀ̳ª unsignÀÎÁö, ¾ó¸¶³ª ¸¹Àº ºñÆ®°¡ »ç¿ëµÇ´ÂÁö¿Í °°Àº ŸÀÔ ±¸Á¶ÀÇ ´Ù¸¥ ¸â¹öµé¿¡ ÀÇÇØ ±¸º°µÈ´Ù.

Builtin Types (e.g., builtin_type_void, builtin_type_char).

Builtin ŸÀÔ (e.g., builtin_type_void, builtin_type_char).

These are instances of type structs that roughly correspond to fundamental types and are created as global types for GDB to use for various ugly historical reasons. We eventually want to eliminate these. Note for example that builtin_type_int initialized in `gdbtypes.c' is basically the same as a TYPE_CODE_INT type that is initialized in `c-lang.c' for an FT_INTEGER fundamental type. The difference is that the builtin_type is not associated with any particular objfile, and only one instance exists, while `c-lang.c' builds as many TYPE_CODE_INT types as needed, with each one associated with some particular objfile.

À̰͵éÀº ±âº» ŸÀÔ°ú °ü·ÃµÇ´Â ŸÀÔ ±¸Á¶ °´Ã¼ÀÌ¸ç ´Ù¾çÇÑ ¿ª»çÀûÀÎ ÀÌÀ¯·Î »ç¿ëµÇ´Â GDB Àü¿ª ŸÀÔó·³ ¸¸µé¾îÁø´Ù. °á±¹ ¿ì¸®´Â À̰͵éÀ» ÁÙÀÌ±æ ¿øÇÑ´Ù. `gdbtypes.c'¿¡¼­ ÃʱâÈ­µÇ´Â builtin_type_int´Â ±âº»ÀûÀ¸·Î FT_INTEGER ±âº» ŸÀÔÀ» À§ÇØ `c-lang.c'¿¡¼­ ÃʱâÈ­µÇ´Â TYPE_CODE_INT ŸÀÔ°ú °°´Ù. ´Ù¸¥ Á¡Àº builtin_type´Â ¾î¶² ƯÁ¤ objfile°ú °ü·ÃÀÌ ¾øÀ¸¸ç ´ÜÁö °´Ã¼¸¸ Á¸ÀçÇÏ°í, ¹Ý¸é¿¡ `c-lang.c'´Â ¸î¸î ƯÁ¤ objfile°ú °ü·ÃµÉ¶§¸¶´Ù ÇÊ¿äÇÑ TYPE_CODE_INT ŸÀÔ ¸¸Å­ ¸¸µç´Ù.

Object File Formats

°´Ã¼ ÆÄÀÏ Çü½Äµé

a.out

The a.out format is the original file format for Unix. It consists of three sections: text, data, and bss, which are for program code, initialized data, and uninitialized data, respectively.

a.out Çü½ÄÀº UnixÀÇ ¿ø ÆÄÀÏ Çü½ÄÀÌ´Ù. ÀÌ Çü½ÄÀº ¼¼ ¼½¼ÇÀ¸·Î ÀÌ·ç¾îÁ® ÀÖ´Ù:text, data, ±×¸®°í bss, °¢°¢Àº ÇÁ·Î±×·¥ ÄÚµå, ÃʱâÈ­µÈ µ¥ÀÌÅÍ, ÃʱâÈ­µÇÁö ¾ÊÀº µ¥ÀÌÅÍÀÌ´Ù.

The a.out format is so simple that it doesn't have any reserved place for debugging information. (Hey, the original Unix hackers used `adb', which is a machine-language debugger!) The only debugging format for a.out is stabs, which is encoded as a set of normal symbols with distinctive attributes.

a.out Çü½ÄÀº ¸Å¿ì ´Ü¼øÇÏ¸ç µð¹ö±ë Á¤º¸¸¦ À§ÇÑ Àå¼Ò¸¦ À¯ÁöÇÏÁö ¾Ê´Â´Ù. (¿ø·¡ Unix ÇØÄ¿´Â ±â°è-¾ð¾î µð¹ö°ÅÀÎ `adb'¸¦ »ç¿ëÇÑ´Ù.) a.out¸¦ À§ÇÑ µð¹ö±ë Çü½ÄÀº stabÀ̸ç ÀÌ°ÍÀº ±¸º°ÀûÀΠƯ¼ºÀ» °¡Áö´Â º¸ÅëÀÇ ½Éº¼ ÁýÇÕó·³ ÀÎÄÚµùµÈ´Ù.

The basic a.out reader is in `dbxread.c'.

±âº»ÀûÀÎ a.out ¸®´õ´Â `dbxread.c'¿¡ ÀÖ´Ù.

COFF

The COFF format was introduced with System V Release 3 (SVR3) Unix. COFF files may have multiple sections, each prefixed by a header. The number of sections is limited.

COFF Çü½ÄÀº System V Release 3(SVR3) Unix¿¡¼­ ¼Ò°³µÇ¾ú´Ù. COFF ÆÄÀÏÀº ¿©·¯ ¼½¼ÇÀ» °¡Áö°í ÀÖÀ¸¸ç °¢°¢ Çì´õ°¡ Á¢µÎ»ç·Î ³õÀδÙ. ¼½¼ÇÀÇ ¼ö´Â Á¦ÇѵǾî ÀÖ´Ù.

The COFF specification includes support for debugging. Although this was a step forward, the debugging information was woefully limited. For instance, it was not possible to represent code that came from an included file.

COFF ¸í¼¼¼­´Â µð¹ö±ë Áö¿øÀ» Æ÷ÇÔÇÑ´Ù. ºñ·Ï ÀÌ°ÍÀÌ ¾Õ ´Ü°è¶ó Çصµ, µð¹ö±ë Á¤º¸´Â Á¦ÇѵǾî ÀÖ´Ù. ¿¹¸¦µé¾î, Æ÷ÇÔµÈ ÆÄÀÏ¿¡¼­ ¿Â Äڵ带 ³ªÅ¸³»´Â°ÍÀº °¡´ÉÇÏÁö ¾Ê´Ù.

The COFF reader is in `coffread.c'.

COFF ¸®´õ´Â `coffread.c'¿¡ ÀÖ´Ù.

ECOFF

ECOFF is an extended COFF originally introduced for Mips and Alpha workstations.

ECOFF´Â Mips¿Í Alpha workstationÀ» À§ÇØ ¼Ò°³µÈ È®ÀåµÈ COFFÀÌ´Ù.

The basic ECOFF reader is in `mipsread.c'.

±âº» ECOFF ¸®´õ´Â `mipsread.c'¿¡ ÀÖ´Ù.

XCOFF

The IBM RS/6000 running AIX uses an object file format called XCOFF. The COFF sections, symbols, and line numbers are used, but debugging symbols are dbx-style stabs whose strings are located in the .debug section (rather than the string table). For more information, see section `Top' in The Stabs Debugging Format.

IBM RS/6000¿¡¼­ µ¹¾Æ°¡´Â AIX´Â XCOFF¶ó ºÒ¸®´Â °´Ã¼ ÆÄÀÏ Çü½ÄÀ» »ç¿ëÇÑ´Ù. COFF ¼½¼Ç, ½Éº¼ ±×¸®°í ¶óÀÎ ³Ñ¹ö´Â »ç¿ëµÈ´Ù. ±×·¯³ª µð¹ö±ë ½Éº¼Àº ¹®ÀÚ¿­ÀÌ .debug ¼½¼Ç(¹®ÀÚ¿­ Å×ÀÌºí º¸´Ù´Â)¿¡ À§Ä¡ÇÏ´Â dbx ½ºÅ¸ÀÏ stabÀÌ´Ù. ´õ ¸¹Àº Á¤º¸¸¦ À§ÇØ The Stabs Debugging FormatÀÇ 'Top' ¼½¼ÇÀ» ÂüÁ¶Çضó.

The shared library scheme has a clean interface for figuring out what shared libraries are in use, but the catch is that everything which refers to addresses (symbol tables and breakpoints at least) needs to be relocated for both shared libraries and the main executable. At least using the standard mechanism this can only be done once the program has been run (or the core file has been read).

°øÀ¯ ¶óÀ̺귯¸® ±¸Á¶´Â °øÀ¯ ¶óÀ̺귯¸®°¡ »ç¿ëµÇ´Â ¹æ¹ýÀ» ÀÌÇØÇϱâ À§ÇÑ °£ÆíÇÑ ÀÎÅÍÆäÀ̽º¸¦ °¡Áö°í ÀÖÁö¸¸ catch´Â ÁÖ¼Ò¸¦ ÂüÁ¶ÇÏ´Â ¸ðµç °ÍÀº °øÀ¯ ¶óÀ̺귯¸®¿Í ¸ÞÀÎ ½ÇÇàÀ» À§ÇØ ÀçÇÒ´çÇÒ ÇÊ¿ä°¡ ÀÖ´Â °ÍÀÌ´Ù. Àû¾îµµ, ÀÌ·¸°Ô ÇÒ¼ö Àִ ǥÁØ ¸ÞÄ«´ÏÁîÀÇ »ç¿ëÀº µ¹¾Æ°¡´Â(¶Ç´Â ÄÚ¾î ÆÄÀÏÀ» Àд´Ù.) ÇÁ·Î±×·¥¿¡¼­ ÇàÇØÁø´Ù.

PE

Windows 95 and NT use the PE (Portable Executable) format for their executables. PE is basically COFF with additional headers.

Window 95¿Í NT´Â ½ÇÇàÀ» À§ÇØ PE(Portable Executable) Çü½ÄÀ» »ç¿ëÇÑ´Ù. PE´Â Ãß°¡ÀûÀÎ Çì´õ¸¦ °¡Áö´Â COFFÀÌ´Ù.

While BFD includes special PE support, GDB needs only the basic COFF reader.

BFD°¡ Ưº°ÇÑ PE Áö¿øÀ» Æ÷ÇÔÇÏ´Â ¹Ý¸é, GDB´Â ±âº» COFF ¸®´õ¸¸ÀÌ ÇÊ¿äÇÏ´Ù.

ELF

The ELF format came with System V Release 4 (SVR4) Unix. ELF is similar to COFF in being organized into a number of sections, but it removes many of COFF's limitations.

ELF Çü½ÄÀº System V Release 4(SVR4) À¯´Ð½º¿¡¼­ ¿Ô´Ù. ELF´Â ¼½¼Ç¼ö·Î Á¶Á÷È­µÇ´Â COFF¿Í ºñ½ÁÇÏÁö¸¸ COFFÀÇ Á¦ÇÑ °ªÀ» Á¦°ÅÇÏ¿´´Ù.

The basic ELF reader is in `elfread.c'.

±âº» ELF ¸®´õ´Â `elfread.c'¿¡ ÀÖ´Ù.

SOM

SOM is HP's object file and debug format (not to be confused with IBM's SOM, which is a cross-language ABI).

SOMÀº HPÀÇ °´Ã¼ ÆÄÀÏÀÌ¸ç µð¹ö±ë Çü½Ä(cross ¾ð¾î ABIÀÎ IBMÀÇ SOM°ú È¥µ¿ÇÏÁö ¸¶¶ó.)ÀÌ´Ù.

The SOM reader is in `hpread.c'.

SOM ¸®´õ´Â `hpread.c'¿¡ ÀÖ´Ù.

Other File Formats

´Ù¸¥ ÆÄÀÏ Çü½Äµé

Other file formats that have been supported by GDB include Netware Loadable Modules (`nlmread.c').

GDB°¡ Áö¿øÇÏ´Â ´Ù¸¥ ÆÄÀÏ Çü½ÄÀº Netware Loadable Modules(`nlmread.c')À» Æ÷ÇÔÇÑ´Ù.

Debugging File Formats

ÆÄÀÏ Çü½Ä µð¹ö±ëÇϱâ

This section describes characteristics of debugging information that are independent of the object file format.

ÀÌ ¼½¼ÇÀº µ¶¸³ÀûÀÎ °´Ã¼ ÆÄÀÏ Çü½ÄÀÇ µð¹ö±ë Á¤º¸ÀÇ Æ¯¼ºÀ» ±â¼úÇÑ´Ù.

stabs

stabs started out as special symbols within the a.out format. Since then, it has been encapsulated into other file formats, such as COFF and ELF.

stabs´Â a.out Çü½Ä³» Ưº°ÇÑ ½Éº¼Ã³·³ ½ÃÀÛÇÑ´Ù. ±×·¸±â ¶§¹®¿¡, COFF³ª ELF ó·³ ´Ù¸¥ ÆÄÀÏ Çü½ÄÀ¸·Î ĸ½¶È­µÈ´Ù.

While `dbxread.c' does some of the basic stab processing, including for encapsulated versions, `stabsread.c' does the real work.

`dbxread.c'°¡ ĸ½¶È­µÈ ¹öÀüÀ» Æ÷ÇÔÇÏ¿© ±âº» stab 󸮸¦ ÇÏ´Â µ¿¾È, `stabsread.c'´Â ½ÇÁ¦ ÀÛ¾÷À» ÇÑ´Ù.

COFF

The basic COFF definition includes debugging information. The level of support is minimal and non-extensible, and is not often used.

±âº» COFF Á¤ÀÇ´Â µð¹ö±ë Á¤º¸¸¦ Æ÷ÇÔÇÑ´Ù. Áö¿ø ·¹º§Àº ÃÖ¼ÒÀÌ°í ºñ È®ÀåÀ̸ç ÀÚÁÖ »ç¿ëµÇÁö ¾Ê´Â´Ù.

Mips debug (Third Eye)

ECOFF includes a definition of a special debug format.

ECOFF´Â Ưº°ÇÑ µð¹ö±ë Çü½ÄÀÇ Á¤ÀǸ¦ Æ÷ÇÔÇÑ´Ù.

The file `mdebugread.c' implements reading for this format.

ÆÄÀÏ `mdebugread.c'´Â ÀÌ Çü½ÄÀ» À§ÇÑ Àб⸦ ¼öÇàÇÑ´Ù.

DWARF 1

DWARF 1 is a debugging format that was originally designed to be used with ELF in SVR4 systems.

DWARF 1Àº SVR4 ½Ã½ºÅÛ¿¡¼­ ELF¿Í ÇÔ²² »ç¿ëÇϱâ À§ÇØ µðÀÚÀÎµÈ µð¹ö±ë Çü½ÄÀÌ´Ù.

The DWARF 1 reader is in `dwarfread.c'.

DWARF 1 ¸®´õ´Â `dwarfread.c'¿¡ ÀÖ´Ù.

DWARF 2

DWARF 2 is an improved but incompatible version of DWARF 1.

DWARF 2´Â Ç⼧µÇ¾úÁö¸¸ DWARF 1°ú´Â ȣȯµÇÁö ¾Ê´Â´Ù.

The DWARF 2 reader is in `dwarf2read.c'.

DWARF 2 ¸®´õ´Â `dwarf2read.c'¿¡ ÀÖ´Ù.

SOM

Like COFF, the SOM definition includes debugging information.

COFF ó·³, SOM Á¤ÀÇ´Â µð¹ö±ë Á¤º¸¸¦ Æ÷ÇÔÇÑ´Ù.

Adding a New Symbol Reader to GDB

»õ ½Éº¼ ¸®´õ¸¦ GDB¿¡ Ãß°¡½ÃÅ°±â

If you are using an existing object file format (a.out, COFF, ELF, etc), there is probably little to be done.

¸¸ÀÏ ¿©·¯ºÐÀÌ Á¸ÀçÇÏ´Â °´Ã¼ ÆÄÀÏ Çü½Ä(a.out, COFF, ELF µî)À» »ç¿ëÇÑ´Ù¸é, ÇؾßÇÒ°ÍÀÌ ¾Æ¸¶µµ °ÅÀÇ ¾ø´Ù.

If you need to add a new object file format, you must first add it to BFD. This is beyond the scope of this document.

¸¸ÀÏ ¿©·¯ºÐÀÌ »õ·Î¿î °´Ã¼ ÆÄÀÏ Çü½ÄÀ» Ãß°¡ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù¸é, ¿©·¯ºÐÀº ¿ì¼± BFD¿¡ Ãß°¡ÇØ¾ß ÇÑ´Ù. ÀÌ°ÍÀº ÀÌ ¹®¼­ÀÇ ¹üÀ§¸¦ ³Ñ¾î¼±´Ù.

You must then arrange for the BFD code to provide access to the debugging symbols. Generally GDB will have to call swapping routines from BFD and a few other BFD internal routines to locate the debugging information. As much as possible, GDB should not depend on the BFD internal data structures.

¿©·¯ºÐÀº µð¹ö±ë ½Éº¼¿¡ Á¢±ÙÀ» Á¦°øÇϱâ À§ÇØ BFD Äڵ带 Àç¹è¿­ÇØ¾ß ÇÑ´Ù. ÀϹÝÀûÀ¸·Î GDB´Â BFD¿¡¼­ swap ·çƾÀ» È£ÃâÇÏ°í µð¹ö±ë Á¤º¸¸¦ ã±â À§ÇØ ´Ù¸¥ BFD ³»ºÎ ·çƾÀ» È£ÃâÇÑ´Ù. °¡´ÉÇÑ ¸¹ÀÌ, GDB´Â BFD ³»ºÎ µ¥ÀÌÅÍ ±¸Á¶¿¡ ÀÇÁ¸ÇÏÁö ¾Ê¾Æ¾ß ÇÑ´Ù.

For some targets (e.g., COFF), there is a special transfer vector used to call swapping routines, since the external data structures on various platforms have different sizes and layouts. Specialized routines that will only ever be implemented by one object file format may be called directly. This interface should be described in a file `bfd/libxyz.h', which is included by GDB.

¸î¸î Ÿ°Ù(e.g., COFF)¸¦ À§ÇØ, swap ·çƾ È£Ãâ½Ã »ç¿ëÇϴ Ưº°ÇÑ Àü¼Û º¤ÅÍ°¡ ÀÖ´Ù. ¿Ö³ÄÇÏ¸é ´Ù¾çÇÑ Ç÷§Æû¿¡¼­ ³»ºÎ µ¥ÀÌÅÍ ±¸Á¶´Â ´Ù¸¥ Å©±â¿Í ·¹À̾ƿôÀ» °¡Áö°í Àֱ⠶§¹®ÀÌ´Ù. ÇÑ °´Ã¼ ÆÄÀÏ Çü½Ä¿¡ ÀÇÇؼ­ ¼öÇàµÇ´Â ƯÁ¤ ·çƾµéÀº Á÷Á¢ È£ÃâµÈ´Ù. ÀÌ ÀÎÅÍÆäÀ̽º´Â GDB¿¡ Æ÷ÇÔµÈ `bfd/libxyz.h' ÆÄÀϳ»¿¡ ±â¼úµÇ¾î¾ß ÇÑ´Ù.


Go to the first, previous, next, last section, table of contents.