\." $Revision: 1.12 $\." $Date: 2002/01/14 23:40:11 $\."\."\." the following line may be removed if the ff ligature works on your machine.lg 0\." set up heading formats.ds HF 3 3 3 3 3 2 2.ds HP +2 +2 +1 +0 +0.nr Hs 5.nr Hb 5\." ==============================================\." Put current date in the following at each rev.ds vE rev 1.20, 4 Sep 2007\." ==============================================\." ==============================================.ds | |.ds ~ ~.ds ' '.if t .ds Cw \&\f(CW.if n .ds Cw \fB.de Cf \" Place every other arg in Cw font, beginning with first.if \\n(.$=1 \&\*(Cw\\$1\fP.if \\n(.$=2 \&\*(Cw\\$1\fP\\$2.if \\n(.$=3 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP.if \\n(.$=4 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4.if \\n(.$=5 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP.if \\n(.$=6 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6.if \\n(.$=7 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP.if \\n(.$=8 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8.if \\n(.$=9 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8\*(Cw...nr Cl 3.SA 1.TLA Producer Library Interface to DWARF.AF "".AU "David Anderson".PF "'\*(vE '- \\\\nP -''".AS 1This document describes an interface to a library of functionsto create DWARF debugging information entries and DWARF line numberinformation. It does not make recommendations as to how the functionsdescribed in this document should be implemented nor does itsuggest possible optimizations. .PThe document is oriented to creating DWARF version 2.Support for creating DWARF3 is intended but such supportis not yet fully present..P\*(vE .AE.MT 4.H 1 "INTRODUCTION"This document describes an interface to \f(CWlibdwarf\fP, alibrary of functions to provide creation of DWARF debugging informationrecords, DWARF line number information, DWARF address range andpubnames information, weak names information, and DWARF frame description information..H 2 "Copyright"Copyright 1993-2006 Silicon Graphics, Inc.Copyright 2007 David Anderson.Permission is hereby granted tocopy or republish or use any or all of this document withoutrestriction except that when publishing more than a small amountof the documentplease acknowledge Silicon Graphics, Inc and David Anderson.This document is distributed in the hope that it would be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE..H 2 "Purpose and Scope"The purpose of this document is to propose a library of functions to create DWARF debugging information. Reading (consuming) of such records is discussed in a separate document.The functions in this document have mostly been implemented at Silicon Graphicsand are being used by the code generator to provide debugging information.Some functions (and support for some extensions) were providedby Sun Microsystems..PThe focus of this document is the functional interface,and as such, implementation and optimization issues areintentionally ignored..PError handling, error codes, and certain \f(CWLibdwarf\fP codes are discussedin the "\fIA Consumer Library Interface to DWARF\fP", which should be read (or at least skimmed) before reading this document..PHowever the general style of functions here in the producer librar is rather C-traditionalwith various types as return values (quite differentfrom the consumer library interfaces). The stylegenerally follows the style of the original DWARF1 readerproposed as an interface to DWARF.When the style of the reader interfaces was changed (1994) in thedwarf reader ( See the "Document History"section of "A Consumer Library Interface to DWARF")the interfaces here were not changed as it seemed liketoo much of a change for the two applications then usingthe interface! So this interface remains in the traditional C styleof returning various data types with various (somewhat inconsistent)means of indicating failure..H 2 "Document History"This document originally prominently referenced"UNIX International Programming Languages Special Interest Group " (PLSIG).Both UNIX International and theaffiliated Programming Languages Special Interest Groupare defunct(UNIX is a registered trademark of UNIX System Laboratories, Inc.in the United States and other countries).Nothing except the general interface style is actuallyrelated to anything shown to the PLSIG(this document was open sourced with libdwarf in the mid 1990's)..PSee "http://www.dwarfstd.org" for information on currentDWARF standards and committee activities..H 2 "Definitions"DWARF debugging information entries (DIEs) are the segments of information placed in the \f(CW.debug_info\fP and relatedsections by compilers, assemblers, and linkage editors that, in conjunction with line number entries, are necessary for symbolic source-level debugging. Refer to the document "\fIDWARF Debugging Information Format\fP" from UI PLSIG for a more complete description of these entries..PThis document adopts all the terms and definitions in"\fIDWARF Debugging Information Format\fP" version 2.and the "\fIA Consumer Library Interface to DWARF\fP"..PIn addition, this document refers to Elf, the ATT/USL System VRelease 4 object format.This is because the library was first developed for that objectformat.Hopefully the functions defined here can easily beapplied to other object formats..H 2 "Overview"The remaining sections of this document describe a proposed producer (compiler or assembler) interface to \fILibdwarf\fP, first by describing the purpose of additional types defined by the interface, followed by descriptions of the available operations. This document assumes you are thoroughly familiar with the information contained in the \fIDWARF Debugging Information Format\fP document, and "\fIA Consumer Library Interface to DWARF\fP"..PThe interface necessarily knows a little bit about the object format(which is assumed to be Elf). We make an attempt to make this knowledge as limited as possible. For example, \fILibdwarf\fP does not do the writing of object data to the disk. The producer program does that..H 2 "Revision History".VL 15.LI "March 1993"Work on dwarf2 sgi producer draft begins.LI "March 1999"Adding a function to allow any number of tripsthru the dwarf_get_section_bytes() call..LI "April 10 1999"Added support for assembler text output of dwarf(as when the output must pass thru an assembler).Revamped internals for better performance andsimpler provision for differences in ABI..LI "Sep 1, 1999"Added support for little- and cross- endiandebug info creation..LI "May 7 2007"This library interface now cleans up, deallocatingall memory it uses (the application simply callsdwarf_producer_finish(dbg))..LE.H 1 "Type Definitions".H 2 "General Description"The \fIlibdwarf.h\fP header file contains typedefs and preprocessor definitions of types and symbolic names used to reference objects of \fI Libdwarf \fP . The types defined by typedefs contained in \fI libdwarf.h\fP all use the convention of adding \fI Dwarf_ \fP as a prefix toindicate that they refer to objects used by Libdwarf. The prefix \fI Dwarf_P_\fP is used for objects referenced by the \fI Libdwarf\fP Producer when there are similar but distinct objects used by the Consumer..H 2 "Namespace issues"Application programs should avoid creating namesbeginning with \f(CWDwarf_\fP\f(CWdwarf_\fPor \f(CWDW_\fPas these are reserved to dwarf and libdwarf..H 1 "libdwarf and Elf and relocations"Much of the description below presumes that Elf is the objectformat in use.The library is probably usable with other object formatsthat allow arbitrary sections to be created..H 2 "binary or assembler output"With \f(CWDW_DLC_STREAM_RELOCATIONS\fP (see below)it is assumed that the calling app will simplywrite the streams and relocations directly intoan Elf file, without going thru an assembler.With \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP the calling app must either A) generate binary relocation streams and writethe generated debug information streams andthe relocation streams direct to an elf fileorB) generate assembler output text for an assemblerto read and produce an object file. With case B) the libdwarf-calling application mustuse the relocation information to changepoints of each binary stream into references to symbolic names. It is necessary for the assembler to bewilling to accept and generate relocationsfor references from arbitrary byte boundaries.For example:.sp.nf.in +4 .data 0a0bcc #producing 3 bytes of data. .word mylabel #producing a reference .word endlabel - startlable #producing absolute length.in -4.fi.sp.H 2 "libdwarf relationship to Elf"When the documentation below refers to 'an elf section number'it is really only dependent on getting (via the callbackfunction passed by the caller of\f(CWdwarf_producer_init()\fP)a sequence of integers back (with 1 as the lowest).When the documentation below refers to 'an Elf symbol index'it is really dependent on Elf symbol numbersonly if\f(CWDW_DLC_STREAM_RELOCATIONS\fP are being generated (see below).With \f(CWDW_DLC_STREAM_RELOCATIONS\fP the library is generating Elf relocationsand the section numbers in binary form sothe section numbers and symbol indices must really be Elf (or elf-like) numbers.With\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP the values passed as symbol indexes can be anyinteger set or even pointer set.All that libdwarf assumes is that where valuesare unique they get unique values.Libdwarf does not generate any kind of symbol tablefrom the numbers and does not check theiruniqueness or lack thereof..H 2 "libdwarf and relocations"With\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP libdwarf creates binary streams of debug informationand arrays of relocation information describingthe necessary relocation.The Elf section numbers and symbol numbers appearnowhere in the binary streams. Such appearonly in the relocation information and the passed-backinformation from calls requesting the relocation information.As a consequence, the 'symbol indices' can beany pointer or integer value as the caller mustarrange that the output deal with relocations.With \f(CWDW_DLC_STREAM_RELOCATIONS\fP all the relocations are directly created by libdwarfas binary streams (libdwarf only creates the streamsin memory,it does not write them to disk)..H 2 "symbols, addresses, and offsets"The following applies to calls thatpass in symbol indices, addresses, and offsets, suchas\f(CWdwarf_add_AT_targ_address() \fP \f(CWdwarf_add_arange_b()\fP and\f(CWdwarf_add_frame_fde_b()\fP.With \f(CWDW_DLC_STREAM_RELOCATIONS\fP a passed in address is one of:a) a section offset and the (non-global) symbol index ofa section symbol.b) A symbol index (global symbol) and a zero offset.With \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fPthe same approach can be used, or, instead,a passed in address may bec) a symbol handle and an offset.In this case, since it is up to the calling app togenerate binary relocations (if appropriate)or to turn the binary stream into a text stream (for input to an assembler, if appropriate)the application has complete control of the interpretationof the symbol handles..H 1 "Memory Management"Several of the functions that comprise the \fILibdwarf\fP producer interface dynamically allocate values and somereturn pointers to those spaces.The dynamically allocated spaces can not be reclaimed (and mustnot be freed) except by \f(CWdwarf_producer_finish(dbg)\fP. All data for a particular \f(CWDwarf_P_Debug\fP descriptoris separate from the data for any other \f(CWDwarf_P_Debug\fP descriptor in use in the library-callingapplication..H 2 "Read-only Properties"All pointers returned by or as a result of a \fILibdwarf\fP call should be assumed to point to read-only memory. Except as defined by this document, the results are undefined for \fILibdwarf\fP clients that attempt to write to a region pointed to by a return value from a \fILibdwarf\fP call..H 2 "Storage Deallocation"Calling \f(CWdwarf_producer_finish(dbg)\fP frees all the space, and invalidates all pointers returned from \f(CWLibdwarf\fP functions on or descended from \f(CWdbg\fP)..H 1 "Functional Interface"This section describes the functions available in the \fILibdwarf\fPlibrary. Each function description includes its definition, followed by a paragraph describing the function's operation..PThe functions may be categorized into groups: \fIinitialization and termination operations\fP,\fIdebugging information entry creation\fP,\fIElf section callback function\fP,\fIattribute creation\fP,\fIexpression creation\fP, \fIline number creation\fP, \fIfast-access (aranges) creation\fP, \fIfast-access (pubnames) creation\fP, \fIfast-access (weak names) creation\fP,\fImacro information creation\fP, \fIlow level (.debug_frame) creation\fP, and\fIlocation list (.debug_loc) creation\fP. .PThe following sections describe these functions..H 2 "Initialization and Termination Operations"These functions setup \f(CWLibdwarf\fP to accumulate debugging informationfor an object, usually a compilation-unit, provided by the producer.The actual addition of information is done by functions in the othersections of this document. Once all the information has been added,functions from this section are used to transform the information toappropriate byte streams, and help to write out the byte streams todisk.Typically then, a producer application would create a \f(CWDwarf_P_Debug\fP descriptor to gather debugging information for a particularcompilation-unit using \f(CWdwarf_producer_init()\fP. The producer application would use this \f(CWDwarf_P_Debug\fP descriptor to accumulate debugging information for this object using functions from other sections of this document. Once all the information had been added, it would call \f(CWdwarf_transform_to_disk_form()\fP to convert the accumulated information into byte streams in accordance with the \f(CWDWARF\fP standard. The application would then repeatedly call \f(CWdwarf_get_section_bytes()\fP for each of the \f(CW.debug_*\fP created. This gives the producer information about the data bytes to be written to disk. At this point, the producer would release all resource used by \f(CWLibdwarf\fP for this object by calling \f(CWdwarf_producer_finish()\fP.It is also possible to create assembler-input character streamsfrom the byte streams created by this library.This feature requires slightly different interfaces thandirect binary output.The details are mentioned in the text..H 3 "dwarf_producer_init()".DS\f(CWDwarf_P_Debug dwarf_producer_init( Dwarf_Unsigned flags, Dwarf_Callback_Func func, Dwarf_Handler errhand, Dwarf_Ptr errarg, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_producer_init() \fP returns a new \f(CWDwarf_P_Debug\fP descriptor that can be used to add \f(CWDwarf\fP information to the object. On error it returns \f(CWDW_DLV_BADADDR\fP. \f(CWflags\fP determine whether the target object is 64-bit or 32-bit. \f(CWfunc\fP is a pointer to a function called-back from \f(CWLibdwarf\fP whenever \f(CWLibdwarf\fP needs to create a new object section (as it will for each .debug_* section and related relocation section). \f(CWerrhand\fP is a pointer to a function that will be used for handling errors detected by \f(CWLibdwarf\fP. \f(CWerrarg\fP is the default error argument used by the function pointed to by \f(CWerrhand\fP..PThe \f(CWflags\fPvalues are as follows:.in +4\f(CWDW_DLC_WRITE\fP is required.The values\f(CWDW_DLC_READ\fP \f(CWDW_DLC_RDWR\fPare not supported by the producer and must not be passed.If \f(CWDW_DLC_SIZE_64\fPis not OR'd into \f(CWflags\fPthen\f(CWDW_DLC_SIZE_32\fPis assumed.Oring in both is an error.If\f(CWDW_DLC_ISA_IA64\fPis not OR'd into \f(CWflags\fPthen \f(CWDW_DLC_ISA_MIPS\fPis assumed.Oring in both is an error.If\f(CWDW_DLC_TARGET_BIGENDIAN\fPis not OR'd into \f(CWflags\fPthen endianness the same as the host is assumed.If\f(CWDW_DLC_TARGET_LITTLEENDIAN\fPis not OR'd into \f(CWflags\fPthen endianness the same as the host is assumed.If both \f(CWDW_DLC_TARGET_LITTLEENDIAN\fPand\f(CWDW_DLC_TARGET_BIGENDIAN\fPare or-d in it is an error.Either one of two output forms is specifiable:\f(CWDW_DLC_STREAM_RELOCATIONS\fP or\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP .The default is\f(CWDW_DLC_STREAM_RELOCATIONS\fP . The\f(CWDW_DLC_STREAM_RELOCATIONS\fPare relocations in a binary stream (as usedin a MIPS Elf object).The\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fPare the same relocations but expressed in anarray of structures defined by libdwarf,which the caller of the relevant function(see below) must deal with appropriately.This method of expressing relocations allows the producer-application to easily produceassembler text output of debugging information.If\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fPis OR'd into \f(CWflags\fPthen relocations are returned not as streamsbut thru an array of structures..in -4.PThe function \f(CWfunc\fP must be provided by the user of this library.Its prototype is:.DS\f(CWtypedef int (*Dwarf_Callback_Func)( char* name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info, int* sect_name_index, int* error) \fP.DEFor each section in the object file that \f(CWlibdwarf\fPneeds to create, it calls this function once, passing inthe section \f(CWname\fP, the section \f(CWtype\fP,the section \f(CWflags\fP, the \f(CWlink\fP field, andthe \f(CWinfo\fP field. For an Elf object file these valuesshould be appropriate Elf section header values.For example, for relocation callbacks, the \f(CWlink\fPfield is supposed to be set (by the app) to the indexof the symtab section (the link field passed thru thecallback must be ignored by the app).And, for relocation callbacks, the \f(CWinfo\fP fieldis passed as the elf section number of the sectionthe relocations apply to.On successthe user function should return the Elf section number of thenewly created Elf section..POn success, the function should also set the integerpointed to by \f(CWsect_name_index\fP to theElf symbol number assigned in the Elf symbol table of thenew Elf section.This symbol number is needed with relocationsdependent on the relocation of this new section.Because "int *" is not guaranteed to work with elf 'symbols'that are really pointers,It is better to use the \f(CWdwarf_producer_init_b()\fPinterface..PFor example, the \f(CW.debug_line\fP section's thirddata element (in a compilation unit) is the offset from thebeginning of the \f(CW.debug_info\fP section of the compilationunit entry for this \f(CW.debug_line\fP set.The relocation entry in \f(CW.rel.debug_line\fPfor this offsetmust have the relocation symbol index of the symbol \f(CW.debug_info\fP returnedby the callback of that section-creation through the pointer \f(CWsect_name_index\fP..POn failure, the function should return -1 and set the \f(CWerror\fPinteger to an error code..PNothing in libdwarf actually depends on the section indexreturned being a real Elf section.The Elf section is simply useful for generating relocationrecords.Similarly, the Elf symbol table index returned thru the \f(CWsect_name_index\fP must simply be an indexthat can be used in relocations against this section.The application will probably want to note thevalues passed to this function in some form, even ifno Elf file is being produced..H 3 "dwarf_producer_init_b()".DS\f(CWDwarf_P_Debug dwarf_producer_init_b( Dwarf_Unsigned flags, Dwarf_Callback_Func_b func, Dwarf_Handler errhand, Dwarf_Ptr errarg, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_producer_init_b() \fP is the same as \f(CWdwarf_producer_init() \fPexcept that the callback function usesDwarf_Unsigned rather than int as thetype of the symbol-index returned to libdwarfthru the pointer argument (see below)..PThe \f(CWflags\fPvalues are as follows:.in +4\f(CWDW_DLC_WRITE\fP is required.The values\f(CWDW_DLC_READ\fP \f(CWDW_DLC_RDWR\fPare not supported by the producer and must not be passed.If \f(CWDW_DLC_SIZE_64\fPis not OR'd into \f(CWflags\fPthen\f(CWDW_DLC_SIZE_32\fPis assumed.Oring in both is an error.If\f(CWDW_DLC_ISA_IA64\fPis not OR'd into \f(CWflags\fPthen \f(CWDW_DLC_ISA_MIPS\fPis assumed.Oring in both is an error.Either one of two output forms are specifiable:\f(CWDW_DLC_STREAM_RELOCATIONS\fPor\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP .\f(CWdwarf_producer_init_b() \fP is usable witheither output form.Either one of two output forms is specifiable:\f(CWDW_DLC_STREAM_RELOCATIONS\fPor\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP .The default is\f(CWDW_DLC_STREAM_RELOCATIONS\fP .The\f(CWDW_DLC_STREAM_RELOCATIONS\fPare relocations in a binary stream (as usedin a MIPS Elf object).\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fPare OR'd into flagsto cause the same relocations to be expressed in anarray of structures defined by libdwarf,which the caller of the relevant function(see below) must deal with appropriately.This method of expressing relocations allowsthe producer-application to easily produceassembler text output of debugging information..in -4.PThe function \f(CWfunc\fP must be provided by the user of this library.Its prototype is:.DS\f(CWtypedef int (*Dwarf_Callback_Func_b)( char* name, int size, Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info, Dwarf_Unsigned* sect_name_index, int* error) \fP.DEFor each section in the object file that \f(CWlibdwarf\fPneeds to create, it calls this function once, passing inthe section \f(CWname\fP, the section \f(CWtype\fP,the section \f(CWflags\fP, the \f(CWlink\fP field, andthe \f(CWinfo\fP field. For an Elf object file these valuesshould be appropriate Elf section header values.For example, for relocation callbacks, the \f(CWlink\fPfield is supposed to be set (by the app) to the indexof the symtab section (the link field passed thru thecallback must be ignored by the app).And, for relocation callbacks, the \f(CWinfo\fP fieldis passed as the elf section number of the sectionthe relocations apply to.On successthe user function should return the Elf section number of thenewly created Elf section..POn success, the function should also set the integerpointed to by \f(CWsect_name_index\fP to theElf symbol number assigned in the Elf symbol table of thenew Elf section.This symbol number is needed with relocationsdependent on the relocation of this new section..PFor example, the \f(CW.debug_line\fP section's thirddata element (in a compilation unit) is the offset from thebeginning of the \f(CW.debug_info\fP section of the compilationunit entry for this \f(CW.debug_line\fP set.The relocation entry in \f(CW.rel.debug_line\fPfor this offsetmust have the relocation symbol index of the symbol \f(CW.debug_info\fP returnedby the callback of that section-creation through the pointer \f(CWsect_name_index\fP..POn failure, the function should return -1 and set the \f(CWerror\fPinteger to an error code..PNothing in libdwarf actually depends on the section indexreturned being a real Elf section.The Elf section is simply useful for generating relocationrecords.Similarly, the Elf symbol table index returned thru the \f(CWsect_name_index\fP must simply be an indexthat can be used in relocations against this section.The application will probably want to note thevalues passed to this function in some form, even ifno Elf file is being produced.Note that the \f(CWDwarf_Callback_Func_b() \fP formpasses back the sect_name_index as a Dwarf_Unsigned.This is guaranteed large enough to hold a pointer.(the other functional interfaces have versions withthe 'symbol index' as a Dwarf_Unsigned too. See below).If \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fPis in use, then the symbol index is simply an arbitraryvalue (from the point of view of libdwarf) so thecaller can put anything in it:a normal elf symbol index,a pointer to a struct (with arbitrary contents)(the caller must cast to/from Dwarf_Unsigned as appropriate), or some other kind of pointer or value.The values show up in the output of \f(CWdwarf_get_relocation_info()\fP(described below) and are not emitted anywhere else..H 3 "dwarf_transform_to_disk_form()".DS\f(CWDwarf_Signed dwarf_transform_to_disk_form( Dwarf_P_Debug dbg, Dwarf_Error* error) \fP.DEThe function \f(CWdwarf_transform_to_disk_form() \fP does the actualconversion of the \f(CWDwarf\fP information provided so far, to theform that is normally written out as \f(CWElf\fP sections. In other words, once all DWARF information has been passed to \f(CWLibdwarf\fP, call \f(CWdwarf_transform_to_disk_form() \fP to transform all the accumulated data into byte streams. This includes turning relocation information into byte streams (and possibly relocation arrays). This function does not write anything to disk. If successful, it returns a count of the number of \f(CWElf\fP sections ready to be retrieved (and, normally, written to disk).In case of error, it returns \f(CWDW_DLV_NOCOUNT\fP..H 3 "dwarf_get_section_bytes()".DS\f(CWDwarf_Ptr dwarf_get_section_bytes( Dwarf_P_Debug dbg, Dwarf_Signed dwarf_section, Dwarf_Signed *elf_section_index, Dwarf_Unsigned *length, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_get_section_bytes() \fP must be called repetitively, with the index \f(CWdwarf_section\fP starting at 0 and continuing for the number of sections returned by \f(CWdwarf_transform_to_disk_form() \fP.It returns \f(CWNULL\fP to indicate that there are no more sections of \f(CWDwarf\fP information. For each non-NULL return, the return valuepoints to \f(CW*length\fP bytes of data that are normallyadded to the output object in \f(CWElf\fP section \f(CW*elf_section\fP by the producer application.It is illegal to call these in any order other than 0 thru N-1 whereN is the number of dwarf sectionsreturned by \f(CWdwarf_transform_to_disk_form() \fP.The \f(CWdwarf_section\fPnumber is actually ignored: the data is returned as if thecaller passed in the correct dwarf_section numbers in therequired sequence.The \f(CWerror\fP argument is not used..PThere is no requirement that the section bytes actually be written to an elf file.For example, consider the .debug_info section and itsrelocation section (the call back function would resulted inassigning 'section' numbers and the link field to tie thesetogether (.rel.debug_info would have a link to .debug_info).One could examine the relocations, split the .debug_infodata at relocation boundaries, emit byte streams (in hex)as assembler output, and at each relocation point,emit an assembler directive with a symbol name for the assembler.Examining the relocations is awkward though. It is much better to use \f(CWdwarf_get_section_relocation_info() \fP.PThe memory space of the section byte stream is freedby the \f(CWdwarf_producer_finish() \fP call(or would be if the \f(CWdwarf_producer_finish() \fPwas actually correct), alongwith all the other space in use with that Dwarf_P_Debug..H 3 "dwarf_get_relocation_info_count()".DS\f(CWint dwarf_get_relocation_info_count( Dwarf_P_Debug dbg, Dwarf_Unsigned *count_of_relocation_sections , int *drd_buffer_version, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_get_relocation_info() \fPreturns, thru the pointer \f(CWcount_of_relocation_sections\fP, thenumber of times that \f(CWdwarf_get_relocation_info() \fPshould be called.The function \f(CWdwarf_get_relocation_info() \fPreturns DW_DLV_OK if the call was successful (the \f(CWcount_of_relocation_sections\fP is therefore meaningful,though \f(CWcount_of_relocation_sections\fPcould be zero).\f(CW*drd_buffer_version\fPis the value 2.If the structure pointed to bythe \f(CW*reldata_buffer\fPchanges this number will change.The application should verify that the number isthe version it understands (that it matchesthe value of DWARF_DRD_BUFFER_VERSION (from libdwarf.h)).The value 1 version was never used in production MIPS libdwarf (version 1 did exist in source).It returns DW_DLV_NO_ENTRY if \f(CWcount_of_relocation_sections\fP is not meaningfulbecause \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP was notpassed in the \f(CWdwarf_producer_init() \fP(or\f(CWdwarf_producer_init_b() \fP ) call.It returns DW_DLV_ERROR if there was an error,in which case\f(CWcount_of_relocation_sections\fP is not meaningful..H 3 "dwarf_get_relocation_info()".DS\f(CWint dwarf_get_relocation_info( Dwarf_P_Debug dbg, Dwarf_Signed *elf_section_index, Dwarf_Signed *elf_section_index_link, Dwarf_Unsigned *relocation_buffer_count, Dwarf_Relocation_Data *reldata_buffer, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_get_relocation_info() \fP should normally be called repetitively, for the number of relocation sections that \f(CWdwarf_get_relocation_info_count() \fPindicated exist.It returns \f(CWDW_DLV_OK\fP to indicate that valid values are returned thru the pointer arguments.The \f(CWerror\fP argument is not set.It returns DW_DLV_NO_ENTRY if there are no entries(the count of relocation arrays is zero.).The \f(CWerror\fP argument is not set.It returns \f(CWDW_DLV_ERROR\fP if there is an error.Calling \f(CWdwarf_get_relocation_info() \fPmore than the number of times indicated by\f(CWdwarf_get_relocation_info_count() \fP(without an intervening call to\f(CWdwarf_reset_section_bytes() \fP )results in a return of \f(CWDW_DLV_ERROR\fP once pastthe valid count.The \f(CWerror\fP argument is set to indicate the error.Now consider the returned-thru-pointer values for\f(CWDW_DLV_OK\fP .\f(CW*elf_section_index\fPis the 'elf section index' of the section implied bythis group of relocations.\f(CW*elf_section_index_link\fPis the section index of the section that theserelocations apply to.\f(CW*relocation_buffer_count\fPis the number of array entries of relocation informationin the array pointed to by\f(CW*reldata_buffer\fP .\f(CW*reldata_buffer\fPpoints to an array of 'struct Dwarf_Relocation_Data_s'structures.The version 2 array information is as follows:.nfenum Dwarf_Rel_Type {dwarf_drt_none, dwarf_drt_data_reloc, dwarf_drt_segment_rel, dwarf_drt_first_of_length_pair, dwarf_drt_second_of_length_pair};typedef struct Dwarf_Relocation_Data_s * Dwarf_Relocation_Data;struct Dwarf_Relocation_Data_s { unsigned char drd_type; /* contains Dwarf_Rel_Type */ unsigned char drd_length; /* typically 4 or 8 */ Dwarf_Unsigned drd_offset; /* where the data to reloc is */ Dwarf_Unsigned drd_symbol_index;};.fiThe \f(CWDwarf_Rel_Type\fP enum is encoded (via casts if necessary)into the single unsigned char \f(CWdrd_type\fP field to controlthe space used for this information (keep the space to 1 byte).The unsigned char \f(CWdrd_length\fP fieldholds the size in bytes of the field to be relocated.So for elf32 object formats with 32 bit apps, \f(CWdrd_length\fPwill be 4. For objects with MIPS -64 contents,\f(CWdrd_length\fP will be 8. For some dwarf 64 bit environments, such as ia64, \f(CWdrd_length\fPis 4 for some relocations (file offsets, for example) and 8 for others (run timeaddresses, for example).If \f(CWdrd_type\fP is \f(CWdwarf_drt_none\fP, this is an unused slotand it should be ignored.If \f(CWdrd_type\fP is \f(CWdwarf_drt_data_reloc\fP this is an ordinary relocation.The relocation type means either(R_MIPS_64) or (R_MIPS_32) (or the like forthe particular ABI.f(CWdrd_length\fP gives the length of the field to be relocated.\f(CWdrd_offset\fP is an offset (of thevalue to be relocated) inthe section this relocation stuff is linked to.\f(CWdrd_symbol_index\fP is the symbol index (if elf symbolindices were provided) or the handle to arbitraryinformation (if that is what the caller passed in to the relocation-creating dwarf calls) of the symbolthat the relocation is relative to.When \f(CWdrd_type\fP is \f(CWdwarf_drt_first_of_length_pair\fPthe next data record will be \f(CWdrt_second_of_length_pair\fPand the \f(CWdrd_offset\fP of the two data records will match.The relevant 'offset' in the section this reloc applies toshould contain a symbolic pair like.nf.in +4 .word second_symbol - first_symbol.in -4.fito generate a length.\f(CWdrd_length\fP gives the length of the field to be relocated.\f(CWdrt_segment_rel\fP means (R_MIPS_SCN_DISP)is the real relocation (R_MIPS_SCN_DISP applies toexception tables and this part may need further work).\f(CWdrd_length\fP gives the length of the field to be relocated..PThe memory space of the section byte stream is freedby the \f(CWdwarf_producer_finish() \fP call(or would be if the \f(CWdwarf_producer_finish() \fPwas actually correct), alongwith all the other space in use with that Dwarf_P_Debug..H 3 "dwarf_reset_section_bytes()".DS\f(CWvoid dwarf_reset_section_bytes( Dwarf_P_Debug dbg ) \fP.DEThe function \f(CWdwarf_reset_section_bytes() \fP is used to reset the internal information so that\f(CWdwarf_get_section_bytes() \fP will begin (on the nextcall) at the initial dwarf section again.It also resets so that calls to \f(CWdwarf_get_relocation_info() \fPwill begin again at the initial array of relocation information.Some dwarf producers need to be able to run thruthe \f(CWdwarf_get_section_bytes()\fPand/orthe \f(CWdwarf_get_relocation_info()\fPcalls more than once and this call makes additional passes possible.The set of Dwarf_Ptr values returned is identical to theset returned by the first pass.It is acceptable to call this before finishing a passof \f(CWdwarf_get_section_bytes()\fPor\f(CWdwarf_get_relocation_info()\fPcalls.No errors are possible as this just resets someinternal pointers.It is unwise to call this before\f(CWdwarf_transform_to_disk_form() \fP has been called..P.H 3 "dwarf_producer_finish()".DS\f(CWDwarf_Unsigned dwarf_producer_finish( Dwarf_P_Debug dbg, Dwarf_Error* error) \fP.DEThe function \f(CWdwarf_producer_finish() \fP should be called after all the bytes of data have been copied somewhere(normally the bytes are written to disk). It frees all dynamic space allocated for \f(CWdbg\fP, include space for the structure pointed to by\f(CWdbg\fP. This should not be called till the data have been copied or written to disk or are no longer of interest. It returns non-zero if successful, and \f(CWDW_DLV_NOCOUNT\fP if there is an error..H 2 "Debugging Information Entry Creation"The functions in this section add new \f(CWDIE\fPs to the object,and also the relationships among the \f(CWDIE\fP to be specifiedby linking them up as parents, children, left or right siblingsof each other. In addition, there is a function that marks theroot of the graph thus created..H 3 "dwarf_add_die_to_debug()".DS\f(CWDwarf_Unsigned dwarf_add_die_to_debug( Dwarf_P_Debug dbg, Dwarf_P_Die first_die, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_die_to_debug() \fP indicates to \f(CWLibdwarf\fPthe root \f(CWDIE\fP of the \f(CWDIE\fP graph that has been built so far. It is intended to mark the compilation-unit \f(CWDIE\fP for the object represented by \f(CWdbg\fP. The root \f(CWDIE\fP is specified by \f(CWfirst_die\fP.It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_new_die()".DS\f(CWDwarf_P_Die dwarf_new_die( Dwarf_P_Debug dbg, Dwarf_Tag new_tag, Dwarf_P_Die parent, Dwarf_P_Die child, Dwarf_P_Die left_sibling, Dwarf_P_Die right_sibling, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_new_die() \fP creates a new \f(CWDIE\fP withits parent, child, left sibling, and right sibling \f(CWDIE\fPsspecified by \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,and \f(CWright_sibling\fP, respectively. There is no requirementthat all of these \f(CWDIE\fPs be specified, i.e. any of thesedescriptors may be \f(CWNULL\fP. If none is specified, this willbe an isolated \f(CWDIE\fP. A \f(CWDIE\fP is transformed to disk form by \f(CWdwarf_transform_to_disk_form() \fP only if there is a path fromthe \f(CWDIE\fP specified by \f(CWdwarf_add_die_to_debug\fP to it.This function returns \f(CWDW_DLV_BADADDR\fP on error.\f(CWnew_tag\fP is the tag which is given to the new \f(CWDIE\fP.\f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP, and\f(CWright_sibling\fP are pointers to establish links to existing \f(CWDIE\fPs. Only one of \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP, and \f(CWright_sibling\fP may be non-NULL.If \f(CWparent\fP (\f(CWchild\fP) is given, the \f(CWDIE\fP is linked into the list after (before) the \f(CWDIE\fP pointed to. If \f(CWleft_sibling\fP (\f(CWright_sibling\fP) is given, the \f(CWDIE\fP is linked into the list after (before) the \f(CWDIE\fP pointed to.To add attributes to the new \f(CWDIE\fP, use the \f(CWAttribute Creation\fP functions defined in the next section..H 3 "dwarf_die_link()".DS\f(CWDwarf_P_Die dwarf_die_link( Dwarf_P_Die die, Dwarf_P_Die parent, Dwarf_P_Die child, Dwarf_P_Die left-sibling, Dwarf_P_Die right_sibling, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_die_link() \fP links an existing \f(CWDIE\fPdescribed by the given \f(CWdie\fP to other existing \f(CWDIE\fPs.The given \f(CWdie\fP can be linked to a parent \f(CWDIE\fP, a child\f(CWDIE\fP, a left sibling \f(CWDIE\fP, or a right sibling \f(CWDIE\fPby specifying non-NULL \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,and \f(CWright_sibling\fP \f(CWDwarf_P_Die\fP descriptors. It returnsthe given \f(CWDwarf_P_Die\fP descriptor, \f(CWdie\fP, on success,and \f(CWDW_DLV_BADADDR\fP on error.Only one of \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,and \f(CWright_sibling\fP may be non-NULL. If \f(CWparent\fP(\f(CWchild\fP) is given, the \f(CWDIE\fP is linked into the list after (before) the \f(CWDIE\fP pointed to. If \f(CWleft_sibling\fP(\f(CWright_sibling\fP) is given, the \f(CWDIE\fP is linked into the list after (before) the \f(CWDIE\fP pointed to. Non-NULL linksoverwrite the corresponding links the given \f(CWdie\fP may havehad before the call to \f(CWdwarf_die_link() \fP..H 2 "Attribute Creation"The functions in this section add attributes to a \f(CWDIE\fP.These functions return a \f(CWDwarf_P_Attribute\fP descriptor that represents the attribute added to the given \f(CWDIE\fP. In most cases the return value is only useful to determine if an error occurred.Some of the attributes have values that are relocatable. Theyneed a symbol with respect to which the linker will performrelocation. This symbol is specified by means of an index intothe Elf symbol table for the object(of course, the symbol index can be more general than an index)..H 3 "dwarf_add_AT_location_expr()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_location_expr( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_P_Expr loc_expr, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_location_expr() \fP adds the attributespecified by \f(CWattr\fP to the \f(CWDIE\fP descriptor given by\f(CWownerdie\fP. The attribute should be one that has a locationexpression as its value. The location expression that is the valueis represented by the \f(CWDwarf_P_Expr\fP descriptor \f(CWloc_expr\fP.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributegiven, on success. On error it returns \f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_name()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_name( Dwarf_P_Die ownerdie, char *name, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_name() \fP adds the string specifiedby \f(CWname\fP as the value of the \f(CWDW_AT_name\fP attributefor the given \f(CWDIE\fP, \f(CWownerdie\fP. It returns the \f(CWDwarf_P_attribute\fP descriptor for the \f(CWDW_AT_name\fP attribute on success. On error, it returns \f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_comp_dir()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_comp_dir( Dwarf_P_Die ownerdie, char *current_working_directory, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_comp_dir() \fP adds the string given by\f(CWcurrent_working_directory\fP as the value of the \f(CWDW_AT_comp_dir\fPattribute for the \f(CWDIE\fP described by the given \f(CWownerdie\fP. It returns the \f(CWDwarf_P_Attribute\fP for this attribute on success.On error, it returns \f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_producer()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_producer( Dwarf_P_Die ownerdie, char *producer_string, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_producer() \fP adds the string given by\f(CWproducer_string\fP as the value of the \f(CWDW_AT_producer\fPattribute for the \f(CWDIE\fP given by \f(CWownerdie\fP. It returnsthe \f(CWDwarf_P_Attribute\fP descriptor representing this attributeon success. On error, it returns \f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_const_value_signedint()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_signedint( Dwarf_P_Die ownerdie, Dwarf_Signed signed_value, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_const_value_signedint() \fP adds thegiven \f(CWDwarf_Signed\fP value \f(CWsigned_value\fP as the valueof the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fPdescribed by the given \f(CWownerdie\fP. It returns the \f(CWDwarf_P_Attribute\fP descriptor for this attribute on success. On error, it returns \f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_const_value_unsignedint()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_unsignedint( Dwarf_P_Die ownerdie, Dwarf_Unsigned unsigned_value, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_const_value_unsignedint() \fP adds thegiven \f(CWDwarf_Unsigned\fP value \f(CWunsigned_value\fP as the valueof the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP described by the given \f(CWownerdie\fP. It returns the \f(CWDwarf_P_Attribute\fPdescriptor for this attribute on success. On error, it returns\f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_const_value_string()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_string( Dwarf_P_Die ownerdie, char *string_value, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_const_value_string() \fP adds the string value given by \f(CWstring_value\fP as the value of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP described by the given \f(CWownerdie\fP. It returns the \f(CWDwarf_P_Attribute\fPdescriptor for this attribute on success. On error, it returns\f(CWDW_DLV_BADADDR\fP..H 3 "dwarf_add_AT_targ_address()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_targ_address( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Unsigned pc_value, Dwarf_Signed sym_index, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_targ_address() \fP adds an attribute thatbelongs to the "address" class to the die specified by \f(CWownerdie\fP. The attribute is specified by \f(CWattr\fP, and the object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The relocatable address that is the value of the attribute is specified by \f(CWpc_value\fP. The symbol to be used for relocation is specified by the \f(CWsym_index\fP,which is the index of the symbol in the Elf symbol table.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_AT_targ_address_b()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_targ_address_b( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_targ_address_b() \fP is identical to \f(CWdwarf_add_AT_targ_address_b() \fPexcept that \f(CWsym_index() \fP is guaranteed to be large enough that it can contain a pointer toarbitrary data (so the caller can pass in a real elfsymbol index, an arbitrary number, or a pointerto arbitrary data). The ability to pass in a pointer thru \f(CWsym_index() \fPis only usable with \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.The \f(CWpc_value\fPis put into the section stream output andthe \f(CWsym_index\fP is applied to the relocationinformation.Do not use this function for attr \f(CWDW_AT_high_pc\fPif the value to be recorded is an offset (not a pc)[ use \f(CWdwarf_add_AT_unsigned_const()\fP (for example)instead]..H 3 "dwarf_add_AT_dataref()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_dataref( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error) \fP.DEThis is very similar to \f(CWdwarf_add_AT_targ_address_b() \fPbut results in a different FORM (results in DW_FORM_data4or DW_FORM_data8).Useful for adding relocatable addresses in location lists.\f(CWsym_index() \fP is guaranteed tobe large enough that it can contain a pointer toarbitrary data (so the caller can pass in a real elfsymbol index, an arbitrary number, or a pointerto arbitrary data).The ability to pass in a pointer thru \f(CWsym_index() \fPis only usable with\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.The \f(CWpc_value\fPis put into the section stream output andthe \f(CWsym_index\fP is applied to the relocationinformation.Do not use this function for \f(CWDW_AT_high_pc\fP, use\f(CWdwarf_add_AT_unsigned_const()\fP [ (for example)if the value to be recorded isan offset of \f(CWDW_AT_low_pc\fP]or \f(CWdwarf_add_AT_targ_address_b()\fP [ if the valueto be recorded is an address]..H 3 "dwarf_add_AT_ref_address()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_ref_address( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Unsigned pc_value, Dwarf_Unsigned sym_index, Dwarf_Error *error) \fP.DEThis is very similar to \f(CWdwarf_add_AT_targ_address_b() \fPbut results in a different FORM (results in \f(CWDW_FORM_ref_addr\fPbeing generated).Useful for \f(CWDW_AT_type\fP and \f(CWDW_AT_import\fP attributes.\f(CWsym_index() \fP is guaranteed tobe large enough that it can contain a pointer toarbitrary data (so the caller can pass in a real elfsymbol index, an arbitrary number, or a pointerto arbitrary data).The ability to pass in a pointer thru \f(CWsym_index() \fPis only usable with\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.The \f(CWpc_value\fPis put into the section stream output andthe \f(CWsym_index\fP is applied to the relocationinformation.Do not use this function for \f(CWDW_AT_high_pc\fP..H 3 "dwarf_add_AT_unsigned_const()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_unsigned_const( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Unsigned value, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_unsigned_const() \fP adds an attributewith a \f(CWDwarf_Unsigned\fP value belonging to the "constant" class, to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object thatthe \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attributeis specified by \f(CWattr\fP, and its value is specified by \f(CWvalue\fP.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_AT_signed_const()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_signed_const( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Signed value, Dwarf_Error *error) \fP.DEThe function \f(CWdwarf_add_AT_signed_const() \fP adds an attributewith a \f(CWDwarf_Signed\fP value belonging to the "constant" class,to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object thatthe \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attributeis specified by \f(CWattr\fP, and its value is specified by \f(CWvalue\fP.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_AT_reference()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_reference( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_P_Die otherdie, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_AT_reference()\fP adds an attributewith a value that is a reference to another \f(CWDIE\fP in thesame compilation-unit to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attribute is specified by \f(CWattr\fP, and the other \f(CWDIE\fPbeing referred to is specified by \f(CWotherdie\fP.This cannot generate DW_FORM_ref_addr references to\f(CWDIE\fPs in other compilation units.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_AT_flag()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_flag( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, Dwarf_Small flag, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_AT_flag()\fP adds an attribute with a \f(CWDwarf_Small\fP value belonging to the "flag" class, to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attributeis specified by \f(CWattr\fP, and its value is specified by \f(CWflag\fP.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_AT_string()".DS\f(CWDwarf_P_Attribute dwarf_add_AT_string( Dwarf_P_Debug dbg, Dwarf_P_Die ownerdie, Dwarf_Half attr, char *string, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_AT_string()\fP adds an attribute with a value that is a character string to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attribute is specified by \f(CWattr\fP, and its value is pointed to by \f(CWstring\fP.It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attributeon success, and \f(CWDW_DLV_BADADDR\fP on error..H 2 "Expression Creation"The following functions are used to convert location expressions intoblocks so that attributes with values that are location expressionscan store their values as a \f(CWDW_FORM_blockn\fP value. This is for both .debug_info and .debug_loc expression blocks.To create an expression, first call \f(CWdwarf_new_expr()\fP to get a \f(CWDwarf_P_Expr\fP descriptor that can be used to build up theblock containing the location expression. Then insert the parts of the expression in prefix order (exactly the order they would be interpreted in in an expression interpreter). The bytes of the expression are then built-up as specified by the user..H 3 "dwarf_new_expr()".DS\f(CWDwarf_Expr dwarf_new_expr( Dwarf_P_Debug dbg, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_new_expr()\fP creates a new expression area in which a location expression stream can be created. It returnsa \f(CWDwarf_P_Expr\fP descriptor that can be used to add operatorsto build up a location expression. It returns \f(CWNULL\fP on error..H 3 "dwarf_add_expr_gen()".DS\f(CWDwarf_Unsigned dwarf_add_expr_gen( Dwarf_P_Expr expr, Dwarf_Small opcode, Dwarf_Unsigned val1, Dwarf_Unsigned val2, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_expr_gen()\fP takes an operator specifiedby \f(CWopcode\fP, along with up to 2 operands specified by \f(CWval1\fP,and \f(CWval2\fP, converts it into the \f(CWDwarf\fP representation and appends the bytes to the byte stream being assembled for the locationexpression represented by \f(CWexpr\fP. The first operand, if present,to \f(CWopcode\fP is in \f(CWval1\fP, and the second operand, if present,is in \f(CWval2\fP. Both the operands may actually be signed or unsigneddepending on \f(CWopcode\fP. It returns the number of bytes in the bytestream for \f(CWexpr\fP currently generated, i.e. after the addition of\f(CWopcode\fP. It returns \f(CWDW_DLV_NOCOUNT\fP on error.The function \f(CWdwarf_add_expr_gen()\fP works for all opcodes exceptthose that have a target address as an operand. This is because it doesnot set up a relocation record that is needed when target addresses areinvolved..H 3 "dwarf_add_expr_addr()".DS\f(CWDwarf_Unsigned dwarf_add_expr_addr( Dwarf_P_Expr expr, Dwarf_Unsigned address, Dwarf_Signed sym_index, Dwarf_Error *error)\fP .DEThe function \f(CWdwarf_add_expr_addr()\fP is used to add the\f(CWDW_OP_addr\fP opcode to the location expression representedby the given \f(CWDwarf_P_Expr\fP descriptor, \f(CWexpr\fP. Thevalue of the relocatable address is given by \f(CWaddress\fP. The symbol to be used for relocation is given by \f(CWsym_index\fP,which is the index of the symbol in the Elf symbol table. It returns the number of bytes in the byte stream for \f(CWexpr\fP currently generated, i.e. after the addition of the \f(CWDW_OP_addr\fP operator. It returns \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_add_expr_addr_b()".DS\f(CWDwarf_Unsigned dwarf_add_expr_addr_b( Dwarf_P_Expr expr, Dwarf_Unsigned address, Dwarf_Unsigned sym_index, Dwarf_Error *error)\fP .DEThe function \f(CWdwarf_add_expr_addr_f()\fP isidentical to \f(CWdwarf_add_expr_addr()\fPexcept that \f(CWsym_index() \fP is guaranteed tobe large enough that it can contain a pointer toarbitrary data (so the caller can pass in a real elfsymbol index, an arbitrary number, or a pointerto arbitrary data).The ability to pass in a pointer thru \f(CWsym_index() \fPis only usable with\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP..H 3 "dwarf_expr_current_offset()".DS\f(CWDwarf_Unsigned dwarf_expr_current_offset( Dwarf_P_Expr expr, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_expr_current_offset()\fP returns the numberof bytes currently in the byte stream for the location expressionrepresented by the given \fCW(Dwarf_P_Expr\fP descriptor, \f(CWexpr\fP.It returns \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_expr_into_block()".DS\f(CWDwarf_Addr dwarf_expr_into_block( Dwarf_P_Expr expr, Dwarf_Unsigned *length, Dwarf_Error *error)\fP .DEThe function \f(CWdwarf_expr_into_block()\fP returns the addressof the start of the byte stream generated for the location expressionrepresented by the given \f(CWDwarf_P_Expr\fP descriptor, \f(CWexpr\fP.The length of the byte stream is returned in the location pointed toby \f(CWlength\fP. It returns \f(CWDW_DLV_BADADDR\fP on error..H 2 "Line Number Operations"These are operations on the .debug_line section. They provide information about instructions in the program and the source lines the instruction come from. Typically, code is generated in contiguous blocks, which may then be relocated as contiguous blocks. To make the provision of relocation information more efficient, the information is recorded in such a manner that onlythe address of the start of the block needs to be relocated. This is done by providing the address of the first instruction in a block using the function \f(CWdwarf_lne_set_address()\fP. Information about the instructions in the block are then added using the function \f(CWdwarf_add_line_entry()\fP, which specifiesoffsets from the address of the first instruction. The end of a contiguous block is indicated by calling the function \f(CWdwarf_lne_end_sequence()\fP..PLine number operations do not support\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP..H 3 "dwarf_add_line_entry()".DS\f(CWDwarf_Unsigned dwarf_add_line_entry( Dwarf_P_Debug dbg, Dwarf_Unsigned file_index, Dwarf_Addr code_offset, Dwarf_Unsigned lineno, Dwarf_Signed column_number, Dwarf_Bool is_source_stmt_begin, Dwarf_Bool is_basic_block_begin, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_line_entry()\fP adds an entry to thesection containing information about source lines. It specifiesin \f(CWcode_offset\fP, the offset from the address set using\f(CWdwarfdwarf_lne_set_address()\fP, of the address of the firstinstruction in a contiguous block. The source file that gave riseto the instruction is specified by \f(CWfile_index\fP, the sourceline number is specified by \f(CWlineno\fP, and the source column number is specified by \f(CWcolumn_number\fP(column numbers begin at 1)(if the source column is unknown, specify 0). \f(CWfile_index\fP is the index of the source file in a list of source files which is built up using the function \f(CWdwarf_add_file_decl()\fP. \f(CWis_source_stmt_begin\fP is a boolean flag that is true only if the instruction at \f(CWcode_address\fP is the first instruction in the sequence generated for the source line at \f(CWlineno\fP. Similarly,\f(CWis_basic_block_begin\fP is a boolean flag that is true only ifthe instruction at \f(CWcode_address\fP is the first instruction ofa basic block.It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_lne_set_address()".DS\f(CWDwarf_Unsigned dwarf_lne_set_address( Dwarf_P_Debug dbg, Dwarf_Addr offs, Dwarf_Unsigned symidx, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_lne_set_address()\fP sets the target addressat which a contiguous block of instructions begin. Information aboutthe instructions in the block is added to .debug_line using calls to\f(CWdwarfdwarf_add_line_entry()\fP which specifies the offset of eachinstruction in the block relative to the start of the block. This is done so that a single relocation record can be used to obtain the finaltarget address of every instruction in the block.The relocatable address of the start of the block of instructions isspecified by \f(CWoffs\fP. The symbol used to relocate the address is given by \f(CWsymidx\fP, which is normally the index of the symbol in theElf symbol table. It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_lne_end_sequence()".DS\f(CWDwarf_Unsigned dwarf_lne_end_sequence( Dwarf_P_Debug dbg, Dwarf_Addr address; Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_lne_end_sequence()\fP indicates the end of acontiguous block of instructions. \f(CWaddress()\fP should be just higher than the end of the last address in the sequence of instructions.block of instructions, a call to \f(CWdwarf_lne_set_address()\fP will have to be made to set the address of the start of the target addressof the block, followed by calls to \f(CWdwarf_add_line_entry()\fP foreach of the instructions in the block.It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_add_directory_decl()".DS\f(CWDwarf_Unsigned dwarf_add_directory_decl( Dwarf_P_Debug dbg, char *name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_directory_decl()\fP adds the string specified by \f(CWname\fP to the list of include directories in the statement program prologue of the .debug_line section. Thestring should therefore name a directory from which source fileshave been used to create the present object.It returns the index of the string just added, in the list of include directories for the object. This index is then used to refer to this string. It returns \f(CWDW_DLV_NOCOUNT\fP on error..H 3 "dwarf_add_file_decl()".DS\f(CWDwarf_Unsigned dwarf_add_file_decl( Dwarf_P_Debug dbg, char *name, Dwarf_Unsigned dir_idx, Dwarf_Unsigned time_mod, Dwarf_Unsigned length, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_file_decl()\fP adds the name of a sourcefile that contributed to the present object. The name of the file isspecified by \f(CWname\fP (which must not be the empty stringor a null pointer, it must point to a string with length greater than 0). In case the name is not a fully-qualifiedpathname, it is prefixed with the name of the directory specified by\f(CWdir_idx\fP. \f(CWdir_idx\fP is the index of the directory to beprefixed in the list builtup using \f(CWdwarf_add_directory_decl()\fP.\f(CWtime_mod\fP gives the time at which the file was last modified,and \f(CWlength\fP gives the length of the file in bytes.It returns the index of the source file in the list built up so farusing this function, on success. This index can then be used to refer to this source file in calls to \f(CWdwarf_add_line_entry()\fP.On error, it returns \f(CWDW_DLV_NOCOUNT\fP..H 2 "Fast Access (aranges) Operations"These functions operate on the .debug_aranges section. .H 3 "dwarf_add_arange()".DS\f(CWDwarf_Unsigned dwarf_add_arange( Dwarf_P_Debug dbg, Dwarf_Addr begin_address, Dwarf_Unsigned length, Dwarf_Signed symbol_index, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_arange()\fP adds another address range to be added to the section containing address range information, .debug_aranges. The relocatable start address of the range is specified by \f(CWbegin_address\fP, and the length of the address range is specified by \f(CWlength\fP. The relocatable symbol to be used to relocate the start of the address range is specified by \f(CWsymbol_index\fP, which is normally the index of the symbol in the Elfsymbol table.It returns a non-zero value on success, and \f(CW0\fP on error..H 3 "dwarf_add_arange_b()".DS\f(CWDwarf_Unsigned dwarf_add_arange_b( Dwarf_P_Debug dbg, Dwarf_Addr begin_address, Dwarf_Unsigned length, Dwarf_Unsigned symbol_index, Dwarf_Unsigned end_symbol_index, Dwarf_Addr offset_from_end_symbol, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_arange_b()\fP adds another address rangeto be added to the section containing address range information, .debug_aranges. If\f(CWend_symbol_index is not zero\fPwe are using two symbols to create a length(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful).sp.in +2\f(CWbegin_address\fPis the offset from the symbol specified by\f(CWsymbol_index\fP .\f(CWoffset_from_end_symbol\fPis the offset from the symbol specified by\f(CWend_symbol_index\fP.\f(CWlength\fP is ignored.This begin-end pair will be show up in therelocation array returned by\f(CWdwarf_get_relocation_info() \fPas a\f(CWdwarf_drt_first_of_length_pair\fPand\f(CWdwarf_drt_second_of_length_pair\fPpair of relocation records.The consuming application will turn that pair intosomething conceptually identical to.sp.nf.in +4 .word end_symbol + offset_from_end - \\ ( start_symbol + begin_address).in -4.fi.spThe reason offsets are allowed on the begin and end symbolsis to allow the caller to re-use existing labelswhen the labels are availableand the corresponding offset is known (economizing on the number of labels in use).The 'offset_from_end - begin_address'will actually be in the binary stream, not the relocationrecord, so the app processing the relocation arraymust read that stream value into (for example)net_offset and actually emit something like.sp.nf.in +4 .word end_symbol - start_symbol + net_offset.in -4.fi.sp.in -2If\f(CWend_symbol_index\fP is zerowe must be given a length(either\f(CWDW_DLC_STREAM_RELOCATIONS\fPor\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP):.sp.in +2The relocatable start address of the range isspecified by \f(CWbegin_address\fP, and the length of the addressrange is specified by \f(CWlength\fP. The relocatable symbol to beused to relocate the start of the address range is specified by\f(CWsymbol_index\fP, which is normallythe index of the symbol in the Elfsymbol table.The \f(CWoffset_from_end_symbol\fPis ignored..in -2It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "Fast Access (pubnames) Operations"These functions operate on the .debug_pubnames section..sp.H 3 "dwarf_add_pubname()".DS\f(CWDwarf_Unsigned dwarf_add_pubname( Dwarf_P_Debug dbg, Dwarf_P_Die die, char *pubname_name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_pubname()\fP adds the pubname specifiedby \f(CWpubname_name\fP to the section containing pubnames, i.e. .debug_pubnames. The \f(CWDIE\fP that represents the functionbeing named is specified by \f(CWdie\fP. It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "Fast Access (weak names) Operations"These functions operate on the .debug_weaknames section..H 3 "dwarf_add_weakname()".DS\f(CWDwarf_Unsigned dwarf_add_weakname( Dwarf_P_Debug dbg, Dwarf_P_Die die, char *weak_name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_weakname()\fP adds the weak name specifiedby \f(CWweak_name\fP to the section containing weak names, i.e. .debug_weaknames. The \f(CWDIE\fP that represents the functionbeing named is specified by \f(CWdie\fP. It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "Static Function Names Operations"The .debug_funcnames section contains the names of static function names defined in the object, and also the offsets of the \f(CWDIE\fPsthat represent the definitions of the functions in the .debug_info section..H 3 "dwarf_add_funcname()".DS\f(CWDwarf_Unsigned dwarf_add_funcname( Dwarf_P_Debug dbg, Dwarf_P_Die die, char *func_name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_funcname()\fP adds the name of a staticfunction specified by \f(CWfunc_name\fP to the section containing thenames of static functions defined in the object represented by \f(CWdbg\fP.The \f(CWDIE\fP that represents the definition of the function isspecified by \f(CWdie\fP.It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "File-scope User-defined Type Names Operations"The .debug_typenames section contains the names of file-scopeuser-defined types in the given object, and also the offsets of the \f(CWDIE\fPs that represent the definitions of the types in the .debug_info section..H 3 "dwarf_add_typename()".DS\f(CWDwarf_Unsigned dwarf_add_typename( Dwarf_P_Debug dbg, Dwarf_P_Die die, char *type_name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_typename()\fP adds the name of a file-scopeuser-defined type specified by \f(CWtype_name\fP to the section that contains the names of file-scope user-defined type. The object that this section belongs to is specified by \f(CWdbg\fP. The \f(CWDIE\fP that represents the definition of the type is specified by \f(CWdie\fP.It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "File-scope Static Variable Names Operations"The .debug_varnames section contains the names of file-scope staticvariables in the given object, and also the offsets of the \f(CWDIE\fPsthat represent the definition of the variables in the .debug_infosection..H 3 "dwarf_add_varname()".DS\f(CWDwarf_Unsigned dwarf_add_varname( Dwarf_P_Debug dbg, Dwarf_P_Die die, char *var_name, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_varname()\fP adds the name of a file-scopestatic variable specified by \f(CWvar_name\fP to the section that contains the names of file-scope static variables defined by the object represented by \f(CWdbg\fP. The \f(CWDIE\fP that representsthe definition of the static variable is specified by \f(CWdie\fP.It returns a non-zero value on success, and \f(CW0\fP on error..H 2 "Macro Information Creation"All strings passed in by the caller are copied by thesefunctions, so the space in which the caller provides the stringsmay be ephemeral (on the stack, or immediately reused or whatever)without this causing any difficulty..H 3 "dwarf_def_macro()".DS\f(CWint dwarf_def_macro(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno, char *name char *value, Dwarf_Error *error);\fP.DEAdds a macro definition.The \f(CWname\fP argument should include the parenthesesand parameter names if this is a function-like macro.Neither string should contain extraneous whitespace.\f(CWdwarf_def_macro()\fP adds the mandated space after thename and before the value in theoutput DWARF section(but does not change thestrings pointed to by the arguments).If this is a definition before any files are read,\f(CWlineno\fP should be 0.Returns \f(CWDW_DLV_ERROR\fPand sets \f(CWerror\fPif there is an error.Returns \f(CWDW_DLV_OK\fP if the call was successful..H 3 "dwarf_undef_macro()".DS\f(CWint dwarf_undef_macro(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno, char *name, Dwarf_Error *error);\fP.DEAdds a macro un-definition note.If this is a definition before any files are read,\f(CWlineno\fP should be 0.Returns \f(CWDW_DLV_ERROR\fPand sets \f(CWerror\fPif there is an error.Returns \f(CWDW_DLV_OK\fP if the call was successful..H 3 "dwarf_start_macro_file()".DS\f(CWint dwarf_start_macro_file(Dwarf_P_Debug dbg, Dwarf_Unsigned lineno, Dwarf_Unsigned fileindex, Dwarf_Error *error);\fP.DE\f(CWfileindex\fP is an index in the .debug_line header: the index ofthe file name.See the function \f(CWdwarf_add_file_decl()\fP.The \f(CWlineno\fP should be 0 if this file isthe file of the compilation unit source itself(which, of course, is not a #include in anyfile).Returns \f(CWDW_DLV_ERROR\fPand sets \f(CWerror\fPif there is an error.Returns \f(CWDW_DLV_OK\fP if the call was successful..H 3 "dwarf_end_macro_file()".DS\f(CWint dwarf_end_macro_file(Dwarf_P_Debug dbg, Dwarf_Error *error);\fP.DEReturns \f(CWDW_DLV_ERROR\fPand sets \f(CWerror\fPif there is an error.Returns \f(CWDW_DLV_OK\fP if the call was successful..H 3 "dwarf_vendor_ext()".DS\f(CWint dwarf_vendor_ext(Dwarf_P_Debug dbg, Dwarf_Unsigned constant, char * string, Dwarf_Error* error); \fP.DEThe meaning of the \f(CWconstant\fP and the\f(CWstring\fPin the macro info sectionare undefined by DWARF itself, but the string must bean ordinary null terminated string.This call is not an extension to DWARF. It simply enables storingmacro information as specified in the DWARF document.Returns \f(CWDW_DLV_ERROR\fPand sets \f(CWerror\fPif there is an error.Returns \f(CWDW_DLV_OK\fP if the call was successful..H 2 "Low Level (.debug_frame) operations"These functions operate on the .debug_frame section. Refer to \f(CWlibdwarf.h\fP for the register names and register assignment mapping. Both of these are necessarily machine dependent..H 3 "dwarf_new_fde()".DS\f(CWDwarf_P_Fde dwarf_new_fde( Dwarf_P_Debug dbg, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_new_fde()\fP returns a new \f(CWDwarf_P_Fde\fPdescriptor that should be used to build a complete \f(CWFDE\fP. Subsequent calls to routines that build up the \f(CWFDE\fP should usethe same \f(CWDwarf_P_Fde\fP descriptor.It returns a valid \f(CWDwarf_P_Fde\fP descriptor on success, and\f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_frame_cie()".DS\f(CWDwarf_Unsigned dwarf_add_frame_cie( Dwarf_P_Debug dbg, char *augmenter, Dwarf_Small code_align, Dwarf_Small data_align, Dwarf_Small ret_addr_reg, Dwarf_Ptr init_bytes, Dwarf_Unsigned init_bytes_len, Dwarf_Error *error);\fP.DEThe function \f(CWdwarf_add_frame_cie()\fP creates a \f(CWCIE\fP,and returns an index to it, that should be used to refer to this\f(CWCIE\fP. \f(CWCIE\fPs are used by \f(CWFDE\fPs to setupinitial values for frames. The augmentation string for the \f(CWCIE\fPis specified by \f(CWaugmenter\fP. The code alignment factor,data alignment factor, and the return address register for the\f(CWCIE\fP are specified by \f(CWcode_align\fP, \f(CWdata_align\fP,and \f(CWret_addr_reg\fP respectively. \f(CWinit_bytes\fP pointsto the bytes that represent the instructions for the \f(CWCIE\fPbeing created, and \f(CWinit_bytes_len\fP specifies the numberof bytes of instructions.There is no convenient way to generate the \f(CWinit_bytes\fPstream. One justhas to calculate it by hand or separatelygenerate something with the correct sequence and use dwarfdump -v and elfdump -h and somekind of hex dumper to see the bytes.This is a serious inconvenience! It returns an index to the \f(CWCIE\fP just created on success.On error it returns \f(CWDW_DLV_NOCOUNT\fP..H 3 "dwarf_add_frame_fde()".DS\f(CWDwarf_Unsigned dwarf_add_frame_fde( Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die, Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len, Dwarf_Unsigned sym_idx, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fPspecified by \f(CWfde\fP to the list of \f(CWFDE\fPs for theobject represented by the given \f(CWdbg\fP. \f(CWdie\fP specifiesthe \f(CWDIE\fP that represents the function whose frame informationis specified by the given \f(CWfde\fP. \f(CWcie\fP specifies theindex of the \f(CWCIE\fP that should be used to setup the initialconditions for the given frame. It returns an index to the given \f(CWfde\fP..H 3 "dwarf_add_frame_fde_b()".DS\f(CWDwarf_Unsigned dwarf_add_frame_fde_b( Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die, Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len, Dwarf_Unsigned sym_idx, Dwarf_Unsigned sym_idx_of_end, Dwarf_Addr offset_from_end_sym, Dwarf_Error* error)\fP.DEThis function is like \f(CWdwarf_add_frame_fde()\fP except that \f(CWdwarf_add_frame_fde_b()\fP has new arguments to allow usewith\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.The function \f(CWdwarf_add_frame_fde_b()\fP adds the \f(CWFDE\fPspecified by \f(CWfde\fP to the list of \f(CWFDE\fPs for theobject represented by the given \f(CWdbg\fP. \f(CWdie\fP specifiesthe \f(CWDIE\fP that represents the function whose frame informationis specified by the given \f(CWfde\fP. \f(CWcie\fP specifies theindex of the \f(CWCIE\fP that should be used to setup the initialconditions for the given frame. \f(CWvirt_addr\fP represents therelocatable address at which the code for the given function begins,and \f(CWsym_idx\fP gives the index of the relocatable symbol tobe used to relocate this address (\f(CWvirt_addr\fP that is).\f(CWcode_len\fP specifies the size in bytes of the machine instructionsfor the given function.If \f(CWsym_idx_of_end\fP is zero (may be \f(CWDW_DLC_STREAM_RELOCATIONS\fP or\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP ):.sp.in +2\f(CWvirt_addr\fP represents therelocatable address at which the code for the given function begins,and \f(CWsym_idx\fP gives the index of the relocatable symbol tobe used to relocate this address (\f(CWvirt_addr\fP that is).\f(CWcode_len\fP specifies the size in bytes of the machine instructionsfor the given function.\f(CWsym_idx_of_end\fPand\f(CWoffset_from_end_sym\fPare unused..in -2.spIf \f(CWsym_idx_of_end\fP is non-zero (must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful):.sp.in +2\f(CWvirt_addr\fPis the offset from the symbol specified by\f(CWsym_idx\fP .\f(CWoffset_from_end_sym\fPis the offset from the symbol specified by\f(CWsym_idx_of_end\fP.\f(CWcode_len\fP is ignored.This begin-end pair will be show up in therelocation array returned by\f(CWdwarf_get_relocation_info() \fPas a\f(CWdwarf_drt_first_of_length_pair\fPand\f(CWdwarf_drt_second_of_length_pair\fPpair of relocation records.The consuming application will turn that pair intosomething conceptually identical to.sp.nf.in +4 .word end_symbol + begin - \\ ( start_symbol + offset_from_end).in -4.fi.spThe reason offsets are allowed on the begin and end symbolsis to allow the caller to re-use existing labelswhen the labels are availableand the corresponding offset is known(economizing on the number of labels in use).The 'offset_from_end - begin_address'will actually be in the binary stream, not the relocationrecord, so the app processing the relocation arraymust read that stream value into (for example)net_offset and actually emit something like.sp.nf.in +4 .word end_symbol - start_symbol + net_offset.in -4.fi.sp.in -2It returns an index to the given \f(CWfde\fP.On error, it returns \f(CWDW_DLV_NOCOUNT\fP..H 3 "dwarf_add_frame_info_b()".DS\f(CWDwarf_Unsigned dwarf_add_frame_info_b( Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die, Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len, Dwarf_Unsigned sym_idx, Dwarf_Unsigned end_symbol_index, Dwarf_Addr offset_from_end_symbol, Dwarf_Signed offset_into_exception_tables, Dwarf_Unsigned exception_table_symbol, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fPspecified by \f(CWfde\fP to the list of \f(CWFDE\fPs for theobject represented by the given \f(CWdbg\fP. \f(CWdie\fP specifiesthe \f(CWDIE\fP that represents the function whose frame informationis specified by the given \f(CWfde\fP. \f(CWcie\fP specifies theindex of the \f(CWCIE\fP that should be used to setup the initialconditions for the given frame. \f(CWoffset_into_exception_tables\fP specifies theoffset into \f(CW.MIPS.eh_region\fP elf section where the exception tables for this function begins. \f(CWexception_table_symbol\fP gives the index of the relocatable symbol to be used to relocate this offset.If\f(CWend_symbol_index is not zero\fPwe are using two symbols to create a length(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful).sp.in +2\f(CWvirt_addr\fPis the offset from the symbol specified by\f(CWsym_idx\fP .\f(CWoffset_from_end_symbol\fPis the offset from the symbol specified by\f(CWend_symbol_index\fP.\f(CWcode_len\fP is ignored.This begin-end pair will be show up in therelocation array returned by\f(CWdwarf_get_relocation_info() \fPas a\f(CWdwarf_drt_first_of_length_pair\fPand\f(CWdwarf_drt_second_of_length_pair\fPpair of relocation records.The consuming application will turn that pair intosomething conceptually identical to.sp.nf.in +4 .word end_symbol + offset_from_end_symbol - \\ ( start_symbol + virt_addr).in -4.fi.spThe reason offsets are allowed on the begin and end symbolsis to allow the caller to re-use existing labelswhen the labels are availableand the corresponding offset is known (economizing on the number of labels in use).The 'offset_from_end - begin_address'will actually be in the binary stream, not the relocationrecord, so the app processing the relocation arraymust read that stream value into (for example)net_offset and actually emit something like.sp.nf.in +4 .word end_symbol - start_symbol + net_offset.in -4.fi.sp.in -2If\f(CWend_symbol_index\fP is zerowe must be given a code_len value(either\f(CWDW_DLC_STREAM_RELOCATIONS\fPor\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP):.sp.in +2The relocatable start address of the range isspecified by \f(CWvirt_addr\fP, and the length of the addressrange is specified by \f(CWcode_len\fP. The relocatable symbol to beused to relocate the start of the address range is specified by\f(CWsymbol_index\fP, which is normallythe index of the symbol in the Elfsymbol table.The \f(CWoffset_from_end_symbol\fPis ignored..in -2It returns an index to the given \f(CWfde\fP.On error, it returns \f(CWDW_DLV_NOCOUNT\fP..H 3 "dwarf_add_frame_info()".DS\f(CWDwarf_Unsigned dwarf_add_frame_info( Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die, Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len, Dwarf_Unsigned sym_idx, Dwarf_Signed offset_into_exception_tables, Dwarf_Unsigned exception_table_symbol, Dwarf_Error* error)\fP.DEThe function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fPspecified by \f(CWfde\fP to the list of \f(CWFDE\fPs for theobject represented by the given \f(CWdbg\fP. \f(CWdie\fP specifiesthe \f(CWDIE\fP that represents the function whose frame informationis specified by the given \f(CWfde\fP. \f(CWcie\fP specifies theindex of the \f(CWCIE\fP that should be used to setup the initialconditions for the given frame. \f(CWvirt_addr\fP represents therelocatable address at which the code for the given function begins,and \f(CWsym_idx\fP gives the index of the relocatable symbol tobe used to relocate this address (\f(CWvirt_addr\fP that is).\f(CWcode_len\fP specifies the size in bytes of the machine instructionsfor the given function. \f(CWoffset_into_exception_tables\fP specifies theoffset into \f(CW.MIPS.eh_region\fP elf section where the exception tables for this function begins. \f(CWexception_table_symbol\fP gives the index of the relocatable symbol to be used to relocate this offset.It returns an index to the given \f(CWfde\fP..H 3 "dwarf_fde_cfa_offset()".DS\f(CWDwarf_P_Fde dwarf_fde_cfa_offset( Dwarf_P_Fde fde, Dwarf_Unsigned reg, Dwarf_Signed offset, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_fde_cfa_offset()\fP appends a \f(CWDW_CFA_offset\fPoperation to the \f(CWFDE\fP, specified by \f(CWfde\fP, being constructed. The first operand of the \f(CWDW_CFA_offset\fP operation is specified by \f(CWreg\P. The register specified should not exceed 6 bits. The second operand of the \f(CWDW_CFA_offset\fP operation is specified by \f(CWoffset\fP.It returns the given \f(CWfde\fP on success.It returns \f(CWDW_DLV_BADADDR\fP on error..H 3 "dwarf_add_fde_inst()".DS\f(CWDwarf_P_Fde dwarf_add_fde_inst( Dwarf_P_Fde fde, Dwarf_Small op, Dwarf_Unsigned val1, Dwarf_Unsigned val2, Dwarf_Error *error)\fP.DEThe function \f(CWdwarf_add_fde_inst()\fP adds the operation specifiedby \f(CWop\fP to the \f(CWFDE\fP specified by \f(CWfde\fP. Upto twooperands can be specified in \f(CWval1\fP, and \f(CWval2\fP. Based onthe operand specified \f(CWLibdwarf\fP decides how many operands aremeaningful for the operand. It also converts the operands to the appropriate datatypes (they are passed to \f(CWdwarf_add_fde_inst\fPas \f(CWDwarf_Unsigned\fP).It returns the given \f(CWfde\fP on success, and \f(CWDW_DLV_BADADDR\fPon error..S.TC 1 1 4.CS