⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.dwarf

📁 早期freebsd实现
💻 DWARF
📖 第 1 页 / 共 2 页
字号:
	LE			    * -----------------> "foobar.c" <---	LE								|	LE								|	LE  <---------------------- *					|	LE			    * -----------------> "foobar.h" <|	|	LE							     |	|	LE							     |	|	LE  <---------------------- *				     |	|	LE			    * ----------------->  "inner.h"  |	|	LE							     |	|	LE  <---------------------- *				     |	|	LE			    * -------------------------------	|	LE								|	LE								|	LE								|	LE								|	LE  <---------------------- *					|	LE			    * -----------------------------------	LE	LE	LEIn effect, each entry in the .debug_srcinfo section points to *both* afilename (in the .debug_sfnames section) and to the start of a block ofconsecutive LEs (in the .line section).Note that just like in the .line section, there are specialized first andlast entries in the .debug_srcinfo section for each object file.  Thesespecial first and last entries for the .debug_srcinfo section are verydifferent from the normal .debug_srcinfo section entries.  They provideadditional information which may be helpful to a debugger when it isinterpreting the data in the .debug_srcinfo, .debug_sfnames, and .linesections.The first entry in the .debug_srcinfo section for each compilation unitconsists of five 4-byte words of data.  The contents of these five wordsshould be interpreted (by debuggers) as follows:	(1)	The starting address (relative to the entire .line section)		of the .line section for this compilation unit.	(2)	The starting address (relative to the entire .debug_sfnames		section) of the .debug_sfnames section for this compilation		unit.	(3)	The starting address (in the execution virtual address space)		of the .text section for this compilation unit.	(4)	The ending address plus one (in the execution virtual address		space) of the .text section for this compilation unit.	(5)	The date/time (in seconds since midnight 1/1/70) at which the		compilation of this compilation unit occurred.  This value		should be interpreted as an unsigned quantity because gcc		might be configured to generate a default value of 0xffffffff		in this field (in cases where it is desired to have object		files created at different times from identical source files		be byte-for-byte identical).  By default, these timestamps		are *not* generated by dwarfout.c (so that object files		compiled at different times will be byte-for-byte identical).		If you wish to enable this "timestamp" feature however, you		can simply place a #define for the symbol `DWARF_TIMESTAMPS'		in your target configuration file and then rebuild the GNU		compiler(s).Note that the first string placed into the .debug_sfnames section for eachcompilation unit is the name of the directory in which compilation occurred.This string ends with a `/' (to help indicate that it is the pathname of adirectory).  Thus, the second word of each specialized initial .debug_srcinfoentry for each compilation unit may be used as a pointer to the (string)name of the compilation directory, and that string may in turn be used to"absolutize" any relative pathnames which may appear later on in the.debug_sfnames section entries for the same compilation unit.The fifth and last word of each specialized starting entry for a compilationunit in the .debug_srcinfo section may (depending upon your configuration)indicate the date/time of compilation, and this may be used (by a debugger)to determine if any of the source files which contributed code to thiscompilation unit are newer than the object code for the compilation unititself.  If so, the debugger may wish to print an "out-of-date" warningabout the compilation unit.The .debug_srcinfo section associated with each compilation will also havea specialized terminating entry.  This terminating .debug_srcinfo sectionentry will consist of the following two 4-byte words of data:	(1)	The offset, measured from the start of the .line section to		the beginning of the terminating entry for the .line section.	(2)	A word containing the value 0xffffffff.--------------------------------In the current DWARF version 1 specification, no mechanism is specified bywhich information about macro definitions and un-definitions may be providedto the DWARF consumer.The DWARF version 2 (draft) specification does specify such a mechanism.That specification was based on the GNU ("vendor specific extension")which provided some support for macro definitions and un-definitions,but the "official" DWARF version 2 (draft) specification mechanism forhandling macros and the GNU implementation have diverged somewhat.  Iplan to update the GNU implementation to conform to the "official"DWARF version 2 (draft) specification as soon as I get time to do that.Note that in the GNU implementation, additional information about macrodefinitions and un-definitions is *only* provided when the -g3 level ofdebug-info production is selected.  (The default level is -g2 and theplain old -g option is considered to be identical to -g2.)GCC records information about macro definitions and undefinitions primarilyin a section called the .debug_macinfo section.  Normal entries in the.debug_macinfo section consist of the following three parts:	(1)	A special "type" byte.	(2)	A 3-byte line-number/filename-offset field.	(3)	A NUL terminated string.The interpretation of the second and third parts is dependent upon thevalue of the leading (type) byte.The type byte may have one of four values depending upon the type of the.debug_macinfo entry which follows.  The 1-byte MACINFO type codes presentlyused, and their meanings are as follows:	MACINFO_start		A base file or an include file starts here.	MACINFO_resume		The current base or include file ends here.	MACINFO_define          A #define directive occurs here.	MACINFO_undef           A #undef directive occur here.(Note that the MACINFO_... codes mentioned here are simply symbolic namesfor constants which are defined in the GNU dwarf.h file.)For MACINFO_define and MACINFO_undef entries, the second (3-byte) fieldcontains the number of the source line (relative to the start of the currentbase source file or the current include files) when the #define or #undefdirective appears.  For a MACINFO_define entry, the following string fieldcontains the name of the macro which is defined, followed by its definition.Note that the definition is always separated from the name of the macroby at least one whitespace character.  For a MACINFO_undef entry, thestring which follows the 3-byte line number field contains just the nameof the macro which is being undef'ed.For a MACINFO_start entry, the 3-byte field following the type byte containsthe offset, relative to the start of the .debug_sfnames section for thecurrent compilation unit, of a string which names the new source file whichis beginning its inclusion at this point.  Following that 3-byte field,each MACINFO_start entry always contains a zero length NUL terminatedstring.For a MACINFO_resume entry, the 3-byte field following the type byte containsthe line number WITHIN THE INCLUDING FILE at which the inclusion of thecurrent file (whose inclusion ends here) was initiated.  Following that3-byte field, each MACINFO_resume entry always contains a zero length NULterminated string.Each set of .debug_macinfo entries for each compilation unit is terminatedby a special .debug_macinfo entry consisting of a 4-byte zero value followedby a single NUL byte.--------------------------------In the current DWARF draft specification, no provision is made for providinga separate level of (limited) debugging information necessary to supporttracebacks (only) through fully-debugged code (e.g. code in system libraries).A proposal to define such a level was submitted (by me) to the UI/PLSIG.This proposal was rejected by the UI/PLSIG for inclusion into the DWARFversion 1 specification for two reasons.  First, it was felt (by the PLSIG)that the issues involved in supporting a "traceback only" subset of DWARFwere not well understood.  Second, and perhaps more importantly, the PLSIGis already having enough trouble agreeing on what it means to be "conformant"to the DWARF specification, and it was felt that trying to specify multipledifferent *levels* of conformance would only complicate our discussions ofthis already divisive issue.  Nonetheless, the GNU implementation of DWARFprovides an abbreviated "traceback only" level of debug-info production foruse with fully-debugged "system library" code.  This level should only beused for fully debugged system library code, and even then, it should onlybe used where there is a very strong need to conserve disk space.  Thisabbreviated level of debug-info production can be used by specifying the-g1 option on the compilation command line.--------------------------------As mentioned above, the GNU implementation of DWARF currently uses the DWARFversion 2 (draft) approach for inline functions (and inlined instancesthereof).  This is used in preference to the version 1 approach because(quite simply) the version 1 approach is highly brain-damaged and probablyunworkable.--------------------------------GNU DWARF Representation of GNU C Extensions to ANSI C------------------------------------------------------The file dwarfout.c has been designed and implemented so as to providesome reasonable DWARF representation for each and every declarativeconstruct which is accepted by the GNU C compiler.  Since the GNU Ccompiler accepts a superset of ANSI C, this means that there are somecases in which the DWARF information produced by GCC must take someliberties in improvising DWARF representations for declarations whichare only valid in (extended) GNU C.In particular, GNU C provides at least three significant extensions toANSI C when it comes to declarations.  These are (1) inline functions,and (2) dynamic arrays, and (3) incomplete enum types.  (See the GCCmanual for more information on these GNU extensions to ANSI C.)  Whenused, these GNU C extensions are represented (in the generated DWARFoutput of GCC) in the most natural and intuitively obvious ways.In the case of inline functions, the DWARF representation is exactly ascalled for in the DWARF version 2 (draft) specification for an identicalfunction written in C++; i.e. we "reuse" the representation of inlinefunctions which has been defined for C++ to support this GNU C extension.In the case of dynamic arrays, we use the most obvious representationalmechanism available; i.e. an array type in which the upper bound ofsome dimension (usually the first and only dimension) is a variablerather than a constant.  (See the DWARF version 1 specification for moredetails.)In the case of incomplete enum types, such types are represented simplyas TAG_enumeration_type DIEs which DO NOT contain either AT_byte_sizeattributes or AT_element_list attributes.--------------------------------Future Directions-----------------The codes, formats, and other paraphernalia necessary to provide propersupport for symbolic debugging for the C++ language are still being workedon by the UI/PLSIG.  The vast majority of the additions to DWARF which willbe needed to completely support C++ have already been hashed out and agreedupon, but a few small issues (e.g. anonymous unions, access declarations)are still being discussed.  Also, we in the PLSIG are still discussingwhether or not we need to do anything special for C++ templates.  (At thistime it is not yet clear whether we even need to do anything special forthese.) Unfortunately, as mentioned above, there are quite a few problems in theg++ front end itself, and these are currently responsible for severlyrestricting the progress which can be made on adding DWARF supportspecifically for the g++ front-end.  Furthermore, Richard Stallman hasexpressed the view that C++ friendships might not be important enough todescribe (in DWARF).  This view directly conflicts with both the DWARFversion 1 and version 2 (draft) specifications, so until this smallmisunderstanding is cleared up, DWARF support for g++ is unlikely.With regard to FORTRAN, the UI/PLSIG has defined what is believed to be acomplete and sufficient set of codes and rules for adequately representingall of FORTRAN 77, and most of Fortran 90 in DWARF.  While some support forthis has been implemented in dwarfout.c, further implementation and testingwill have to await the arrival of the GNU Fortran front-end (which iscurrently in early alpha test as of this writing).GNU DWARF support for other languages (i.e. Pascal and Modula) is a mootissue until there are GNU front-ends for these other languages.GNU DWARF support for DWARF version 2 will probably not be attempted untilsuch time as the version 2 specification is finalized.  (More work needsto be done on the version 2 specification to make the new "abbreviations"feature of version 2 more easily implementable.  Until then, it will bea royal pain the ass to implement version 2 "abbreviations".)  For thetime being, version 2 features will be added (in a version 1 compatiblemanner) when and where these features seem necessary or extremely desirable.As currently defined, DWARF only describes a (binary) language which canbe used to communicate symbolic debugging information from a compilerthrough an assembler and a linker, to a debugger.  There is no clearspecification of what processing should be (or must be) done by theassembler and/or the linker.  Fortunately, the role of the assembleris easily inferred (by anyone knowledgeable about assemblers) just bylooking  at examples of assembly-level DWARF code.  Sadly though, theallowable (or required) processing steps performed by a linker areharder to infer and (perhaps) even harder to agree upon.  There areseveral forms of very useful `post-processing' steps which intelligentlinkers *could* (in theory) perform on object files containing DWARF,but any and all such link-time transformations are currently both disallowedand unspecified.In particular, possible link-time transformations of DWARF code which couldprovide significant benefits include (but are not limited to):	Commonization of duplicate DIEs obtained from multiple input	(object) files.	Cross-compilation type checking based upon DWARF type information	for objects and functions.	Other possible `compacting' transformations designed to save disk	space and to reduce linker & debugger I/O activity.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -