You are on page 1of 117

Tool Interface Standards (TIS) DWARF Debugging Information Format Specification

Version 2.0

TIS Committee May 1995

The TIS Committee grants you a non-exclusive, worldwide, royalty-free license to use the information disclosed in the Specifications to make your software TIS-compliant; no other license, express or implied, is granted or intended hereby. The TIS Committee makes no warranty for the use of this standard. THE TIS COMMITTEE SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THE SPECIFICATION AND THE INFORMATION CONTAINED IN IT, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS. THE TIS COMMITTEE DOES NOT ASSUME ANY RESPONSIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THE SPECIFICATION, NOR ANY RESPONSIBILITY TO UPDATE THE INFORMATION CONTAINED IN THEM. The TIS Committee retains the right to make changes to this specification at any time without notice. This document specifies the second generation of symbolic debugging information based on the DWARF format that has been developed by the UNIX International Programming Language Special Interest Group (SIG). This document was distributed earlier as the Industry Reveiw Draft. Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name UNIX International not be used in advertising or publicity pertaining to distribution of the software without specific, written price permission. UNIX International makes no representations about the suitability of this documentation for any purpose. It is provided as is without express or implied warranty. UNIX INTERNATIONAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS DOCUMENTATION, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL UNIX INTERNATIONAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS DOCUMENTATION. IBM is a registered trademark and OS/2 is a trademark of International Business Machines Corporation. The Intel logo is a registered trademark, and i386 and Intel386 are trademarks of Intel Corporation and may be used only to identify Intel products. Microsoft, Microsoft C, MS, MS-DOS, and XENIX are registered trademarks and Windows is a trademark of Microsoft Corporation. Phoenix is a registered trademark of Phoenix Technologies, Ltd. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited. * Other brands and names are the property of their respective owners. Copyright 1992, 1993 UNIX International, Inc.

--

--

T a b le of C on t en t s

1. I N T R O D U C T I O N . . 1.1 P u r pose a n d S cope . 1.2 O ver view . . . . 1.3 Ven d or E xt en sib ilit y 1.4 C h a n ges fr om Ver sion

. . . . 1

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 1 1 2 2 5 5 5 7 7 16 16 16 17 17 17 18 18 19 21 21 23 23 29 30 30 31 33 33 35 35 35 37 37 38 38 39 40 45 45 46

2. G E N E R A L D E S C R I P T I O N . . . . . . . 2.1 T h e D eb u gging I nfor ma t ion E n t r y . . . . 2.2 A t t r ib u t e T ypes . . . . . . . . . . 2.3 R ela t ionsh ip of D eb u ggin g I nfor ma t ion E n t r ies 2.4 L oca t ion D escr ipt ions . . . . . . . . 2.5 T ypes of D ecla r a t ions . . . . . . . . 2.6 A ccessib ilit y of D ecla r a t ions . . . . . 2.7 V isib ilit y of D ecla r a t ions . . . . . . . 2.8 Vir t u a lit y of D ecla r a t ions . . . . . . 2.9 A r t icia l E n t r ies . . . . . . . . . 2.10 T a r get -S pecic A d d r essing I n for ma t ion . . 2.11 N on-D enin g D ecla r a t ions . . . . . . 2.12 D ecla r a t ion C oor d in a t es . . . . . . . 2.13 I den t ier N a m es . . . . . . . . . 3. P R O G R A M S C O P E E N T R I E S . . . 3.1 C omp ila t ion U n it E n t r ies . . . 3.2 M odu le E n t r ies . . . . . . . 3.3 S u b r out in e a n d E n t r y P oin t E n t r ies 3.4 L exica l Block E n t r ies . . . . . 3.5 L a b el E n t r ies . . . . . . . 3.6 W it h S t a t emen t E n t r ies . . . . 3.7 T r y a n d C a t ch Block E n t r ies . . 4. D A T A O BJ E C T A N D O BJ E C T L I ST 4.1 D a t a O bject E n t r ies . . . . 4.2 C omm on Block E n t r ies . . . 4.3 I mpor t ed D ecla r a t ion E n t r ies . 4.4 N a m elist E n t r ies . . . . . 5. T Y P E E N T R I E S . . . . . 5.1 Ba se T ype E n t r ies . . . 5.2 T ype M odier E n t r ies . . 5.3 T yped ef E n t r ies . . . . 5.4 A r r a y T ype E n t r ies . . 5.5 S t r u ct u r e, U nion, a n d C la ss 5.6 E nu m er a t ion T ype E n t r ies 5.7 S u b r out in e T ype E n t r ies . 5.8 S t r in g T ype E n t r ies . . . . . . . . . . . . T ype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

EN TR IES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E n t r ies . . . . . . . . . . . . . . . . . .

-i-

--

--

5.9 5.10 5.11 5.12

S et E n t r ies . . . . S u b r a nge T ype E n t r ies P oint er t o M em ber T ype F ile T ype E n t r ies . .

. . . . . . E n t r ies . . .

. . . .

. . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

46 47 48 48 51 51 52 59 61 69 69 69 69 70 70 75 77 79 79 80 80 80 80 81 81 81 81 81 82 82 82 83 84 84 85 87 97 99 101 103

6. O T H E R D E BU G G I N G I N F O R M A T I O N 6.1 A cceler a t ed A ccess . . . . . 6.2 L ine N u m b er I n for m a t ion . . . 6.3 M a cr o I n for ma t ion . . . . . 6.4 C a ll F r a me I nfor ma t ion . . . .

7. D A T A R E P R E S E N T A T I O N . . . . . 7.1 Ven d or E xt en sib ilit y . . . . . . 7.2 R eser ved E r r or Va lu es . . . . . 7.3 E xecu t a b le O b ject s a n d S h a r ed O b ject s 7.4 F ile C onst r a in t s . . . . . . . 7.5 F or ma t of D eb u ggin g I nfor ma t ion . . 7.6 Va r ia b le L en gt h D a t a . . . . . . 7.7 L oca t ion D escr ipt ions . . . . . . 7.8 Ba se T ype E ncodings . . . . . . 7.9 A ccessib ilit y C odes . . . . . . 7.10 Visib ilit y C odes . . . . . . . . 7.11 Vir t u a lit y C odes . . . . . . . 7.12 S our ce L a ngu a ges . . . . . . . 7.13 A d d r ess C la ss E ncodings . . . . . 7.14 I den t ier C a se . . . . . . . . 7.15 C a lling C onven t ion E ncodings . . . 7.16 I n lin e C odes . . . . . . . . . 7.17 A r r a y O r d er in g . . . . . . . . 7.18 D iscr imin a n t L ist s . . . . . . . 7.19 N a m e L ooku p T a b le . . . . . . 7.20 A d d r ess R a nge T a b le . . . . . . 7.21 L in e N u m ber I n for m a t ion . . . . 7.22 M a cr o I n for m a t ion . . . . . . 7.23 C a ll F r a m e I n for ma t ion . . . . . 7.24 D epen d en cies . . . . . . . . 8. F U T U R E D I R E C T I O N S . . . . . .

A ppen d ix 1 -- C u r r en t A t t r ibu t es b y T a g Va lu e

A ppen d ix 2 -- O r ga n iza t ion of D eb u ggin g I nfor ma t ion A ppen d ix 3 -- S t a t em en t P r ogr a m E xa m ples . . .

A ppen d ix 4 -- E ncoding a n d decodin g va r ia b le len gt h da t a . A ppen d ix 5 -- C a ll F r a m e I nfor ma t ion E xa mples . . . .

- ii -

--

--

L ist of F igu r es F igu r e 1. T a g na mes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 16 17 17 18 21 22 27 37 38 39 45 72 73 73 74 75 76 76 77 78 79 80 80 80 80

F igu r e 2. A t t r ib u t e n a mes F igu r e 3. A cc essib ilit y codes F igu r e 4. Visib ilit y codes F igu r e 5. Vir t u a lit y codes

F igu r e 6. E xa m ple a d dr ess cla ss codes F igu r e 7. L a ngu a ge n a m es . . . . . . . . . . .

F igu r e 8. I den t ier ca se codes . F igu r e 9. I n line codes . . .

F igu r e 10. E n codin g a t t r ib u t e va lu es F igu r e 11. T ype modier t a gs F igu r e 12. A r r a y or d er in g . . . . .

F igu r e 13. D iscr im in a n t d escr ipt or va lu es F igu r e 14. T a g encod in gs ( pa r t 1) . F igu r e 15. T a g encod in gs ( pa r t 2) . . .

F igu r e 16. C h ild d et er m in a t ion en codin gs F igu r e 17. A t t r ibu t e encod in gs, pa r t 1 F igu r e 18. A t t r ibu t e encod in gs, pa r t 2 F igu r e 19. A t t r ibu t e for m en cod in gs

F igu r e 20. E xa mples of u n signed L E B128 en codin gs F igu r e 21. E xa mples of signed L E B128 en codin gs . F igu r e 22. L oca t ion oper a t ion en cod in gs, pa r t 1 F igu r e 23. L oca t ion oper a t ion en cod in gs, pa r t 2 F igu r e 24. Ba se t ype encoding va lu es . F igu r e 25. A cc essib ilit y encod in gs . F igu r e 26. Visib ilit y en codin gs . . . . . . . . . . . . . . . . . . . . . . . .

F igu r e 27. Vir t u a lit y en codin gs .

- iii -

--

--

F igu r e 28. L a n gu a ge en codin gs . F igu r e 29. I den t ier ca se encod in gs

. .

. .

. . . . .

. . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

81 81 81 82 82 82 83 83 83 84

F igu r e 30. C a lling conven t ion en cod in gs . F igu r e 31. I n lin e en codin gs . . . . . . . . .

F igu r e 32. O r d er in g encod in gs

F igu r e 33. D iscr im in a n t d escr ipt or encod in gs F igu r e 34. S t a n da r d O pcode E n codin gs F igu r e 35. E xt en d ed O pcode E n codings F igu r e 36. M a cin fo T ype E ncodings . . . . . . .

. . . .

F igu r e 37. C a ll fr a m e in st r u ct ion en codin gs .

- iv ---

Tool Interface Standards DWARF Debugging Information Format, Version 2.0


The DWARF Debugging Information Format Specification, Version 2.0, is the result of the work of the Tool Interface Standards (TIS) Committee--an association of members of the microcomputer industry formed to work toward standardization of the software interfaces visible to development tools for 32-bit Intel Architecture operating environments. Such interfaces include object module formats, executable file formats, and debug record information and formats. The goal of the committee is to help streamline the software development process throughout the microcomputer industry, currently concentrating on 32-bit operating environments. To that end, the committee has developed specifications--some for file formats that are portable across leading industry operating systems, and others describing formats for 32-bit Windows operating systems. Originally distributed collectively as the TIS Portable Formats Specifications, Version 1.1, these specifications are now separated and distributed individually. The DWARF Debugging Information Format Specification, Version 2.0, is the latest deliverable of the TIS Committee. It is based on existing, proven formats in keeping with the TIS Committee's goal to adopt, and when necessary, extend existing standards rather than invent new ones. TIS Committee members include representatives from Absoft Corporation, Autodesk Corporation, Borland International Corporation, IBM Corporation, Intel Corporation, Lahey Corporation, Lotus Corporation, MetaWare Corporation, Microtec Research, Microsoft Corporation, Novell Corporation, The Santa Cruz Operation, and WATCOM International Corporation. PharLap Software Incorporated and Symantec Corporation also participated in the specification definition efforts.

DWARF Debugging Information Format Specification


This document describes the DWARF specification, a portable debugging information format. The TIS Committee formed a debug subcommittee to evaluate the widely available formats with the objective of adopting one as the TIS standard. After studying many different formats, the TIS Committee approved DWARF Version 1.0 as the most flexible format for handling the present and future computer language debugging needs. The major advantages of DWARF are: it can be easily adopted across numerous 32-bit Intel Architecture environments it has been designed from the beginning to be easily extensible there is a standardization committee (PLSIG) working on extending it. TIS members can use this committee to extend the format as needed. it is a publicly available specification with no licensing requirements. The full report from the debug subcommittee is available from the TIS archives.

There are two versions of DWARF currently available, Version 1.0 and an industry review Version 2.0. Version 1.0 is fully compatible with sdb, an existing debugger from USL, and covers C and Fortran completely. There are also some basic extensions for 64-bit architectures.

UNIX International has published this version of DWARF. This document was originally designed by USL (UNIX System Laboratories) and turned over to the PLSIG (Programming Languages Special Interest Group) of UNIX International in an effort to extend and standardize the format. This current version, DWARF Version 2.0, adds significant new functionality, but its main thrust is to achieve a much denser encoding of the DWARF information. Because of the new encoding, DWARF Version 2.0 is not binary compatible with DWARF Version 1.0. Version 2.0 expands DWARF functionality by addressing the needs of more languages and reducing the size of the DWARF information in the object file. The TIS Committee supports the efforts of the PLSIG by actively reviewing the emerging DWARF Version 2.0 specification. To this end, the following changes are worth noting: DASI: Dwarf Augmented Statement Information. This is an enhanced line number information table, and the on-disk version of this is a compressed version. This was proposed by Borland International, which claims a large reduction in the size of DWARF information with DASI. Some experiments have shown a reduction of more than 20% in the DASI. Abbreviations: This is a means of pre-defining the TAG-attribute combination in the compilation unit in a table. In some experiments, this has cut the size of DWARF in half.

Industry review Version 2.0 provides a feature for expressing MACRO information. It also provides a new and improved location description method, which is an extremely powerful means for describing variable locations and expressing compiler optimizations. More extensive support for C++ has also been added, and at this point, the PLSIG believes that this document sufficiently supports the debugging needs of C, C++, FORTRAN 77, Fortran90, Modula2 and Pascal. The industry review draft of the DWARF Version 2.0 specification is presented here. The final Version 2.0 specification may include some minor changes and will be available in 1994.

--

--

1. IN TRODU CTION
T h is docu men t denes t he for m a t f or t he infor ma t ion gener a t ed b y compiler s, a ssembler s a nd linka ge ed it or s t ha t is necessa r y for symb olic, sour ce-level debu gging. T he debugging infor ma t ion for ma t does not fa vor t he design of a ny compiler or debu gger . I n stea d , t he goa l is t o cr ea t e a met h od of comm u nica t ing a n a ccur a t e pict ur e of t he sour ce pr ogr a m to a ny deb u gger in a for m t ha t is economica lly ext en sible t o d iffer en t la ngu a ges while r et a ining ba ckwar d compa t ibilit y. T he design of t he debu ggin g infor ma t ion for m a t is open-en ded , a llowing for t he a d dit ion of new deb u ggin g infor m a t ion t o a ccom m oda t e new la ngu a ges or deb u gger ca pa b ilit ies while r ema ining compa t ible wit h other la ngu a ges or differ en t debu gger s.

1.1 P urpose and S cope


T he deb u ggin g in for m a t ion f or ma t descr ibed in t h is docu men t is designed t o meet t he symb olic, sour ce-level debu ggin g needs of d iffer en t la ngu a ge s in a u n ied fa shion by r equ ir ing la ngu a ge independen t debu gging infor ma t ion whenever possible . I n d ividua l need s, such a s C + + vir t ua l fu nct ions or F or t r a n comm on b locks a r e a ccomm oda t ed by cr ea t ing a t t r ibu t es t ha t a r e u sed only for t h ose la ngu a ges. T he U N I X I n t er na t iona l P r ogr a m m ing L a ngu a ges SI G believes t ha t t h is docu men t sufficient ly cover s t he debu ggin g infor ma t ion needs of C , C + + , F O R T R A N 77, F or t r a n90, M odu la 2 a nd Pa sca l. T h is docu men t descr ibes D W A R F Ver sion 2, t he sec ond gener a t ion of debu ggin g infor ma t ion ba sed on t he D W A R F for ma t . W h ile D W A R F Ver sion 2 pr ovides new debu ggin g infor ma t ion not a va ila b le in Ver sion 1, t h e pr im a r y focus of t he ch a nges for Ver sion 2 is t he r epr esen t a t ion of t h e infor ma t ion, r a t her t ha n t he infor m a t ion cont ent it self . T he ba sic st r uct u r e of t he Ver sion 2 for ma t r em a ins a s in Ver sion 1 : t he deb u gg ing infor ma t ion is r epr esen t ed a s a ser ies of debu gging in for ma t ion ent r ies, ea ch cont a ining one or m or e a t t r ibu t e s ( na m e/ va lue pa ir s) . T h e Ver sion 2 r epr esen t a t ion, h owever , is m uch mor e compa ct t h a n t he Ver sion 1 r epr esen t a t ion. I n some ca ses, t h is gr ea t er densit y ha s been a chieved a t t he expense of a d d it iona l comple xit y or gr ea t er d ifficu lt y in pr oducin g a nd pr ocessing t he D W A R F infor m a t ion. W e believe t ha t t he r educt ion in I / O a nd in memor y pa ging sh ould m or e t ha n ma ke u p f or a ny incr ea se in pr ocessing t ime. Beca use t h e r epr esen t a t ion of infor ma t ion ha s ch a nged fr om Ver sion 1 t o Ver sion 2 , Ver sion 2 D W A R F infor ma t ion is not bina r y compa t ible wit h Ver sion 1 infor ma t ion. T o ma ke it ea sier for consumer s t o suppor t b ot h Ver sion 1 a nd Ver sion 2 D W A R F infor ma t ion, t he Ver sion 2 in for ma t ion h a s been m oved t o a differ en t object le sect ion, . d e b u g _ i n f o. T he int ended a u dience for t h is docu ment a r e t h e developer s of bot h pr oducer s a nd consumer s of deb u gging in f or ma t ion, t ypica lly la n gua ge compiler s, deb u gger s a nd ot h er t ools t ha t need t o int er pr et a b ina r y pr ogr a m in t er m s of it s or igina l sour ce.

1.2 Overview
T her e a r e t wo ma jor pieces t o t he descr ipt ion of t he D W A R F for m a t in t h is document . T he r st piece is t he infor m a t iona l cont en t of t h e debu ggin g en t r ie s. T h e sec ond piece is t he wa y t he debu ggin g infor ma t ion is encoded a nd r epr esen t ed in a n object le. T he infor m a t iona l cont en t is descr ibed in sect ions t wo t hr ough six. Sect ion t wo descr ibes t he over a ll st r uct ur e of t he infor ma t ion a n d a t t r ibu t es t ha t a r e common t o ma ny or a ll of
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

t he d iffer en t debu ggin g infor ma t ion en t r ies. Sect ions t hr ee, four a nd ve descr ibe t h e specic debu gging infor ma t ion en t r ies a nd h ow t hey com m u nica t e t he necessa r y infor ma t ion a b out t he sour ce pr ogr a m t o a debu gger . Sect ion six descr ibes debu gging infor ma t ion cont a ined ou t side of t h e deb u ggin g in f or m a t ion en t r ies, t h em selves. T he encoding of t he D W A R F infor ma t ion is pr esen t ed in sect ion seven . Sect ion eigh t descr ibes some fu t ur e dir ect ions f or t he D W A R F specica t ion. I n t he following sect ions, t ext in nor ma l f ont descr ibes r equ ir ed a spect s of t he D W A R F for m a t . T ext in it al ics is expla na t or y or supplem en t a r y m a t er ia l, a nd not pa r t of t h e for m a t de nit ion it self .

1.3 Vendor Ex tensibility


T h is docu men t d oes n ot a t t empt t o cover a ll in t er est in g la n gua ge s or even t o cover a ll of t he in t er est ing debu gging infor ma t ion needs f or it s pr ima r y t a r ge t la n gua ges ( C , C + + , F O R T R A N 77, F or t r a n90, M odu la 2, P a sca l) . T her efor e t h e documen t pr ovides vendor s a wa y t o dene t heir own debu ggin g infor ma t ion t a gs, a t t r ib u t es, ba se t ype encodin gs, loca t ion oper a t ions, la ngu a ge na m es, ca lling conven t ions a nd ca ll fr a me in st r uct ions by r eser ving a por t ion of t h e na m e spa ce a nd va lid va lues for t hese const r uct s for vendor specic a d dit ions. F u t ur e ver sions of t h is docu men t will n ot use na mes or va lues r eser ved for vendor specic a d d it ions. A ll na mes a nd va lues n ot r eser ved f or ven dor a d dit ions, however , a r e r eser ved f or fu t ur e ver sions of t h is docu men t . See sect ion 7 for d et a ils.

1.4 Changes from Version 1


T he f ollowing is a list of t he m a jor cha nges ma de t o t he D W A R F D eb u ggin g I nfor m a t ion F or m a t since Ver sion 1 of t he for ma t wa s pu b lished ( J a nua r y 20, 1992) . T he list is n ot mea n t t o be exh a u st ive.

Debu ggin g infor ma t ion en t r ies ha ve been m oved fr om t he . d e b u g . d e b u g _ i n f o sect ion of a n object le.

t o t he

T he t a g, a t t r ibu t e na mes a nd a t t r ibu t e for ms encodin gs ha ve been moved out of t he debu ggin g infor ma t ion it self t o a sepa r a t e a bbr evia t ions t a ble. E xplicit sibling point er s ha ve been ma de opt iona l. E a ch en t r y now species ( t hr ough t he a b br evia t ions t a ble) whet her or not it h a s ch ildr en . N ew mor e compa ct a t t r ibu t e for m s ha ve been a dded , inclu ding a va r ia ble len gt h const a n t da t a for m . A t t r ibu t e va lues ma y now h a ve a n y for m wit h in a given cla ss of for m s. Loca t ion descr ip t ions ha ve been r epla ced by a new, m or e compa c t a nd mor e expr essive for m a t . T her e is n ow a wa y of expr essing mu lt iple loca t ions for a n object whose loca t ion ch a nges du r in g it s lif et ime . T her e is a new for ma t for line n u m ber infor m a t ion t ha t pr ovides infor m a t ion f or code cont r ibu t ed t o a compila t ion u n it fr om a n inclu ded le. L ine nu m ber infor ma t ion is now in t he . d e b u g _ l i n e sect ion of a n object le. T he r epr esen t a t ion of t he t ype of a decla r a t ion h a s been r ewor ked . A new sec t ion pr ovides a n encodin g for pr e- pr ocessor ma cr o infor m a t ion.
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

--

--

DWARF D ebugging Information Format

Debu ggin g infor ma t ion en t r ies now pr ovide for t he r epr esent a t ion of n on-de nin g decla r a t ions of object s, fu nct ions or t ypes. M or e com ple t e suppor t for M odu la 2 a nd Pa sca l ha s been a d ded. T her e is now a wa y of descr ib ing loca t ions for segm en t ed a d dr ess spa ces. A new sec t ion pr ovides a n encodin g for in for m a t ion a bout ca ll fr a me a c t iva t ions. T he r epr esen t a t ion of enu m er a t ion a nd a r r a y t ypes ha s been r ewor ked so t ha t D W A RF pr esen t s only a single wa y of r epr esen t ing list s of it em s. S u ppor t ha s been a dded for C + + t empla t es a nd except ions.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

2. GEN ERAL DESCRIP TION 2.1 The D ebugging Information Entry


DW A R F u ses a ser ies of debu ggin g infor ma t ion en t r ies t o dene a low-level r epr esen t a t ion of a sour ce pr ogr a m . E a ch deb u gging infor ma t ion en t r y is descr ibed by a n ident if ying t a g a nd cont a ins a ser ies of a t t r ibu t es. T he t a g species t h e cla ss t o which a n en t r y belongs, a nd t he a t t r ibu t es dene t he specic ch a r a ct er istics of t he en t r y. T he set of r equ ir ed t a g na mes is list ed in F igur e 1. T he deb u ggin g infor m a t ion en t r ies t hey iden t if y a r e descr ibed in sect ions t hr ee , four a nd ve. T he deb u ggin g in for m a t ion en t r ies in D W A R F Ver sion 2 a r e in t ended t o e xist in t he . d e b u g _ i n f o sect ion of a n object le. _ ________________________________________________________________________________________ _ D W _ T A G _ a c c e s s _ d e c l a r a t i o n DW_TAG_array_type D W _ T A G _ b a s e _ t y p e DW_TAG_catch_block DW_TAG_common_block D W _ T A G _ c l a s s _ t y p e DW_TAG_compile_unit D W _ T A G _ c o m m o n _ i n c l u s i o n DW_TAG_constant D W _ T A G _ c o n s t _ t y p e D W _ T A G _ e n t r y _ p o i n t DW_TAG_enumeration_type D W _ T A G _ e n u m e r a t o r DW_TAG_file_type D W _ T A G _ f o r m a l _ p a r a m e t e r DW_TAG_friend DW_TAG_inheritance D W _ T A G _ i m p o r t e d _ d e c l a r a t i o n DW_TAG_label D W _ T A G _ i n l i n e d _ s u b r o u t i n e D W _ T A G _ l e x i c a l _ b l o c k DW_TAG_member D W _ T A G _ m o d u l e DW_TAG_namelist D W _ T A G _ n a m e l i s t _ i t e m DW_TAG_packed_type DW_TAG_ptr_to_member_type D W _ T A G _ p o i n t e r _ t y p e DW_TAG_set_type DW _ TA G _ re f er e n ce _ t yp e DW_TAG_structure_type DW _ TA G _ st r in g _ ty p e DW _ TA G _ su b pr o g ram DW_TAG_subrange_type DW_TAG_subroutine_type DW_TAG_template_type_param DW_TAG_template_value_param DW_TAG_thrown_type DW_TAG_typedef DW_TAG_try_block DW_TAG_unspecified_parameters DW_TAG_union_type DW_TAG_variable DW_TAG_variant DW_TAG_variant_part DW_TAG_volatile_type DW_TAG_with_stmt _ ________________________________________________________________________________________ _ Figure 1. T a g na mes

2.2 Attribute Types


E a ch a t t r ib u t e va lue is cha r a c t er ized by a n a t t r ib u t e na me. T he set of a t t r ibu t e na mes is list ed in F igu r e 2. T he per m issible va lues for a n a t t r ib u t e belong t o one or mor e cla sses of a t t r ibu t e va lue for m s. E a ch for m cla ss ma y be r epr esen t ed in one or m or e wa ys. F or in st a nce, some a t t r ib u t e va lues consist of a single piece of const a n t da t a . C onst a nt da t a is t he cla ss of a t t r ib u t e va lue t h a t t h ose a t t r ibu t es ma y h a ve. T her e a r e sever a l r epr esen t a t ions of const a n t da t a , h owever ( one , t wo, f our , eigh t b yt es a n d va r ia ble lengt h da t a ) . T he pa r t icu la r r epr esen t a t ion for a ny given in sta nce of a n a t t r ib u t e is encode d a long wit h t he
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

_ _______________________________________________________________________________ _ D W _ A T _ a b s t r a c t _ o r i g i n DW_AT_accessibility D W _ A T _ a d d r e s s _ c l a s s DW_AT_artificial DW_AT_bit_offset D W _ A T _ b a s e _ t y p e s DW_AT_byte_size D W _ A T _ b i t _ s i z e DW_AT_common_reference D W _ A T _ c a l l i n g _ c o n v e n t i o n D W _ A T _ c o m p _ d i r DW_AT_const_value D W _ A T _ c o n t a i n i n g _ t y p e DW_AT_count D W _ A T _ d a t a _ m e m b e r _ l o c a t i o n DW_AT_decl_column DW_AT_decl_line D W _ A T _ d e c l _ f i l e DW_AT_default_value D W _ A T _ d e c l a r a t i o n D W _ A T _ d i s c r DW_AT_discr_list D W _ A T _ d i s c r _ v a l u e DW_AT_encoding D W _ A T _ e x t e r n a l DW_AT_frame_base DW_AT_high_pc D W _ A T _ f r i e n d DW_AT_import D W _ A T _ i d e n t i f i e r _ c a s e DW_AT_is_optional D W _ A T _ i n l i n e D W _ A T _ l a n g u a g e DW_AT_location DW _ A T _ l o w _ p c DW_AT_lower_bound DW _ AT _ m ac r o_ i n fo DW_AT_name DW_AT_ordering DW _ AT _ n am e li s t _i t e m DW_AT_producer DW _ AT _ p ri o rity DW _ AT_pro t otyped DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_stmt_list DW_AT_static_link DW_AT_string_length DW_AT_stride_size DW_AT_upper_bound DW_AT_type DW_AT_use_location DW_AT_variable_parameter DW_AT_virtuality DW_AT_visibility DW_AT_vtable_elem_location _ _______________________________________________________________________________ _ Figure 2. A t t r ibu t e na mes a t t r ib u t e na me a s pa r t of t he in for ma t ion t ha t gu ides t h e in t er pr et a t ion of a debugging infor ma t ion en t r y. A t t r ibu t e va lue for m s ma y belong t o one of t he following cla sses. a ddr ess block const a n t a g r efer ence R efer s t o some loca t ion in t he a ddr ess spa ce of t he descr ibed pr ogr a m . A n a r bit r a r y nu m ber of unint er pr et ed byt es of da t a . O ne, t wo, four or eigh t byt es of u nin t er pr et ed da t a , or da t a encoded in t he va r ia ble lengt h for ma t kn own a s L E B128 ( see sec t ion 7.6) . A sma ll const a n t t h a t indica t es t he pr esence or a bsence of a n a t t r ib u t e. R efer s t o some member of t he set of debugging infor ma t ion ent r ies t h a t descr ibe t h e pr ogr a m. T her e a r e t wo t ypes of r efer ence. T he r st is a n offset r ela t ive t o t he begin ning of t he comp ila t ion u nit in which t he r efer ence occur s a n d m u st r efer t o a n ent r y wit h in t ha t sa me compila t ion u nit . T he second t ype of r efer ence is t he a ddr ess of a ny deb u ggin g in for m a t ion ent r y wit h in t he sa me execu t a ble or sha r ed
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

--

--

DWARF D ebugging Information Format

object ; it m a y r efer t o a n en t r y in a d iffer en t compila t ion u n it fr om t he u nit cont a in in g t he r efer ence. st r in g A nu ll-t er mina t ed sequence of zer o or m or e ( non-nu ll) byt e s. D a t a in t h is f or m a r e gener a lly pr in t a ble st r ings. S t r in gs ma y be r epr esen t ed dir ect ly in t he deb u gging infor m a t ion en t r y or a s a n offset in a sepa r a t e st r ing t a ble.

T her e a r e n o lim it a t ions on t h e or der ing of a t t r ib u t es wit h in a debu ggin g infor ma t ion ent r y, bu t t o pr even t a m bigu it y, no mor e t ha n one a t t r ibu t e wit h a given na me ma y a ppea r in a n y debu ggin g infor ma t ion en t r y.

2.3 Relationship of Debugging Information Entries


A variet y of need s can be m et by perm it t ing a single d ebu gging inf orm at ion ent ry t o own an arbi t rary nu m ber of ot h er d ebu gging ent ries and by perm it t ing t h e sam e d ebu gging inf orm at ion ent ry t o be one of m any owned by anot h er d ebu gging inf orm at ion ent ry . T h is m ak es it p os si bl e t o d escribe, f or ex am p l e, t h e st at ic bl ock st ru ct u re wit h in a sou rce l e, sh ow t h e m em bers of a st ru ct u re, u ni on, or class, and associat e d eclara t ions wit h sou rce les or sou rce l es wit h sh ared obj ect s. T he owner ship r ela t ion of debu gging infor ma t ion en t r ies is a chieved na t ur a lly beca use t he debu ggin g infor ma t ion is r epr esen t ed a s a t r ee. T he n odes of t he t r ee a r e t he debu gging infor ma t ion en t r ies t hemselves. T he ch ild en t r ies of a ny node a r e exa ct ly t h ose deb u ggin g infor ma t ion en t r ies owned b y t ha t n ode.1 T he t r ee it self is r epr esen t ed b y a t t en ing it in pr ex or der . E a ch debu gging infor ma t ion ent r y is dene d e it h er t o ha ve ch ild ent r ies or not t o ha ve ch ild en t r ies ( see sec t ion 7.5.3) . I f a n ent r y is dened not t o ha ve ch ildr en , t he next physica lly succeed ing en t r y is t he siblin g of t h e pr ior en t r y. I f a n en t r y is dened t o ha ve childr en, t he next physica lly succeeding en t r y is t he r st ch ild of t he pr ior en t r y. A d dit iona l ch ildr en of t he pa r ent ent r y a r e r epr esen t ed a s siblin gs of t he r st ch ild . A ch a in of siblin g en t r ies is t er m ina t ed by a n u ll en t r y. I n ca ses wher e a pr odu cer of deb u gging infor m a t ion feels t h a t it will be impor t a n t for consumer s of t ha t infor ma t ion t o quickly sca n cha ins of sibling en t r ies, ignor ing t he ch ildr en of individu a l siblin gs, t ha t pr oducer m a y a t t a ch a n A T _ s i b l i n g a t t r ib u t e t o a ny deb u ggin g in for m a t ion ent r y. T he va lue of t h is a t t r ibu t e is a r efer ence t o t h e sibling ent r y of t he en t r y t o which t he a t t r ib u t e is a t t a ched.

2.4 Location D escriptions


T h e d ebu gging inf orm at ion m u st provid e cons u m ers a way t o nd t h e l ocat ion of p rogram variables, d et erm ine t h e bou nd s of d y na m ic array s and st ri ngs and p os si bl y t o nd t h e base ad d ress of a su brou t ines st ack f ram e or t h e ret u rn ad d ress of a su brou t ine.
___________________ 1. W h ile t h e owner sh ip r ela t ion of t h e d eb u ggin g infor m a t ion en t r ies is r epr esen t ed a s a t r ee, ot h er r ela t ions a m ong t h e en t r ies exist , for exa m p le, a point er fr om a n en t r y r ep r esen t in g a va r ia ble t o a not h er en t ry r ep r esen t in g t h e t ype of t h a t va r ia b le. I f a ll such r ela t ions a r e t a k en in t o a ccou n t , t h e d ebu gging en t r ies for m a gr a ph , not a t r ee.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

Fu rt herm ore, t o m eet t h e need s of recent com p u t er arch it ect u res and op t im iz at ion t ech niqu es , t h e d ebu gging inf orm at ion m u st be abl e t o d escribe t h e l ocat ion of an obj ect wh ose loca t ion ch anges over t h e ob j ect s l if et im e. I nfor ma t ion a b out t he loca t ion of pr ogr a m object s is pr ovided by loca t ion descr ipt ions. Loca t ion descr ip t ions ca n be eit her of t wo for m s: 1. L oca t ion ex pressions which a r e a la ngu a ge in depen den t r epr esen t a t ion of a ddr essing r ules of a r b it r a r y complexit y bu ilt f r om a few ba sic bu ilding blocks, or operat ions. T hey a r e su fficient for descr ib ing t he loca t ion of a ny object a s long a s it s lifet ime is eit her st a t ic or t he sa me a s t he lexica l block t ha t owns it , a nd it does not m ove t h r ough ou t it s lif et im e. L oca t ion l i st s which a r e u sed t o descr ibe object s t ha t ha ve a lim it ed lifet im e or cha nge t heir loca t ion t h r ough out t h eir lif et ime. L oca t ion list s a r e mor e complet ely descr ibed below.

2.

T he t wo for ms a r e d ist ingu ished in a cont ext sen sit ive ma nner . A s t he va lue of a n a t t r ib u t e, a loca t ion expr ession is encode d a s a b lock a nd a loca t ion list is encoded a s a const a n t offset in t o a loca t ion list t a ble. N ot e: T h e V ersion 1 concept of "locat ion d escript ions" was rep l aced in V ersion 2 wit h t h is new abst ract ion becau se it is d enser and m ore d escri pt ive. 2.4.1 Location Ex pressions A loca t ion expr ession con sists of zer o or mor e loca t ion oper a t ions. A n expr ession wit h zer o oper a t ions is u sed t o denote a n object t ha t is pr esen t in t he sour ce code bu t not pr esen t in t he object code ( per ha ps beca use of opt im iza t ion) . T he loca t ion oper a t ions fa ll in t o t wo ca t egor ies, r egist er na mes a n d a ddr essing oper a t ions. R e gist er na mes a lwa ys a ppea r a lone a nd indica t e t ha t t he r efer r ed object is cont a ined inside a pa r t icu la r r e gist er . A ddressing oper a t ions a r e m em or y a ddr ess compu t a t ion r ules. A ll loca t ion oper a t ions a r e encoded a s a st r ea m of opcodes t ha t a r e ea ch f ollowed by zer o or m or e lit er a l oper a n d s. T h e nu m ber of oper a nds is det er mined by t h e opcode. 2.4.2 Register N ame Operators T he f ollowing oper a t ions ca n be u sed t o na me a r egist er . N ot e t h at t h e regi st er nu m ber represent s a DW A R F speci c m ap ping of nu m bers ont o t h e act u al regi st ers of a given arch it ect u re. T h e m app ing sh ou l d be ch osen t o gain op t im al d ens i t y and sh ou l d be sh ared by al l u sers of a given arch it ect u re. T h e Program m ing L angu ages S I G recom m end s t h at t h is m app ing be d e ned by t h e A B I 2 au t h oring com m it t ee f or each arch it ect u re. 1. D W _ O P _ r e g 0, D W _ O P _ r e g 1, ..., D W _ O P _ r e g 3 1 T he D W _ O P _ r e gn oper a t ions encode t he na mes of u p t o 32 r e gist er s, nu mber ed fr om 0 t h r ough 31, inclusive. T he object a ddr essed is in r e gist er n.

___________________ 2. S y st em V A p p l icat i on B ina ry I nt erf ace, consist in g of t h e gen er ic in t er fa ce a nd pr ocessor supplem en t s f or ea ch t a r get a r ch it ect u r e.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

2.

DW_OP_regx T he D W _ O P _ r e g x oper a t ion h a s a single u nsigned L E B128 lit er a l oper a nd t ha t encodes t h e na m e of a r e gist er .

2.4.3 Addressing Operations E a ch a ddr essing oper a t ion r epr esen t s a post x oper a t ion on a simple st a ck ma ch ine . E a ch elem en t of t he st a ck is t h e size of a n a ddr ess on t h e t a r ge t ma chine. T he va lue on t he top of t he sta ck a f t er execu t ing t he loca t ion expr ession is t a ken t o be t he r esu lt ( t he addr ess of t he object , or t h e va lu e of t h e a r r a y boun d, or t h e len gt h of a dyna mic st r ing) . I n t he ca se of loca t ions used f or st r u ct ur e mem ber s, t h e compu t a t ion a ssum es t ha t t h e ba se a ddr ess of t he cont a in ing st r u ct u r e ha s been pu shed on t he st a ck befor e eva lua t ion of t he a ddr essing oper a t ion.
2.4.3 .1 Literal Encodings

T he f ollowing oper a t ions a ll pu sh a va lue ont o t he a ddr essing st a ck. 1. D W _ O P _ l i t 0, D W _ O P _ l i t 1, ..., D W _ O P _ l i t 3 1 T he D W _ O P _ l i tn oper a t ions encode t he u nsigned lit er a l va lues fr om 0 t hr ough 31, inclu sive. DW_OP_addr T he D W _ O P _ a d d r oper a t ion h a s a single oper a n d t ha t encodes a m a ch ine a ddr ess a nd whose size is t he size of a n a ddr ess on t he t a r get ma ch ine. DW_OP_const1u T he single oper a nd of t he D W _ O P _ c o n s t 1 u oper a t ion pr ovides a 1- byt e u nsigned int eger const a n t . DW_OP_const1s T he single oper a nd of t he D W _ O P _ c o n s t 1 s oper a t ion pr ovides a 1- byt e signed int eger const a n t . DW_OP_const2u T he single oper a nd of t he D W _ O P _ c o n s t 2 u oper a t ion pr ovides a 2- byt e u nsigned int eger const a n t . DW_OP_const2s T he single oper a nd of t he D W _ O P _ c o n s t 2 s oper a t ion pr ovides a 2- byt e signed int eger const a n t . DW_OP_const4u T he single oper a nd of t he D W _ O P _ c o n s t 4 u oper a t ion pr ovides a 4- byt e u nsigned int eger const a n t . DW_OP_const4s T he single oper a nd of t he D W _ O P _ c o n s t 4 s oper a t ion pr ovides a 4- byt e signed int eger const a n t . DW_OP_const8u T he single oper a nd of t he D W _ O P _ c o n s t 8 u oper a t ion pr ovides a n 8-byt e u n signed int eger const a n t .

2.

3.

4.

5.

6.

7.

8.

9.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

--

--

DWARF D ebugging Information Format

10.

DW_OP_const8s T he single oper a nd of t he D W _ O P _ c o n s t 8 s oper a t ion pr ovides a n 8-byt e signed int eger const a n t . DW_OP_constu T he single oper a nd of t he D W _ O P _ c o n s t u oper a t ion pr ovides a n u nsigned L E B128 int eger const a n t . DW_OP_consts T he single oper a nd of t he D W _ O P _ c o n s t s oper a t ion pr ovides a signed L E B128 int eger const a n t .

11.

12.

2.4.3 .2 Register Based Addressing

T he f ollowing oper a t ions pu sh a va lue ont o t he sta ck t ha t is t he r esult of a dding t he cont ent s of a r e gist er with a given signed offset . 1. DW_OP_fbreg T he D W _ O P _ f b r e g oper a t ion pr ovides a signed L E B128 offset fr om t he a ddr ess specied b y t he loca t ion descr ipt or in t he D W _ A T _ f r a m e _ b a s e a t t r ib u t e of t he cur r ent fu n ct ion. ( T h is is t y p ical l y a "st ack point er" regist er p l u s or m inu s som e off set . On m ore sop h is t icat ed sy st em s it m igh t be a locat ion l ist t h at ad j u st s t h e off set accord ing t o ch anges in t h e st ack p oi nt er as t h e PC ch anges.) D W _ O P _ b r e g 0, D W _ O P _ b r e g 1, ..., D W _ O P _ b r e g 3 1 T he single oper a nd of t he D W _ O P _ b r e gn oper a t ions pr ovides a signed L E B128 offset fr om t he specied r e gist er . DW_OP_bregx T he D W _ O P _ b r e g x oper a t ion h a s t wo oper a nds: a signed L E B128 offset fr om t he specied r e gist er which is dened wit h a n u n signed L E B128 nu mber .

2.

3.

2.4.3 .3 S tac k Operations

T he f ollowing oper a t ions ma nipu la t e t he loca t ion sta ck. L oca t ion oper a t ions t ha t index t he loca t ion st a ck a ssume t ha t t he t op of t h e st a ck ( m ost r ecent ly a d ded ent r y) h a s index 0. 1. 2. 3. DW_OP_dup T he D W _ O P _ d u p oper a t ion d u plica t es t h e va lu e a t t h e t op of t he loca t ion st a ck. DW_OP_drop T he D W _ O P _ d r o p oper a t ion pops t h e va lu e a t t h e t op of t he st a ck. DW_OP_pick T he single oper a nd of t he D W _ O P _ p i c k oper a t ion pr ovides a 1- byt e index. T he st a ck en t r y wit h t he specied index ( 0 t hr ough 255 , inclu sive) is pushed on t he sta ck. DW_OP_over T he D W _ O P _ o v e r oper a t ion d u plica t es t h e en t r y cur r en t ly second in t he sta ck a t t he t op of t h e st a ck. T h is is equ iva lent t o a n D W _ O P _ p i c k oper a t ion, wit h index 1 . DW_OP_swap T he D W _ O P _ s w a p oper a t ion swa ps t he t op t wo st a ck ent r ies. T he ent r y a t t he t op of t he sta ck becomes t h e second st a ck ent r y, a nd t he second ent r y becomes t he t op of t he st a ck.
D WARF S pecication, Version 2.0

4.

5.

Tool Interface Standards ( TIS)

10

--

--

DWARF D ebugging Information Format

6.

DW_OP_rot T he D W _ O P _ r o t oper a t ion r ot a t es t he r st t hr ee st a ck en t r ies. T h e en t r y a t t he t op of t he st a ck becomes t he t h ir d st a ck en t r y, t h e sec ond en t r y becomes t he t op of t he st a ck, a nd t he t hir d ent r y becomes t he second en t r y. DW_OP_deref T he D W _ O P _ d e r e f oper a t ion pops t h e t op sta ck ent r y a nd t r ea t s it a s a n a ddr ess. T he va lue r et r ieved fr om t ha t a ddr ess is pushed . T he size of t he da t a r et r ieved fr om t he der efer enced a ddr ess is t h e size of a n a ddr ess on t h e t a r ge t ma chine. DW_OP_deref_size T he D W _ O P _ d e r e f _ s i z e oper a t ion beh a ves like t he D W _ O P _ d e r e f oper a t ion: it pops t he t op st a ck ent r y a nd t r ea t s it a s a n a ddr ess. T h e va lu e r et r ieved fr om t ha t a ddr ess is pushed . I n t h e D W _ O P _ d e r e f _ s i z e oper a t ion, however , t h e size in byt es of t he da t a r et r ieved fr om t he der efer enced a ddr ess is specied by t he single oper a nd . T h is oper a n d is a 1- b yt e u n signed int egr a l const a n t whose va lue ma y not be la r ger t ha n t he size of a n a ddr ess on t he t a r get ma ch ine . T he da t a r et r ieved is zer o ext en ded t o t he size of a n a ddr ess on t he t a r get m a ch ine before bein g pu shed on t he expr ession sta ck. DW_OP_xderef T he D W _ O P _ x d e r e f oper a t ion pr ovides a n ext ended der efer ence mecha n ism. T he ent r y a t t he t op of t he st a ck is t r ea t ed a s a n a ddr ess. T he second st a ck en t r y is t r ea t ed a s a n a d dr ess spa ce iden t ier f or t h ose a r ch it ect u r es t h a t suppor t mu lt iple a ddr ess spa ce s. T he t op t wo st a ck elem en t s a r e popped, a da t a it em is r et r ieved t hr ough a n implemen t a t ion- dened a ddr ess ca lcu la t ion a nd pu shed a s t he new st a ck t op. T he size of t h e da t a r et r ieved fr om t he der efer enced a ddr ess is t he size of a n a ddr ess on t he t a r get ma ch ine . DW_OP_xderef_size T he D W _ O P _ x d e r e f _ s i z e oper a t ion beh a ves like t he D W _ O P _ x d e r e f oper a t ion: t he en t r y a t t he t op of t he sta ck is t r ea t ed a s a n a ddr ess. T he sec ond st ack ent r y is t r ea t ed a s a n a ddr ess spa ce iden t ier for t h ose a r ch it ect ur es t hat suppor t mu lt iple a d dr ess spa ces. T he t op t wo st a ck elemen t s a r e popped, a da t a it em is r et r ieved t h r ough a n im plem en t a t ion-dened a ddr ess ca lcula t ion a nd pu shed a s t h e new sta ck t op. I n t he D W _ O P _ x d e r e f _ s i z e oper a t ion, however , t h e size in byt es of t he da t a r et r ieved fr om t he der efer enced a ddr ess is specied by t he single oper a n d . T h is oper a nd is a 1- b yt e u n signed in t egr a l const a n t whose va lue ma y n ot be la r ger t ha n t he size of a n a ddr ess on t he t a r get ma ch ine. T he da t a r et r ieved is zer o ext en ded t o t he size of a n a ddr ess on t he t a r get m a ch ine before bein g pu shed on t he expr ession sta ck.

7.

8.

9.

10.

2.4.3 .4 Arithmetic and Logical Operations

T he f ollowing pr ovide a r it h met ic a nd logica l oper a t ions. T he a r it hmet ic oper a t ions per for m a ddr essing a r it h m et ic, t ha t is, u n signed a r it h m et ic t h a t wr a ps on a n a ddr esssized boun da r y. T he oper a t ions do not ca use a n except ion on over ow. 1. DW_OP_abs T he D W _ O P _ a b s oper a t ion pops t h e t op sta ck ent r y a nd pu shes it s a bsolut e va lue.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

11

--

--

DWARF D ebugging Information Format

2.

DW_OP_and T he D W _ O P _ a n d oper a t ion pops t h e t op t wo st a ck va lues, per for ms a b it wise and oper a t ion on t he t wo, a n d pu shes t h e r esu lt . DW_OP_div T he D W _ O P _ d i v oper a t ion pops t h e t op t wo st a ck va lues, d ivides t he for m er second ent r y by t h e for m er t op of t he sta ck u sing signed division, a n d pu shes t he r esu lt . DW_OP_minus T he D W _ O P _ m i n u s oper a t ion pops t h e t op t wo st a ck va lues, sub t r a c t s t he f or mer t op of t h e st a ck fr om t h e for m er second ent r y, a n d pu shes t he r esult . DW_OP_mod T he D W _ O P _ m o d oper a t ion pops t h e t op t wo st a ck va lues a n d pu shes t he r esu lt of t he ca lcu la t ion: f or mer second st a ck en t r y m odu lo t h e for mer t op of t he sta ck. DW_OP_mul T he D W _ O P _ m u l oper a t ion pops t h e t op t wo st a ck en t r ies, mu lt iplies t h em t oget her , a nd pushes t he r esult . DW_OP_neg T he D W _ O P _ n e g oper a t ion pops t h e t op sta ck ent r y, a nd pu shes it s nega t ion. DW_OP_not T he D W _ O P _ n o t oper a t ion pops t h e t op sta ck ent r y, a nd pu shes it s b it wise complement . DW_OP_or T he D W _ O P _ o r oper a t ion pops t h e t op t wo st a ck en t r ies, per for ms a b it wise or oper a t ion on t he t wo, a n d pu shes t h e r esu lt . DW_OP_plus T he D W _ O P _ p l u s oper a t ion pops t h e t op t wo st a ck en t r ies, a dds t h em t oget her , a nd pushes t he r esult . DW_OP_plus_uconst T he D W _ O P _ p l u s _ u c o n s t oper a t ion pops t h e t op sta ck ent r y, a dds it t o t he unsigned L E B128 const a n t oper a n d a nd pu shes t he r esu lt . T h is operat ion is su ppl ied speci cal l y t o be able t o encod e m ore el d off set s in t wo by t es t h an can be d one wi t h "D W _ O P _ l i tn D W _ O P _ a d d". DW_OP_shl T he D W _ O P _ s h l oper a t ion pops t h e t op t wo st a ck en t r ies, shif t s t he for mer second en t r y lef t b y t h e n u m ber of b it s specied b y t he f or mer t op of t he st a ck , a n d pu shes t he r esult . DW_OP_shr T he D W _ O P _ s h r oper a t ion pops t h e t op t wo st a ck en t r ies, shif t s t he for mer second ent r y r igh t ( logica lly) b y t he n u m ber of b it s specied by t he f or mer t op of t he st a ck, a nd pushes t he r esult . DW_OP_shra T he D W _ O P _ s h r a oper a t ion pops t h e t op t wo st a ck en t r ies, shif t s t he for mer second en t r y r igh t ( a r it hmet ica lly) by t he nu m ber of b it s specied by t h e for mer t op
D WARF S pecication, Version 2.0

3.

4.

5.

6.

7. 8.

9.

10.

11.

12.

13.

14.

Tool Interface Standards ( TIS)

12

--

--

DWARF D ebugging Information Format

of t he sta ck, a nd pushes t he r esult . 15. DW_OP_xor T he D W _ O P _ x o r oper a t ion pops t h e t op t wo st a ck en t r ies, per for ms t he logica l ex clu sive- or oper a t ion on t he t wo, a n d pu shes t h e r esu lt .

2.4.3 .5 Control Flow Operations

T he f ollowing oper a t ions pr ovide simple cont r ol of t he ow of a loca t ion expr ession. 1. R ela t iona l oper a t or s T he six r ela t iona l oper a t or s ea ch pops t he t op t wo st a ck va lu es, compa r es t he f or mer t op of t he st a ck with t he f or m er second ent r y, a n d pu shes t he const a nt va lue 1 ont o t he st a ck if t he r esult of t he oper a t ion is t r u e or t he const a n t va lue 0 if t he r esult of t he oper a t ion is fa lse. T he compa r isons a r e done a s signed oper a t ions. T he six oper a t or s a r e D W _ O P _ l e ( less t ha n or equa l t o) , D W _ O P _ g e ( gr ea t er t ha n or equa l t o) , D W _ O P _ e q ( equ a l t o) , D W _ O P _ l t ( less t ha n) , D W _ O P _ g t ( gr ea t er t ha n) a nd D W _ O P _ n e ( not equ a l t o) . DW_OP_skip D W _ O P _ s k i p is a n u ncond it iona l br a nch . I t s single oper a nd is a 2- b yt e signed int eger const a n t . T he 2- byt e const a nt is t h e nu m ber of byt es of t he loca t ion expr ession t o skip fr om t he cu r r en t oper a t ion, begin n ing a f t er t h e 2- b yt e c onst a n t . DW_OP_bra D W _ O P _ b r a is a cond it iona l br a nch . I t s single oper a nd is a 2- byt e signed int eger const a n t . T h is oper a t ion pops t he t op of st a ck. I f t he va lue popped is not t he const a n t 0, t he 2- byt e const a n t oper a nd is t he nu mber of byt es of t h e loca t ion expr ession t o skip fr om t he cu r r en t oper a t ion, begin n ing a f t er t h e 2- b yt e c onst a n t .

2.

3.

2.4.3 .6 S pecial Operations

T her e a r e t wo specia l oper a t ions cu r r en t ly dened: 1. DW_OP_piece M any com pilers st ore a singl e vari able in set s of regis t ers , or st ore a variabl e part ial ly in m em ory and part ial ly in regist ers. D W _ O P _ p i e c e provid es a way of d escribing h ow l arge a part of a vari able a part icu l ar ad d ressing ex pression ref ers t o. D W _ O P _ p i e c e t a kes a single a r gu m en t which is a n unsigned L E B128 nu m ber . T he n u m ber descr ibes t he size in b yt es of t he piece of t he object r efer enced by t he a ddr essing expr ession whose r esu lt is a t t he t op of t he sta ck. 2. DW_OP_nop T he D W _ O P _ n o p oper a t ion is a pla ce h older . I t h a s no effect on t he loca t ion st a ck or a n y of it s va lue s.

2.4.4 Sample Stack Operations T h e st ack operat ions d e ned in sect ion 2.4.3.3 are f airly convent iona l , bu t t h e f ol l owing ex am ples il lu st rat e t h eir beh av ior graph ical l y .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

13

--

--

DWARF D ebugging Information Format

_______________________________________________________________________________________ Before O per a t ion A _ er __________________________________________________________________ft____________________ 17 DW_OP_dup 0 17 0 29 1 17 1 1000 2 29 2 3 1000 _______________________________________________________________________________________ 0 17 DW_OP_drop 0 29 29 1 1000 1 1000 2 _______________________________________________________________________________________ 0 17 DW_OP_pick 2 0 1000 1 29 1 17 1000 2 29 2 3 1000 _______________________________________________________________________________________ 0 17 DW_OP_over 0 29 1 29 1 17 2 1000 2 29 3 1000 _______________________________________________________________________________________ 0 17 DW_OP_swap 0 29 1 29 1 17 2 1000 2 1000 _______________________________________________________________________________________ 17 DW_OP_rot 0 29 0 29 1 1000 1 ______________________________________________________________________________________ 2 1000 2 17 _ 2.4.5 Ex ample Location Ex pressions T h e ad d res si ng ex pression represent ed by a l ocat ion ex pression, if evalu at ed , genera t es t h e ru nt im e ad d ress of t h e val u e of a sy m bol ex cept where t h e D W _ O P _ r e gn, or D W _ O P _ r e g x operat ions are u sed . H ere are som e ex am p l es of h ow l ocat ion operat ions are u sed t o f orm l ocat ion ex pressions:

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

14

--

--

DWARF D ebugging Information Format

DW_OP_reg3 T h e val u e is in regist er 3 . DW_OP_regx 54 T h e val u e is in regist er 5 4. DW_OP_addr 0x80d0045c T h e val u e of a st at ic vari able is at m ach ine ad d ress 0x 80d 0045c. DW_OP_breg11 44 A d d 4 4 t o t h e val u e in regist er 11 t o get t h e ad d ress of an au t om at ic va ri a bl e ins t ance. DW_OP_fbreg -50 Given an D W _ A T _ f r a m e _ b a s e val u e of "O P B R E G 3 1 6 4," t h is ex am p l e com p u t es t h e ad d ress of a l ocal vari able t h at is - 50 by t es f rom a l ogical f ram e point er t h a t is com pu t ed by ad d ing 64 t o t h e cu rrent s t ack p oint er ( regi st er 31) . DW_OP_bregx 54 3 2 DW_OP_deref A cal l - by - ref erence param et er wh ose ad d ress is in t h e word 32 by t es f rom wh ere regist er 54 p oint s. DW_OP_plus_uconst 4 A st ru ct u re m em ber is f ou r by t es f rom t h e st a rt of t h e st ru ct u re inst ance. T h e base ad d ress is assu m ed t o be al read y on t h e s t ack . DW_OP_reg3 DW_OP_piece 4 DW_OP_reg10 DW_OP_piece 2 A variabl e wh ose rs t f ou r by t es res id e in regist er 3 and wh ose nex t t wo by t es resid e in regist er 10 . 2.4.6 Location Lists Loca t ion list s a r e used in pla ce of loca t ion expr essions whenever t he object whose loca t ion is being descr ibed ca n cha nge loca t ion du r ing it s lifet ime. L oca t ion list s a r e cont a ined in a sepa r a t e object le sec t ion ca lled . d e b u g _ l o c . A loca t ion list is indica t ed by a loca t ion a t t r ibu t e whose va lu e is r epr esen t ed a s a const a n t offset fr om t he begin ning of t he . d e b u g _ l o c sect ion t o t he r st byt e of t he list for t he object in qu est ion. E a ch en t r y in a loca t ion list c onsist s of:
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

15

--

--

DWARF D ebugging Information Format

1.

A begin n ing a d dr ess. T h is a ddr ess is r ela t ive t o t he ba se a ddr ess of t he compila t ion unit r ef er en cin g t h is loca t ion list . I t ma r ks t he beginning of t he a ddr ess r a nge over which t he loca t ion is va lid. A n en d in g a ddr ess, a ga in r ela t ive t o t he ba se a ddr ess of t h e compila t ion u n it r efer encin g t h is loca t ion list . I t ma r ks t he r st a d dr ess pa st t he end of t he a ddr ess r a nge over which t he loca t ion is va lid. A loca t ion expr ession descr ib in g t h e loca t ion of t h e object over t he r a nge specied by t he begin n ing a n d end a ddr esses.

2.

3.

A ddr ess r a nges ma y over la p. W hen t hey do, t hey descr ibe a situa t ion in which a n object exist s simu lt a neously in mor e t ha n one pla ce. I f a ll of t he a ddr ess r a nges in a given loca t ion list do n ot collect ively cover t he ent ir e r a nge over which t he object in qu est ion is dened , it is a ssumed t h a t t he object is not a va ila ble for t he por t ion of t he r a nge t ha t is not cover ed . T he end of a ny given loca t ion list is ma r ked by a 0 for t h e beginning a ddr ess a nd a 0 for t he en d a ddr ess; n o loca t ion descr ip t ion is pr esent . A loca t ion list cont a ining only such a 0 ent r y descr ibes a n object t ha t exist s in t he sour ce code bu t n ot in t he execu t a ble pr ogr a m .

2.5 Types of D eclarations


A ny debu ggin g infor m a t ion en t r y descr ibing a decla r a t ion t ha t h a s a t ype ha s a D W _ A T _ t y p e a t t r ib u t e, whose va lue is a r efer ence t o a n ot her deb u ggin g infor m a t ion ent r y. T he ent r y r efer enced m a y descr ibe a ba se t ype, t ha t is, a t ype t ha t is not de ned in t er m s of ot h er da t a t ypes, or it ma y descr ibe a user -dened t ype , such a s a n a r r a y, st r uc t u r e or en u m er a t ion. A lt er na t ively, t he en t r y r efer enced ma y descr ibe a t ype m odier : const a n t , pa cked , point er , r efer ence or vola t ile , which in t ur n will r efer ence a not h er en t ry descr ibing a t ype or t ype m odier ( u sing a D W _ A T _ t y p e a t t r ib u t e of it s own) . See sect ion 5 for descr ipt ions of t he en t r ies descr ib ing ba se t ypes, user -dened t ypes a n d t ype modier s.

2.6 Acces sibility of Declarations


S om e langu ages, not ably C+ + and A d a, h ave t h e concept of t h e access ibil it y of an obj ect or of som e ot h er p rogram ent i t y . T h e accessi bi l it y speci es wh ich classes of ot h er program obj ect s are perm it t ed access t o t h e obj ect in qu est ion. T he a cce ssibilit y of a decla r a t ion is r epr esen t ed by a D W _ A T _ a c c e s s i b i l i t y a t t r ib u t e, whose va lue is a const a n t dr a wn fr om t he set of codes list ed in F igur e 3. _______________________________ DW_ACCESS_public DW_ACCESS_private ___W__A__C__S_____r__t__c__e___ D __ _C _ E _S _ p _o _e _t _ d Figure 3. Accessib ilit y codes

2.7 Visibility of Declarations


M od u l a2 h as t h e concept of t h e visibil it y of a d eclara t ion. T h e visibil it y speci es wh ich declarat ions are t o be v is ibl e ou t sid e of t h e m od u le in wh ich t h ey are d eclared . T he visib ilit y of a decla r a t ion is r epr esen t ed by a D W _ A T _ v i s i b i l i t y a t t r ib u t e, whose va lu e is a const a nt dr a wn fr om t he set of codes listed in F igu r e 4.
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

16

--

--

DWARF D ebugging Information Format

_ _________________________ DW_VIS_local DW_VIS_exported _D_____I_____u__l__f__e___ _W_V_S_q_a_i _i_d Figure 4. Visib ilit y codes

2.8 Virtuality of Dec larations


C+ + provid es f or virt u al and pu re virt u a l st ru ct u re or class m em ber f u nct ions and f or virt u al base classes. T he vir t ua lit y of a decla r a t ion is r epr esen t ed by a D W _ A T _ v i r t u a l i t y a t t r ib u t e, whose va lu e is a const a nt dr a wn fr om t he set of codes listed in F igu r e 5. _ ________________________________________ DW_VIRTUALITY_none DW_VIRTUALITY_virtual _D_____I__T__A__I__Y__p__r_____i__t__a___ _W_V_R_U_L _T ___u _e_v _r_u _l Figure 5. Vir t u a lit y codes

2.9 Articial Entries


A com p iler m ay wish t o generat e d ebu gging inf orm at ion ent ries f or obj ect s or t y pes t h at were not act u al l y declared in t h e sou rce of t h e app l icat ion. A n ex am p le is a f orm al param et er ent ry t o rep resent t h e h id d en t h i s param et er t h at m ost C + + im p lem ent at ions pass as t h e rs t argu m ent t o non- st at ic m em ber f u nct ions . A ny debu ggin g infor m a t ion en t r y r epr esen t in g t he decla r a t ion of a n object or t ype a r t icia lly gener a t ed b y a compiler a nd n ot explicit ly decla r ed by t he sour ce pr ogr a m ma y ha ve a D W _ A T _ a r t i f i c i a l a t t r ib u t e. T he va lue of t h is a t t r ibu t e is a a g.

2.10 Target-S pecic Addressing Information


I n som e sy s t em s, ad d resses are speci ed as off set s wit h in a given segm ent ra t h er t h an as locat ions wit h in a singl e at ad d res s space. A ny debu ggin g infor m a t ion en t r y t ha t cont a in s a descr ipt ion of t he loca t ion of a n object or subr ou t ine ma y h a ve a D W _ A T _ s e g m e n t a t t r ib u t e, whose va lue is a loca t ion descr ipt ion. T he descr ipt ion eva lua t es t o t he segmen t va lue of t he it em bein g descr ibed . I f t he ent r y cont a ining t he D W _ A T _ s e g m e n t a t t r ib u t e ha s a D W _ A T _ l o w _ p c or D W _ A T _ h i g h _ p c a t t r ib u t e, or a loca t ion descr ipt ion t ha t eva lua t es t o a n a ddr ess, t hen t h ose va lues r epr esen t t he offset por t ion of t he a ddr ess wit h in t he segm en t specied by D W _ A T _ s e g m e n t. I f a n ent r y h a s no D W _ A T _ s e g m e n t a t t r ib u t e, it inher it s t he segm en t va lue fr om it s pa r ent en t r y. I f none of t he en t r ies in t he ch a in of pa r en t s for t h is en t r y ba ck t o it s cont a ining compila t ion u n it en t r y ha ve D W _ A T _ s e g m e n t a t t r ib u t es, t hen t h e en t r y is a ssumed t o exist wit h in a a t a ddr ess spa ce. S im ila r ly, if t he en t r y ha s a D W _ A T _ s e g m e n t a t t r ib u t e cont a in ing a n em pt y loca t ion descr ipt ion, t ha t en t r y is a ssumed t o exist wit h in a a t a ddr ess spa ce. S om e sy st em s su pport d iff erent classes of ad d res ses . T h e ad d ress cl as s m ay aff ect t h e way a point er is d eref erenced or t h e way a su brou t ine is cal l ed . A ny debu ggin g infor m a t ion en t r y r epr esen t in g a point er or r efer ence t ype or a subr ou t ine or su br out ine t ype ma y ha ve a D W _ A T _ a d d r e s s _ c l a s s a t t r ib u t e, whose va lue is a
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

17

--

--

DWARF D ebugging Information Format

const a n t . T he set of per m issible va lues is specic t o ea ch t a r get a r ch it ect ur e. T he va lue D W _ A D D R _ n o n e, however , is common t o a ll encodin gs, a n d mea ns t ha t no a d dr ess cla ss ha s been specied . For ex am p l e, t h e I nt el 386processor m igh t u se t h e f ol l owing val u es: ______________________________________________________________ N _m _ Va lu _ M ea ning ___a __e _______________________e _______________________________ DW_ADDR_none 0 no cla ss specied 1 16-bit offset , n o segment DW_ADDR_near16 2 16-bit offset , 16- bit segm ent DW_ADDR_far16 DW_ADDR_huge16 3 16-bit offset , 16- bit segm ent DW_ADDR_near32 4 32-bit offset , n o segment DW_ADDR_far32 5 32-bit offset , _____ segm ___ _______________________________________________16- bit______ent _ Figure 6. E xa mple a ddr ess cla ss codes

2.11 N on-Dening Declarations


A debugging in f or m a t ion en t r y r epr esen t ing a pr ogr a m object or t ype t ypica lly r epr esen t s t he de nin g decla r a t ion of t h a t object or t ype . I n cer t a in cont ext s, however , a deb u gger migh t need infor ma t ion a bou t a decla r a t ion of a subr out ine, object or t ype t ha t is not a lso a denit ion t o eva lua t e a n expr ession cor r ect ly. A s an ex am pl e, consid er t h e f ol l owi ng f ragm ent of C cod e: void myfunc() { int {

x; extern f loat x; g(x);

} } A N S I - C scoping ru les requ ire t h at t h e val u e of t h e variabl e x passed t o t h e f u nct ion g is t h e va l u e of t h e global variable x rat h er t h an of t h e local version. Debu ggin g infor ma t ion en t r ies t ha t r epr esen t n on- d en in g decla r a t ions of a pr ogr a m object or t ype ha ve a D W _ A T _ d e c l a r a t i o n a t t r ib u t e, whose va lue is a a g.

2.12 Declaration Coordinates


I t is som et im es u sef u l in a d ebu gger t o be able t o associat e a d eclarat ion wit h it s occurrence in t h e program sou rce. A ny debu ggin g infor m a t ion en t r y r epr esen t in g t he decla r a t ion of a n object , modu le, subpr ogr a m or t ype ma y ha ve D W _ A T _ d e c l _ f i l e, D W _ A T _ d e c l _ l i n e a nd D W _ A T _ d e c l _ c o l u m n a t t r ib u t es, ea ch of whose va lu e is a const a nt . T he va lue of t he D W _ A T _ d e c l _ f i l e a t t r ib u t e corr espond s t o a le nu m ber fr om t he st a t emen t infor ma t ion t a ble f or t he compila t ion u n it cont a ining t h is debu gging infor mat ion ent r y a nd r epr esen t s t he sour ce le in which t he decla r a t ion a ppea r ed ( see sec t ion 6.2) . T he va lue 0 indica t es t h a t no sour ce le ha s been specied .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

18

--

--

DWARF D ebugging Information Format

T he va lue of t he D W _ A T _ d e c l _ l i n e a t t r ib u t e r epr esen t s t he sour ce line nu m ber a t which t he r st ch a r a ct er of t he iden t ier of t he decla r ed object a ppea r s. T he va lue 0 indica t es t h a t no sour ce line h a s been specied . T he va lue of t he D W _ A T _ d e c l _ c o l u m n a t t r ib u t e r epr esen t s t he sour ce column nu mber a t which t h e r st cha r a c t er of t he ident ier of t he decla r ed object a ppea r s. T he va lue 0 indica t es t h a t no colum n ha s been specied .

2.13 Identier N ames


A ny debu ggin g infor m a t ion en t r y r epr esen t in g a pr ogr a m en t it y t ha t ha s been given a na me ma y ha ve a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a st r ing r epr esen t ing t h e na m e a s it a ppea r s in t he sour ce pr ogr a m . A deb u ggin g infor ma t ion en t r y cont a in in g no na me a t t r ib u t e, or cont a ining a na m e a t t r ibu t e whose va lue con sists of a na me cont a ining a single nu ll b yt e, r epr esen t s a pr ogr a m en t it y for which no na me wa s given in t he sour ce. N ot e t h at since t h e nam es of p rogram obj ect s d escribed by DW A R F are t h e na m es as t h ey ap pear in t h e sou rce p rogram , im p lem ent at ions of l angu age t ra nsl at ors t h at u se som e f orm of m angled nam e ( as d o m any im p lem ent a t ions of C+ + ) sh ou l d u se t h e u nm angled f orm of t h e nam e in t h e DW A R F D W _ A T _ n a m e at t ri bu t e, inclu d ing t h e k ey word o p e r a t o r, if present . S equ ences of m u l t ip l e wh it espace ch aracters m ay be com pressed .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

19

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

20

--

--

DWARF D ebugging Information Format

3. P ROGRAM SCOP E EN TRIES


T h is sect ion descr ibes debu ggin g infor m a t ion en t r ies t ha t r ela t e t o d iffer en t levels of pr ogr a m scope: compila t ion u n it , modu le, subpr ogr a m , a n d so on. T hese en t r ies m a y be t h ough t of a s bounded b y r a nges of t ext a d dr esses wit hin t he pr ogr a m .

3.1 Compilation U nit Entries


A n object le ma y be der ived f r om one or mor e compila t ion unit s. E a ch such compila t ion unit will be descr ibed b y a debuggin g infor m a t ion en t r y wit h t he t a g D W _ T A G _ c o m p i l e _ u n i t. A com p il at ion u nit t y p ical l y represent s t h e t ex t and d at a cont ribu t ed t o an ex ecu t able by a single rel ocat able obj ect l e. I t m ay be d erived f rom several sou rce l es, incl u d ing pre- processed incl u d e les. T he compila t ion u n it ent r y m a y ha ve t he f ollowing a t t r ibu t es: 1. 2. A D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma ch ine in st r uct ion ge ner a t ed for t ha t compila t ion u nit . A D W _ A T _ h i g h _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st loca t ion pa st t he la st ma ch ine inst r u ct ion gener a t ed f or t ha t compila t ion u n it . T h e ad d res s m ay be bey ond t h e l ast va l id inst ru ct ion in t h e ex ecu t abl e, of cou rse, f or t h is and ot h er sim il ar at t ri bu t es . T he pr esence of low a n d h igh pc a t t r ibu t es in a comp ila t ion u nit en t r y im ply t h a t t he code gener a t ed f or t ha t compila t ion u n it is cont igu ous a nd e xist s t ot a lly wit h in t he boun da r ies specied b y t h ose t wo a t t r ibu t es. I f t ha t is not t h e ca se, no low a nd h igh pc a t t r ibu t es should be pr odu ced. 3. A D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he fu ll or r ela t ive pa t h na m e of t h e pr im a r y sour ce le fr om which t he compila t ion u n it wa s der ived . A D W _ A T _ l a n g u a g e a t t r ib u t e whose const a nt va lue is a code in dica t ing t he sour ce la n gua ge of t he compila t ion unit . T he set of la n gua ge na m es a nd t heir mea n ings a r e given in F igu r e 7. _ ____________________________________________________________ DW_LANG_C N on- A N S I C , such a s K & R DW_LANG_C89 I SO / AN SI C C+ + DW_LANG_C_plus_plus F O R T R A N 77 DW_LANG_Fortran77 F or t r a n90 DW_LANG_Fortran90 DW_LANG_Modula2 M odula 2 D_____A__G__P__s__a__8____________O_________________________ I S _ / A N SI Pa sca l __ W _ L _ N _ _ _ a _ c _ l _ 3 Figure 7. L a n gu a ge na m es A D W _ A T _ s t m t _ l i s t a t t r ib u t e whose va lue is a r efer ence t o line nu m ber infor ma t ion for t h is compila t ion u nit . T h is infor ma t ion is pla ced in a sepa r a t e object le sec t ion fr om t he debu ggin g infor ma t ion en t r ies t hemselves. T he va lue of t h e st a t emen t list a t t r ibu t e is t he offset in t he . d e b u g _ l i n e sect ion of t he r st byt e of t he line nu mber infor ma t ion for
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

4.

5.

21

--

--

DWARF D ebugging Information Format

t h is compila t ion unit . See sec t ion 6.2. 6. A D W _ A T _ m a c r o _ i n f o a t t r ib u t e whose va lue is a r efer ence t o t he ma cr o infor ma t ion for t h is compila t ion u nit . T h is infor ma t ion is pla ced in a sepa r a t e object le sec t ion fr om t he debu ggin g infor ma t ion en t r ies t hemselves. T he va lue of t h e ma cr o infor ma t ion a t t r ibu t e is t he offset in t he . d e b u g _ m a c i n f o sect ion of t he r st byt e of t he ma cr o infor ma t ion for t h is compila t ion u n it . See sect ion 6.3 . 7. A D W _ A T _ c o m p _ d i r a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he cu r r en t wor king dir ec t or y of t he compila t ion comma nd t ha t pr odu ced t h is compila t ion u n it in wha t ever for m ma kes sense for t h e h ost syst em . T h e su gges t ed f orm f or t h e valu e of t h e D W _ A T _ c o m p _ d i r at t ri bu t e on UN I X sy st em s is h os t nam e:pat h nam e. I f no h os t nam e is avail abl e, t h e su ggest ed f orm is :pat h nam e. 8. A D W _ A T _ p r o d u c e r a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining infor ma t ion a b out t he compiler t ha t pr oduced t he compila t ion u n it . T h e a ct ua l cont ent s of t he st r ing will be specic t o ea ch pr oducer , bu t sh ould begin wit h t h e na me of t he compiler vendor or some other iden t ifying cha r a ct er sequence t ha t should a void confu sion wit h ot her pr odu cer va lues. A D W _ A T _ i d e n t i f i e r _ c a s e a t t r ib u t e whose const a nt va lue is a code descr ibing t he t r ea t ment of iden t ier s wit hin t h is compila t ion u n it . T he set of iden t ier ca se codes is given in F igu r e 8. _ __________________________________ DW_ID_case_sensitive DW_ID_up_case DW_ID_down_case _D_____D__c__s_____n__e__s__t__v___ _W_I___a_e _i _s_n _i_i _e Figure 8. I den t ier ca se codes D W _ I D _ c a s e _ s e n s i t i v e is t he defa u lt for a ll compila t ion u n it s t ha t do not ha ve t his a t t r ibu t e. I t in dica t es t ha t na mes given a s t he va lues of D W _ A T _ n a m e a t t r ib u t es in debu ggin g infor ma t ion en t r ies for t he compila t ion u nit r eect t h e na m es a s t hey a ppea r in t he sou r ce pr ogr a m . T he debu gger sh ould be sen sit ive t o t he ca se of ident ier na m es when d oing ident ier looku ps. D W _ I D _ u p _ c a s e mea n s t ha t t he pr oducer of t he debu ggin g infor ma t ion for t h is compila t ion u n it conver t ed a ll sour ce na mes t o upper ca se. T he va lues of t he na me a t t r ib u t es ma y n ot r eect t he na mes a s t hey a ppea r in t he sou r ce pr ogr a m . T he debu gger should conver t a ll na mes t o u pper ca se when d oing looku ps. D W _ I D _ d o w n _ c a s e mea n s t ha t t he pr oducer of t he debu ggin g infor ma t ion for t h is compila t ion u n it conver t ed a ll sour ce na m es t o lower ca se. T h e va lu es of t he na me a t t r ib u t es ma y n ot r eect t he na mes a s t hey a ppea r in t he sou r ce pr ogr a m . T he deb u gger sh ould conver t a ll na mes t o lower ca se when doing looku ps. D W _ I D _ c a s e _ i n s e n s i t i v e mea n s t ha t t he va lues of t he na me a t t r ibu t es r eect t he na mes a s t hey a ppea r in t h e sour ce pr ogr a m bu t t h a t a ca se insensit ive looku p sh ould be used t o a ccess t h ose na mes.
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

9.

22

--

--

DWARF D ebugging Information Format

10. A D W _ A T _ b a s e _ t y p e s a t t r ib u t e whose va lue is a r efer ence. T h is a t t r ibu t e point s t o a deb u ggin g in for m a t ion ent r y r epr esen t ing a not h er compila t ion u n it . I t ma y be u sed t o specify t he compila t ion u n it cont a in in g t h e b a se t ype en t r ies u sed by ent r ies in t h e cu r r en t compila t ion u nit ( see sec t ion 5.1) . T h is at t ri bu t e provid es a consu m er a way t o nd t h e d e ni t ion of base t y pes f or a com p il at ion u ni t t h at d oes no t it sel f cont ain su ch d e nit ions. T h is al l ows a consu m er, f or ex am p l e, t o int erp ret a t y p e conv ersion t o a base t y pe correct l y . A compila t ion u n it en t r y owns deb u ggin g infor ma t ion en t r ies t h a t r epr esen t t he decla r a t ions ma de in t h e cor r esponding compila t ion unit .

3.2 M odule Entries


S everal l angu ages h ave t h e concep t of a m od u le. A m odu le is r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t h e t a g D W _ T A G _ m o d u l e. M odu le en t r ies ma y own ot h er deb u ggin g infor m a t ion en t r ies descr ibing pr ogr a m en t it ies whose decla r a t ion scopes end a t t he end of t he m odu le it self . I f t he modu le h a s a na m e, t h e modu le ent r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a in in g t he m odule na me a s it a ppea r s in t he sour ce pr ogr a m . I f t he modu le cont a ins init ia liza t ion code , t he m odule en t r y ha s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma chine inst r u ct ion gener a t ed for t ha t init ia liza t ion code . I t a lso ha s a D W _ A T _ h i g h _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st loca t ion pa st t he la st ma chine instr uct ion gener a t ed for t he init ia liza t ion code. I f t he modu le ha s been a ssigned a pr ior it y, it ma y ha ve a D W _ A T _ p r i o r i t y a t t r ib u t e. T he va lue of t h is a t t r ibu t e is a r efer ence t o a not h er debuggin g infor ma t ion en t r y descr ibing a va r ia ble wit h a const a nt va lu e. T h e va lu e of t h is va r ia ble is t he a ct ua l const a n t va lue of t he m odules pr ior it y, r epr esen t ed a s it would be on t h e t a r ge t a r ch it ect u r e. A M od u l a2 d e ni t ion m od u l e m ay be rep resent ed by a m od u le ent ry cont aini ng a D W _ A T _ d e c l a r a t i o n at t ri bu t e.

3.3 S ubroutine and Entry P oint Entries


T he f ollowing t a gs e xist t o descr ibe debu ggin g infor ma t ion en t r ies for subr out ines a nd ent r y point s: DW_TAG_subprogram A globa l or le st a t ic su br out ine or funct ion.

D W _ T A G _ i n l i n e d _ s u b r o u t i n e A pa r t icula r inlined in sta nce of a su br out ine or fu nct ion. DW_TAG_entry_point A F or t r a n ent r y point .

3.3.1 General S ubroutine and Entry P oint Information T he subr ou t ine or en t r y point en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu llt er m ina t ed st r ing cont a ining t he su br out ine or en t r y point na me a s it a ppea r s in the sour ce pr ogr a m . I f t he na me of t he subr out ine descr ibed by a n en t r y wit h t he t a g D W _ T A G _ s u b p r o g r a m is visible ou t side of it s cont a ining compila t ion unit , t h a t en t r y
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

23

--

--

DWARF D ebugging Information Format

ha s a D W _ A T _ e x t e r n a l a t t r ib u t e, whose va lue is a a g. A d d it iona l at t ri bu t es f or f u nct ions t h at are m em bers of a cl as s or s t ru ct u re are d escribed in sect ion 5.5.5 . A com m on d ebu gger f eat u re is t o al l ow t h e d ebu gger u ser t o cal l a su brou t ine wit h in t h e su bj ect program . I n cert ain cases, howev er, t h e genera t ed cod e f or a su brou t ine wil l not obey t h e st and ard cal l ing convent ions f or t h e t arget arch it ect u re and wil l t h eref ore not be saf e t o cal l f rom wit h in a d ebu gger. A subr out ine en t r y m a y cont a in a D W _ A T _ c a l l i n g _ c o n v e n t i o n a t t r ib u t e, whose va lue is a const a n t . I f t h is a t t r ibu t e is not pr esen t , or it s va lue is t he const a nt D W _ C C _ n o r m a l, t hen t he su br out ine ma y be sa fely ca lled by obe ying t he st a nda r d ca lling conven t ions of t he t a r get a r ch it ect ur e. I f t he va lue of t he ca lling conven t ion a t t r ib u t e is t he const a n t D W _ C C _ n o c a l l, t he subr ou t ine d oes n ot obey sta nda r d ca lling convent ions, a nd it ma y not be sa fe f or t he debu gger t o ca ll t h is subr out in e. I f t he sema nt ics of t he la ngu a ge of t h e compila t ion u n it cont a in in g t h e su br out ine en t r y dist ingu ishes bet ween or dina r y su br out ines a nd subr out ines t ha t ca n ser ve a s t he ma in pr ogr a m , t ha t is, subr ou t in es t h a t ca n n ot be ca lled d ir ect ly f ollowing t he or d ina r y ca llin g conven t ions, t hen t he deb u ggin g in for m a t ion ent r y f or such a subr out ine ma y ha ve a ca lling conven t ion a t t r ib u t e whose va lue is t he const a n t D W _ C C _ p r o g r a m. T h e D W _ C C _ p r o g r a m val u e is int end ed t o su p port Fort ra n m ain program s. I t is no t int end ed as a way of nd ing t h e ent ry ad d ress f or t h e p rogram . 3.3.2 Subroutine and Entry P oint Return Types I f t he subr out ine or en t r y point is a fu nct ion t ha t r et ur n s a va lue, t hen it s deb u gging infor ma t ion en t r y ha s a D W _ A T _ t y p e a t t r ib u t e t o denot e t he t ype r et ur ned by t ha t fu nct ion. Debu gging inf orm at ion ent ries f or C v o i d f u nct ions sh ou l d not h ave an at t ri bu t e f or t h e ret u rn t y p e. I n A N S I - C t here is a d iff erence bet ween t h e t y pes of f u nct ions d eclared u sing f u nct ion prot ot y pe s t y le d eclara t ions and t h ose d eclared u sing non- prot ot y pe d eclarat ions. A subr out ine en t r y decla r ed wit h a funct ion pr otot ype st yle decla r a t ion ma y h a ve a D W _ A T _ p r o t o t y p e d a t t r ib u t e, whose va lue is a a g. 3.3.3 Subroutine and Entry P oint Locations A subr out ine en t r y h a s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma ch ine inst r uct ion gener a t ed for t h e subr ou t ine . I t a lso h a s a D W _ A T _ h i g h _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st loca t ion pa st t he la st ma chine inst r uct ion gener a t ed for t he su br out ine. N ot e t h at f or t h e l ow and h igh pc at t ribu t es t o h ave m eaning, DW A R F m ak es t h e assu m p t ion t h at t h e cod e f or a singl e su brou t ine is al l ocat ed in a single cont igu ou s block of m em ory . A n en t r y point ha s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma ch ine inst r u ct ion gener a t ed for t he ent r y point .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

24

--

--

DWARF D ebugging Information Format

S u br ou t ines a nd en t r y point s ma y a lso ha ve DW_AT_segment a nd D W _ A T _ a d d r e s s _ c l a s s a t t r ib u t es, a s a ppr opr ia t e, t o specif y which segmen t s t he code for t he subr out ine r esides in a n d t he a ddr essing mode t o be u sed in ca lling t ha t subr ou t ine . A subr out ine en t r y r epr esen t ing a subr ou t ine decla r a t ion t h a t is n ot a lso a de nit ion does not h a ve low a nd high pc a t t r ibu t es. 3.3.4 Declarations Owned by S ubroutines and Entry P oints T he decla r a t ions enclosed by a subr out ine or en t r y point a r e r epr esen t ed by debu gging infor ma t ion en t r ies t ha t a r e owned by t he subr out ine or en t r y p oint en t r y. E n t r ies r epr esen t ing t he f or ma l pa r a met er s of t he subr out ine or en t r y point a ppea r in t he sa me or der a s t he cor r espond ing decla r a t ions in t he sour ce pr ogr a m . T h ere is no ord eri ng requ irem ent on ent ries f or declarat ions t h at are ch il d ren of su brou t ine or ent ry p oi nt ent ries bu t t h at d o not represent f orm al param et ers . T h e f orm al param et er ent ries m ay be int erspersed wit h ot h er ent ries u sed by f orm a l param et er ent ri es, su ch as t y pe ent ri es. T he u nspecied pa r a m et er s of a va r ia ble pa r a m et er list a r e r epr esen t ed by a debu gging infor ma t ion en t r y wit h t he t a g D W _ T A G _ u n s p e c i f i e d _ p a r a m e t e r s. T he ent r y f or a su br out ine or ent r y point t h a t includes a F or t r a n comm on block ha s a ch ild ent r y wit h t he t a g D W _ T A G _ c o m m o n _ i n c l u s i o n. T he comm on inclusion en t r y ha s a D W _ A T _ c o m m o n _ r e f e r e n c e a t t r ib u t e whose va lue is a r efer ence t o t he debu ggin g ent r y for t h e common b lock bein g inclu ded ( see sect ion 4.2) . 3.3.5 Low- Level Information A subr out ine or ent r y point en t r y m a y ha ve a D W _ A T _ r e t u r n _ a d d r a t t r ib u t e, whose va lue is a loca t ion descr ipt ion. T he loca t ion ca lcu la t ed is t h e pla ce wher e t he r e t u r n a ddr ess for t he su br out ine or ent r y point is stor ed. A subr out ine or ent r y point en t r y m a y a lso ha ve a D W _ A T _ f r a m e _ b a s e a t t r ib u t e, whose va lu e is a loca t ion descr ipt ion t ha t compu t es t h e fr a me ba se f or t he subrout ine or ent r y point . T h e f ram e base f or a proced u re is t y pical l y an ad d res s x ed rel at ive t o t h e rs t u ni t of st orage al l ocat ed f or t h e proced u res st ack f ram e. T h e D W _ A T _ f r a m e _ b a s e at t ri bu t e can be u sed in several way s: 1. I n proced u res t h at need l ocat ion l is t s t o locat e local variables, t h e D W _ A T _ f r a m e _ b a s e can h ol d t h e need ed l ocat ion l ist , wh ile al l variables locat ion d escript ions can be sim pl er locat ion ex pressions invol ving t h e f ram e base. I t can be u sed as a k ey in res olving "u p- level" ad d ressing wit h nest ed rou t ines. ( S ee D W _ A T _ s t a t i c _ l i n k, bel ow)

2.

S om e langu ages su p p ort nes t ed su brou t ines. I n su ch langu ages , it is p ossibl e t o ref erence t h e l ocal variabl es of an ou t er su brou t ine f rom wit h in an inner su brou t ine. T h e D W _ A T _ s t a t i c _ l i n k and D W _ A T _ f r a m e _ b a s e at t ri bu t es a l l ow d ebu ggers t o su p p ort t h is sam e k ind of ref erencing.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

25

--

--

DWARF D ebugging Information Format

I f a su br out ine or en t r y point is nest ed, it m a y ha ve a D W _ A T _ s t a t i c _ l i n k a t t r ib u t e, whose va lu e is a loca t ion descr ipt ion t ha t compu t es t h e fr a me ba se of t he r eleva n t in stance of t he subr out ine t ha t im m ed ia t ely en c loses t he subr out ine or en t r y point . I n t he cont ext of suppor t ing n est ed subr out ine s, t he D W _ A T _ f r a m e _ b a s e a t t r ib u t e va lue should obe y t he f ollowing const r a int s: 1. 2. I t should compu t e a va lue t h a t does not cha nge dur in g t he life of t he pr oced u r e, a nd T h e compu t ed va lue should be u n iqu e a mong inst a nces of t he sa me su br out ine. ( F or t ypica l D W _ A T _ f r a m e _ b a s e use, t his mea ns t h a t a r ecur sive subr ou t ines st a ck fr a m e m u st ha ve non-zer o size.)

I f a d ebu gger is at tem p t ing t o resol ve an u p- level ref erence t o a variabl e, it u ses t h e nest ing st ru ct u re of DW A R F t o d et erm ine wh ich su brou t ine is t h e lex ical parent and t h e D W _ A T _ s t a t i c _ l i n k val u e t o id ent if y t h e approp ri at e act ive f ram e of t h e p arent . I t can t h en at t em p t t o nd t h e ref erence wit h in t h e cont ex t of t h e parent . 3.3.6 Types Thrown by Ex c eptions I n C + + a su brou t ine m ay d eclare a set of t y pes f or wh ich t h a t su brou t ine m ay generat e or t h row an ex cept ion. I f a su br out ine explic it ly decla r es t ha t it m a y t h r ow a n except ion f or one or mor e t ypes, ea ch such t ype is r epr esen t ed by a debu gging infor ma t ion ent r y wit h t he t a g D W _ T A G _ t h r o w n _ t y p e. E a ch such en t r y is a ch ild of t h e en t r y r epr esen t ing t he subr ou t ine t ha t m a y t hr ow t h is t ype. A ll t h r own t ype ent r ies should f ollow a ll en t r ies r epr esen t ing t he f or ma l pa r a met er s of t he subr out ine a nd pr ecede a ll en t r ies r epr esen t ing t he loca l va r ia bles or lexica l b locks cont a ined in t he su br out ine. E a ch t h r own t ype ent r y cont a ins a D W _ A T _ t y p e a t t r ib u t e, whose va lue is a r efer ence t o a n ent r y descr ibing t h e t ype of t he except ion t h a t ma y be t h r own. 3.3.7 Function Template Instantiations I n C + + a f u nct ion t em p l at e is a generic d e ni t ion of a f u nct ion t h a t is ins t ant iat ed d iff erent ly wh en cal l ed wit h val u es of d iff erent t y pes. DW A R F d oes not represent t h e generic t em p l at e d e ni t ion, bu t d oes rep resent each inst ant iat ion. A t empla t e inst a n t ia t ion is r epr esen t ed b y a debuggin g infor m a t ion en t r y wit h t he t a g D W _ T A G _ s u b p r o g r a m. W it h t h r ee except ions, such a n en t r y will cont a in t he sa me a t t r ib u t es a nd ha ve t he sa me t ypes of ch ild en t r ies a s would a n en t r y for a subr out ine dened explic it ly u sing t he in sta n t ia t ion t ypes. T he except ions a r e: 1. E a ch for ma l pa r a met er ized t ype decla r a t ion a ppea r ing in t he t empla t e de nit ion is r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t he ta g D W _ T A G _ t e m p l a t e _ t y p e _ p a r a m e t e r. E a ch such en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a in in g t he na me of t he for m a l t ype pa r a met er a s it a ppea r s in t he sour ce pr ogr a m . T he t em pla t e t ype pa r a met er en t r y a lso ha s a D W _ A T _ t y p e a t t r ib u t e descr ib ing t he a ct ua l t ype by which t h e for m a l is r epla ced for t h is in st a n t ia t ion. A ll t em pla t e t ype pa r a met er en t r ies should a ppea r befor e t h e en t r ies descr ib ing t he inst a n t ia t ed for ma l pa r a met er s t o t he fu nct ion.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

26

--

--

DWARF D ebugging Information Format

2.

I f t he compiler ha s ge ner a t ed a specia l compila t ion unit t o hold t he t empla t e inst a nt ia t ion a nd t ha t compila t ion unit ha s a d iffer en t na me fr om t he compila t ion unit cont a ining t he t em pla t e denit ion, t he na me a t t r ibu t e f or t he debu ggin g ent r y r epr esen t ing t ha t compila t ion u n it should be empt y or omit t ed . I f t he subpr ogr a m en t r y r epr esen t ing t h e t em pla t e inst a n t ia t ion or a n y of it s ch ild ent r ies cont a in decla r a t ion coor dina t e a t t r ibu t es, t h ose a t t r ibu t es should r efer t o t he sour ce for t he t em pla t e denit ion, n ot t o a ny sour ce ge ner a t ed a r t icia lly by t h e compiler f or t h is inst a n t ia t ion.

3.

3.3.8 Inline S ubroutines A decla r a t ion or a denit ion of a n in lina ble subr ou t ine is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ s u b p r o g r a m. T he en t r y f or a su br out ine t ha t is explicit ly decla r ed t o be a va ila b le for in line expa n sion or t ha t wa s expa nded inline implicit ly by t he compiler ha s a D W _ A T _ i n l i n e a t t r ib u t e whose va lue is a const a n t . T he set of va lues f or t he D W _ A T _ i n l i n e a t t r ib u t e is given in F igur e 9. _ _________________________________________________________________________________________ _ N________________________________________________ing _____________________________________ M ea n ___ _ _ a me _ N ot decla r ed in line nor inlined by t h e compiler DW_INL_not_inlined N ot decla r ed in line bu t inlined by t h e compiler DW_INL_inlined DW_INL_declared_not_inlined Decla r ed in line b u t not inlined by t h e compiler __________________________________________________r ed _____e ___d _____ed __y _________________ Decla ___ in lin _ a n _ in lin __ b _ t he compiler _D W _ I N L _ d e c l a r e d _ i n l i n e d Figure 9. I n lin e code s
3.3.8 .1 Abstract Instances

F or t h e r em a inder of t h is discu ssion, a ny debu ggin g infor m a t ion en t r y t ha t is owned ( eit her dir ect ly or indir ect ly) b y a debugging infor ma t ion en t r y t ha t cont a ins t h e D W _ A T _ i n l i n e a t t r ib u t e will be r efer r ed t o a s a n a b str a ct inst a nce en t r y. A ny subr ou t ine en t r y t ha t cont a in s a D W _ A T _ i n l i n e a t t r ib u t e will be known a s a n a b st r a ct inst a nce r oot . A ny set of a b str a ct inst a nce en t r ies t h a t a r e a ll ch ildr en ( e it her dir ect ly or indir ec t ly) of some a b st r a ct inst a nce r oot , t oget her with t he r oot it self , will be known as a n a b str a ct inst a nce t r ee. A debugging in f or m a t ion en t r y t h a t is a m em ber of a n a b st r a ct in st a nce t r ee sh ould n ot cont a in a D W _ A T _ h i g h _ p c, D W _ A T _ l o w _ p c, D W _ A T _ l o c a t i o n, D W _ A T _ r e t u r n _ a d d r, D W _ A T _ s t a r t _ s c o p e, or D W _ A T _ s e g m e n t a t t r ib u t e. I t wou l d not m ak e sense t o pu t t h ese at t ri bu t es int o abs t ract inst ance ent ries since su ch ent ries d o not rep resent act u al ( concret e) ins t ances and t h u s d o not act u al l y ex ist at ru nt im e. T he r ules for t he r ela t ive loca t ion of en t r ies belongin g t o a b str a ct inst a nce t r ees a r e exa ct ly t h e sa me a s for ot h er simila r t ype s of en t r ie s t h a t a r e n ot a b st r a ct . S pecica lly, t he r u le t ha t r equ ir es t ha t a n en t r y r epr esen t ing a decla r a t ion be a dir ec t ch ild of t he en t ry r epr esen t ing t he scope of t he decla r a t ion a pplies equa lly t o bot h a bst r a c t a nd n on-a b str a ct ent r ies. A lso, t he or der ing r u les for f or ma l pa r a met er en t r ie s, member ent r ie s, a nd so on, a ll a pply r ega r dless of whet her or n ot a given en t r y is a bst r a c t .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

27

--

--

DWARF D ebugging Information Format

3.3.8 .2 Concrete Inlined Instances

E a ch inline expa nsion of a n in lina b le subr out ine is r epr esen t ed b y a debuggin g informa t ion ent r y wit h t he t a g D W _ T A G _ i n l i n e d _ s u b r o u t i n e. E a ch such en t r y should be a dir ect ch ild of t he en t r y t ha t r epr esen t s t he scope wit h in which t he inlin ing occur s. E a ch inlined subr ou t in e en t r y cont a in s a D W _ A T _ l o w _ p c a t t r ib u t e, r epr esen t ing t he a ddr ess of t he r st in st r uct ion a ssocia t ed wit h t he given in line expa nsion. E a ch in lined subr ou t ine en t r y a lso cont a in s a D W _ A T _ h i g h _ p c a t t r ib u t e, r epr esen t ing t he a d dr ess of t he r st loca t ion pa st t h e la st inst r uc t ion a ssocia t ed with t he inline expa nsion. F or t h e r em a inder of t h is discu ssion, a ny debu ggin g infor m a t ion en t r y t ha t is owned ( eit her dir ect ly or indir ect ly) b y a debugging infor ma t ion en t r y wit h t he t a g D W _ T A G _ i n l i n e d _ s u b r o u t i n e will be r efer r ed t o a s a concr et e in lined in sta nce ent r y. A n y en t r y t ha t h a s t he t a g D W _ T A G _ i n l i n e d _ s u b r o u t i n e will be known a s a concr et e in lined inst a nce r oot . A n y set of conc r et e in lined inst a nce en t r ies t h a t a re a ll ch ildr en ( eit her dir ect ly or indir ect ly) of some concr et e inlined inst a nce r oot , t oget her wit h t he r oot it self , will be known a s a concr et e inlined in st a nce t r ee. E a ch concr et e in lined inst a nce t r ee is u n iqu ely a ssocia t ed wit h one ( a nd only one) a bst r a c t inst a nce t r ee. N ot e, h owever, t h at t h e reverse is not t ru e. A ny given abst ract ins t ance t ree m ay be associa t ed wit h several d iff erent concret e inl ined inst ance t rees, or m ay even be associat ed wit h z ero concret e inl ined ins t ance trees . A lso, ea ch sepa r a t e en t r y wit hin a given concr et e in lined in sta nce t r ee is uniqu ely a ssocia t ed wit h one pa r t icula r en t r y in t he a ssocia t ed a b st r a ct in st a nce t r ee. I n ot her wor d s, t her e is a one- t o-one m a ppin g fr om en t r ies in a given concr et e in lined inst a nce t r ee t o t he en t r ies in t h e a ssocia t ed a b st r a ct in sta nce t r ee. N ot e, h owever, t h at t h e reverse is not t ru e. A given abs t ract inst ance t ree t h at is associa t ed wit h a given concret e inl ined inst ance t ree m ay ( and qu it e p robabl y wil l ) cont ain m ore ent ries t h an t h e associa t ed concret e inl ined inst ance t ree ( see bel ow) . C oncr et e inlined inst a nce en t r ies d o not h a ve m ost of t he a t t r ibu t es ( excep t for D W _ A T _ l o w _ p c, D W _ A T _ h i g h _ p c, D W _ A T _ l o c a t i o n, D W _ A T _ r e t u r n _ a d d r, D W _ A T _ s t a r t _ s c o p e a nd D W _ A T _ s e g m e n t) t ha t such en t r ies wou ld ot h er wise nor m a lly h a ve. I n pla ce of t hese om it t ed a t t r ibu t es, ea ch concr et e in lined inst a nce en t r y ha s a D W _ A T _ a b s t r a c t _ o r i g i n a t t r ib u t e t h a t ma y be u sed t o obt a in t he m issing infor ma t ion ( indir ec t ly) fr om t he a ssocia t ed a b st r a ct inst a nce ent r y. T he va lue of t he a bst r a c t or igin a t t r ibu t e is a r efer ence t o t he a ssocia t ed a b st r a ct inst a nce en t r y. F or ea ch pa ir of en t r ies t ha t a r e a ssocia t ed via a D W _ A T _ a b s t r a c t _ o r i g i n a t t r ib u t e, b ot h m em ber s of t h e pa ir will ha ve t he sa me t a g. S o, for exa m ple, a n ent ry wit h t he t a g D W _ T A G _ l o c a l _ v a r i a b l e ca n only be a ssocia t ed wit h a n ot her en t r y t ha t a lso h a s t he t a g D W _ T A G _ l o c a l _ v a r i a b l e . T he only except ion t o t h is r u le is t ha t t he r oot of a concr et e in sta nce t r ee ( which mu st a lwa ys ha ve t he t a g D W _ T A G _ i n l i n e d _ s u b r o u t i n e) ca n only be a ssocia t ed wit h t he r oot of it s a ssocia t ed a b st r a ct in st a nce t r ee ( which mu st h a ve t h e t a g D W _ T A G _ s u b p r o g r a m) .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

28

--

--

DWARF D ebugging Information Format

I n ge ner a l, t he st r uct u r e a nd cont en t of a n y given conc r et e in sta nce t r ee will be d ir ect ly a na logous t o t he st r uct ur e a n d cont en t of it s a ssocia t ed a b st r a ct in sta nce t r ee. T her e a r e t wo except ions t o t h is gener a l r u le h owever . 1. 2. N o en t r ies r epr esen t ing a n onym ous t ypes a r e ever ma de a pa r t of a ny concr e t e inst a nce in lined t r ee. N o en t r ies r epr esen t ing member s of st r uct ur e, u n ion or cla ss t ypes a r e ever ma de a pa r t of a ny concr e t e in lined in sta nce t r ee.

E nt ries t h a t rep resent m em bers and anony m ou s t y pes are om it t ed f rom concret e inl ined inst ance t rees becau se t h ey wou l d sim p ly be red u nd ant d u p l icat es of t h e corresp ond ing ent ries in t h e associa t ed abs t ract inst ance t rees. I f any ent ry wit h in a concret e inl ined inst ance t ree need s t o ref er t o an anony m ou s t y pe t h at was d eclared wit h in t h e scope of t h e relevant inl ine f u nct ion, t h e ref erence sh ou l d sim ply ref er t o t h e abs t ract inst ance ent ry f or t h e given anony m ou s t y p e. I f a n ent r y wit h in a concr et e in lined inst a nce t r ee cont a ins a t t r ibu t es descr ib in g t he decla r a t ion coor dina t es of t h a t en t r y, t hen t h ose a t t r ib u t es should r efer t o t he le, line a n d column of t he or igina l decla r a t ion of t he subr ou t ine, n ot t o t he point a t which it wa s inlined .
3.3.8 .3 Out- of- Line Instances of Inline S ubroutines

U nder some cond it ions, compiler s ma y need t o gener a t e concr et e execu t a ble inst a nces of inline subr ou t ine s ot h er t h a n a t p oint s wher e t h ose su br out ines a r e a ct u a lly ca lled . F or t he r ema inder of t h is discu ssion, such concr e t e in st a nces of in line su br out ines will be r efer r ed t o a s concr et e out -of- line in sta nces. I n C + + , f or ex am pl e, t ak ing t h e ad d ress of a f u nct ion d eclared t o be inl ine can necessit at e t h e genera t ion of a concret e ou t - of - l ine inst ance of t h e given f u nct ion. T he D W A R F r epr esen t a t ion of a concr et e out - of-line in st a nce of a n in line su br out ine is essent ia lly t he sa me a s f or a concr et e inlined in sta nce of t ha t subr out ine ( a s descr ibed in t he pr eced ing sec t ion) . T he r epr esen t a t ion of such a concr et e out - of- lin e in st a nce m a kes use of D W _ A T _ a b s t r a c t _ o r i g i n a t t r ib u t es in exa c t ly t he sa me wa y a s t hey a r e used f or a concr et e inlined in sta nce ( t ha t is, a s r efer ences t o cor r espond ing en t r ies wit hin t he a ssocia t ed a b st r a ct inst a nce t r ee) a nd, a s for concr et e in sta nce t r ees, t he en t r ies for a n onym ous t ypes a nd f or a ll mem ber s a r e om it t ed . T he d iffer ences bet ween t he D W A R F r epr esen t a t ion of a concr et e ou t -of-line inst a nce of a given subr ou t ine a nd t h e r epr esen t a t ion of a concr et e inlined in st a nce of t ha t sa me subr ou t ine a r e a s follows: 1. T h e r oot ent r y f or a concr et e ou t -of-line inst a nce of a given in lin e subr out ine ha s t h e sa me t a g a s does it s a ssocia t ed ( a b st r a ct ) inline subr out ine ent r y ( t ha t is, it does not ha ve t he t a g D W _ T A G _ i n l i n e d _ s u b r o u t i n e) . T h e r oot ent r y f or a concr et e ou t -of-line inst a nce t r ee is a lwa ys d ir ect ly owned by t he sa me pa r en t en t r y t ha t a lso owns t he r oot ent r y of t he a ssocia t ed a b str a ct inst a nce.

2.

3.4 Lex ical Block Entries


A lex ical bl ock is a brack et ed sequ ence of sou rce st at em ent s t h at m ay cont ain any nu m ber of d eclara t ions . I n som e l angu ages ( C and C+ + ) bl ock s can be nest ed wit h in ot h er
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

29

--

--

DWARF D ebugging Information Format

block s t o any d ep t h . A lexica l b lock is r epr esen t ed by a deb u gging infor m a t ion ent r y wit h t h e t a g D W _ T A G _ l e x i c a l _ b l o c k. T he lexica l block en t r y ha s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma chine in st r uct ion ge ner a t ed for t he lexica l b lock . T h e lexica l b lock ent r y a lso h a s a D W _ A T _ h i g h _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st loca t ion pa st t he la st ma chine inst r uct ion gener a t ed for t he lexica l b lock . I f a na me ha s been given t o t he lexica l block in t h e sour ce pr ogr a m , t hen t he cor r espond ing lexica l block en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he na me of t he lexica l b lock a s it a ppea r s in t he sour ce pr ogr a m . T h is is not t h e sam e as a C or C + + l abel ( see bel ow) . T he lexica l block en t r y owns debu ggin g infor ma t ion en t r ies t ha t descr ibe t he decla r a t ions wit h in t ha t lexica l b lock. T her e is one such debu ggin g infor ma t ion en t r y for ea ch loca l decla r a t ion of a n iden t ier or inner lexica l block.

3.5 Label Entries


A l abel is a way of id ent i f y ing a sou rce st at em ent . A l abeled s t at em ent is u su al l y t h e t arget of one or m ore go t o st at em ent s. A la bel is r epr esen t ed b y a deb u ggin g infor m a t ion en t r y wit h t he t a g D W _ T A G _ l a b e l. T he ent r y f or a la b el sh ould be owned by t h e deb u ggin g infor ma t ion en t r y r epr esen t ing t he scope wit h in which t he na me of t he la bel could be lega lly r efer enced wit hin t h e sour ce pr ogr a m . T he la bel ent r y ha s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma ch ine inst r u ct ion gener a t ed for t he st a t em en t ident ied by t h e la bel in t he sour ce pr ogr a m . T he la bel en t r y a lso ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll- t er m ina t ed st r ing cont a ining t he na me of t he la b el a s it a ppea r s in t h e sour ce pr ogr a m .

3.6 With S tatement Entries


B ot h Pascal and M od u l a su p port t h e concept of a wit h st at em ent . T h e wit h st at em ent speci es a sequ ence of ex ecu t able s t at em ent s wit h in wh ich t h e eld s of a record vari able m ay be ref erenced , u nq u al i ed by t h e nam e of t h e record variabl e. A wit h st a t emen t is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ w i t h _ s t m t. A with st a t em en t en t r y ha s a D W _ A T _ l o w _ p c a t t r ib u t e whose va lu e is t h e r eloca t ed a ddr ess of t he r st ma ch ine in st r uct ion gener a t ed for t he b ody of t he wit h sta t em en t . A wit h sta t em en t en t r y a lso ha s a D W _ A T _ h i g h _ p c a t t r ib u t e whose va lu e is t h e r eloca t ed a ddr ess of t he r st loca t ion a f t er t he la st ma chine inst r uct ion gener a t ed f or t he body of t he sta t em en t . T he wit h st a t ement en t r y ha s a D W _ A T _ t y p e a t t r ib u t e, den ot ing t he t ype of r ecor d whose eld s ma y be r efer enced wit hout f u ll qua lica t ion wit h in t he b ody of t he st a t em en t . I t a lso ha s a D W _ A T _ l o c a t i o n a t t r ib u t e, descr ib ing h ow t o nd t he ba se a ddr ess of t h e r ecor d object r efer enced wit h in t he body of t he wit h st a t ement .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

30

--

--

DWARF D ebugging Information Format

3.7 Try and Catch Block Entries


I n C + + a lex ical block m ay be d esignat ed as a cat ch block . A cat ch bl ock is an ex cept ion h and l er t h at h and l es ex cept ions t h rown by an im m ed iat ely preced ing t ry block . A cat ch block d esi gnat es t h e t y pe of t h e ex cept ion t h at it can h and l e. A t r y block is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ t r y _ b l o c k. A ca t ch block is r epr esen t ed by a debu gging infor ma t ion ent r y wit h t he t a g D W _ T A G _ c a t c h _ b l o c k. Bot h t r y a n d ca t ch block en t r ies cont a in a D W _ A T _ l o w _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st ma chine inst r uct ion gener a t ed f or t ha t block. T hese en t r ies a lso cont a in a D W _ A T _ h i g h _ p c a t t r ib u t e whose va lue is t he r eloca t ed a ddr ess of t he r st loca t ion pa st t h e la st ma ch ine inst r uct ion gener a t ed f or t ha t block. C a t ch block ent r ies ha ve a t lea st one ch ild en t r y, a n en t r y r epr esen t ing t h e t ype of except ion a ccept ed by t ha t ca t ch b lock . T h is ch ild en t r y will ha ve one of t he t a gs D W _ T A G _ f o r m a l _ p a r a m e t e r or D W _ T A G _ u n s p e c i f i e d _ p a r a m e t e r s, a nd will h a ve t h e sa m e for m a s ot h er pa r a met er en t r ies. T he r st sibling of ea ch t r y block en t r y will be a ca t ch b lock ent r y.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

31

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

32

--

--

DWARF D ebugging Information Format

4. D ATA OBJECT AN D OBJECT LIST EN TRIES


T h is sect ion pr esen t s t h e deb u ggin g infor ma t ion en t r ies t h a t descr ibe individua l da ta object s: va r ia ble s, pa r a met er s a nd const a n t s, a nd list s of t h ose object s t ha t ma y be gr ouped in a single decla r a t ion, such a s a common block.

4.1 D ata Object Entries


P r ogr a m va r ia b les, for ma l pa r a me t er s a n d const a n t s a r e r epr esen t ed b y debu gging infor ma t ion en t r ies wit h t he t a gs D W _ T A G _ v a r i a b l e, D W _ T A G _ f o r m a l _ p a r a m e t e r a nd D W _ T A G _ c o n s t a n t, r espect ively. T h e t ag D W _ T A G _ c o n s t a n t is u sed f or l angu ages t h at d ist ingu ish bet ween variables t h at m ay h ave const ant va l u e and t ru e na m ed const ant s. T he deb u ggin g in for m a t ion en t r y f or a pr ogr a m va r ia ble, for m a l pa r a m et er or const a n t ma y ha ve t he f ollowing a t t r ib u t es: 1. A D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he da t a object na me a s it a ppea r s in t he sour ce pr ogr a m . I f a va r ia ble en t r y descr ibes a C + + a nonym ous u nion, t he na me a t t r ibu t e is om it t ed or consist s of a single zer o byt e. 2. I f t he na m e of a va r ia ble is visible out side of it s enclosing compila t ion unit , t he va r ia ble en t r y ha s a D W _ A T _ e x t e r n a l a t t r ib u t e, whose va lue is a a g. T h e d e ni t ions of C+ + st at ic d at a m em bers of s t ru ct u res or classes are represent ed by variabl e ent ries agged as ex t erna l . B ot h le st at ic and l ocal variabl es in C and C+ + are represent ed by non- ex t erna l variabl e ent ri es. 3. A D W _ A T _ l o c a t i o n a t t r ib u t e, whose va lue descr ibes t h e loca t ion of a va r ia ble or pa r a met er a t r u n - t ime. A da t a object en t r y r epr esen t ing a n on-de nin g decla r a t ion of t he object will n ot ha ve a loca t ion a t t r ibu t e, a nd will ha ve t he D W _ A T _ d e c l a r a t i o n a t t r ib u t e. I n a va r ia b le en t r y r epr esen t ing t he denit ion of t he va r ia ble ( t ha t is, wit h no D W _ A T _ d e c l a r a t i o n a t t r ib u t e) if no loca t ion a t t r ib u t e is pr esen t , or if t he loca t ion a t t r ibu t e is pr esen t b u t descr ibes a nu ll en t r y ( a s descr ibed in sec t ion 2.4) , t he va r ia ble is a ssum ed t o e xist in t h e sour ce code bu t n ot in t h e execu t a ble pr ogr a m ( bu t see nu mber 9 , below) . T he loca t ion of a va r ia ble ma y be fur t her specied wit h a D W _ A T _ s e g m e n t a t t r ib u t e, if a ppr opr ia t e . 4. 5. A D W _ A T _ t y p e a t t r ib u t e descr ib ing t he t ype of t he va r ia b le, const a n t or for ma l pa r a met er . I f t he va r ia ble ent r y r epr esen t s t h e dening decla r a t ion for a C + + st a t ic da t a mem ber of a st r uc t u r e, cla ss or u n ion, t he ent r y h a s a D W _ A T _ s p e c i f i c a t i o n a t t r ib u t e, whose va lue is a r efer ence t o t he debu ggin g infor ma t ion en t r y r epr esen t in g t he decla r a t ion of t h is da t a member . T he r efer enced ent r y will be a ch ild of some cla ss, st r u c t u r e or u n ion t ype en t r y.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

33

--

--

DWARF D ebugging Information Format

Va r ia ble en t r ies cont a ining t he D W _ A T _ s p e c i f i c a t i o n a t t r ib u t e do not need t o du plica t e infor ma t ion pr ovided by t he decla r a t ion en t r y r efer enced b y t he specica t ion a t t r ibu t e. I n pa r t icu la r , such va r ia ble en t r ies d o not need t o cont a in a t t r ib u t es f or t he na me or t ype of t he da t a m em ber whose de nit ion t hey r epr esen t. 6. S om e langu ages d ist ingu ish bet ween param et ers wh ose val u e in t h e cal l ing f u nct ion can be m od i ed by t h e callee ( variable param et ers) , and param et ers wh ose val u e in t h e cal l ing f u nct ion cannot be m od i ed by t h e callee ( const ant param et ers) . I f a f or m a l pa r a m et er en t r y r epr esen t s a pa r a m et er whose va lue in t he ca lling fu nct ion m a y be modied by t he ca llee , t h a t en t r y ma y ha ve a D W _ A T _ v a r i a b l e _ p a r a m e t e r a t t r ib u t e, whose va lue is a a g. T he a bsence of t h is a t t r ibu t e implies t ha t t h e pa r a met er s va lue in t he ca lling fu nct ion ca n n ot be modied b y t he ca llee. 7. Fort ran90 h as t h e concept of an op t iona l param et er. I f a pa r a met er en t r y r epr esen t s a n opt iona l pa r a met er , D W _ A T _ i s _ o p t i o n a l a t t r ib u t e, whose va lue is a a g. 8. it ha s a

A f or ma l pa r a met er ent r y descr ib ing a f or ma l pa r a met er t ha t ha s a defa ult va lue ma y ha ve a D W _ A T _ d e f a u l t _ v a l u e a t t r ib u t e. T he va lue of t h is a t t r ibu t e is a r efer ence t o t he deb u gging infor ma t ion ent r y f or a va r ia ble or subr ou t in e. T h e defa u lt va lue of t h e pa r a met er is t he va lue of t he va r ia ble ( which m a y be const a nt ) or t he va lue r et ur ned by t he su br out ine. I f t he va lue of t he D W _ A T _ d e f a u l t _ v a l u e a t t r ib u t e is 0, it mea ns t h a t no defa u lt va lu e ha s been specied . A n en t r y descr ibing a va r ia ble whose va lu e is const a n t a n d n ot r epr esen t ed b y a n object in t h e a ddr ess spa ce of t he pr ogr a m , or a n en t r y descr ibing a na med const a n t , does not ha ve a loca t ion a t t r ib u t e. S uch en t r ies h a ve a D W _ A T _ c o n s t _ v a l u e a t t r ib u t e, whose va lue ma y be a st r ing or a ny of t he const a n t da t a or da t a b lock for m s, a s a ppr opr ia t e f or t he r epr esen t a t ion of t he va r ia bles va lu e. T he va lue of t h is a t t r ib u t e is t he a ct ua l const a n t va lue of t he va r ia ble, r epr esen t ed a s it would be on t he t a r ge t a r ch it ect ur e.

9.

10. I f t he scope of a n object begins somet ime a f t er t he low pc va lue for t he scope most closely enclosing t he object , t he object en t r y m a y ha ve a D W _ A T _ s t a r t _ s c o p e a t t r ib u t e. T he va lue of t h is a t t r ibu t e is t he offset in byt es of t he begin ning of t he scope for t h e object fr om t he low pc va lue of t he deb u ggin g infor m a t ion en t r y t ha t denes it s scope. T h e scope of a variabl e m ay begin som ewhere in t h e m id d le of a lex ical bl ock in a langu age t h at al l ows ex ecu t able cod e in a bl ock bef ore a variabl e declarat ion, or wh ere one d eclarat ion cont aining init ial iz at ion cod e m ay ch ange t h e scope of a su bsequ ent d ecl arat ion. For ex am pl e, in t h e f ol l owi ng C code:

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

34

--

--

DWARF D ebugging Information Format

float x = 99.99; int myfunc() { float f = x; float x = 88.99; return 0 ; } A N S I - C scoping ru les requ ire t h at t h e val u e of t h e variabl e x assigned t o t h e variable f in t h e init ial iz at ion sequence is t h e va l u e of t h e global variable x, rat h er t h an t h e l ocal x, becau se t h e scope of t h e loca l variable x onl y s t art s af t er t h e f u l l d ecl arat or f or t h e loca l x.

4.2 Common Block Entries


A F or t r a n com m on block ma y be descr ibed by a debu ggin g infor ma t ion ent r y wit h t he t a g D W _ T A G _ c o m m o n _ b l o c k. T he comm on b lock en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lu e is a n u ll- t er m ina t ed st r ing c ont a in ing t h e common b lock na me a s it a ppea r s in t he sour ce pr ogr a m . I t a lso ha s a D W _ A T _ l o c a t i o n a t t r ib u t e whose va lue descr ibes t he loca t ion of t he begin ning of t he comm on block. T h e common block en t r y owns debu ggin g infor ma t ion en t r ies descr ib in g t he va r ia bles cont a ined wit hin t he common b lock .

4.3 Imported Declaration Entries


S om e langu ages su p p ort t h e concept of im port ing int o a given m od u le d eclarat ions m ad e in a d iff erent m od u le. A n impor t ed decla r a t ion is r epr esen t ed b y a debugging infor m a t ion en t r y wit h t he t a g D W _ T A G _ i m p o r t e d _ d e c l a r a t i o n. T he en t r y f or t he impor t ed decla r a t ion ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he na me of t he en t it y whose decla r a t ion is bein g im por t ed a s it a ppea r s in t he sour ce pr ogr a m . T he impor t ed decla r a t ion ent r y a lso ha s a D W _ A T _ i m p o r t a t t r ib u t e, whose va lue is a r efer ence t o t he deb u gging infor ma t ion ent r y r epr esent ing t he decla r a t ion t h a t is being im por t ed .

4.4 N amelist Entries


A t lea st one langu age, Fort ra n90, h as t h e concept of a nam el ist . A nam el ist is an ord ered list of t h e nam es of som e set of declared obj ect s. T h e nam el ist obj ect it sel f m ay be u sed as a rep l acem ent f or t h e l ist of nam es in variou s cont ex t s. A na melist is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ n a m e l i s t. I f t he na me list it self ha s a na me, t he na me list en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a ining t he na me lists na me a s it a ppea r s in t he sour ce pr ogr a m . E a ch na me t ha t is pa r t of t he na me list is r epr esen t ed by a deb u ggin g infor ma t ion ent r y wit h t he t a g D W _ T A G _ n a m e l i s t _ i t e m. E a ch such en t r y is a ch ild of t h e na m elist ent r y, a nd a ll of t h e na m elist it em en t r ies f or a given na melist a r e or der ed a s wer e t he list of na mes t h ey cor r espond t o in t he sour ce pr ogr a m .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

35

--

--

DWARF D ebugging Information Format

E a ch na me list it em en t r y cont a ins a D W _ A T _ n a m e l i s t _ i t e m a t t r ib u t e whose va lue is a r efer ence t o t he debu ggin g infor m a t ion en t r y r epr esen t in g t he decla r a t ion of t he it em whose na m e a ppea r s in t he na me list .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

36

--

--

DWARF D ebugging Information Format

5. TYP E EN TRIES
T h is sect ion pr esen t s t h e deb u ggin g infor ma t ion en t r ies t h a t descr ibe pr ogr a m t ypes: ba se t ypes, m odied t ypes a nd user -dened t ype s. I f t he scope of t he decla r a t ion of a na med t ype begins somet ime a f t er t he low pc va lue for t he scope m ost closely enclosing t h e decla r a t ion, t he decla r a t ion ma y h a ve a D W _ A T _ s t a r t _ s c o p e a t t r ib u t e. T he va lue of t h is a t t r ibu t e is t he offset in byt es of t he begin n ing of t he scope for t he decla r a t ion fr om t he low pc va lu e of t he debu ggin g infor ma t ion en t r y t ha t denes it s scope.

5.1 Base Type Entries


A base t y pe is a d at a t y pe t h at is not d e ned in t erm s of ot h er d at a t y p es. E ach program m ing l angu age h as a set of base t y pes t h at are cons id ered t o be bu il t int o t h at langu age. A ba se t ype is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ b a s e _ t y p e. A ba se t ype en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er mina t ed st r ing descr ib ing t he na me of t he ba se t ype a s r ecognized b y t he pr ogr a m m ing la ngu a ge of t h e compila t ion u n it cont a ining t he ba se t ype en t r y. A ba se t ype en t r y a lso h a s a D W _ A T _ e n c o d i n g a t t r ib u t e descr ib ing h ow t he ba se t ype is encoded a nd is t o be in t er pr e t ed . T he va lue of t h is a t t r ibu t e is a const a n t . The set of va lues a nd t heir mea n ings for t he D W _ A T _ e n c o d i n g a t t r ib u t e is given in F igur e 10. _ _______________________________________________________________ _ __________________________________M ____________________________ _N a m e __ea ning linea r ma chine a ddr ess DW_ATE_address t r ue or fa lse DW_ATE_boolean complex oa t ing-point nu m ber DW_ATE_complex_float DW_ATE_float oa t ing- point nu mber DW_ATE_signed signed bina r y in t eger DW_ATE_signed_char signed cha r a ct er u n signed b ina r y int ege r DW_ATE_unsigned _D ________________________________u_____ed_cha _a __er ____________ __W _ A T E _ u n s i g n e d _ c h a r _nsign __ ___r _ct __ Figure 10. E ncoding a t t r ibu t e va lues A ll encodings a ssum e t he r epr esen t a t ion t ha t is nor ma l f or t he t a r ge t a r ch it ec t u r e. A ba se t ype en t r y ha s a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose va lue is a const a n t , descr ibing t he size in b yt es of t he st ora ge u nit u sed t o r epr esen t a n object of t he given t ype . I f t he va lue of a n object of t he given t ype does not fu lly occu py t he st or a ge u n it descr ibed by t h e byt e size a t t r ibu t e, t he ba se t ype ent r y ma y ha ve a D W _ A T _ b i t _ s i z e a t t r ib u t e a nd a D W _ A T _ b i t _ o f f s e t a t t r ib u t e, b ot h of whose va lues a r e const a nt s. T he b it size a t t r ib u t e descr ibes t he a ct ua l size in bit s u sed t o r epr esen t a va lue of t he given t ype . T he bit offset a t t r ibu t e descr ibes t he offset in bit s of t he h igh or der b it of a va lue of t he given t ype f r om t he h igh or der b it of t he st ora ge u nit u sed t o cont a in t ha t va lue. For ex am p l e, t h e C t y pe i n t on a m ach ine t h at u ses 32- bi t int egers wou l d be represent ed by a base t y pe ent ry wit h a nam e at t ri bu t e wh ose va l u e was i n t, an encod ing at t ribu t e wh ose val u e was D W _ A T E _ s i g n e d and a by t e siz e at t ribu t e wh ose val u e was 4.
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

37

--

--

DWARF D ebugging Information Format

5.2 Type M odier Entries


A ba se or user -dened t ype m a y be modied in d iffer en t wa ys in d iffer en t la ngu a ge s. A t ype modier is r epr esen t ed in D W A R F b y a debu gging infor ma t ion en t r y with one of t he t a gs given in F igu r e 11. _ _____________________________________________________________________________________________ _ ag M ___in _ _T____________________________________ea n__g__________________________________________________ DW_TAG_const_type C or C + + const qu a lied t ype P a sca l pa cked t ype DW_TAG_packed_type T he a ddr ess of t h e object whose t ype is being m odied DW_TAG_pointer_type DW_TAG_reference_type A C + + r efer ence t o t he object whose t ype is bein g m odied _W _T _G _v _l _t _l __ _y _e C __ C + _ vola t __ __a lied t ype _D_____A_____o__a__i__e__t__p_________or ____+______ile_qu______________________________________ Figure 11. T ype modier t a gs E a ch of t he t ype m odier en t r ies ha s a D W _ A T _ t y p e a t t r ib u t e, whose va lue is a r efer ence t o a debuggin g infor m a t ion en t r y descr ib in g a ba se t ype, a u ser -dened t ype or a not her t ype m odier . A m odied t ype ent r y descr ibing a point er or r efer ence t ype ma y h a ve a D W _ A T _ a d d r e s s _ c l a s s a t t r ib u t e t o descr ibe h ow object s ha ving t he given point er or r efer ence t ype ough t t o be der efer enced . W hen m u lt iple t ype m odier s a r e cha ined t oget her t o modify a ba se or user -dened t ype, t hey a r e or der ed a s if pa r t of a r igh t -a ssocia t ive expr ession involving t he ba se or user dened t ype. A s ex am p l es of h ow t y pe m od i ers are ord ered , t ak e t h e f ol l owing C d eclara t ions: const char * volatile p; wh ich rep resent s a vol at ile p oint er t o a const ant ch aract er. T h is is encod ed in DW A R F as: DW_TAG_volatile_type DW_TAG_pointer_type DW_TAG_const_type DW_TAG_base_type volatile char * c onst p; on t h e ot h er h and , rep resent s a cons t ant p oint er t o a vol at ile ch aract er. T h is is encod ed as: DW_TAG_const_type DW_TAG_pointer_type DW_TAG_volatile_type DW_TAG_base_type

5.3 Typedef Entries


A ny a r b it r a r y t ype na m ed via a t ypedef is r epr esen t ed by a debu gging infor ma t ion ent r y wit h t he t a g D W _ T A G _ t y p e d e f. T he t ypedef en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lu e is a n u ll- t er m ina t ed st r ing cont a in ing t h e na m e of t he t ypedef a s it a ppea rs in t he sour ce pr ogr a m . T h e t ypedef en t r y a lso cont a ins a D W _ A T _ t y p e a t t r ib u t e.
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

38

--

--

DWARF D ebugging Information Format

I f t he debu ggin g infor ma t ion en t r y for a t ypedef r epr esen t s a decla r a t ion of t he t ype t hat is not a lso a de nit ion, it d oes n ot cont a in a t ype a t t r ibu t e .

5.4 Array Type Entries


M any l angu ages sh are t h e concept of an array , wh ich is a t abl e of com ponent s of id ent ical t y pe. A n a r r a y t ype is r epr esen t ed b y a debugging infor ma t ion en t r y wit h t he t a g D W _ T A G _ a r r a y _ t y p e. I f a na me ha s been given t o t he a r r a y t ype in t he sour ce pr ogr a m , t hen t he cor r espond ing a r r a y t ype ent r y h a s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he a r r a y t ype na m e a s it a ppea r s in t h e sour ce pr ogr a m . T he a r r a y t ype en t r y descr ib ing a m u lt idimen siona l a r r a y m a y ha ve a D W _ A T _ o r d e r i n g a t t r ib u t e whose const a nt va lue is in t er pr e t ed t o mea n eit her r owma jor or colum n-ma jor or der ing of a r r a y element s. T he set of va lues a n d t heir mea n ings for t h e or der ing a t t r ibu t e a r e listed in F igu r e 12. I f no or der in g a t t r ibu t e is pr esen t, t he defa u lt or der ing f or t he sour ce la n gua ge ( which is indica t ed by t h e D W _ A T _ l a n g u a g e a t t r ib u t e of t he en closing compila t ion u n it en t r y) is a ssumed. _ _________________________ DW_ORD_col_major W O D r w m j r _D_____R_____o_____a__o___ _ _ _ _ _ _ _ _ Figure 12. A r r a y or der ing T he or der ing a t t r ibu t e ma y opt iona lly a ppea r on one-dimensiona l a r r a ys; it will be ignor ed. A n a r r a y t ype en t r y ha s a D W _ A T _ t y p e a t t r ib u t e descr ib ing t he t ype of ea ch elem en t of t he a r r a y. I f t he a m ount of st or a ge a lloca t ed t o hold ea ch elem en t of a n object of t he given a r r a y t ype is d iffer en t fr om t he a m ou n t of st or a ge t h a t is n or m a lly a lloca t ed t o h old a n in d ividu a l object of t h e indica t ed elem ent t ype, t hen t he a r r a y t ype en t r y ha s a D W _ A T _ s t r i d e _ s i z e a t t r ib u t e, whose const a nt va lue r epr esen t s t he size in bit s of ea ch element of t he a r r a y. I f t he size of t he en t ir e a r r a y ca n be de t er m ined st a t ica lly a t comp ile t ime, t he a r r ay t ype ent r y ma y h a ve a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose const a nt va lue r epr esen t s t he t ota l size in byt es of a n inst a nce of t h e a r r a y t ype. N ot e t h at if t h e siz e of t h e array can be d et erm ined st at ical l y at com pile t im e, t h is val u e can u su al l y be com pu t ed by m u l t ip l y ing t h e nu m ber of array elem ent s by t h e siz e of each elem ent . E a ch a r r a y dimen sion is descr ibed by a debu gging infor ma t ion en t r y with eit her t he ta g D W _ T A G _ s u b r a n g e _ t y p e or t he t a g D W _ T A G _ e n u m e r a t i o n _ t y p e. T hese ent r ies a r e childr en of t h e a r r a y t ype en t r y a nd a r e or der ed t o r eect t he a ppea r a nce of t he dimensions in t h e sour ce pr ogr a m ( i.e. lef t m ost dimension r st , next t o lef t m ost sec ond , a nd so on) . I n l angu ages, su ch as A N S I - C, in wh ich t h ere is no concept of a m u l t id im ens iona l array , an array of array s m ay be represent ed by a d ebu gging inf orm at ion ent ry f or a m u l t id im ensional array .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

39

--

--

DWARF D ebugging Information Format

5.5 S tructure, U nion, and Class Type Entries


T h e l angu ages C, C+ + , and Pascal , am ong ot h ers, al low t h e program m er t o d e ne t y pes t h at are col lect ions of rel at ed com ponent s. I n C and C + + , t h ese col lect ions are cal l ed st ru ct u res. I n Pascal , t h ey are cal l ed record s. T h e com ponent s m ay be of d iff erent t y pes . T h e com ponent s are cal l ed m em bers in C and C+ + , and el d s in Pascal . T h e com ponent s of t h ese col l ect ions each ex ist in t h eir own sp ace in com pu t er m em ory . T h e com ponent s of a C or C+ + u nion a l l coex ist in t h e sam e m em ory . Pascal and ot h er langu ages h ave a d iscrim inat ed u nion, al so cal l ed a va riant record . H ere, sel ect ion of a nu m ber of al t erna t ive su bs t ru ct u res ( variant s) is based on t h e val u e of a com ponent t h at is not part of any of t h ose su bst ru ct u res ( t h e d iscrim ina nt ) . A m ong t h e l angu ages d iscu ssed in t h is d ocu m ent , t h e class concept is u ni qu e t o C+ + . A class is sim il ar t o a st ru ct u re. A C + + class or s t ru ct u re m ay h ave m em ber f u nct ions wh ich are su brou t ines t h at are wit h in t h e scope of a cl as s or s t ru ct u re. 5.5.1 General Structure Description S t r uct ur e, union, a nd cla ss t ypes a r e r epr esent ed by debugging infor ma t ion ent r ies wit h t he t a gs D W _ T A G _ s t r u c t u r e _ t y p e, DW_TAG_union_type a nd D W _ T A G _ c l a s s _ t y p e, r espect ively. I f a na me ha s been given t o t he st r uct ur e , u n ion, or cla ss in t h e sour ce pr ogr a m , t hen t he cor r espond ing str uc t ur e t ype , u n ion t ype , or cla ss t ype ent r y h a s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he t ype na me a s it a ppea r s in t he sour ce pr ogr a m . I f t he size of a n in sta nce of t h e st r u ct ur e t ype, u n ion t ype, or cla ss t ype en t r y ca n be det er mined st a t ica lly a t compile t ime, t h e en t r y ha s a D W _ A T _ b y t e _ s i z e a t t r ib u t e whose const a n t va lu e is t h e n u m ber of byt es r equir ed t o h old a n in sta nce of t he st ruct u r e, u n ion, or cla ss, a n d a ny pa d d ing b yt es. For C and C + + , an incom p l et e st ru ct u re, u ni on or class t y pe is represent ed by a st ru ct u re, u nion or class ent ry t h at d oes not h ave a by t e siz e a t t ri bu t e and t h at h as a D W _ A T _ d e c l a r a t i o n at t ri bu t e. T he mem ber s of a str uct ur e, u nion, or cla ss a r e r epr esen t ed b y debuggin g infor m a t ion ent r ies t ha t a r e owned b y t he cor r espond ing st r u ct u r e t ype, union t ype , or cla ss t ype en t ry a nd a ppea r in t he sa me or der a s t he cor r espond ing decla r a t ions in t he sour ce pr ogr a m . Dat a m em ber d eclara t ions occu rring wi t h in t h e d ecl arat ion of a st ru ct u re, u nion or class t y pe are consid ered t o be d e ni t ions of t h ose m em bers , wit h t h e ex cept ion of C+ + st at ic d at a m em ber s, wh ose d e nit ions appear ou t sid e of t h e declarat ion of t h e enclosing s t ru ct u re, u nion or class t y pe. Fu nct ion m em ber declarat ions appearing wit h in a st ru ct u re, u nion or class t y pe d eclarat ion are d e ni t ions on ly if t h e bod y of t h e f u nct ion al so appears wit h in t h e t y pe d eclarat ion. I f t he denit ion for a given member of t he str uct ur e, u n ion or cla ss does n ot a ppea r with in t he b ody of t he decla r a t ion, t h a t member a lso ha s a debuggin g infor m a t ion en t r y descr ib ing it s de nit ion. T h a t en t r y will ha ve a D W _ A T _ s p e c i f i c a t i o n a t t r ib u t e r efer encin g t he debu gging en t r y owned b y t he b ody of t he st r uct u r e, u n ion or cla ss debu gging ent r y a nd r epr esen t ing a non- dening decla r a t ion of t he da t a or fu nct ion mem ber . T he r efer enced en t r y will n ot ha ve infor ma t ion a b out t he loca t ion of t h a t member ( low a nd high pc a t t r ibu t es for fu nct ion mem ber s, loca t ion descr ipt ions for da t a mem ber s) a nd will
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

40

--

--

DWARF D ebugging Information Format

ha ve a D W _ A T _ d e c l a r a t i o n a t t r ib u t e. 5.5.2 Derived Classes and Structures T he cla ss t ype or st r u ct ur e t ype en t r y t ha t descr ibes a der ived cla ss or st r u ct ur e owns debu ggin g infor ma t ion en t r ies descr ib in g ea ch of t he cla sses or st r uct u r es it is der ived fr om , or der ed a s t hey wer e in t he sou r ce pr ogr a m . E a ch such en t r y ha s t h e t a g D W _ T A G _ i n h e r i t a n c e. A n inher it a nce ent r y ha s a D W _ A T _ t y p e a t t r ib u t e whose va lue is a r efer ence t o t he debu ggin g infor ma t ion en t r y descr ibing t he st r uct u r e or cla ss fr om which t he pa r en t st r u c t u r e or cla ss of t he inher it a nce en t r y is der ived . I t a lso h a s a D W _ A T _ d a t a _ m e m b e r _ l o c a t i o n a t t r ib u t e, whose va lue is a loca t ion descr ipt ion descr ibing t he loca t ion of t he begin ning of t he da t a member s cont r ibu t ed t o t h e ent ir e cla ss by t h is su b object r ela t ive t o t h e beginning a ddr ess of t he da t a mem ber s of t he ent ir e cla ss. A n inher it a nce ent r y m a y ha ve a D W _ A T _ a c c e s s i b i l i t y a t t r ib u t e. I f no a ccessib ilit y a t t r ibu t e is pr esen t , pr iva t e a ccess is a ssum ed . I f t he st r uct ur e or cla ss r efer enced by t he inher it a nce en t r y ser ves a s a vir t ua l ba se cla ss, t h e inher it a nce en t r y ha s a D W _ A T _ v i r t u a l i t y a t t r ib u t e. I n C + + , a d erived class m ay cont ain access d eclara t ions t h at ch ange t h e accessibil it y of ind ivid u al class m em bers f rom t h e overa l l accessi bi l it y speci ed by t h e inh erit ance declarat ion. A single access d eclarat ion m ay ref er t o a set of overl oad ed nam es. I f a der ived cla ss or st r u ct ur e cont a ins a ccess decla r a t ions, ea ch such decla r a t ion ma y be r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t he ta g D W _ T A G _ a c c e s s _ d e c l a r a t i o n. E a ch such en t r y is a ch ild of t h e st r u ct ur e or cla ss t ype ent r y. A n a ccess decla r a t ion ent r y h a s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu llt er m ina t ed st r ing r epr esen t ing t he na me used in t he decla r a t ion in t he sour ce progr a m , inclu ding a ny cla ss or st r uct u r e qua lier s. A n a ccess decla r a t ion ent r y a lso ha s a D W _ A T _ a c c e s s i b i l i t y a t t r ib u t e descr ib ing t he decla r ed a ccessib ilit y of t he na med en t it ies. 5.5.3 Friends E a ch fr iend decla r ed by a str uct ur e, u n ion or cla ss t ype m a y be r epr esen t ed by a debu ggin g infor ma t ion en t r y t ha t is a ch ild of t h e st r uc t u r e, union or cla ss t ype en t r y; t he fr ien d en t r y ha s t h e t a g D W _ T A G _ f r i e n d . A fr iend en t r y ha s a D W _ A T _ f r i e n d a t t r ib u t e, whose va lue is a r efer ence t o t he debu ggin g infor ma t ion en t r y descr ibing t he decla r a t ion of t he fr ien d . 5.5.4 Structure Data Member Entries A da t a member ( a s opposed t o a member funct ion) is r epr esen t ed b y a debu gging infor ma t ion en t r y wit h t he t a g D W _ T A G _ m e m b e r. T he mem ber en t r y for a na med mem ber ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he m em ber na m e a s it a ppea r s in t he sour ce pr ogr a m . I f t he mem ber en t r y descr ibes a C + + a n onym ous u n ion, t h e n a m e a t t r ibu t e is omit t ed or c onsist s of a single zer o byt e .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

41

--

--

DWARF D ebugging Information Format

T he str uct u r e da t a mem ber en t r y ha s a D W _ A T _ t y p e a t t r ib u t e t o denot e t he t ype of t ha t m e m ber . I f t he mem ber ent r y is dened in t he str uct ur e or cla ss b ody, it ha s a D W _ A T _ d a t a _ m e m b e r _ l o c a t i o n a t t r ib u t e whose va lue is a loca t ion descr ip t ion t ha t descr ibes t he loca t ion of t ha t m em ber r ela t ive t o t he ba se a ddr ess of t he st r uct ur e , u n ion, or cla ss t h a t m ost closely encloses t he cor r espond in g mem ber decla r a t ion. T h e ad d res si ng ex pression represent ed by t h e l ocat ion d escrip t ion f or a st ru ct u re d at a m em ber ex pect s t h e base ad d ress of t h e st ru ct u re d at a m em ber t o be on t h e ex pression st ack bef ore bei ng eval u at ed . T h e l ocat ion d escrip t ion f or a d at a m em ber of a u nion m ay be om it t ed , since al l d at a m em bers of a u ni on begin at t h e sam e ad d ress. I f t he mem ber en t r y descr ibes a b it eld , t h en t ha t en t r y ha s t h e f ollowing a t t r ib ut es: 1. A D W _ A T _ b y t e _ s i z e a t t r ib u t e whose const a nt va lue is t h e nu m ber of byt es t ha t cont a in a n inst a nce of t he b it eld a n d a ny pa d d ing b it s. T h e by t e siz e at t ri bu t e m ay be om it t ed if t h e siz e of t h e obj ect cont aining t h e bi t el d can be inf erred f rom t h e t y pe at t ribu t e of t h e d at a m em ber cont aini ng t h e bit el d . 2. 3. A D W _ A T _ b i t _ o f f s e t a t t r ib u t e whose const a nt va lue is t h e nu m ber of bit s t o t he left of t h e lef t most ( most signica n t ) b it of t h e b it eld va lue. A D W _ A T _ b i t _ s i z e a t t r ib u t e whose const a nt va lue is t h e nu m ber of bit s occu pied b y t he b it eld va lue .

T he loca t ion descr ipt ion for a bit eld ca lcula t es t he a ddr ess of a n a nonym ous object cont a ining t h e b it eld . T h e a ddr ess is r ela t ive t o t he st r uct u r e, u n ion, or cla ss t hat m ost closely encloses t he b it eld decla r a t ion. T he n u m ber of byt es in t h is a n onym ous object is t he va lue of t he b yt e size a t t r ib u t e of t he b it eld . T he offset ( in b it s) fr om t he m ost signica n t bit of t he a n onym ous object t o t he m ost signica nt b it of t he b it eld is t he va lue of t he bit offset a t t r ibu t e. For ex am p l e, t ak e one p ossible rep resent at ion of t h e f ol l owing st ru ct u re d e nit ion in bot h big and l it t l e end ian by t e ord ers: struct S { int int int int }; I n bot h cas es, t h e l ocat ion d escrip t ions f or t h e d ebu gging inf orm at ion ent ries f or j, k, m and n d escribe t h e ad d ress of t h e sam e 32- bit word t h at cont ains a l l t h ree m em bers . ( I n t h e big- end ian case, t h e l ocat ion d escrip t ion ad d resses t h e m ost signi cant by t e, in t h e l it t le- end ian cas e, t h e l eas t signi cant ) . T h e f ol l owi ng d iagram sh ows t h e st ru ct u re l ay ou t and l i st s t h e bit off set s f or each cas e. T h e off set s are f rom t h e m os t signi cant bi t of t h e obj ect ad d ressed by t h e locat ion d escript ion.
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

j:5; k:6; m:5; n:8;

42

--

--

DWARF D ebugging Information Format

Bit O ffset s: j:0 k:5 m:11 n:16 Bit O ffset s: j:27 k:21 m:16 n:8

Big-E ndia n
0 31

j
26

k
20

m
15

n
7

pad
0

L it t le-E ndia n pad


31 23

n
15

m
10

k
4

0 0

5.5.5 Structure Member Function Entries A member funct ion is r epr esen t ed in t he deb u ggin g infor m a t ion b y a debu gging infor ma t ion en t r y wit h t he t a g D W _ T A G _ s u b p r o g r a m. T he mem ber fu n ct ion en t r y ma y cont a in t he sa me a t t r ibu t es a nd follows t he sa me r ules a s non- mem ber globa l subr ou t ine en t r ies ( see sect ion 3.3) . I f t he mem ber fu n ct ion en t r y descr ibes a vir t ua l fu nct ion, t h en t ha t en t r y has a D W _ A T _ v i r t u a l i t y a t t r ib u t e. A n en t r y for a vir t ua l fu nct ion a lso h a s a D W _ A T _ v t a b l e _ e l e m _ l o c a t i o n a t t r ib u t e whose va lue cont a ins a loca t ion descr ipt ion yield ing t he a ddr ess of t he slot for t h e fu nct ion with in t he vir t ua l fu nct ion t a ble for t he enclosing cla ss or str uct ur e. I f a su br out ine en t r y r epr esen t s t he dening decla r a t ion of a mem ber fu nct ion a nd t h a t denit ion a ppea r s out side of t he b ody of t he enclosing cla ss or st r u ct ur e decla r a t ion, t he subr ou t ine en t r y ha s a D W _ A T _ s p e c i f i c a t i o n a t t r ib u t e, whose va lue is a r efer ence t o t he debu ggin g infor ma t ion en t r y r epr esen t in g t he decla r a t ion of t h is funct ion member . T he r efer enced ent r y will be a ch ild of some cla ss or st r uct ur e t ype en t r y. S u br ou t in e en t r ies c ont a in in g t h e D W _ A T _ s p e c i f i c a t i o n a t t r ib u t e do not need t o du plica t e infor m a t ion pr ovided by t he decla r a t ion en t r y r efer enced by t he specica t ion a t t r ib u t e. I n pa r t icu la r , such ent r ies do not need t o cont a in a t t r ibu t es for t he na me or r et ur n t ype of t he funct ion member whose denit ion t hey r epr esen t . 5.5.6 Class Template Instantiations I n C + + a cl as s t em p l at e is a generic d e ni t ion of a class t y pe t h at is inst ant iat ed d iff erent ly wh en an inst ance of t h e class is d eclared or d e ned . T h e generic d escript ion of t h e cl as s m ay incl u d e bot h param et eriz ed t y pes and p aram et eriz ed const ant va l u es. DW A R F d oes not represent t h e generic t em p l at e d e nit ion, bu t d oes represent each inst ant iat ion. A cla ss t em pla t e inst a n t ia t ion is r epr esen t ed by a deb u ggin g infor ma t ion wit h t he t a g D W _ T A G _ c l a s s _ t y p e. W it h four except ions, such a n en t r y will cont a in t he sa me a t t r ib u t es a nd ha ve t he sa me t ypes of ch ild en t r ies a s would a n en t r y for a cla ss t ype dened explic it ly u sing t he in sta n t ia t ion t ypes a nd va lues. T he except ions a r e: 1. E a ch for ma l pa r a met er ized t ype decla r a t ion a ppea r ing in t he t empla t e de nit ion is r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t he ta g
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

43

--

--

DWARF D ebugging Information Format

D W _ T A G _ t e m p l a t e _ t y p e _ p a r a m e t e r. E a ch such en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a in in g t he na me of t he for m a l t ype pa r a met er a s it a ppea r s in t he sour ce pr ogr a m . T he t em pla t e t ype pa r a met er en t r y a lso ha s a D W _ A T _ t y p e a t t r ib u t e descr ib ing t he a ct ua l t ype by which t h e for m a l is r epla ced for t h is in st a n t ia t ion. 2. E a ch for ma l pa r a met er ized va lu e decla r a t ion a ppea r ing in t he t em pla t ed d en it ion is r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t he ta g D W _ T A G _ t e m p l a t e _ v a l u e _ p a r a m e t e r. E a ch such en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a in in g t he na me of t he for m a l va lu e pa r a met er a s it a ppea r s in t he sour ce pr ogr a m . T he t em pla t e va lu e pa r a m e t er en t r y a lso ha s a D W _ A T _ t y p e a t t r ib u t e descr ib ing t he t ype of t he pa r a m et er ized va lue. F ina lly, t he t empla t e va lue pa r a met er ent r y ha s a D W _ A T _ c o n s t _ v a l u e a t t r ib u t e, whose va lue is t he a ct ua l const a nt va lue of t he va lue pa r a met er f or t h is inst a nt ia t ion a s r epr esen t ed on t he t a r ge t a r ch it ec t ur e. I f t he compiler ha s ge ner a t ed a specia l compila t ion unit t o hold t he t empla t e inst a nt ia t ion a nd t ha t compila t ion unit ha s a d iffer en t na me fr om t he compila t ion unit cont a ining t he t em pla t e denit ion, t he na me a t t r ibu t e f or t he debu ggin g ent r y r epr esen t ing t ha t compila t ion u n it should be empt y or omit t ed . I f t he cla ss t ype en t r y r epr esen t in g t he t empla t e in st a n t ia t ion or a ny of it s child ent r ies cont a in decla r a t ion coor dina t e a t t r ibu t es, t h ose a t t r ibu t es should r efer t o t he sour ce for t he t em pla t e denit ion, n ot t o a ny sour ce ge ner a t ed a r t icia lly by t h e compiler .

3.

4.

5.5.7 Variant Entries A va r ia n t pa r t of a st r uct ur e is r epr esen t ed by a debu gging infor ma t ion ent r y wit h t he t a g D W _ T A G _ v a r i a n t _ p a r t a nd is owned by t he cor r esponding str uct ur e t ype en t r y. I f t he va r ia n t pa r t ha s a discr imina n t , t he discr im ina n t is r epr esen t ed by a sepa r a t e debu ggin g infor ma t ion en t r y which is a ch ild of t he va r ia n t pa r t en t r y. T h is en t r y h a s t he for m of a st r uct ur e da t a mem ber en t r y. T h e va r ia nt pa r t en t r y will h a ve a D W _ A T _ d i s c r a t t r ib u t e whose va lue is a r efer ence t o t he mem ber en t r y for t he discr imina nt . I f t he va r ia n t pa r t does n ot ha ve a discr im ina n t ( t a g eld) , t he va r ia nt pa r t en t r y ha s a D W _ A T _ t y p e a t t r ib u t e t o r epr esen t t h e t a g t ype . E a ch va r ia nt of a pa r t icula r va r ia n t pa r t is r epr esen t ed by a debu gging infor ma t ion en t r y wit h t he t a g D W _ T A G _ v a r i a n t a nd is a ch ild of t h e va r ia nt pa r t en t r y. T he va lue t ha t select s a given va r ia n t ma y be r epr esen t ed in one of t h r ee wa ys. T h e va r ia nt en t r y ma y ha ve a D W _ A T _ d i s c r _ v a l u e a t t r ib u t e whose va lue r epr esen t s a single ca se la bel. T he va lue of t h is a t t r ib u t e is encoded a s a n L E B128 n u m ber . T he nu m ber is signed if t he t a g t ype f or t he va r ia nt pa r t cont a ining t h is va r ia nt is a signed t ype . T h e nu m ber is u nsigned if t he t a g t ype is a n u n signed t ype . A lt er na t ively, t h e va r ia nt en t r y ma y cont a in a D W _ A T _ d i s c r _ l i s t a t t r ib u t e, whose va lue r epr esen t s a list of discr imina nt va lues. T h is list is r epr esen t ed by a ny of t he block for m s a nd ma y cont a in a m ixt ur e of ca se la bels a nd la bel r a nges. E a ch it em on t he list is pr exed with a discr im ina n t va lue descr ipt or t h a t det er m ines whet her t he list it em r epr esen t s a single la be l or a la bel r a nge . A single ca se la bel is r epr esen t ed a s a n L E B128
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

44

--

--

DWARF D ebugging Information Format

nu m ber a s dened a b ove for t he D W _ A T _ d i s c r _ v a l u e a t t r ib u t e. A la bel r a nge is r epr esen t ed by t wo L E B128 nu m ber s, t h e low va lue of t he r a nge f ollowed by t he h igh va lue . Bot h va lues f ollow t he r ules f or signedness ju st descr ibed . T he discr im ina n t va lue descr ipt or is a const a n t t ha t m a y ha ve one of t he va lues given in F igur e 13. _ ___________________ DW_DSC_label W D C r n e _D_____S_____a__g___ _ _ _ _ _ _ Figure 13. Discr imina nt descr ipt or va lues I f a va r ia n t ent r y h a s neit her a D W _ A T _ d i s c r _ v a l u e a t t r ib u t e nor a D W _ A T _ d i s c r _ l i s t a t t r ib u t e, or if it ha s a D W _ A T _ d i s c r _ l i s t a t t r ib u t e with 0 size, t he va r ia n t is a defa u lt va r ia n t . T he componen t s select ed by a pa r t icu la r va r ia n t a r e r epr esen t ed b y deb u ggin g infor ma t ion ent r ies owned by t he corr espond in g va r ia nt en t r y a nd a ppea r in t h e sa me or der a s t he corr esponding decla r a t ions in t he sour ce pr ogr a m .

5.6 Enumeration Type Entries


A n enu m erat ion t y pe is a scal ar t h at can assu m e one of a x ed nu m ber of sy m bol ic val u es. A n en u mer a t ion t ype is r epr esen t ed by a deb u ggin g infor m a t ion ent r y wit h t h e t a g D W _ T A G _ e n u m e r a t i o n _ t y p e. I f a na me ha s been given t o t he en u m er a t ion t ype in t he sour ce pr ogr a m , t hen t h e corr esponding enu m er a t ion t ype ent r y h a s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll- t er m ina t ed st r ing cont a ining t he en u mer a t ion t ype na me a s it a ppea r s in t he sou rce pr ogr a m . T hese ent r ies a lso h a ve a D W _ A T _ b y t e _ s i z e a t t r ib u t e whose const a nt va lue is t he nu m ber of b yt es r equ ir ed t o h old a n inst a nce of t h e enu mer a t ion. E a ch en u m er a t ion lit er a l is r epr esen t ed b y a debugging infor m a t ion en t r y wit h t he t a g D W _ T A G _ e n u m e r a t o r. E a ch such en t r y is a ch ild of t h e enu mer a t ion t ype en t r y, a nd t he en u mer a t or ent r ies a ppea r in t he sa me or der a s t he decla r a t ions of t he en u m er a t ion lit er a ls in t h e sour ce pr ogr a m . E a ch en u m er a t or en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a ining t he na me of t he en u mer a t ion lit er a l a s it a ppea r s in t he sour ce pr ogr a m . E a ch en u m er a t or en t r y a lso h a s a D W _ A T _ c o n s t _ v a l u e a t t r ib u t e, whose va lue is t he a ct ua l nu m er ic va lu e of t h e en u m er a t or a s r epr esent ed on t h e t a r ge t syst em .

5.7 S ubroutine Type Entries


I t is p ossibl e in C t o d ecl are p oint ers t o su brou t ines t h at ret u rn a val u e of a speci c t y pe. I n bot h A N S I C and C+ + , it is possible t o d eclare point ers t o su brou t ines t h at not onl y ret u rn a val u e of a speci c t y p e, bu t accept onl y argu m ent s of speci c t y p es. T h e t y pe of su ch point ers wou l d be d escribed wit h a point er t o m od i er ap pl ied t o a u ser- d e ned t y pe. A subr out ine t ype is r epr esen t ed by a deb u ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ s u b r o u t i n e _ t y p e. I f a na me h a s been given t o t h e subr ou t ine t ype in t he sour ce pr ogr a m , t hen t h e cor r esponding subr out ine t ype en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he su br out ine t ype na me a s it a ppea r s in t he sou r ce pr ogr a m .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

45

--

--

DWARF D ebugging Information Format

I f t he subr out ine t ype descr ibes a fu nct ion t ha t r et ur ns a va lu e, t hen t he subr out ine type ent r y ha s a D W _ A T _ t y p e a t t r ib u t e t o denot e t he t ype r et ur ned by t he subr out ine . I f t he t ypes of t he a r gu men t s a r e necessa r y t o descr ibe t he su br out ine t ype , t hen t he corr esponding subr out ine t ype en t r y owns deb u ggin g in f or m a t ion en t r ies t h a t descr ibe t he a r gu men t s. T hese debu ggin g infor ma t ion en t r ies a ppea r in t he or der t h a t t he corr esponding a r gu m ent t ypes a ppea r in t he sour ce pr ogr a m . I n A N S I - C t here is a d iff erence bet ween t h e t y pes of f u nct ions d eclared u sing f u nct ion prot ot y pe s t y le d eclara t ions and t h ose d eclared u sing non- prot ot y pe d eclarat ions. A subr out ine en t r y decla r ed wit h a funct ion pr otot ype st yle decla r a t ion ma y h a ve a D W _ A T _ p r o t o t y p e d a t t r ib u t e, whose va lue is a a g. E a ch debu ggin g infor ma t ion en t r y owned by a subr out ine t ype en t r y ha s a t a g whose va lue ha s one of t wo possible int er pr et a t ions. 1. E a ch deb u ggin g infor m a t ion en t r y t ha t is owned by a subr ou t ine t ype en t r y a nd t h a t denes a single a r gu m ent of a specic t ype ha s t he ta g D W _ T A G _ f o r m a l _ p a r a m e t e r. T he f or ma l pa r a met er ent r y h a s a t ype a t t r ibu t e t o den ot e t he t ype of t he corr esponding for m a l pa r a m et er . 2. T h e u nspecied pa r a met er s of a va r ia b le pa r a met er list a r e r epr esen t ed by a debu ggin g infor ma t ion en t r y owned by t he subr out ine t ype en t r y wit h t he t a g D W _ T A G _ u n s p e c i f i e d _ p a r a m e t e r s.

5.8 S tring Type Entries


A st ring is a sequ ence of ch aract ers t h at h ave speci c sem ant ics and operat ions t h at separat e t h em f rom array s of ch ara cters . Fort ran is one of t h e l angu ages t h at h as a s t ring t y pe. A st r ing t ype is r epr esen t ed b y a debuggin g infor m a t ion en t r y wit h t he t a g D W _ T A G _ s t r i n g _ t y p e. I f a na me h a s been given t o t h e st r in g t ype in t he sour ce pr ogr a m , t hen t h e cor r esponding st r ing t ype en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er mina t ed st r ing cont a in ing t he str ing t ype na me a s it a ppea r s in t he sour ce pr ogr a m . T he str ing t ype en t r y m a y ha ve a D W _ A T _ s t r i n g _ l e n g t h a t t r ib u t e whose va lue is a loca t ion descr ipt ion yield in g t he loca t ion wher e t he len gt h of t he st r ing is st or ed in t h e pr ogr a m . T he st r ing t ype en t r y ma y a lso h a ve a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose const a n t va lue is t he size in b yt es of t he da t a t o be r et r ieved fr om t he loca t ion refer enced by t h e st r in g lengt h a t t r ibu t e. I f no b yt e size a t t r ibu t e is pr esen t , t he size of t he da t a t o be r et r ieved is t he sa me a s t he size of a n a ddr ess on t he t a r get ma ch ine. I f no str ing len gt h a t t r ib u t e is pr esen t , t he str ing t ype ent r y m a y ha ve a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose const a nt va lue is t h e len gt h in b yt es of t he st r ing.

5.9 S et Entries
Pascal provid es t h e concept of a set , wh ich represent s a grou p of val u es of ord inal t y p e. A set is r epr esen t ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ s e t _ t y p e. I f a na me h a s been given t o t h e set t ype , t hen t he set t ype en t r y
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

46

--

--

DWARF D ebugging Information Format

ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he set t ype na me a s it a ppea r s in t he sour ce pr ogr a m . T he set t ype en t r y ha s a D W _ A T _ t y p e a t t r ib u t e t o denot e t he t ype of a n elemen t of t he set . I f t he a m ount of st or a ge a lloca t ed t o hold ea ch elem en t of a n object of t he given set t ype is differ en t fr om t he a m ou n t of st or a ge t h a t is n or m a lly a lloca t ed t o h old a n in d ividu a l object of t he indica t ed elem en t t ype, t hen t he set t ype ent r y ha s a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose const a nt va lue r epr esen t s t he size in byt es of a n in sta nce of t h e set t ype .

5.10 Subrange Type Entries


S everal l angu ages su p port t h e concept of a su brange t y pe obj ect . T h ese obj ect s can represent a su bset of t h e val u es t h at an obj ect of t h e ba si s t y pe f or t h e su brange can represent . S u brange t y pe ent ries m ay al so be u sed t o represent t h e bou nd s of array d im ensions. A subr a nge t ype is r epr esent ed by a debu ggin g infor ma t ion en t r y wit h t he t a g D W _ T A G _ s u b r a n g e _ t y p e. I f a na me h a s been given t o t h e subr a nge t ype , t h en t he subr a nge t ype en t r y ha s a D W _ A T _ n a m e a t t r ib u t e whose va lue is a nu ll-t er m ina t ed st r in g cont a ining t he su br a nge t ype na me a s it a ppea r s in t he sour ce pr ogr a m . T he subr a nge ent r y ma y ha ve a D W _ A T _ t y p e a t t r ib u t e t o descr ibe t he t ype of object of whose va lu es t h is subr a nge is a subset . I f t he a m ount of st or a ge a lloca t ed t o hold ea ch elem en t of a n object of t he given subr a nge t ype is d iffer en t fr om t he a m ou n t of st or a ge t h a t is n or m a lly a lloca t ed t o h old a n in d ividu a l object of t h e indica t ed elem ent t ype, t hen t he su br a nge t ype en t r y ha s a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose const a nt va lue r epr esen t s t he size in byt es of ea ch elem en t of t he su br a nge t ype. T he subr a nge ent r y ma y ha ve t he a t t r ibu t es D W _ A T _ l o w e r _ b o u n d a nd D W _ A T _ u p p e r _ b o u n d t o descr ibe, r espect ively, t he lower a nd u pper b ound va lues of t he su br a nge. T h e D W _ A T _ u p p e r _ b o u n d a t t r ib u t e m a y be r epla ced by a D W _ A T _ c o u n t a t t r ib u t e, whose va lue descr ibes t h e nu m ber of element s in t he su br a nge r a t her t ha n t he va lue of t he la st elem en t . I f a boun d or coun t va lue is descr ibed b y a const a n t n ot r epr esen t ed in t h e pr ogr a ms a ddr ess spa ce a n d ca n be r epr esen t ed by one of t he const a n t a t t r ibu t e for m s, t hen t h e va lu e of t h e lower or u pper b oun d or coun t a t t r ibu te ma y be one of t he const a nt t ypes. O t her wise, t he va lue of t he lower or u pper b oun d or count a t t r ib u t e is a r efer en ce t o a deb u ggin g infor m a t ion en t r y descr ib in g a n object cont a ining t he b oun d va lue or it self descr ibing a const a n t va lue. I f eit her t he lower or u pper b oun d or count va lues a r e m issin g, t h e b ound va lue is a ssumed t o be a la n gua ge-depen den t defa u lt const a n t . T h e d ef au l t lower bou nd val u e f or C or C + + is 0. For Fort ra n, it is 1. N o ot h er d ef au l t val u es are cu rrent ly d e ned by DW A R F. I f t he subr a nge en t r y ha s no t ype a t t r ibu t e descr ibing t he ba sis t ype, t he ba sis t ype is a ssumed t o be t he sa me a s t he object descr ibed b y t he lower b ound a t t r ib u t e ( if it r efer ences a n object ) . I f t her e is no lower b ound a t t r ib u t e, or it does not r efer ence a n object , t he ba sis t ype is t he t ype of t h e u pper bound or count a t t r ibu t e ( if it r efer ences an object ) . I f t her e is no u pper b oun d or count a t t r ib u t e or it does not r efer ence a n object ,
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

47

--

--

DWARF D ebugging Information Format

t he t ype is a ssum ed t o be t he sa me t ype , in t he sou r ce la ngu a ge of t h e compila t ion u n it cont a ining t he su br a nge en t r y, a s a signed int eger wit h t he sa me size a s a n a ddr ess on t he t a r ge t ma chine.

5.11 P ointer to Member Type Entries


I n C + + , a p oint er t o a d at a or f u nct ion m em ber of a class or st ru ct u re is a u niqu e t y pe. A debugging in f or m a t ion en t r y r epr esen t ing t h e t ype of a n object t ha t is a point er t o a st r uc t ur e or cla ss mem ber ha s t he t a g D W _ T A G _ p t r _ t o _ m e m b e r _ t y p e. I f t he point er t o m em ber t ype ha s a na me, t he point er t o mem ber en t r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a in in g t he t ype na me a s it a ppea r s in t he sour ce pr ogr a m . T he point er t o member en t r y ha s a D W _ A T _ t y p e a t t r ib u t e t o descr ibe t he t ype of t he cla ss or st r u ct ur e mem ber t o which object s of t h is t ype ma y point . T he point er t o member en t r y a lso ha s a D W _ A T _ c o n t a i n i n g _ t y p e a t t r ib u t e, whose va lue is a r efer ence t o a deb u ggin g infor m a t ion en t r y f or t he cla ss or st r u ct ur e t o whose mem ber s object s of t h is t ype ma y point . F ina lly, t he point er t o m em ber en t r y ha s a D W _ A T _ u s e _ l o c a t i o n a t t r ib u t e whose va lue is a loca t ion descr ipt ion t ha t compu t es t h e a ddr ess of t he member of t he cla ss or st r u c t u r e t o which t he point er t o member t ype en t r y ca n point . T h e m et h od u sed t o nd t h e ad d ress of a given m em ber of a cl as s or st ru ct u re is com m on t o any ins t ance of t h at cl as s or st ru ct u re and t o any ins t ance of t h e p oint er or m em ber t y pe. T h e m et h od is t h u s associa t ed wit h t h e t y pe ent ry , ra t h er t h an wit h each inst ance of t h e t y pe. T h e D W _ A T _ u s e _ l o c a t i o n ex pression, h owever, cannot be u sed on it s own , bu t m u st be u sed in conj u nct ion wit h t h e locat ion ex pressions f or a p art icu lar obj ect of t h e given point er t o m em ber t y pe and f or a pa rt icu l ar st ru ct u re or class ins t ance. T h e D W _ A T _ u s e _ l o c a t i o n at t ri bu t e ex pect s t wo val u es t o be p u sh ed ont o t h e l ocat ion ex pression st ack bef ore t h e D W _ A T _ u s e _ l o c a t i o n ex pression is evalu at ed . T h e rs t val u e pu sh ed sh ou l d be t h e valu e of t h e p oi nt er t o m em ber obj ect it sel f . T h e second val u e pu sh ed sh ou l d be t h e base ad d ress of t h e ent ire s t ru ct u re or u nion inst ance cont aini ng t h e m em ber wh ose ad d res s is bei ng cal cu l at ed . S o, f or an ex pression l ik e object.*mbr_ptr wh ere m b r _ p t r h as som e p oint er t o m em ber t y pe, a d ebu gger sh ou l d : 1. 2. 3. Pu sh t h e va l u e of m b r _ p t r ont o t h e l ocat ion ex pression st ack . Pu sh t h e base ad d res s of o b j e c t ont o t h e l ocat ion ex pression st ack . E val u at e t h e D W _ A T _ u s e _ l o c a t i o n ex pression f or t h e t y pe of m b r _ p t r.

5.12 File Type Entries


S om e langu ages, su ch as Pascal , provid e a rs t class d at a t y pe t o represent l es.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

48

--

--

DWARF D ebugging Information Format

A le t ype is r epr esent ed by a deb u ggin g infor m a t ion en t r y wit h t h e t a g D W _ T A G _ f i l e _ t y p e . I f t h e le t ype ha s a na m e, t he le t ype ent r y ha s a D W _ A T _ n a m e a t t r ib u t e, whose va lue is a nu ll-t er mina t ed st r in g cont a in in g t he t ype na me a s it a ppea r s in t he sour ce pr ogr a m . T he le t ype en t r y h a s a D W _ A T _ t y p e a t t r ib u t e descr ib ing t he t ype of t he object s cont a ined in t he le. T he le t ype en t r y a lso h a s a D W _ A T _ b y t e _ s i z e a t t r ib u t e, whose va lue is a const a n t r epr esen t ing t he size in byt es of a n inst a nce of t h is le t ype .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

49

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

50

--

--

DWARF D ebugging Information Format

6. OTHER D EBU GGIN G IN FORMATION


T h is sect ion descr ibes debu ggin g infor m a t ion t ha t is not r epr esen t ed in t he for m of debu ggin g infor ma t ion en t r ies a nd is not cont a ined wit h in t he . d e b u g _ i n f o sect ion.

6.1 Accelerated Access


A d ebu gger f requ ent ly need s t o nd t h e d ebu gging inf orm a t ion f or a p rogram obj ect d e ned ou t sid e of t h e com p il at ion u nit where t h e d ebu gged program is cu rrent ly st opped . S om et im es it wil l k now onl y t h e nam e of t h e obj ect; som et im es onl y t h e ad d res s. T o nd t h e d ebu gging inf orm a t ion a ssoci at ed wit h a gl oba l obj ect by na m e, u sing t h e DW A R F d ebu gging inf orm at ion ent ries al one, a d ebu gger wou l d need t o ru n t h rou gh al l ent ries at t h e h igh est scope wit h in each com p il at ion u ni t . For l ook u p by ad d ress, f or a su brou t ine, a d ebu gger can u se t h e l ow and h igh pc at t ribu t es of t h e com pil at ion u ni t ent ries t o qu ick ly na rrow d own t h e search , bu t t h ese at t ri bu t es onl y cover t h e range of ad d resses f or t h e t ex t associa t ed wit h a com pil at ion u ni t ent ry . T o nd t h e d ebu gging inf orm at ion associa t ed wit h a d at a obj ect , an ex h au st ive search wou l d be need ed . Fu rt h erm ore, any search t h rou gh d ebu gging inf orm at ion ent ries f or d iff erent com p il at ion u ni t s wit h in a large program wou l d p ot ent ial ly requ ire t h e access of m any m em ory pages, probably h u rt ing d ebu gger perf orm ance. T o m a ke looku ps of pr ogr a m object s by na me or by a d dr ess fa st er , a pr oducer of D W AR F infor ma t ion ma y pr ovide t wo d iffer en t t ypes of t a b les cont a in ing infor m a t ion a b out t he debu ggin g infor ma t ion en t r ies owned by a pa r t icu la r compila t ion u n it en t r y in a m or e condensed for m a t . 6.1.1 Lookup by N ame F or looku p by na me, a t a ble is ma in t a ined in a sepa r a t e object le sect ion ca lled . d e b u g _ p u b n a m e s. T he t a ble consist s of set s of va r ia b le lengt h en t r ies, ea ch set descr ibing t he na mes of globa l object s whose d en it ions or decla r a t ions a r e r epr esen t ed by debu ggin g infor ma t ion en t r ies owned by a single compila t ion u n it . E a ch set begins wit h a hea der cont a in in g four va lu e s: t h e t ot a l lengt h of t he ent r ies for t ha t set , n ot including t he len gt h eld it self , a ver sion nu mber , t he offset fr om t he begin ning of t he . d e b u g _ i n f o sect ion of t he compila t ion u n it en t r y r efer enced by t h e set a n d t he size in byt es of t he cont ent s of t he . d e b u g _ i n f o sect ion gener a t ed t o r epr esen t t ha t compila t ion unit . T h is hea der is f ollowed by a va r ia ble nu mber of offset / na me pa ir s. E a ch pa ir consist s of t he offset fr om t he begin ning of t he com pila t ion u n it ent r y cor r espond in g t o t h e cu r r en t set t o t he debugging infor ma t ion ent r y for t he given object , followed b y a nu ll-t er m ina t ed cha r a ct er st r ing r epr esen t ing t he na me of t he object a s given by t he D W _ A T _ n a m e a t t r ib u t e of t he r efer enced debu gging en t r y. E a ch set of na m es is t er m ina t ed b y zer o. I n t he ca se of t he na me of a st a t ic da t a mem ber or funct ion member of a C + + st r u ct ur e, cla ss or u n ion, t he na me pr esent ed in t he . d e b u g _ p u b n a m e s sect ion is n ot t he simple na me given by t h e D W _ A T _ n a m e a t t r ib u t e of t he r efer enced debu gging en t r y, bu t r a t her t he fu lly cla ss qua lied na me of t he da t a or fu nct ion m em ber . 6.1.2 Lookup by Address F or looku p by a d dr ess, a t a ble is ma int a ined in a sepa r a t e object le sec t ion ca lled . d e b u g _ a r a n g e s. T he t a ble consist s of set s of va r ia b le lengt h en t r ies, ea ch set descr ibing t he por t ion of t he pr ogr a ms a ddr ess spa ce t ha t is cover ed by a single compila t ion u n it . E a ch set begins wit h a hea der cont a ining ve va lues:
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

51

--

--

DWARF D ebugging Information Format

1. 2. 3. 4. 5.

T h e t ot a l len gt h of t h e en t r ie s for t ha t set , not inclu d ing t he len gt h eld itself . A ver sion nu m ber . T h e offset fr om t he begin ning of t he . d e b u g _ i n f o sect ion of t he compila t ion u n it ent r y r efer enced by t he set . T h e size in byt es of a n a ddr ess on t he t a r get a r ch it ect ur e. F or segmen t ed a ddr essing, t h is is t he size of t h e offset por t ion of t he a ddr ess. T h e size in byt es of a segm ent descr ipt or on t h e t a r ge t a r ch it ect u r e. I f t h e t a r get syst em u ses a a t a ddr ess spa ce , t h is va lue is 0.

T h is hea der is f ollowed by a va r ia ble nu m ber of a ddr ess r a nge descr ipt or s. E a ch descr ipt or is a pa ir consist in g of t h e beginning a ddr ess of a r a nge of t ext or da t a cover ed by some ent r y owned by t h e cor r esponding compila t ion unit ent r y, f ollowed by t he len gt h of t ha t r a nge. A pa r t icu la r set is t er m ina t ed by a n en t r y con sist in g of t wo zer oes. By sca n n in g t he t a ble, a deb u gger ca n qu ickly decide which compila t ion unit t o look in t o nd t he debu ggin g infor ma t ion for a n object t ha t ha s a given a ddr ess.

6.2 Line N umber Information


A sou rce- level d ebu gger wil l need t o k no w h ow t o associa t e st at em ent s in t h e sou rce les wit h t h e correspond ing m ach ine inst ru ct ion ad d resses in t h e ex ecu t able obj ect or t h e sh ared obj ect s u sed by t h at ex ecu t able ob j ect . S u ch an associa t ion wou ld m ak e it possible f or t h e d ebu gger u ser t o specif y m ach ine ins t ru ct ion ad d resses in t erm s of sou rce st at em ent s . T h is wou l d be d one by specif y ing t h e l ine nu m ber and t h e sou rce le cont aining t h e st at em ent . T h e d ebu gger can al so u se t h is inf orm a t ion t o d isp l ay l ocat ions in t erm s of t h e sou rce l es and t o single st ep f rom st at em ent t o st at em ent . A s m en t ioned in sect ion 3.1 , a bove, t he line nu mber infor m a t ion gener a t ed for a compila t ion u n it is r epr esen t ed in t he . d e b u g _ l i n e sect ion of a n object le a nd is r efer enced by a cor r espond in g compila t ion u n it debu ggin g infor ma t ion en t r y in t h e . d e b u g _ i n f o sect ion. I f space were not a cons id era t ion, t h e inf orm at ion provid ed in t h e . d e b u g _ l i n e sect ion cou ld be represent ed as a l arge m at rix , wit h one row f or each ins t ru ct ion in t h e em it t ed obj ect cod e. T h e m at rix wou l d h ave col u m ns f or: t h e sou rce le nam e t h e sou rce l ine nu m ber t h e sou rce col u m n nu m ber wh et h er t h is inst ru ct ion is t h e beginning of a sou rce st at em ent wh et h er t h is inst ru ct ion is t h e beginning of a basic block . S u ch a m at rix , h owever, wou l d be im pract ical l y l arge. W e sh rink it wit h t wo t ech niqu es. First , we d elet e f rom t h e m at rix each row wh ose le, l ine and sou rce col u m n inf orm at ion is id ent ical wit h t h at of i t s pred ecessors. S econd , we d esign a by t e- cod ed l angu age f or a st at e m ach ine and st ore a st ream of by t es in t h e obj ect le ins t ead of t h e m at rix . T h is langu age can be m u ch m ore com pact t h an t h e m at rix . W h en a consu m er of t h e st at em ent inf orm at ion ex ecu t es, i t m u st ru n t h e s t at e m ach ine t o genera t e t h e m at rix f or each com p il at ion u ni t it is int erest ed in. T h e concept of an encod ed m at rix al so leaves room
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

52

--

--

DWARF D ebugging Information Format

f or ex pans ion. I n t h e f u t u re, colu m ns can be ad d ed t o t h e m at rix t o encod e ot h er t h ings t h at are rel at ed t o ind ivid u al inst ru ct ion ad d resses. 6.2.1 Denitions T he f ollowing t er ms a r e used in t he descr ipt ion of t he line nu mber infor ma t ion for m a t : st a t e ma ch ine T h e h yp ot h et ica l ma ch ine used b y a consumer of t h e line nu m ber infor ma t ion t o expa nd t he byt e-coded in str uct ion st r ea m in t o a ma t r ix of line nu mber infor m a t ion. A ser ies of byt e-coded line n u m ber infor m a t ion in st r uct ions r epr esen t ing one compila t ion u n it . A sequence of in st r uct ions t h a t is en t er ed only a t t he r st inst r uct ion a nd e xit ed only a t t he la st in st r uct ion. W e dene a pr oced u r e invoca t ion t o be a n exit fr om a ba sic b lock . A ser ie s of c ont igu ous t a r get m a ch ine inst r uct ions. O ne compila t ion unit ma y em it m u lt iple sequences ( t ha t is, not a ll in st r uct ions wit h in a compila t ion u n it a r e a ssu m ed t o b e cont igu ous) . Sma ll signed in t eger . S m a ll u n signed int eger . M ed iu m u n signed in t eger . L a r ge signed in t eger . L a r ge u n signed int ege r . Va r ia ble len gt h signed a n d u n signed da t a . See sec t ion 7.6.

st a t emen t pr ogr a m ba sic block

sequence

sbyt e ubyt e uh a lf swor d uwor d L E B128

6.2.2 State Mac hine Registers T he sta t em en t infor ma t ion st a t e m a ch ine ha s t h e f ollowing r egist er s: address file line T he pr ogr a m-coun t er va lue cor r espond ing t o a ma ch ine in st r uct ion gener a t ed b y t he compiler . A n u nsigned in t eger in dica t ing t he iden t it y of t he sou r ce le corr esponding t o a ma chine inst r uct ion. A n u nsigned in t eger in dica t ing a sour ce line nu mber . L ines a r e nu m ber ed begin ning a t 1. T h e compiler ma y em it t he va lue 0 in ca ses wher e a n in str uct ion ca nnot be a t t r ibu t ed t o a ny sour ce line. A n u nsigned in t eger in dica t ing a colum n nu m ber wit hin a sour ce line. C olumns a r e nu m ber ed begin ning a t 1. T h e va lu e 0 is r eser ved t o indica t e t ha t a st a t em en t begins a t t h e lef t edge of t h e line. A b oolea n indica t ing t h a t t he cu r r ent in st r uct ion is t he begin ning of a st a t em en t . A b oolea n indica t ing t h a t t he cu r r ent in st r uct ion is t he begin ning of a ba sic block.
D WARF S pecication, Version 2.0

column

is_stmt basic_block

Tool Interface Standards ( TIS)

53

--

--

DWARF D ebugging Information Format

end_sequence

A b oolea n indica t ing t h a t t he cu r r ent a ddr ess is t ha t of t he r st byt e a ft er t h e end of a sequence of t a r get m a ch ine in st r uct ions.

A t t h e beginning of ea ch sequence wit h in a st a t emen t pr ogr a m , t h e st a t e of t he r egist er s is: address file line column is_stmt basic_block end_sequence 0 1 1 0 det er mined by d e f a u l t _ i s _ s t m t in t he sta t ement pr ogr a m pr ologue fa lse fa lse

6.2.3 Statement P rogram Instructions T he sta t e m a ch in e in st r uct ions in a st a t em en t pr ogr a m belong t o one of t hr ee ca t egor ies: specia l opcodes st a nda r d opcodes T hese ha ve a ubyt e opcode eld a nd n o a r gu men t s. M ost of t h e inst r uct ions in a sta t em en t pr ogr a m a r e specia l opcodes. T hese ha ve a u b yt e opcode eld which m a y be f ollowed by zer o or mor e L E B128 a r gu m ent s ( except f or D W _ L N S _ f i x e d _ a d v a n c e _ p c, see below) . T he opcode implies t he nu m ber of a r gu m en t s a nd t heir mea nings, bu t t h e st a t e men t pr ogr a m pr ologue a lso species t he nu m ber of a r gu m ent s for ea ch st a nda r d opcode. T hese ha ve a m u lt iple byt e f or m a t . T h e r st b yt e is zer o; t h e next byt es a r e a n u n signed L E B128 in t eger giving t h e nu m ber of byt es in t he inst r u ct ion it self ( does not include t he r st zer o byt e or t he size) . T he r em a in ing b yt es a r e t he in str uct ion it self .

ext en ded opcodes

6.2.4 The Statement P rogram P rologue T he opt ima l encoding of line nu m ber infor m a t ion depends t o a cer t a in degr ee upon t he a r ch it ect ur e of t h e t a r ge t ma chine. T he st a t ement pr ogr a m pr ologue pr ovides infor ma t ion used by consumer s in decoding t he sta t ement pr ogr a m in st r uct ions for a pa r t icu la r compila t ion u n it a nd a lso pr ovides infor ma t ion used t h r ough out t he r e st of t h e st a t emen t pr ogr a m . T he st a t emen t pr ogr a m f or ea ch compila t ion u n it begin s wit h a pr ologue cont a ining t he f ollowing elds in or der : 1. t o t a l _ l e n g t h ( uwor d) T he size in byt es of t he st a t em en t infor ma t ion for t h is compila t ion unit ( not including t he t o t a l _ l e n g t h eld it self ) . v e r s i o n ( u h a lf) Ver sion iden t ier for t h e st a t em en t infor ma t ion for m a t . p r o l o g u e _ l e n g t h ( uwor d) T h e n u m ber of b yt es f ollowing t he p r o l o g u e _ l e n g t h eld t o t h e begin n ing of t he r st b yt e of t h e st a t e men t pr ogr a m it self. m i n i m u m _ i n s t r u c t i o n _ l e n g t h ( u byt e) T he size in byt es of t he sma lle st t a r get ma chine inst r u ct ion. S t a t emen t pr ogr a m opcodes t h a t a lt er t he a d d r e s s r e gist er r st m u lt iply t heir oper a n d s by t h is va lue.
D WARF S pecication, Version 2.0

2. 3.

4.

Tool Interface Standards ( TIS)

54

--

--

DWARF D ebugging Information Format

5.

d e f a u l t _ i s _ s t m t ( u byt e) T he init ia l va lue of t he i s _ s t m t r e gist er . A sim ple cod e genera t or t h at em it s m ach ine ins t ru ct ions in t h e ord er im pl ied by t h e sou rce program wou l d set t h is t o t ru e, and every ent ry in t h e m at rix wou l d represent a st at em ent bou nd ary . A pipel ine sch ed u l ing cod e genera t or wou l d set t h is t o f al se and em it a speci c st at em ent p rogram op cod e f or each inst ru ct ion t h at represent ed a st a t em ent bou nd ary .

6. 7. 8. 9.

l i n e _ b a s e ( sbyt e) T h is pa r a m et er a ffect s t he mea ning of t he specia l opcodes. See below. l i n e _ r a n g e ( u byt e) T h is pa r a m et er a ffect s t he mea ning of t he specia l opcodes. See below. o p c o d e _ b a s e ( u byt e) T he n u m ber a ssigned t o t he r st specia l opcode. s t a n d a r d _ o p c o d e _ l e n g t h s ( a r r a y of u b yt e) T h is a r r a y species t he nu m ber of L E B128 oper a nds for ea ch of t h e st a n da r d opcodes. T he r st elem en t of t he a r r a y cor r espond s t o t he opcode whose va lue is 1, a nd t he la st element cor r espond s t o t he opcode whose va lue is o p c o d e _ b a s e 1. By incr ea sing o p c o d e _ b a s e, a nd a dd in g elem en t s t o t h is a r r a y, new st a nda r d opcodes ca n be a d ded , while a llowing consumer s who do n ot know a b out t hese new opcodes t o be a ble t o skip t hem . i n c l u d e _ d i r e c t o r i e s ( sequence of pa t h na mes) T he sequence cont a ins a n en t r y for ea ch pa t h t ha t wa s sea r ch ed for inclu ded sour ce les in t h is compila t ion. ( T he pa t h s inclu de t h ose dir ect or ies specied explic it ly by t he user for t he compiler t o sea r ch a n d t h ose t he compiler sea r ches wit h out explicit dir ect ion) . E a ch pa t h ent r y is eit her a fu ll pa t h na me or is r ela t ive t o t he cu r r ent dir ect or y of t he compila t ion. T he cur r en t dir ect or y of t he compila t ion is under st ood t o be t he r st en t r y a nd is not explic it ly r epr esen t ed . E a ch en t r y is a nu ll- t er m ina t ed st r in g cont a ining a fu ll pa t h na me. T he la st ent r y is f ollowed by a single n u ll b yt e. f i l e _ n a m e s ( seq u en ce of le ent r ies) T he sequence cont a ins a n en t r y for ea ch sour ce le t ha t cont r ibu t ed t o t h e st a t emen t infor ma t ion for t h is compila t ion u nit or is used in ot h er cont ext s, such a s in a decla r a t ion coor dina t e or a m a cr o le inclusion . E a ch en t r y ha s a n u ll- t er m ina t ed st r in g cont a ining t he le na m e, a n u nsigned L E B128 nu m ber r epr esen t ing t h e dir ect or y index of t he d ir ect or y in which t he le wa s f oun d , a n u n signed L E B128 nu m ber r epr esen t ing t he t im e of la st m odica t ion for t he le a nd a n u n signed L E B128 n u m ber r epr esen t in g t h e len gt h in b yt es of t h e le. A compiler ma y choose t o em it L E B128( 0) for t he t im e a nd len gt h elds t o indica t e t ha t t h is infor m a t ion is not a va ila b le. T h e la st ent r y is followed b y a single nu ll byt e. T he d ir ect or y index r epr esen t s a n ent r y in t he i n c l u d e _ d i r e c t o r i e s sect ion. T he index is L E B128( 0) if t he le wa s found in t he cur r en t d ir ect or y of t h e compila t ion, L E B128( 1) if it wa s f ound in t he r st dir ect or y in t he i n c l u d e _ d i r e c t o r i e s sect ion, a n d so on. T he d ir ect or y index is ignor ed for le na mes t ha t r epr esen t fu ll pa t h na mes.

10.

11.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

55

--

--

DWARF D ebugging Information Format

T he sta t em en t pr ogr a m a ssigns nu mber s t o ea ch of t h e le ent r ies in or der , beginning wit h 1, a nd uses t h ose n u m ber s in st ea d of le na mes in t he f i l e r e gist er . A compiler ma y gener a t e a single n u ll byt e for t h e le na mes eld a nd dene le na mes u sing t he ext ended opcode D E F I N E _ F I L E. 6.2.5 The Statement P rogram A s st a t ed befor e, t he goa l of a sta t em en t pr ogr a m is t o b u ild a ma t r ix r epr esen t ing one compila t ion u n it , which ma y ha ve pr odu ced m u lt iple sequences of t a r get -ma ch ine inst r uct ions. W it hin a sequence, a d dr esses ma y only incr ea se. ( L ine nu mber s ma y decr ea se in ca ses of pipe lin e sch edu lin g.)
6.2.5 .1 S pecial Opcodes

E a ch 1- byt e specia l opcode h a s t he f ollowing effect on t he st a t e ma ch ine: 1. 2. 3. 4. A d d a signed in t eger t o t he l i n e r e gist er . M u lt iply a n u n signed in t eger by t he m i n i m u m _ i n s t r u c t i o n _ l e n g t h eld of t he st a t ement pr ogr a m pr ologue a n d a dd t he r esult t o t he a d d r e s s r e gist er . A ppend a r ow t o t he m a t r ix using t he cur r en t va lues of t he sta t e m a ch ine r egist er s. Set t he b a s i c _ b l o c k r e gist er t o fa lse.

A ll of t he specia l opcodes do t hose sa me f our t h ings; t hey d iffer fr om one a not h er only in wha t va lues t hey a dd t o t he l i n e a nd a d d r e s s r e gist er s. I ns t ead of ass igning a x ed m eaning t o each special opcod e, t h e st at em ent p rogram u ses several param et ers in t h e pro logu e t o con gu re t h e inst ru ct ion set . T h ere are t wo reasons f or t h is . First , al t h ou gh t h e op cod e sp ace avail able f or special op cod es now ranges f rom 10 t h rou gh 255, t h e l ower bou nd m ay increase i f one ad d s new st and ard opcod es. T h u s, t h e o p c o d e _ b a s e el d of t h e s t at em ent p rogram prol ogu e gives t h e val u e of t h e rs t special op cod e. S econd , t h e best ch oice of special - op cod e m eani ngs d epend s on t h e t arget arch i t ect u re. F or ex am pl e, f or a R I S C m ach ine wh ere t h e com p il er- genera t ed cod e int erl eav es ins t ru ct ions f rom d i ff erent l ines t o sch ed u l e t h e p ip el ine, it is im port a nt t o be able t o ad d a nega t ive val u e t o t h e l i n e regist er t o ex press t h e f act t h a t a l at er inst ru ct ion m ay h ave been em it t ed f or an earl ier sou rce l ine. For a m ach ine where pipel ine sched u l ing never occu rs , i t is ad vant ageou s t o t ra d e away t h e abil it y t o d ecrease t h e l i n e regist er ( a s t and ard op cod e provid es an al t ernat e way t o d ecrease t h e l ine nu m ber) in ret u rn f or t h e abi l i t y t o ad d l arger p osit ive va l u es t o t h e a d d r e s s regist er. T o perm it t h is variet y of st ra t egies , t h e st a tem ent program prol ogu e d e nes a l i n e _ b a s e el d t h at speci es t h e m inim u m val u e wh ich a specia l opcod e can ad d t o t h e l i n e regist er and a l i n e _ r a n g e el d t h at d e nes t h e range of val u es it can ad d t o t h e l i n e regist er. A specia l opcode va lue is ch osen ba sed on t he a moun t t ha t needs t o be a d ded t o t he l i n e a nd a d d r e s s r e gist er s. T he ma ximu m line incr emen t f or a specia l opcode is t he va lue of t he l i n e _ b a s e eld in t he pr ologue, plus t he va lue of t he l i n e _ r a n g e eld, minu s 1 (l i n e b a s e + l i n e r a n g e - 1) . I f t h e desir ed line incr em en t is gr ea t er t h a n t he m a xim um line incr em en t , a st a n da r d opcode m u st be u sed in st ea d of a specia l opcode. T he a ddr ess a d va nce is ca lcu la t ed by dividing t he desir ed a ddr ess incr em en t by t he m i n i m u m _ i n s t r u c t i o n _ l e n g t h eld f r om t he pr ologue. T he specia l opcode is
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

56

--

--

DWARF D ebugging Information Format

t hen ca lcu la t ed u sing t h e f ollowing for m ula : opcode = (desired line increment - line_base) + (line_range * address advance) opcode_base I f t he r esu lt ing opcode is gr ea t er t ha n 255, a st a n da r d opcode mu st be u sed in st ea d .

T o decode a specia l opcode, sub t r a ct t he o p c o d e _ b a s e fr om t h e opcode it self . T h e a m oun t t o incr em en t t h e a d d r e s s r e gist er is t he a d ju st ed opcode divided by t he l i n e _ r a n g e. T he a m ount t o incr em en t t he l i n e r e gist er is t he l i n e _ b a s e plu s t he r esult of t he a d ju st ed opcode m odu lo t he l i n e _ r a n g e. T ha t is, line increment = line_base + ( adjusted opcode % line_range) A s an ex am pl e, su ppose t h at t h e o p c o d e _ b a s e is 16, l i n e _ b a s e is - 1 and l i n e _ r a n g e is 4. T h is m eans t h at we can u se a special opcod e whenever t wo su ccess ive rows in t h e m at rix h ave sou rce l ine nu m bers d iff ering by any val u e wit h in t h e range [- 1, 2] ( and , becau se of t h e l im it ed nu m ber of op cod es avail abl e, wh en t h e d iff erence bet ween ad d resses is wit h in t h e range [0, 59]) . T h e opcod e m ap ping wou l d be: _ ___________________________________________ _______ L ___ a dva n __ A __r ___ a dva ___ _O pcode _____ine ______ce _____dd_ess _____nce _ -1 0 16 0 0 17 1 0 18 19 2 0 20 -1 1 21 0 1 1 1 22 2 1 23 253 0 59 254 1 59 255 2 5_ _ __________________________________9________ T her e is no r equ ir em en t t ha t t he expr ession 2 5 5 - l i n e _ b a s e + 1 be a n int egr a l mu lt iple of l i n e _ r a n g e.
6.2.5 .2 Standard Opcodes

T her e a r e cur r en t ly 9 st a nda r d u byt e opcodes. I n t he fu t u r e a dd it iona l u b yt e opcodes may be dened by set t ing t h e o p c o d e _ b a s e eld in t he sta t em en t pr ogr a m pr ologue t o a va lue gr ea t er t ha n 10. 1. DW_LNS_copy T a kes no a r gu m ent s. A ppen d a r ow t o t he ma t r ix u sing t he cur r en t va lues of t he sta t e-m a ch ine r e gist er s. T h e n set t h e b a s i c _ b l o c k r e gist er t o fa lse. DW_LNS_advance_pc T a kes a single u n signed L E B128 oper a n d, m u lt iplies it by t he m i n i m u m _ i n s t r u c t i o n _ l e n g t h eld of t he pr ologue, a n d a dds t he r esult t o t he a d d r e s s r e gist er of t he st a t e ma chine.
D WARF S pecication, Version 2.0

2.

Tool Interface Standards ( TIS)

57

--

--

DWARF D ebugging Information Format

3.

DW_LNS_advance_line T a kes a single signed L E B128 oper a nd a nd a d d s t ha t va lue t o t he l i n e r e gist er of t he st a t e ma ch ine . DW_LNS_set_file T a kes a single u n signed L E B128 oper a n d a nd stor es it in t he f i l e r e gist er of t he st a t e ma ch ine. DW_LNS_set_column T a kes a single u n signed L E B128 oper a n d a nd stor es it in t he c o l u m n r e gist er of t he st a t e ma ch ine . DW_LNS_negate_stmt T a kes no a r gu m ent s. S et t he i s _ s t m t r e gist er of t he st a t e ma chine t o t he logica l nega t ion of it s cu r r en t va lue. DW_LNS_set_basic_block T a kes no a r gu m ent s. S et t he b a s i c _ b l o c k r e gist er of t he st a t e ma chine t o t r u e. DW_LNS_const_add_pc T a kes no a r gu m ent s. A dd t o t he a d d r e s s r e gist er of t he st a t e ma chine t he a ddr ess incr ement va lu e cor r esponding t o specia l opcode 255. T h e m ot ivat ion f or D W _ L N S _ c o n s t _ a d d _ p c is t h is: wh en t h e st at em ent program need s t o ad vance t h e ad d ress by a sm a l l am ou nt , it can u se a single special opcod e, wh ich occu p ies a single by t e. W h en it need s t o ad vance t h e ad d ress by u p t o t wice t h e range of t h e l a st special op cod e, it can u se D W _ L N S _ c o n s t _ a d d _ p c f ol l owed by a special op cod e, f or a t ot al of t wo by t es. Only if i t need s t o ad vance t h e ad d ress by m ore t h an t wice t h at range wil l it need t o u se bot h D W _ L N S _ a d v a n c e _ p c and a special op cod e, requ iri ng t h ree or m ore by t es.

4.

5.

6.

7.

8.

9.

DW_LNS_fixed_advance_pc T a kes a single u h a lf oper a nd. A dd t o t he a d d r e s s r e gist er of t he st a t e ma chine t he va lue of t he ( u nencoded) oper a n d. T h is is t h e only ext en ded opcode t ha t t a kes a n a r gu men t t ha t is n ot a va r ia ble len gt h nu m ber . T h e m ot ivat ion f or D W _ L N S _ f i x e d _ a d v a n c e _ p c is t h is: ex ist ing assem blers cannot em i t D W _ L N S _ a d v a n c e _ p c or special opcod es becau se t hey cannot encode L E B 128 nu m bers or j u d ge wh en t h e com pu t a t ion of a special op cod e over ows and requ ires t h e u se of D W _ L N S _ a d v a n c e _ p c. S u ch assem bl ers, h owever, can u se D W _ L N S _ f i x e d _ a d v a n c e _ p c inst ead , sacri cing com pression.

6.2.5 .3 Ex tended Opcodes

T her e a r e t h r ee ext ended opcodes c ur r ent ly dened. T he r st byt e following t he len gt h eld of t he encoding for ea ch cont a ins a su b-opcode. 1. DW_LNE_end_sequence Set t h e e n d _ s e q u e n c e r e gist er of t he st a t e ma chine t o t r ue a n d a ppend a r ow t o t he ma t r ix u sing t he cur r en t va lues of t h e st a t e-ma chine r egist er s. T hen r eset t h e r e gist er s t o t he in it ia l va lues specied a b ove.
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

58

--

--

DWARF D ebugging Information Format

E ver y st a t emen t pr ogr a m sequence m u st en d wit h a D W _ L N E _ e n d _ s e q u e n c e inst r uct ion which cr ea t es a r ow whose a d dr ess is t ha t of t he b yt e a f t er t he la st ta r ge t ma ch ine in st r uct ion of t he sequence. 2. DW_LNE_set_address T a kes a single r eloca t a ble a d dr ess a s a n oper a n d. T he size of t he oper a nd is t he size a ppr opr ia t e t o h old a n a ddr ess on t h e t a r ge t ma chine. Set t he a d d r e s s r e gist er t o t he va lue given b y t he r eloca t a ble a ddr e ss. A l l of t h e ot h er st a tem ent program opcod es t h at aff ect t h e a d d r e s s regist er ad d a d el t a t o it . T h is ins t ru ct ion st ores a reloca t abl e va l u e int o it inst ead . 3. DW_LNE_define_file T a kes 4 a r gu m en t s. T h e r st is a nu ll t er m ina t ed str ing cont a ining a sour ce le na me . T he second is a n u n signed L E B128 nu m ber r epr esen t ing t he dir ect or y index of t he dir ect or y in which t he le wa s foun d . T he t hir d is a n u n signed L E B128 nu m ber r epr esen t ing t he t im e of la st m odica t ion of t he le. T he f our t h is a n unsigned L E B128 nu mber r epr esen t ing t he len gt h in byt es of t he le. T he t im e a nd lengt h eld s ma y cont a in L E B128( 0) if t h e infor m a t ion is n ot a va ila ble . T he d ir ect or y index r epr esen t s a n ent r y in t he i n c l u d e _ d i r e c t o r i e s sect ion of t he st a t e men t pr ogr a m pr ologue. T he index is L E B128( 0) if t he le wa s found in t he cu r r en t dir ect or y of t he compila t ion, L E B128( 1) if it wa s foun d in t h e r st dir ect or y in t he i n c l u d e _ d i r e c t o r i e s sect ion, a n d so on. T he d ir ect or y index is ign or ed f or le na m e s t h a t r epr esent fu ll pa t h na mes. T he les a r e n u m ber ed , st a r t ing a t 1, in t he or der in which t hey a ppea r ; t h e na m es in t he pr ologu e come before na mes dened by t he D W _ L N E _ d e f i n e _ f i l e inst r uct ion. T hese nu m ber s a r e u sed in t h e t he f i l e r e gist er of t he st a t e ma chine. A ppend ix 3 gives som e sam p l e st at em ent program s.

6.3 Macro Information


S om e langu ages, su ch as C and C+ + , provid e a way t o rep l ace t ex t in t h e sou rce program wit h m acros d e ned eit h er in t h e sou rce le i t sel f , or in anot h er le inclu d ed by t h e sou rce l e. B ecau se t h ese m acros are not t h em selves d e ned in t h e t arget l angu age, it is d ifficu l t t o rep resent t h eir d e ni t ions u sing t h e st and ard l angu age const ru ct s of DW A R F. T h e d ebu gging inf orm at ion t h eref ore re ect s t h e st at e of t h e sou rce af t er t h e m acro d e nit ion h as been ex pand ed , ra t h er t h an as t h e program m er wrot e it . T h e m acro inf orm at ion t abl e provid es a way of preserving t h e or iginal sou rce in t h e d ebu gging inf orm at ion. A s descr ibed in sect ion 3.1, t h e ma cr o infor ma t ion for a given compila t ion u n it is r epr esen t ed in t h e . d e b u g _ m a c i n f o sect ion of a n object le. T he m a cr o infor ma t ion for ea ch compila t ion u nit is r epr esen t ed a s a ser ies of ma cinfo ent r ie s. E a ch ma cinfo ent r y consist s of a t ype code a nd up t o t wo a d dit iona l oper a nds. T he ser ies of en t r ies for a given compila t ion u n it ends wit h a n en t r y cont a in in g a t ype code of 0. 6.3.1 Mac info Types T he va lid m a cinfo t ypes a r e a s follows:

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

59

--

--

DWARF D ebugging Information Format

DW_MACINFO_define DW_MACINFO_undef

A ma cr o de nit ion. A ma cr o u n-denit ion.

D W _ M A C I N F O _ s t a r t _ f i l e T he sta r t of a new sour ce le inclu sion. DW_MACINFO_end_file T he end of t he cu r r en t sour ce le inclusion.

D W _ M A C I N F O _ v e n d o r _ e x t Ven d or specic ma cr o infor ma t ion dir ect ives t ha t do not t in t o one of t h e st a nda r d ca t egor ie s.
6.3.1 .1 Dene and U ndene Entries

A ll D W _ M A C I N F O _ d e f i n e a nd D W _ M A C I N F O _ u n d e f ent r ies ha ve t wo oper a nds. T he r st oper a n d en codes t h e line n u m ber of t he sour ce line on which t he r eleva n t de nin g or u n dening pr e-pr ocessor dir ect ives a ppea r ed. T he second oper a nd c onsist s of a nu ll-t er mina t ed cha r a ct er str in g. I n t h e ca se of a D W _ M A C I N F O _ u n d e f ent r y, t he va lue of t h is st r ing will be simply t he na me of t he pr e-pr ocessor symbol which wa s u ndened a t t he indica t ed sour ce line . I n t he ca se of a D W _ M A C I N F O _ d e f i n e ent r y, t he va lue of t h is st r ing will be t he na me of t he pr e-pr ocessor symbol t ha t wa s dened a t t he indica t ed sour ce line , followed im m ed ia t ely by t he ma cr o for ma l pa r a me t er list inclu ding t he sur r oun d ing pa r en t heses ( in t he ca se of a fu nct ion- like ma cr o) f ollowed by t he de nit ion st r in g for t h e ma cr o. I f t her e is no f or ma l pa r a met er list , t h en t he na me of t he dened ma cr o is f ollowed dir ect ly b y it s denit ion str ing. I n t he ca se of a fu n ct ion- like ma cr o denit ion, n o whit espa ce cha r a ct er s should a ppea r bet ween t h e na m e of t he dened ma cr o a n d t he f ollowing lef t pa r ent he sis. A lso, no wh it espa ce cha r a ct er s should a ppea r bet ween successive f or ma l pa r a met er s in t he for ma l pa r a met er list . ( S uccessive f or ma l pa r a met er s should, however , be sepa r a t ed by comm a s.) A lso, exa ct ly one spa ce ch a r a ct er should sepa r a t e t he r igh t pa r en t hesis which t er m ina t es t h e f or m a l pa r a m et er list a n d t he f ollowing de nit ion str in g. I n t he ca se of a nor ma l ( i.e. non-funct ion- like) ma cr o de nit ion, exa ct ly one spa ce cha r a ct er should sepa r a t e t he na me of t he dened ma cr o fr om t he f ollowing de nit ion t ext .
6.3.1 .2 Start File Entries

E a ch D W _ M A C I N F O _ s t a r t _ f i l e ent r y a lso h a s t wo oper a nd s. T he r st oper a nd encodes t h e line n u m ber of t h e sour ce line on which t h e inclu sion pr e-pr oce ssor dir ect ive occu r r ed . T he second oper a nd encodes a sour ce le na me inde x. T h is index cor r espond s t o a le nu m ber in t he st a t em en t infor ma t ion t a b le for t he r eleva n t compila t ion unit . T h is in dex indica t es ( indir ect ly) t he na me of t h e le which is bein g included b y t he inclu sion dir ec t ive on t h e indica t ed sour ce line.
6.3.1 .3 End File Entries

A D W _ M A C I N F O _ e n d _ f i l e ent r y ha s n o oper a nds. T he pr esence of t h e en t r y ma r ks t he en d of t h e cur r en t sour ce le inc lu sion .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

60

--

--

DWARF D ebugging Information Format

6.3.1 .4 Vendor Ex tension Entries

A D W _ M A C I N F O _ v e n d o r _ e x t ent r y ha s t wo oper a nds. T he r st is a const a nt . T he second is a nu ll- t er m ina t ed cha r a ct er st r ing. T h e mea ning a nd / or signica nce of t hese oper a nds is int en t iona lly lef t undened b y t h is specica t ion. A consumer m u st be a b le t o t ota lly ignor e a ll D W _ M A C I N F O _ v e n d o r _ e x t ent r ies t ha t it does not u nder sta nd. 6.3.2 Base Source Entries I n a d dit ion t o pr oducin g a ma t ch ed pa ir of D W _ M A C I N F O _ s t a r t _ f i l e a nd D W _ M A C I N F O _ e n d _ f i l e ent r ies for ea ch inclu sion dir ect ive a ct ua lly pr ocessed du r ing compila t ion, a pr oducer should ge ner a t e such a ma t ched pa ir a lso for t h e ba se sour ce le subm it t ed t o t he compiler for compila t ion. I f t h e ba se sour ce le f or a compila t ion is subm it t ed t o t he compiler via some mea n s ot h er t ha n via a na med d isk le ( e.g. via t h e sta nda r d in pu t st rea m on a U N I X syst em) t hen t he compiler sh ould st ill pr oduce t h is ma t ched pa ir of D W _ M A C I N F O _ s t a r t _ f i l e a nd D W _ M A C I N F O _ e n d _ f i l e ent r ies for t he ba se sour ce le, however , t he le na me indica t ed ( indir ect ly) b y t he D W _ M A C I N F O _ s t a r t _ f i l e ent r y of t he pa ir sh ould r efer ence a st a t em en t infor ma t ion le na me ent r y consist ing of a nu ll str ing. 6.3.3 Mac info Entries for Command Line Options I n a d dit ion t o pr oducin g D W _ M A C I N F O _ d e f i n e a nd D W _ M A C I N F O _ u n d e f ent r ies for ea ch of t he dene a n d u ndene d ir ect ives pr ocessed dur ing compila t ion, t he D W A R F pr oducer should gener a t e a D W _ M A C I N F O _ d e f i n e or D W _ M A C I N F O _ u n d e f ent r y for ea ch pr e-pr ocessor symb ol which is dened or u n dened by some mea ns other t ha n via a dene or u ndene dir ect ive wit h in t he compiled sour ce t ext . I n pa r t icu la r , pr e- processor symb ol de nit ions a nd un-de nit ions which occu r a s a r esu lt of comma nd line opt ions ( when invoking t he compiler ) should be r epr esen t ed by t heir own D W _ M A C I N F O _ d e f i n e a nd D W _ M A C I N F O _ u n d e f ent r ies. A ll such D W _ M A C I N F O _ d e f i n e a nd D W _ M A C I N F O _ u n d e f ent r ies r epr esen t ing compila t ion opt ions sh ould a ppea r befor e t he r st D W _ M A C I N F O _ s t a r t _ f i l e ent r y for t h a t compila t ion u n it a nd should encode t he va lue 0 in t heir line nu m ber oper a n d s. 6.3.4 General Rules and Restrictions

A ll m a cinfo en t r ies wit h in a . d e b u g _ m a c i n f o sect ion for a given compila t ion u n it should a ppea r in t he sa me or der in which t he dir ect ives wer e pr ocessed b y t he compiler . A ll m a cinfo en t r ies r epr esen t ing comm a nd line opt ions sh ould a ppea r in t he sa me or der a s t he r eleva n t comma nd line opt ions wer e given t o t he compiler . I n t he ca se wher e t he compiler it self implicit ly supplies one or mor e ma cr o denit ions or u n-denit ions in a d d it ion t o t hose which ma y be specied on t he comm a nd line, ma cinfo en t r ies should a lso be pr oduced for t hese implicit denit ions a nd u n-de nit ions, a nd t hese en t r ies should a lso a ppea r in t h e pr oper or der r ela t ive t o ea ch ot her a nd t o a ny de nit ions or u nde nit ions given explicit ly b y t he user on t he comm a nd lin e.

6.4 Call Frame Information


Debu ggers of t en need t o be able t o view and m od if y t h e st at e of any su brou t ine act ivat ion t h at is on t h e cal l s t ack . A n act iva t ion cons is t s of :
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

61

--

--

DWARF D ebugging Information Format

A cod e loca t ion t h at is wit h in t h e su brou t ine. T h is l ocat ion is eit h er t h e p l ace where t h e p rogram st op ped wh en t h e d ebu gger got cont rol ( e.g. a break point ) , or is a pl ace wh ere a su brou t ine m ad e a cal l or was int erru p t ed by an asy nch ronou s event ( e.g. a signal) . A n area of m em ory t h at is al l ocat ed on a st ack cal l ed a cal l f ram e. T h e cal l f ram e is id ent i ed by an ad d ress on t h e st ack . W e ref er t o t h is ad d ress as t h e Canonical Fram e A d d ress or CFA . A set of regi st ers t h at are in u se by t h e su brou t ine at t h e cod e l ocat ion.

T y p ical l y , a set of regist ers are d esignat ed t o be preserved across a cal l . I f a cal lee wish es t o u se su ch a regis t er, it saves t h e val u e t h a t t h e regist er h ad a t ent ry t im e in it s cal l f ram e and rest ores it on ex it . T h e cod e t h at al l ocat es space on t h e cal l f ram e st ack and perf orm s t h e save op erat ion is cal l ed t h e su brou t ines prol ogu e, and t h e cod e t h at perf orm s t h e res t ore op erat ion and d eal l ocat es t h e f ram e is cal l ed it s ep il ogu e. T y pical l y , t h e p rol ogu e cod e is ph y sical ly at t h e begi nni ng of a su brou t ine and t h e epil ogu e cod e is at t h e end . T o be able t o view or m od if y an act ivat ion t h at is not on t h e t op of t h e cal l f ram e s t ack , t h e d ebu gger m u st vi rt u al l y u nwi nd t h e st ack of act ivat ions u nt il it nd s t h e act ivat ion of int erest . A d ebu gger u nwi nd s a st ack in st eps. S t art ing wit h t h e cu rrent act iva t ion it rest ores any regi st ers t h at were preserved by t h e cu rrent act ivat ion and com p u t es t h e pred ecessors CFA and cod e locat ion. T h is h as t h e l ogical eff ect of ret u rning f rom t h e cu rrent su brou t ine t o it s pred ecess or. W e say t h at t h e d ebu gger virt u al l y u nwind s t h e st ack becau se it preserves enou gh inf orm at ion t o be able t o rewind t h e st ack back t o t h e st at e i t was in bef ore it at tem p t ed t o u nwi nd it . T h e u nwind ing operat ion need s t o k now where regist ers are saved and h ow t o com p u t e t h e pred ecessors CFA and cod e locat ion. W h en consid ering an arch it ect u re- ind epend ent way of encod ing t h is inf orm at ion one h as t o consid er a nu m ber of special t h ings.

Prol ogu e and ep i logu e cod e i s not a lway s in d ist inct block s at t h e beginning and end of a su brou t ine. I t is com m on t o d u p l icat e t h e ep il ogu e cod e at t h e sit e of each ret u rn f rom t h e cod e. S om et im es a com p il er break s u p t h e regist er save/u nsave op erat ions and m oves t h em int o t h e bod y of t h e su brou t ine t o j u st where t h ey are need ed . Com pilers u se d iff erent way s t o m anage t h e cal l f ram e. S om et im es t h ey u se a f ram e point er regist er, som et im es not . T h e a lgorit h m t o com p u t e t h e CFA ch anges as y ou p rogress t h rou gh t h e prol ogu e and epil ogu e cod e. ( B y d e nit ion, t h e CFA valu e d oes not ch ange.) S om e su brou t ines h ave no cal l f ram e. S om et im es a regi st er is saved in anot h er regist er t h at by convent ion d oes not need t o be saved . S om e arch i t ect u res h ave special inst ru ct ions t h at p erf orm som e or al l of t h e regist er m anagem ent in one ins t ru ct ion, leav ing specia l inf orm at ion on t h e st ack t h at ind icat es h ow regist ers are saved . S om e arch i t ect u res t reat ret u rn ad d ress va l u es special l y . For ex am p l e, in one arch i t ect u re, t h e cal l inst ru ct ion gu ara nt ees t h at t h e low ord er t wo bi t s wil l be z ero
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

62

--

--

DWARF D ebugging Information Format

and t h e ret u rn ins t ru ct ion ignores t h ose bit s. T h is leaves t wo bi t s of st orage t h at are avail able t o ot h er u ses t h at m u st be t reat ed special l y . 6.4.1 Structure of Call Frame Information DW A R F suppor t s vir t ua l u nwind ing by dening a n a r ch it ect u r e indepen dent ba sis for r ecor ding h ow pr ocedu r es sa ve a nd r est ore r e gist er s t hr ough out t heir lifet im es. T h is ba sis mu st be a u gm en t ed on some ma ch ines with specic infor m a t ion t ha t is dened by e it her a n a r ch it ect ur e specic A BI a u t hor in g comm it t ee, a ha r dwa r e ven d or , or a compiler pr oducer . T he b ody d en in g a specic a u gm ent a t ion is r efer r ed t o be low a s t he a ugm ent er . A b st r a ct ly, t h is mecha nism descr ibes a ver y la r ge t a ble t ha t ha s t h e following str uct ur e: LOC CFA L0 L1 ... LN R0 R1 ... R N

T he r st colum n indica t es a n a ddr ess for ever y loca t ion t ha t cont a ins code in a pr ogr a m . ( I n sha r ed object s, t h is is a n object -r ela t ive offset .) T he r ema in ing colum ns cont a in vir t ua l unwinding r ules t ha t a r e a ssocia t ed wit h t he indica t ed loca t ion. T he r st column of t he r ules denes t he C F A r ule which is a r egist er a nd a signed offset t h a t a r e a dded t oget her t o compu t e t h e C F A va lu e. T he r em a in ing colum n s a r e la beled by r e gist er nu m ber . T h is includes some r e gist er s t hat ha ve specia l designa t ion on some a r ch it ect ur es such a s t he P C a nd t he st a ck point er r e gist er . ( T he a ct ua l m a pp in g of r e gist er s for a pa r t icu la r a r ch it ect ur e is per for m ed by t h e a u gm ent er .) T he r egist er colum ns cont a in r ules t ha t descr ibe whet her a given r egist er ha s been sa ved a nd t h e r ule t o nd t he va lue for t he r e gist er in t he pr evious fr a me. T he r egist er r u les a r e: undened sa me va lue A r e gist er t h a t ha s t h is r u le ha s no va lue in t h e pr evious fr a me. ( By conven t ion, it is n ot pr eser ved b y a ca llee.) T h is r egist er ha s n ot been m odied fr om t he pr evious fr a me. ( By conven t ion, it is pr eser ved by t h e ca llee , b u t t h e ca llee ha s n ot m odied it .) T he pr evious va lue of t h is r e gist er is sa ved a t t h e a ddr ess C F A + N wher e C F A is t he cu r r ent C F A va lu e a nd N is a signed offset . T he pr evious va lue of t h is r e gist er is stor ed in a n ot her r egist er n u m ber e d R . T he r u le is dened ext er na lly t o t h is specica t ion by t he a u gm en t er .

offset ( N ) r e gist er ( R ) a r ch it ect ur a l

T h is t able wou l d be ex t rem el y l arge if act u al l y const ru ct ed as d escribed . M os t of t h e ent ries at any p oi nt in t h e t abl e are id ent ical t o t h e ones above t h em . T h e wh ol e t abl e can be represent ed qu it e com pact l y by record ing j u st t h e d iff erences st a rt ing at t h e beginning ad d ress of each su brou t ine in t h e p rogram .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

63

--

--

DWARF D ebugging Information Format

T he vir t ua l unwind infor ma t ion is encoded in a self-cont a ined sec t ion ca lled . d e b u g _ f r a m e. E n t r ies in a . d e b u g _ f r a m e sect ion a r e a ligned on a n a ddr essing unit b ounda r y a n d come in t wo for ms: A C omm on I nfor ma t ion E nt r y ( C I E ) a nd a F ra me D escr ipt ion E n t r y ( F D E ) . S izes of da t a object s used in t he encoding of t he . d e b u g _ f r a m e sect ion a r e descr ibed in t er m s of t h e sa m e da t a d en it ions u sed for t he line n u m ber infor ma t ion ( see sect ion 6.2 .1) . A C omm on I nfor ma t ion E n t r y h olds infor m a t ion t ha t is sha r ed a mong ma ny F r a m e D escr ipt or s. T her e is a t lea st one C I E in ever y non-em pt y . d e b u g _ f r a m e sect ion. A C I E cont a ins t he f ollowing eld s, in or der : 1. length A u wor d const a n t t ha t gives t he nu mber of byt es of t he C I E st r uct u r e, not inclu ding t he lengt h eld , it self ( len gt h mod < a ddr essing unit size> = = 0) . CIE_id A u wor d const a n t t ha t is used t o d ist ingu ish C I E s fr om F D E s. version A u b yt e ver sion n u m ber . T h is nu m ber is specic t o t h e ca ll fr a me infor m a t ion a nd is independent of t h e D W A R F ver sion nu m ber . augmentation A nu ll t er m ina t ed str in g t ha t iden t ies t he a u gm en t a t ion t o t h is C I E or t o t he FD E s t ha t u se it . I f a r ea der encount er s a n a ugm ent a t ion st r ing t ha t is u nexpect ed , t hen only t he f ollowing eld s ca n be r ea d : C I E : l e n g t h, C I E _ i d, v e r s i o n, a u g m e n t a t i o n; F D E : l e n g t h, C I E _ p o i n t e r, i n i t i a l _ l o c a t i o n, a d d r e s s _ r a n g e. I f t her e is n o a u gm en t a t ion, t h is va lue is a zer o b yt e. code_alignment_factor A n u nsigned L E B128 const a nt t ha t is fa ct or ed out of a ll a dva nce loca t ion in st r uct ions ( see below) . data_alignment_factor A signed L E B128 const a n t t h a t is fa ct or ed out of a ll offset in str uct ions ( see below.) return_address_register A u b yt e const a n t t ha t in dica t es which colum n in t he r u le t a ble r epr esen t s t he r e t ur n a ddr ess of t he fu n ct ion. N ote t ha t t h is column m igh t n ot cor r espond t o a n a ct ua l ma ch ine r e gist er . initial_instructions A sequence of r u les t ha t a r e in t er pr e t ed t o cr ea t e t he in it ia l set t ing of ea ch colu m n in t he t a ble. padding E nough D W _ C F A _ n o p inst r uct ions t o m a ke t h e size of t h is en t r y ma t ch t he l e n g t h va lue a bove.

2. 3.

4.

5.

6. 7.

8.

9.

A n F D E cont a ins t he f ollowing eld s, in or der : 1. length A u wor d const a n t t ha t gives t he nu mber of byt es of t he hea der a nd inst r u ct ion st r ea m for t h is fu nct ion ( not inclu d ing t he len gt h eld it self) ( len gt h m od
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

64

--

--

DWARF D ebugging Information Format

< a ddr essing u n it size> = = 0) . 2. CIE_pointer A u wor d const a n t offset in t o t he . d e b u g _ f r a m e sect ion t ha t den otes t he C I E t ha t is a ssocia t ed wit h t h is F D E . i n i t i a l _ l o c a t i o n A n a d dr e ssing- u nit sized const a n t indica t ing t he a ddr ess of t he r st loca t ion a ssocia t ed wit h t h is t a ble en t r y. address_range A n a d dr e ssing u n it sized const a n t indica t ing t h e nu m ber of byt es of pr ogr a m inst r uct ions descr ibed by t h is en t r y. instructions A sequence of t a b le de nin g inst r u ct ions t ha t a r e descr ibed below.

3. 4.

5.

6.4.2 Call Frame Instructions E a ch ca ll fr a m e in st r u ct ion is dened t o t a ke 0 or mor e oper a nd s. S ome of t he oper a n ds ma y be encoded a s pa r t of t he opcode ( see sect ion 7.23) . T he inst r u ct ions a r e a s follows: 1. D W _ C F A _ a d v a n c e _ l o c t a kes a single a r gu m en t t ha t r epr esen t s a const a nt delt a . T he r equ ir ed a ct ion is t o cr ea t e a new t a ble r ow wit h a loca t ion va lu e t ha t is compu t ed by t a king t he cu r r ent en t r ys loca t ion va lue a nd a dding ( delt a * c o d e _ a l i g n m e n t _ f a c t o r) . A ll ot her va lues in t he new r ow a r e init ia lly iden t ica l t o t he cu r r en t r ow. D W _ C F A _ o f f s e t t a kes t wo a r gu m ent s: a n u n signed L E B128 const a n t r epr esen t ing a fa ct or ed offset a n d a r e gist er n u m ber . T h e r equ ir ed a c t ion is t o cha nge t he r ule for t he r egist er indica t ed b y t he r egist er nu m ber t o be a n offset ( N ) r ule wit h a va lue of ( N = fa ct or ed offset * d a t a _ a l i g n m e n t _ f a c t o r) . D W _ C F A _ r e s t o r e t a kes a single a r gu m en t t ha t r epr esen t s a r egist er nu m ber . T he r equ ir ed a ct ion is t o cha nge t he r ule for t he indica t ed r e gist er t o t he r u le a ssigned it by t he i n i t i a l _ i n s t r u c t i o n s in t he C I E . D W _ C F A _ s e t _ l o c t a kes a single a r gu m en t t ha t r epr esen t s a n a ddr ess. T h e r equ ir ed a c t ion is t o cr ea t e a new t a ble r ow using t he specied a ddr ess a s t he loca t ion. A ll ot h er va lu es in t h e new r ow a r e in it ia lly iden t ica l t o t h e cur r en t r ow. T he new loca t ion va lue should a lwa ys be gr ea t er t ha n t he cu r r ent one. D W _ C F A _ a d v a n c e _ l o c 1 t a kes a single u b yt e a r gu m en t t ha t r epr esen t s a const a n t de lt a . T h is in st r u ct ion is iden t ica l t o D W _ C F A _ a d v a n c e _ l o c except for t h e encoding a nd size of t h e de lt a a r gu m ent . D W _ C F A _ a d v a n c e _ l o c 2 t a kes a single u h a lf a r gu men t t h a t r epr esen t s a const a n t de lt a . T h is in st r u ct ion is iden t ica l t o D W _ C F A _ a d v a n c e _ l o c except for t h e encoding a nd size of t h e de lt a a r gu m ent . D W _ C F A _ a d v a n c e _ l o c 4 t a kes a single u wor d a r gu m en t t ha t r epr esen t s a const a n t de lt a . T h is in st r u ct ion is iden t ica l t o D W _ C F A _ a d v a n c e _ l o c except for t h e encoding a nd size of t h e de lt a a r gu m ent . D W _ C F A _ o f f s e t _ e x t e n d e d t a kes t wo u nsigned L E B128 a r gu m en t s r epr esen t ing a r e gist er nu m ber a nd a fa ct ored offset . T h is in st r uct ion is iden t ica l t o
D WARF S pecication, Version 2.0

2.

3.

4.

5.

6.

7.

8.

Tool Interface Standards ( TIS)

65

--

--

DWARF D ebugging Information Format

D W _ C F A _ o f f s e t except for t he encoding a nd size of t he r e gist er a r gu m ent . 9. D W _ C F A _ r e s t o r e _ e x t e n d e d t a kes a single u n signed L E B128 a r gu m ent t ha t r epr esen t s a r e gist er nu mber . T h is inst r uc t ion is iden t ica l t o D W _ C F A _ r e s t o r e except for t he encoding a nd size of t he r e gist er a r gu m ent . D W _ C F A _ u n d e f i n e d t a kes a single u n signed L E B128 a r gu m ent t ha t r epr esen t s a r e gist er nu mber . T he r equ ir ed a ct ion is t o set t he r u le f or t he specied r e gist er t o undened. D W _ C F A _ s a m e _ v a l u e t a kes a single u n signed L E B128 a r gu m ent t ha t r epr esen t s a r e gist er n u m ber . T h e r equ ir ed a ct ion is t o set t h e r ule for t he specied r e gist er t o sa me va lue. D W _ C F A _ r e g i s t e r t a kes t wo u nsigned L E B128 a r gu men t s r epr esen t ing r e gist er nu m ber s. T he r equir ed a ct ion is t o set t he r ule for t he r st r e gist er t o be t he second r e gist er . DW_CFA_remember_state DW_CFA_restore_state T hese in st r uct ions dene a st a ck of infor ma t ion. E ncount er ing t h e D W _ C F A _ r e m e m b e r _ s t a t e inst r uct ion mea n s t o sa ve t he r ules f or ever y r e gist er on t he cu r r en t r ow on t he st a ck . E ncount er ing t he D W _ C F A _ r e s t o r e _ s t a t e inst r uct ion mea n s t o pop t he set of r u les off t he st a ck a nd pla ce t h em in t he cu r r en t r ow. ( T h is operat ion is u sef u l f or com p il ers t h at m ove epil ogu e cod e int o t h e bod y of a f u nct ion.) D W _ C F A _ d e f _ c f a t a kes t wo u nsigned L E B128 a r gu men t s r epr esen t ing a r e gist er nu m ber a n d a n offset . T he r equir ed a ct ion is t o dene t he cur r en t C F A r u le t o u se t he pr ovided r e gist er a n d offset . D W _ C F A _ d e f _ c f a _ r e g i s t e r t a kes a single u n signed L E B128 a r gu m ent r epr esen t ing a r e gist er nu m ber . T h e r equ ir ed a c t ion is t o dene t h e cur r ent C F A r ule t o use t he pr ovided r egist er ( bu t t o keep t he old offset ) . D W _ C F A _ d e f _ c f a _ o f f s e t t a kes a single u n signed L E B128 a r gu m ent r epr esen t ing a n offset . T he r equir ed a ct ion is t o dene t he cur r en t C F A r u le t o u se t he pr ovided offset ( b u t t o keep t h e old r e gist er ) . D W _ C F A _ n o p ha s n o a r gu men t s a nd n o r equ ir ed a ct ions. I t is u sed a s pa d d ing t o ma ke t he F D E a n a ppr opr ia t e size .

10.

11.

12.

13. 14.

15.

16.

17.

18.

6.4.3 Call Frame Instruction U sage T o d eterm ine t h e vi rt u a l u nwi nd ru l e set f or a given l ocat ion ( L 1) , one search es t h rou gh t h e FDE h ead ers look ing at t h e i n i t i a l _ l o c a t i o n and a d d r e s s _ r a n g e val u es t o see if L 1 is cont ained in t h e FDE . I f so, t h en: 1. 2. I ni t ia l iz e a regi st er set by read ing t h e i n i t i a l _ i n s t r u c t i o n s el d of t h e associa t ed CI E . R ead and process the FDE s ins t ru ct ion sequ ence u nt il a D W _ C F A _ a d v a n c e _ l o c, D W _ C F A _ s e t _ l o c, or t h e end of t h e inst ru ct ion st ream is encou nt ered .
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

66

--

--

DWARF D ebugging Information Format

3.

I f a D W _ C F A _ a d v a n c e _ l o c or D W _ C F A _ s e t _ l o c inst ru ct ion was encou nt ered , t h en com pu t e a new l ocat ion val u e ( L 2) . I f L 1 > = L 2 t h en process t h e inst ru ct ion and go back t o st ep 2. T h e end of t h e inst ru ct ion st ream can be t h ou gh t of as a DW_CFA_set_loc( initial_location + address_range ) inst ru ct ion. Unl ess t h e FDE is il l - f orm ed , L 1 sh ou l d be less t h an L 2 at t h is p oi nt .

4.

T h e ru les in t h e regist er set now apply t o l ocat ion L 1. For a n ex am p l e, see A p pend ix 5.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

67

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

68

--

--

DWARF D ebugging Information Format

7. D ATA REP RESEN TATION


T h is sect ion descr ibes t he bina r y r epr esen t a t ion of t h e debu ggin g infor ma t ion en t r y it self , of t he a t t r ib u t e t ypes a n d of ot her fu nda ment a l elem ent s descr ibed a bove.

7.1 Vendor Ex tensibility


T o r eser ve a por t ion of t he D W A R F na me spa ce a nd r a nges of enu mer a t ion va lues for u se for vendor specic ext ension s, specia l la bels a r e r eser ved f or t a g na mes, a t t r ibut e na mes, ba se t ype encodings, loca t ion oper a t ions, la n gua ge na mes, ca lling conven t ions a n d ca ll fr a m e in st r uct ions. T h e la be ls den ot in g t he beginning a nd end of t he r eser ved va lue r a nge for vendor specic ext ensions c onsist of t he a ppr opr ia t e pr e x ( D W _ T A G, D W _ A T, D W _ A T E, D W _ O P, D W _ L A N G, or D W _ C F A r espect ively) f ollowed by _ l o _ u s e r or _ h i _ u s e r. F or exa m ple, for en t r y t a gs, t he specia l la bels a r e D W _ T A G _ l o _ u s e r a nd D W _ T A G _ h i _ u s e r. Va lues in t he r a nge bet ween pre x _ l o _ u s e r a nd pre x _ h i _ u s e r inclu sive, a r e r eser ved for vendor specic ext ension s. Ve n dor s ma y u se va lues in t h is r a nge wit hout conict ing wit h cur r en t or fu t ur e syst em -dened va lue s. A ll ot her va lues a r e r eser ved for u se by t he system . Ven d or dened t a gs, a t t r ibu t es, ba se t ype encodings, loca t ion a t oms, la ngu a ge na mes, ca lling conven t ions a n d ca ll f r a me inst r u ct ions, conven t iona lly use t he for m pre x _vend or_id_nam e, wher e vend or_id is some ident if ying cha r a ct er sequence chosen so a s t o a void con ict s wit h ot h er ven d or s. T o en sur e t ha t ext en sions a dded by one vendor ma y be sa fely ign or ed by consumer s t ha t d o not u nder st a nd t h ose ext en sions, t h e f ollowing r ules should be f ollowed : 1. 2. 3. N ew a t t r ibu t es should be a d ded in such a wa y t ha t a deb u gger ma y r ecognize t he for m a t of a new a t t r ibu t e va lu e wit h ou t kn owing t he cont en t of t ha t a t t r ibu te va lu e. T h e sem a nt ics of a ny new a t t r ibu t es sh ould n ot a lt er t he sema nt ics of pr eviously exist ing a t t r ibu t e s. T h e sem a nt ics of a ny new t a gs sh ould n ot conict wit h t he sema nt ics of pr eviou sly exist ing t a gs.

7.2 Reserved Error Values


A s a convenience for consum er s of D W A R F infor ma t ion, t he va lue 0 is r eser ved in t he encodings for a t t r ibu t e na me s, a t t r ibu t e f or m s, ba se t ype encodin gs, loca t ion oper a t ions, la n gu a ge s, st a t e men t pr ogr a m opc odes, ma cr o infor ma t ion en t r ies a n d t a g na mes t o r epr esen t a n er r or cond it ion or u nknown va lue. D W A R F d oes not specify na mes for t hese r eser ved va lues, since t hey d o not r epr esen t va lid encodin gs for t h e given t ype a nd sh ould not a ppea r in D W A R F debu ggin g infor m a t ion.

7.3 Executable Objects and S hared Objects


T he r eloca t ed a d dr esses in t h e debu ggin g infor ma t ion for a n execu t a ble object a r e vir t ua l a ddr esses a nd t he r eloca t ed a ddr esses in t he deb u ggin g infor m a t ion for a sha r ed object a r e offset s r ela t ive t o t he sta r t of t he lowest segm en t u sed by t ha t sha r ed object . T h is requ irem ent m ak es t h e d ebu gging inf orm at ion f or sh ared obj ect s pos it ion ind epend ent . V i rt u al ad d resses in a sh ared obj ect m ay be calcu l a t ed by ad d ing t h e off set t o t h e base ad d res s at wh ich t h e obj ect was at t ached . T h is off set is avail able in t h e ru nt im e l ink ers d at a st ru ct u res .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

69

--

--

DWARF D ebugging Information Format

7.4 File Constraints


A ll deb u gging in for ma t ion ent r ies in a r e loca t a ble object le, execu t a ble object or sha r ed object a r e r equ ir ed t o be ph ysica lly cont igu ous.

7.5 Format of Debugging Information


F or ea ch compila t ion u nit compiled wit h a D W A R F Ver sion 2 pr oducer , a cont r ibu t ion is ma de t o t he . d e b u g _ i n f o sect ion of t he object le. E a ch such cont r ibu t ion consist s of a compila t ion u n it hea der f ollowed by a ser ies of debu ggin g infor ma t ion en t r ies. U nlike t he infor m a t ion encoding for D W A R F Ver sion 1, Ver sion 2 debu ggin g infor ma t ion en t r ies do n ot t hem selves cont a in t he debu ggin g infor ma t ion en t r y t a g or t he a t t r ibu t e na m e a nd for m encodings f or ea ch a t t r ibu t e. I nst ea d, ea ch debu ggin g infor ma t ion en t r y begins wit h a code t ha t r epr esen t s a n en t r y in a sepa r a t e a bbr evia t ions t a ble. T h is code is f ollowed dir ect ly by a ser ies of a t t r ibu t e va lu e s. T he a ppr opr ia t e en t r y in t he a bbr evia t ions t able gu ides t he int er pr et a t ion of t h e infor m a t ion cont a ined dir ect ly in t he . d e b u g _ i n f o sect ion. E a ch compila t ion u n it is a ssocia t ed wit h a pa r t icu la r a bbr evia t ion t a ble, bu t mu lt iple comp ila t ion u nit s m a y sha r e t he sa me t a ble. T h is encod ing was based on t h e observat ion t h at t y p ical DW A R F prod u cers prod u ce a very l im it ed nu m ber of d iff erent t y pes of d ebu gging inf orm at ion ent ries. B y ex t ract ing t h e com m on inf orm a t ion f rom t h ose ent ries int o a separa t e t able, we are able t o com press t h e generat ed inf orm at ion. 7.5.1 Compilation U nit H eader T he hea der for t h e ser ies of debugging infor ma t ion en t r ies cont r ibu t ed by a single compila t ion u n it con sist s of t he f ollowing infor ma t ion: 1. 2. 3. A 4-b yt e u n signed in t eger r epr esen t in g t h e lengt h of t h e . d e b u g _ i n f o cont r ibu t ion for t ha t compila t ion u nit , n ot inclu ding t he len gt h eld it self . A 2-b yt e u n signed in t eger r epr esen t in g t h e ver sion of t he D W A R F infor ma t ion f or t ha t compila t ion u n it . F or D W A R F Ver sion 2, t he va lue in t h is eld is 2. A 4-b yt e u n signed offset in t o t h e . d e b u g _ a b b r e v sect ion. T h is offset a ssocia t es t he comp ila t ion u nit with a pa r t icu la r set of debuggin g infor ma t ion en t r y a bbr evia t ions. A 1-b yt e u n signed in t eger r epr esen t in g t h e size in b yt es of a n a d dr ess on t he t a r ge t a r ch it ect u r e. I f t h e syst em u ses segmen t ed a ddr essing, t h is va lue r epr esen t s t he size of t he offset por t ion of a n a ddr ess.

4.

T h e com p il at ion u ni t h ead er d oes not rep l ace t h e D W _ T A G _ c o m p i l e _ u n i t d ebu gging inf orm at ion ent ry . I t is ad d it iona l inf orm at ion t h at is represent ed ou t sid e t h e st and ard DW A R F t ag/at t ribu t es f orm at . 7.5.2 Debugging Information Entry E a ch debu ggin g infor ma t ion en t r y begin s wit h a n u n signed L E B128 n u m ber cont a ining t he a bbr evia t ion code for t he en t r y. T h is code r epr esen t s a n en t r y wit h in t he a bbr evia t ion t a ble a ssocia t ed wit h t h e compila t ion u n it cont a ining t h is ent r y. T he a b br evia t ion code is followed b y a ser ies of a t t r ibu t e va lues.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

70

--

--

DWARF D ebugging Information Format

O n some a r ch it ect u r es, t her e a r e a lignment const r a in t s on sect ion boun da r ie s. T o m a ke it ea sier t o pa d debu ggin g infor ma t ion sec t ions t o sa t isfy such const r a in t s, t he a bbr evia t ion code 0 is r eser ved . D eb u ggin g infor ma t ion en t r ies c onsist ing of only t h e 0 a bbr evia t ion code a r e consider ed nu ll en t r ies. 7.5.3 Abbreviation Tables T he a bbr evia t ion t a bles for a ll compila t ion u n it s a r e cont a ined in a sepa r a t e object le sect ion ca lled . d e b u g _ a b b r e v. A s m en t ioned befor e, mu lt iple compila t ion u nit s m a y sha r e t he sa me a b br evia t ion t a ble. T he a bbr evia t ion t a ble for a single compila t ion unit consist s of a ser ies of a bbr evia t ion decla r a t ions. E a ch decla r a t ion species t he t a g a nd a t t r ibu t es for a pa r t icu la r f or m of debu ggin g infor ma t ion en t r y. E a ch decla r a t ion begins wit h a n u n signed L E B128 n u m ber r epr esen t ing t he a bbr evia t ion code it self . I t is t h is code t ha t a ppea r s a t t h e beginning of a debu ggin g infor ma t ion en t r y in t he . d e b u g _ i n f o sect ion. A s descr ibed a bove, t he a bbr evia t ion code 0 is r eser ved for n u ll debu gging infor ma t ion en t r ies. T he a bbr evia t ion code is f ollowed by a n ot her u nsigned L E B128 nu m ber t ha t encodes t he en t r ys t a g. T he encodings for t he t a g na mes a r e given in F igur es 14 a n d 15. F ollowing t he t a g encoding is a 1- b yt e va lue t ha t det er mines whet her a deb u ggin g infor ma t ion en t r y u sing t h is a bbr evia t ion ha s child ent r ies or not . I f t he va lue is D W _ C H I L D R E N _ y e s, t he next physica lly succeed ing en t r y of a ny debu gging infor ma t ion ent r y using t h is a bbr evia t ion is t he r st ch ild of t he pr ior en t r y. I f t h e 1- b yt e value following t he a bbr evia t ions t a g encodin g is D W _ C H I L D R E N _ n o, t he next physica lly succeeding en t r y of a ny debu ggin g infor ma t ion ent r y u sing t h is a bbr evia t ion is a siblin g of t he pr ior en t r y. ( E it her t he r st ch ild or sibling ent r ies ma y be nu ll ent r ies) . T he encodings for t he ch ild det er mina t ion byt e a r e given in F igu r e 16. ( A s m en t ioned in sect ion 2.3 , ea ch ch a in of sibling en t r ies is t er m ina t ed by a n u ll en t r y) . F ina lly, t he ch ild encoding is followed by a ser ies of a t t r ibu t e specica t ions. E a ch a t t r ibu t e specica t ion c onsist s of t wo pa r t s. T he r st pa r t is a n u nsigned L E B128 nu m ber r epr esen t ing t he a t t r ib u t es na me. T he second pa r t is a n u n signed L E B128 nu mber r epr esen t ing t he a t t r ib u t es f or m . T he ser ies of a t t r ibu t e specica t ions en ds wit h a n en tr y cont a ining 0 for t he na me a nd 0 for t he for m . T he a t t r ibu t e for m D W _ F O R M _ i n d i r e c t is a specia l ca se. F or a t t r ibu t es wit h t h is for m , t he a t t r ibu t e va lu e it self in t he . d e b u g _ i n f o sect ion begins with a n u nsigned L E B128 n u m ber t h a t r epr esen t s it s for m . T h is a llows pr oducer s t o ch oose for ms for pa r t icu la r a t t r ibu t es d yna m ica lly, wit h out ha ving t o a dd a new en t r y t o t he a bbr evia t ion t a ble . T he a bbr evia t ions for a given compila t ion u n it en d with a n ent r y consist ing of a 0 byt e for t he a b br evia t ion code. S ee A ppend ix 2 f or a d epict ion of t h e orga niz at ion of t h e d ebu gging inf orm at ion. 7.5.4 Attribute Encodings T he encodings for t he a t t r ibu t e na m es a r e given in F igur es 17 a nd 18. T he a t t r ibu t e for m gover ns h ow t he va lue of t he a t t r ib u t e is encode d. T h e possible for ms ma y belong t o one of t he following f or m cla sses:
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

71

--

--

DWARF D ebugging Information Format

______________________________________________________________________ T a g n ____ _______a me _____________________________________Va____________________ __ lue 0x01 D W _ T A G _ a r r a y _ t y p e 0x02 D W _ T A G _ c l a s s _ t y p e 0x03 D W _ T A G _ e n t r y _ p o i n t D W _ T A G _ e n u m e r a t i o n _ t y p e 0x04 D W _ T A G _ f o r m a l _ p a r a m e t e r 0x05 D W _ T A G _ i m p o r t e d _ d e c l a r a t i o n 0x08 0x0a D W _ T A G _ l a b e l 0x0b D W _ T A G _ l e x i c a l _ b l o c k D W _ T A G _ m e m b e r 0x0d D W _ T A G _ p o i n t e r _ t y p e 0x0f D W _ T A G _ r e f e r e n c e _ t y p e 0x10 0x11 D W _ T A G _ c o m p i l e _ u n i t 0x12 D W _ T A G _ s t r i n g _ t y p e 0x13 D W _ T A G _ s t r u c t u r e _ t y p e D W _ T A G _ s u b r o u t i n e _ t y p e 0x15 D W _ T A G _ t y p e d e f 0x16 DW _ T A G _ u n i o n _ t y p e 0x17 0x18 DW _ TA G _ un s pe c i fi e d _p a ra m e te r s 0x19 DW _ TA G _ va r ia n t DW _ TA G _ co m mo n _ bl o c k 0x1a DW _ TA G _ co m mo n _ in c l us i on 0x1b DW_TAG_inheritance 0x1c 0x1d DW_TAG_inlined_subroutine 0x1e DW_TAG_module 0x1f DW_TAG_ptr_to_member_type DW_TAG_set_type 0x20 DW_TAG_subrange_type 0x21 DW_TAG_with_stmt 0x22 0x23 DW_TAG_access_declaration 0x24 DW_TAG_base_type DW_TAG_catch_block 0x25 DW_TAG_const_type 0x26 DW_TAG_constant 0x27 0x28 DW_TAG_enumerator ________________________________________________0__2__________________ DW_TAG_file_type _x _9 Figure 14. T a g encodings ( pa r t 1) a ddr ess R epr esen t ed a s a n object of a ppr opr ia t e size t o h old a n a ddr ess on t he t a r ge t ma chine (D W _ F O R M _ a d d r) . T h is a ddr ess is r eloca t a ble in a r eloca t a ble object le a nd is r eloca t ed in a n execu t a ble le or sha r ed object . Blocks come in f our for m s. T he r st c onsist s of a 1- b yt e followed by 0 to 255 cont igu ous infor ma t ion (D W _ F O R M _ b l o c k 1) . T he second consist s of a 2- b yt e followed b y 0 t o 65,535 cont igu ous infor ma t ion (D W _ F O R M _ b l o c k 2) . T he t h ir d con sists of a 4- byt e followed b y 0 t o 4,294,967,2 95 cont igu ous infor ma t ion
D WARF S pecication, Version 2.0

block

len gt h b yt es lengt h byt es lengt h b yt es


72

Tool Interface Standards ( TIS)

--

--

DWARF D ebugging Information Format

_______________________________________________________ T a g n ____ _______a me __________________________________Va________ __ lue 0x2a DW_TAG_friend 0x2b DW_TAG_namelist 0x2c DW_TAG_namelist_item DW_TAG_packed_type 0x2d DW_TAG_subprogram 0x2e DW_TAG_template_type_param 0x2f 0x30 DW_TAG_template_value_param 0x31 DW_TAG_thrown_type DW_TAG_try_block 0x32 DW_TAG_variant_part 0x33 DW_TAG_variable 0x34 0x35 DW_TAG_volatile_type 0x4080 DW_TAG_lo_user DW_TAG_hi_user _____________________________________________0__f__f___ _x _f _f Figure 15. T a g encodings ( pa r t 2) ____________________________________ C _ ild det er m ___ ion _a me Va lu _ ___h__________ina t____n____________e _ 0 DW_CHILDREN_no 1 ___W__C__I__D__E_____e______________ D __ _H _ L _R _ N _ y _s Figure 16. C h ild det er mina t ion encodings (D W _ F O R M _ b l o c k 4) . T he four t h consist s of a n u n signed L E B128 len gt h f ollowed b y t he nu m ber of b yt es specied by t h e len gt h (D W _ F O R M _ b l o c k) . I n a ll for m s, t he len gt h is t he nu m ber of infor ma t ion byt es t ha t f ollow. T he infor ma t ion byt es ma y cont a in a ny m ixt ur e of r eloca t ed ( or r eloca t a ble) a ddr esses, r efer ences t o ot h er debu ggin g infor ma t ion en t r ies or da t a b yt es. const a n t T her e a r e six f or m s of const a n t s: one, t wo, four a nd eigh t byt e va lues ( r espect ively, D W _ F O R M _ d a t a 1, D W _ F O R M _ d a t a 2, D W _ F O R M _ d a t a 4, a nd D W _ F O R M _ d a t a 8) . T her e a r e a lso va r ia ble lengt h const a nt da t a for m s encoded u sing L E B128 nu m ber s ( see below) . Bot h signed ( D W _ F O R M _ s d a t a) a nd unsigned (D W _ F O R M _ u d a t a) va r ia ble lengt h const a nt s a r e a va ila ble. A a g is r epr esen t ed a s a single byt e of da t a (D W _ F O R M _ f l a g) . I f t he a g ha s va lue zer o, it indica t es t h e a bsence of t he a t t r ibu t e. I f t h e a g h a s a non-zer o va lu e, it in dica t es t he pr esence of t h e a t t r ibu t e. T her e a r e t wo t ypes of r efer ence. T he r st is a n offset r ela t ive t o t he r st b yt e of t he compila t ion u nit hea der for t he compila t ion unit cont a ining t he r efer ence. T he offset m u st r efer t o a n en t r y wit h in t ha t sa me compila t ion u n it . T her e a r e ve for ms for t h is t ype of r efer ence: one, t wo, four a nd eigh t byt e offset s ( r espect ively, D W _ F O R M _ r e f 1, D W _ F O R M _ r e f 2, D W _ F O R M _ r e f 4, a nd D W _ F O R M _ r e f 8) . T her e a r e is a lso a n u n signed va r ia ble len gt h offset encoded u sing L E B128 n u m ber s (D W _ F O R M _ r e f _ u d a t a) .

a g

r efer ence

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

73

--

--

DWARF D ebugging Information Format

_ ___________________________________________________________________ _ A_t r ib_______________________________Va_________la___________________ C _ sses _ _ t ___ u t e na me _ __ lue 0x01 r efer ence D W _ A T _ s i b l i n g 0x02 block, const a n t D W _ A T _ l o c a t i o n 0x03 st r in g D W _ A T _ n a m e D W _ A T _ o r d e r i n g 0x09 const a n t D W _ A T _ b y t e _ s i z e 0x0b const a n t D W _ A T _ b i t _ o f f s e t 0x0c const a n t 0x0d const a n t D W _ A T _ b i t _ s i z e 0x10 const a n t D W _ A T _ s t m t _ l i s t D W _ A T _ l o w _ p c 0x11 a ddr ess DW _ A T _ h i g h _ p c 0x12 a ddr ess DW _ AT _ l an g ua g e 0x13 const a n t 0x15 r efer ence DW _ AT _ d is c r 0x16 const a n t DW _ AT _ d is c r_ v a lu e 0x17 const a n t DW _ AT _ v is i bi l i ty DW _ AT _ i mp o rt 0x18 r efer ence DW_AT_string_length 0x19 block, const a n t DW_AT_common_reference 0x1a r efer ence 0x1b st r in g DW_AT_comp_dir 0x1c st r in g, const a n t , block DW_AT_const_value DW_AT_containing_type 0x1d r efer ence DW_AT_default_value 0x1e r efer ence DW_AT_inline 0x20 const a n t 0x21 a g DW_AT_is_optional 0x22 const a n t , r efer ence DW_AT_lower_bound 0x25 st r in g DW_AT_producer DW_AT_prototyped 0x27 a g DW_AT_return_addr 0x2a block, const a n t DW_AT_start_scope 0x2c const a n t 0x2e const a n t DW_AT_stride_size const _n t _ r ef ______ _D ___________________________________0__2__________a __, ___er ence ____ __W _ A T _ u p p e r _ b o u n d _x _f Figure 17. A t t r ibu t e encodin gs, pa r t 1 T he second t ype of r efer ence is t he a ddr ess of a n y debu ggin g infor ma t ion en t r y wit h in t he sa me execu t a ble or sha r ed object ; it ma y r efer t o a n ent r y in a d iffer en t compila t ion u n it f r om t he u n it cont a ining t he r efer ence. T h is t ype of r ef e r e n ce (D W _ F O R M _ r e f _ a d d r) is t h e size of a n a d dr ess on t he t a r ge t a r ch it ect u r e; it is r eloca t a ble in a r eloca t a ble object le a nd r eloca t ed in a n execu t a ble le or sha r ed object . T h e u se of com p il at ion u ni t rel at ive ref erences wil l red u ce t h e nu m ber of l ink - t im e rel ocat ions and so speed u p l ink ing. T h e u se of ad d ress- t y pe ref erences al l ows f or t h e com m oniz at ion of inf orm at ion, su ch as t y pes, across com p i lat ion u ni t s. st r in g A st r ing is a sequence of cont igu ous non- nu ll b yt es f ollowed by one nu ll b yt e. A st r ing ma y be r epr esen t ed im media t ely in t he debu gging infor ma t ion en t r y it self (D W _ F O R M _ s t r i n g) , or ma y be
D WARF S pecication, Version 2.0

Tool Interface Standards ( TIS)

74

--

--

DWARF D ebugging Information Format

_ _________________________________________________________________________ _ A_t r______n________________________________Va____________la________________ C _ sses _ _ t _ ibu t e _a me _ __ lue 0x31 r efer ence D W _ A T _ a b s t r a c t _ o r i g i n 0x32 const a n t D W _ A T _ a c c e s s i b i l i t y 0x33 const a n t D W _ A T _ a d d r e s s _ c l a s s D W _ A T _ a r t i f i c i a l 0x34 a g D W _ A T _ b a s e _ t y p e s 0x35 r efer ence D W _ A T _ c a l l i n g _ c o n v e n t i o n 0x36 const a n t 0x37 const a n t , r efer ence D W _ A T _ c o u n t 0x38 block, r efer ence D W _ A T _ d a t a _ m e m b e r _ l o c a t i o n D W _ A T _ d e c l _ c o l u m n 0x39 const a n t D W _ A T _ d e c l _ f i l e 0x3a const a n t DW _ A T _ d e c l _ l i n e 0x3b const a n t 0x3c a g DW _ AT _ d ec l ar a t io n 0x3d block DW _ AT _ d is c r_ l i st 0x3e const a n t DW _ AT _ e nc o di n g DW _ AT _ e xt e rn a l 0x3f a g DW _ AT _ f ra m e_ b a se 0x40 block, const a n t DW _ AT_fri e nd 0x41 r efer ence 0x42 const a n t DW_AT_identifier_case 0x43 const a n t DW_AT_macro_info DW_AT_namelist_item 0x44 block DW_AT_priority 0x45 r efer ence DW_AT_segment 0x46 block, const a n t 0x47 r efer ence DW_AT_specification 0x48 block, const a n t DW_AT_static_link 0x49 r efer ence DW_AT_type DW_AT_use_location 0x4a block, const a n t DW_AT_variable_parameter 0x4b a g DW_AT_virtuality 0x4c const a n t 0x4d block, r efer ence DW_AT_vtable_elem_location 0x2000 DW_AT_lo_user __W________________________________________0__3__f________________________ D_ _AT_hi_user x _f _f _ _ Figure 18. A t t r ibu t e encodin gs, pa r t 2 r epr esen t ed a s a 4-byt e offset in t o a st r ing t a ble cont a ined in t h e . d e b u g _ s t r sect ion of t he object le (D W _ F O R M _ s t r p) . T he f or m encodings a r e listed in F igu r e 1 9.

7.6 Variable Length D ata


T he specia l const a n t da t a for ms D W _ F O R M _ s d a t a a nd D W _ F O R M _ u d a t a a r e encoded using L it t le E n dia n Ba se 128 ( L E B128) nu mber s. L E B128 is a sch eme for encoding int eger s densely t ha t e xploit s t he a ssu m p t ion t h a t m ost in t eger s a r e sma ll in m a gn it ude. ( T h is encoding is equa lly su it a ble whet h er t he t a r ge t ma ch ine a r ch it ect ur e r epr esen t s da t a in big-endia n or lit t le-endia n or der . I t is lit t le endia n only in t he sense t ha t it a voids using spa ce t o r epr esen t t he big end of a n u n signed int eger , when t he big en d is a ll zer oes or sign ext en sion b it s) .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

75

--

--

DWARF D ebugging Information Format

_ ________________________________________________________ _ F or m ___m________________________e ____C_________________ Va lu _ _ _____ na _ e _ _ la ss 0x01 a ddr ess DW _ FO R M _a d dr 0x03 block DW _ FO R M _b l oc k 2 0x04 block DW _ FO R M _b l ock4 DW _ FO R M _d a ta2 0x05 const a n t DW_FORM_data4 0x06 const a n t DW_FORM_data8 0x07 const a n t 0x08 st r in g DW_FORM_string 0x09 block DW_FORM_block DW_FORM_block1 0x0a block DW_FORM_data1 0x0b const a n t DW_FORM_flag 0x0c a g 0x0d const a n t DW_FORM_sdata 0x0e st r in g DW_FORM_strp 0x0f const a n t DW_FORM_udata DW_FORM_ref_addr 0x10 r efer ence DW_FORM_ref1 0x11 r efer ence DW_FORM_ref2 0x12 r efer ence 0x13 r efer ence DW_FORM_ref4 0x14 r efer ence DW_FORM_ref8 0x15 r efer ence DW_FORM_ref_udata __W _ F O R M _ i n d i r e c t 0_1_ _D_____________________________x__6____( see_____ion _____) _ ___ sect ___ 7.5 .3 _ Figure 19. A t t r ibu t e f or m encodin gs D W _ F O R M _ u d a t a ( u n signed L E B128) nu mber s a r e encode d a s f ollows: st a r t a t t he low or der en d of a n u n signed in t eger a n d ch op it in t o 7- b it chu nk s. P la ce ea ch ch u n k in t o t he low or der 7 bit s of a byt e . T ypica lly, sever a l of t h e h igh or der byt es will be zer o; disca r d t hem . E m it t he r ema in ing byt es in a st r ea m , st a r t ing wit h t he low or der b yt e; set the h igh or der bit on ea ch b yt e except t he la st em it t ed byt e. T he high b it of zer o on t he la st byt e indica t es t o t he decoder t ha t it ha s encount er ed t he la st byt e. T he int eger zer o is a specia l ca se, c onsist ing of a single zer o b yt e. Figu re 20 gives som e ex am p l es of D W _ F O R M _ u d a t a nu m bers . T h e 0 x 8 0 in each case is t h e h igh ord er bit of t h e by t e, ind icat ing t h at an ad d it iona l by t e f ol l ows: _ _____________________________________ _ __ u m ber S _____ _yt _ _N__________F ____byt e ______econd_b__e _ _ir st ____ 2 2 127 127 128 0+0x80 1 129 1+0x80 1 130 2+0x80 1 12857 57+0x80 1_ 0 _ __________________________0__________ _ Figure 20. E xa mples of u n signed L E B128 encodin gs T he encoding for D W _ F O R M _ s d a t a ( signed , 2s complem ent L E B128) nu m ber s is simila r , except t h a t t he cr it er ion for disca r ding high or der b yt es is not whe t her t hey a r e zer o, bu t whe t her t hey con sist en t ir ely of sign ext en sion b it s. C onsider t he 32- bit in t eger - 2. T he t hr ee h igh level b yt es of t he nu mber a r e sign ext ension, t h u s L E B128 would r epr esen t it a s a single b yt e cont a in ing t he low or der 7 b it s, with t he high or der b it clea r ed
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

76

--

--

DWARF D ebugging Information Format

t o indica t e t he en d of t he byt e str ea m . N ote t ha t t her e is not h ing wit hin t h e L E B128 r epr esen t a t ion t h a t indica t es whet her a n encoded nu mber is signed or u nsigned . T h e decoder m u st kn ow wha t t ype of nu mber t o expec t . Figu re 21 gives som e ex am p l es of D W _ F O R M _ s d a t a nu m bers . A ppend ix 4 gives al gor it h m s f or encod ing and decod ing t h ese f orm s. _ ________________________________________ _ ____________F ____byt e _________econd_b__e _ S _____ _yt _ _N u m ber _ir st ____ 2 2 -2 0x7e 127+0x80 0 127 -127 1+0x80 0x7f 128 0+0x80 1 -128 0+0x80 0x7f 1+0x80 1 129 0x7f+0x80 0_ 7_ _ __1__9_______________________x__e_______ _ - _ 2 _ Figure 21. E xa mples of signed L E B128 encodings

7.7 Location D escriptions


7.7.1 Location Ex pressions A loca t ion expr ession is st or ed in a b lock of cont igu ou s b yt e s. T h e byt es for m a set of oper a t ions. E a ch loca t ion oper a t ion ha s a 1- byt e code t ha t ident ies t ha t oper a t ion. O per a t ions ca n be followed b y one or mor e byt es of a d dit iona l da t a . A ll oper a t ions in a loca t ion expr ession a r e conca t ena t ed fr om lef t t o r igh t . T he encodings f or t he oper a t ions in a loca t ion expr ession a r e descr ibed in F igur es 22 a nd 23 .

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

77

--

--

DWARF D ebugging Information Format

_______________________________________________________________________________________________ O ________ N o. of O _____ds N ot __ ___per a t ion ___________________C ode _____________per a n_________es _______________________________ _____ 0x03 1 const a n t a ddr ess ( size t a r ge t specic) D W _ O P _ a d d r 0x06 0 D W _ O P _ d e r e f 0x08 1 1- b yt e c onst a n t D W _ O P _ c o n s t 1 u D W _ O P _ c o n s t 1 s 0x09 1 1- b yt e c onst a n t D W _ O P _ c o n s t 2 u 0x0a 1 2- b yt e c onst a n t DW _ O P _ c o n s t 2 s 0x0b 1 2- b yt e c onst a n t 0x0c 1 4- b yt e c onst a n t DW _ OP _ c on s t4 u 0x0d 1 4- b yt e c onst a n t DW _ OP _ c on s t4 s DW _ OP _ c on s t8 u 0x0e 1 8- b yt e c onst a n t DW _ OP _ c on s t8 s 0x0f 1 8- b yt e c onst a n t DW _ OP _ c on s tu 0x10 1 U L E B128 const a n t 0x11 1 S L E B128 const a n t DW _ OP_con s ts 0x12 0 DW_OP_dup 0x13 0 DW_OP_drop DW_OP_over 0x14 0 DW_OP_pick 0x15 1 1- b yt e st a ck index DW_OP_swap 0x16 0 0x17 0 DW_OP_rot 0x18 0 DW_OP_xderef DW_OP_abs 0x19 0 DW_OP_and 0x1a 0 DW_OP_div 0x1b 0 0x1c 0 DW_OP_minus 0x1d 0 DW_OP_mod 0x1e 0 DW_OP_mul DW_OP_neg 0x1f 0 DW_OP_not 0x20 0 DW_OP_or 0x21 0 0x22 0 DW_OP_plus 0x23 1 U L E B128 a ddend DW_OP_plus_uconst DW_OP_shl 0x24 0 DW_OP_shr 0x25 0 DW_OP_shra 0 ______________________________0__2_____________________________________________________________ _x_ 6 Figure 22. L oca t ion oper a t ion encodin gs, pa r t 1

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

78

--

--

DWARF D ebugging Information Format

________________________________________________________________________________________________________ ______ ion N __ of ____ a __s N ot __ _O per a t_______________________C__________o. ___O per__nd________es ________________________________________ _ ode 0x27 0 D W _ O P _ x o r 0x2f 1 signed 2- byt e const a n t D W _ O P _ s k i p 0x28 1 signed 2- byt e const a n t D W _ O P _ b r a D W _ O P _ e q 0x29 0 D W _ O P _ g e 0x2a 0 DW _ O P _ g t 0x2b 0 0x2c 0 DW _ O P _ l e 0x2d 0 DW _ OP _ l t DW _ OP _ n e 0x2e 0 DW _ OP _ l it 0 0x30 0 lit er a ls 0..31 = ( D W_O P_L I T 0 er a l) lit DW _ OP _ l it 1 0x31 0 .. . 0x4f 0 DW _ OP _ l it 3 1 0x50 0 r eg 0..31 = ( D W_O P_R E G 0 egn um ) r DW _ OP _ r eg 0 DW _ OP _ r eg1 0x51 0 ... DW _ OP _ r eg 3 1 0x6f 0 0x70 1 S L E B128 offset DW_OP_breg0 0x71 1 ba se r eg 0 ..31 = ( D W_O P_BR E G 0 egn um ) r DW_OP_breg1 ... DW_OP_breg31 0x8f 1 DW_OP_regx 0x90 1 U L E B128 r e gist er 0x91 1 S L E B128 offset DW_OP_fbreg 0x92 2 U L E B128 r e gist er f ollowed by S L E B128 offset DW_OP_bregx 0x93 1 U L E B128 size of piece a ddr essed DW_OP_piece DW_OP_deref_size 0x94 1 1- b yt e size of da t a r et r ieved DW_OP_xderef_size 0x95 1 1- b yt e size of da t a r et r ieved DW_OP_nop 0x96 0 0xe0 DW_OP_lo_user _D_____P__h_____s__r__________0__f______________________________________________________________________ _ W_ O_ __ i_ u_ e_ _ x _f Figure 23. L oca t ion oper a t ion encodin gs, pa r t 2 7.7.2 Location Lists E a ch en t r y in a loca t ion list c onsist s of t wo r ela t ive a ddr esses followed b y a 2- b yt e lengt h , followed b y a block of cont igu ous b yt es. T he lengt h species t he n u m ber of b yt es in t he block t ha t f ollows. T he t wo a ddr esses a r e t he sa me size a s u sed by D W _ F O R M _ a d d r on t he t a r ge t m a ch in e.

7.8 Base Type Encodings


T he va lues of t he const a nt s u sed in t he D W _ A T _ e n c o d i n g a t t r ib u t e a r e given in F igu r e 24.

7.9 Acces sibility Codes


T he encodings of t he const a n t s u sed in t he D W _ A T _ a c c e s s i b i l i t y a t t r ib u t e a r e given in F igur e 25.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

79

--

--

DWARF D ebugging Information Format

_ ________________________________________ _ Ba___t___e ____________m___________Va_____ _ __se yp _ encoding na _ e _ __ lue 0x1 DW_ATE_address 0x2 DW_ATE_boolean 0x3 DW_ATE_complex_float DW_ATE_float 0x4 DW_ATE_signed 0x5 DW_ATE_signed_char 0x6 0x7 DW_ATE_unsigned 0x8 DW_ATE_unsigned_char DW_ATE_lo_user 0x80 __________________________________0__f___ DW_ATE_hi_user _ _x _f Figure 24. Ba se t ype encoding va lues _ ______________________________________ _ __ ccess____ y code na me Va lu _ _A_____ib ilit__________________________e _ 1 DW_ACCESS_public 2 DW_ACCESS_protected 3 __W _ A C C E S S _ p r i v a t e _D _____________________________________ Figure 25. Accessib ilit y encodin gs

7.10 Visibility Codes


T he encodings of t he const a n t s u sed in t he D W _ A T _ v i s i b i l i t y a t t r ib u t e a r e given in F igu r e 26. ___________________________________ Visib __ y code na me Va lu _ ______ilit_________________________e _ DW_VIS_local 1 2 DW_VIS_exported 3 DW_VIS_qualified ___________________________________ Figure 26. Visib ilit y encodings

7.11 Virtuality Codes


T he encodings of t he const a n t s u sed in t he D W _ A T _ v i r t u a l i t y a t t r ib u t e a r e given in F igu r e 27. __________________________________________________ Vir t _a lit y _ode _a m _ Va lu _ _____u_____c____n___e ___________________________e _ DW_VIRTUALITY_none 0 1 DW_VIRTUALITY_virtual 2 DW_VIRTUALITY_pure_virtual __________________________________________________ Figure 27. Vir t u a lit y encodings

7.12 Source Languages


T he encodings for sour ce la n gua ge s a r e given in F igu r e 28. N a mes ma r ked with a n d t heir a ssocia t ed va lues a r e r eser ved , bu t t he la n gua ge s t hey r epr esen t a r e not suppor t ed in DW A R F Ver sion 2.

7.13 Address Class Encodings


T he va lue of t he com m on a ddr ess cla ss encodin g D W _ A D D R _ n o n e is 0.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

80

--

--

DWARF D ebugging Information Format

___________________________________________ L a n __a ge na m e _____gu__________________________Va lu______ ____ e 0x0001 DW_LANG_C89 0x0002 DW_LANG_C 0x0003 DW_LANG_Ada83 DW_LANG_C_plus_plus 0x0004 DW_LANG_Cobol74 0x0005 DW_LANG_Cobol85 0x0006 0x0007 DW_LANG_Fortran77 0x0008 DW_LANG_Fortran90 DW_LANG_Pascal83 0x0009 DW_LANG_Modula2 0x000a DW_LANG_lo_user 0x8000 _________________________________0__f__f___ DW_LANG_hi_user _x_f _f Figure 28. L a n gua ge encodings

7.14 Identier Case


T he encodings of t he const a n t s u sed in t he D W _ A T _ i d e n t i f i e r _ c a s e a t t r ib u t e a r e given in F igur e 29. ____________________________________________ I _en t ier C a se _ a _ e Va lu _ __d_____________N__m______________________e _ DW_ID_case_sensitive 0 1 DW_ID_up_case 2 DW_ID_down_case ___________________________________________ DW_ID_case_insensitive 3 _ Figure 29. I den t ier ca se encodin gs

7.15 Calling Convention Encodings


T he encodings for t he va lues of t he D W _ A T _ c a l l i n g _ c o n v e n t i o n a t t r ib u t e a r e given in F igur e 30. ____________________________________ _ a lling C onven t io_ _ ____ __ lue _C________________n_N_a me ___Va_____ 0x1 DW_CC_normal 0x2 DW_CC_program DW_CC_nocall 0x3 DW_CC_lo_user 0x40 D_____C__h_____s__r_________0__f___ __ W _ C _ _ _ i _ u _ e _ _x_f Figure 30. C a lling conven t ion encodin gs

7.16 Inline Codes


T he encodings of t he const a n t s u sed in t he D W _ A T _ i n l i n e a t t r ib u t e a r e given in F igur e 31.

7.17 Array Ordering


T he encodings for t he va lues of t he or der a t t r ibu t es of a r r a ys is given in F igur e 32 .

7.18 Discriminant Lists


T he descr ipt or s u sed in t he D W _ A T _ d i c s r _ l i s t a t t r ib u t e a r e encoded a s 1- byt e const a n t s. T he dened va lues a r e pr esen t ed in F igur e 33 .
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

81

--

--

DWARF D ebugging Information Format

_ __________________________________________________ _ _______C_________________________________________e _ Va lu _ _I n lin e _ ode N a m e 0 DW_INL_not_inlined 1 DW_INL_inlined 2 DW_INL_declared_not_inlined __W _ I N L _ d e c l a r e d _ i n l i n e d 3 _D _________________________________________________ Figure 31. I nline encodings ___________________________________ O _____ g na me Va lu _ ___r der in_________________________e _ 0 DW_ORD_row_major 1 ___________________________________ DW_ORD_col_major Figure 32. O r der ing encodings _____________________________ D ___ ipt __ N a m e Va lu _ ___escr___or ________________e _ 0 DW_DSC_label 1 _____________________________ DW_DSC_range Figure 33. Discr imina nt descr ipt or encodin gs

7.19 N ame Lookup Table


E a ch set of ent r ies in t he t a ble of globa l na mes cont a ined in t he . d e b u g _ p u b n a m e s sect ion begins with a hea der consist ing of: a 4- b yt e lengt h cont a in ing t h e len gt h of t h e set of en t r ies for t h is com pila t ion u n it , not inc lu d in g t h e len gt h eld it self ; a 2- b yt e ver sion iden t ier cont a in ing t h e va lu e 2 for D W A R F Ver sion 2; a 4- byt e offset in t o t he . d e b u g _ i n f o sect ion; a n d a 4- b yt e lengt h cont a in ing t h e size in byt es of t h e cont en t s of t he . d e b u g _ i n f o sect ion gener a t ed t o r epr esen t t h is compila t ion unit . T h is hea der is f ollowed by a ser ies of t u ples. E a ch t u ple consist s of a 4- b yt e offset f ollowed by a str ing of non-nu ll byt es t er m ina t ed by one nu ll b yt e. E a ch set is t er mina t ed by a 4- byt e wor d cont a ining t he va lue 0.

7.20 Address Range Table


E a ch set of ent r ies in t he t a ble of a ddr ess r a nges cont a ined in t he . d e b u g _ a r a n g e s sect ion begins with a hea der consist ing of: a 4- b yt e lengt h cont a in ing t h e len gt h of t h e set of en t r ies for t h is com pila t ion u n it , not inc lu d in g t h e len gt h eld it self ; a 2- b yt e ver sion iden t ier cont a in ing t h e va lu e 2 for D W A R F Ver sion 2; a 4- byt e offset in t o t he . d e b u g _ i n f o sect ion; a 1-b yt e u n signed in t eger c ont a ining t he size in byt es of a n a ddr ess ( or t he offset por t ion of a n a ddr ess for segm en t ed a d dr essing) on t he t a r ge t syst em ; a nd a 1- byt e u n signed int eger cont a ining t he size in b yt es of a segmen t descr ip t or on t he t a r ge t system . T h is hea der is f ollowed by a ser ies of t u ple s. E a ch t u ple consist s of a n a ddr ess a n d a len gt h , ea ch in t he size a ppr opr ia t e for a n a ddr ess on t he t a r get a r ch it ect ur e. T he r st t u ple f ollowing t he hea der in ea ch set begins a t a n offset t h a t is a mu lt iple of t h e size of a single t u ple ( t h a t is, t wice t h e size of a n a ddr ess) . T he hea der is pa dded , if necessa r y, t o t he a ppr opr ia t e boun da r y. E a ch set of t u ples is t er m ina t ed by a 0 f or t he a ddr ess a n d 0 for t he len gt h .

7.21 Line N umber Information


T he sizes of t he in t eger s used in t he line nu mber a nd ca ll fr a m e informa t ion sec t ions a r e a s follows:

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

82

--

--

DWARF D ebugging Information Format

sbyt e ubyt e uha lf swor d uwor d

S ign ed 1- b yt e va lue. U n signed 1- byt e va lue . U n signed 2-byt e va lue. S ign ed 4- b yt e va lue. U n signed 4- byt e va lu e.

T he ver sion nu m ber in t he st a t emen t pr ogr a m pr ologue is 2 f or D W A R F Ver sion 2. T he boolea n va lues t r u e a nd fa lse used by t he sta t emen t infor m a t ion pr ogr a m a re encoded a s a single b yt e cont a in ing t he va lue 0 for fa lse, a nd a non- zer o va lue f or t r ue. T h e encodings for t he pr e-dened st a nda r d opcodes a r e given in F igu r e 34. _ ____________________________________________ _ O_________________________________________e _ Va lu _ _ _ pcode N a me _ 1 DW_LNS_copy 2 DW_LNS_advance_pc 3 DW_LNS_advance_line DW_LNS_set_file 4 DW_LNS_set_column 5 DW_LNS_negate_stmt 6 7 DW_LNS_set_basic_block 8 DW_LNS_const_add_pc __W _ L N S _ f i x e d _ a d v a n c e _ p c 9 _D ___________________________________________ Figure 34. S t a n da r d O pcode E ncodings T he encodings for t he pr e-dened ext ended opcodes a r e given in F igu r e 35 . _ ______________________________________ _ _____________________________________e _ Va lu _ _O pcode N a me DW_LNE_end_sequence 1 2 DW_LNE_set_address 3 __W _ L N E _ d e f i n e _ f i l e _D _____________________________________ Figure 35. E xt ended O pcode E ncodin gs

7.22 Macro Information


T he sour ce line n u m ber s a nd sour ce le in dices encoded in t he ma cr o infor ma t ion sect ion a r e r epr esen t ed a s u n signed L E B128 nu mber s a s a r e t he const a n t s in a n D W _ M A C I N F O _ v e n d o r _ e x t ent r y. T he ma cinfo t ype is encoded a s a single b yt e. T he encodings a r e given in F igur e 36. _ _________________________________________ _ ___a cinf____ype __________________________e _ Va lu _ _M ____ o T ___ N a me 1 DW_MACINFO_define 2 DW_MACINFO_undef 3 DW_MACINFO_start_file DW_MACINFO_end_file 4 _____________________________________5____ DW_MACINFO_vendor_ext 2 _5 _ Figure 36. M a cinfo T ype E ncodings

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

83

--

--

DWARF D ebugging Information Format

7.23 Call Frame Information


T he va lue of t he C I E id in t he C I E hea der is 0 x f f f f f f f f. T he init ia l va lue of t he C I E ver sion nu m ber is 1. C a ll fr a me inst r u ct ions a r e encoded in one or m or e byt es. T h e pr ima r y opcode is encoded in t he high or der t wo b it s of t he r st b yt e ( t h a t is, opcode = byt e > > 6) . A n oper a nd or ext en ded opcode ma y be encoded in t he low or der 6 b it s. A d dit iona l oper a nds a r e encoded in subsequ en t byt es. T h e inst r uct ions a nd t heir encodings a r e pr esent ed in F igur e 37. _ ________________________________________________________________________________________________ _ I n st r uct ion H igh L ow O per a n d 1 O per a n d 2 2 Bit s 6 Bit s _ ________________________________________________________________________________________________ _ 0x1 delt a DW _ CF A _ ad v an c e _l o c 0x2 r e gist er U L E B128 offset DW _ CF A _ of f se t DW _ CF A _ re s tore 0x3 r e gist er DW _ CFA_se t _loc 0 0x01 a ddr ess DW_CFA_advance_loc1 0 0x02 1-byt e delt a 0 0x03 2-byt e delt a DW_CFA_advance_loc2 0 0x04 4-byt e delt a DW_CFA_advance_loc4 DW_CFA_offset_extended 0 0x05 U L E B128 r egist er U L E B128 offset DW_CFA_restore_extended 0 0x06 U L E B128 r egist er DW_CFA_undefined 0 0x07 U L E B128 r egist er 0 0x08 U L E B128 r egist er DW_CFA_same_value 0 0x09 U L E B128 r egist er U L E B128 r e gist er DW_CFA_register 0 0x0a DW_CFA_remember_state DW_CFA_restore_state 0 0x0b DW_CFA_def_cfa 0 0x0c U L E B128 r egist er U L E B128 offset DW_CFA_def_cfa_register 0 0x0d U L E B128 r egist er 0 0x0e U L E B128 offset DW_CFA_def_cfa_offset 0 0 DW_CFA_nop DW_CFA_lo_user 0 0x1c D_____F_____i__u__e_____________________________x__f____________________________________________ W _C _A _h __ _s _r 0 0_ 3_ __ _ Figure 37. C a ll fr a me inst r u ct ion encodings

7.24 Dependencies
T he deb u ggin g in for m a t ion in t h is f or ma t is in t en ded t o e xist in t h e . d e b u g _ a b b r e v, . d e b u g _ a r a n g e s, . d e b u g _ f r a m e, . d e b u g _ i n f o, . d e b u g _ l i n e, . d e b u g _ l o c, . d e b u g _ m a c i n f o, . d e b u g _ p u b n a m e s a nd . d e b u g _ s t r sect ions of a n object le. T he infor ma t ion is not wor d-a lign ed , so t he a ssembler m u st pr ovide a wa y for t he compiler t o pr oduce 2- byt e a nd 4-byt e qu a n t it ies wit h ou t a lign ment r est r ict ions, a nd t he linker m u st be a ble t o r eloca t e a 4- byt e r efer ence a t a n a r b it r a r y a lign men t . I n t a r get a r ch it ect ur es wit h 64-b it a ddr esses, t h e a ssembler a nd linker m u st simila r ly h a ndle 8- byt e r efer ences a t a r b it r a r y a lignmen t s.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

84

--

--

DWARF D ebugging Information Format

8. FU TU RE D IRECTION S
T he U N I X I n t er na t iona l P r ogr a m ming L a n gua ges SI G is wor king on a specica t ion for a set of int er fa ces f or r ea d ing D W A R F infor m a t ion, t h a t will hide cha nges in t h e r epr esen t a t ion of t ha t infor m a t ion fr om it s consumer s. I t is hoped t ha t u sing t hese int er fa ces will m a ke t h e t r a n sit ion f r om D W A R F Ver sion 1 t o Ver sion 2 m u c h sim pler a n d will ma ke it ea sier for a single consumer t o suppor t object s u sing e it her Ver sion 1 or Ver sion 2 D W A R F . A dr a ft of t h is specica t ion is a va ila ble for r eview fr om U N I X I n t er na t iona l. T h e P r ogr a m m ing L a ngu a ges SI G wishes t o str ess, however , t ha t t he specica t ion is st ill in ux.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

85

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

86

--

--

DWARF D ebugging Information Format

Appendix 1 - - Current Attributes by Tag Value


T he list below en u mer a t es t h e a t t r ib u t es t ha t a r e most a pplica ble t o ea ch t ype of debu gging infor ma t ion en t r y. D W A R F does n ot in gener a l r equ ir e t ha t a given deb u ggin g infor ma t ion en t r y cont a in a pa r t icu la r a t t r ibu t e or set of a t t r ibu t e s. I n st ea d , a D W A R F pr oducer is fr ee t o gener a t e a n y, a ll, or none of t h e a t t r ibu t es descr ibed in t he t ext a s being a pplica ble t o a given en t r y. O t her a t t r ibu t es ( bot h t h ose dened with in t his document bu t not explic it ly a ssocia t ed wit h t he en t r y in qu est ion, a n d new, ven d or -dened ones) ma y a lso a ppea r in a given debu ggin g ent r y. T her ef or e, t he list ma y be t a ken a s in str uct ive, bu t ca n n ot be consider ed d en it ive. _ _________________________________________________________________________ _ TAG_N_______________________________________LI_____________R____________ AP P __CABLE ATT _ IBU TES _ ____ _ AME _ DECL D W _ T A G _ a c c e s s _ d e c l a r a t i o n DW_AT_accessibility DW_AT_name D __ _T _s _b _i _g _ __________________________________________W__A_____i__l__n_______________ _ D W _ T A G _ a r r a y _ t y p e DECL DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_ordering DW_AT_sibling DW_AT_start_scope DW_AT_stride_size DW_AT_type D __ _T _v _s _b _l _t _ _ __________________________________________W__A_____i__i__i__i__y_________ _ DW_AT_bit_offset DW _ T A G _ b a s e _ t y p e DW_AT_bit_size DW_AT_byte_size DW_AT_encoding DW_AT_name D __ _T _s _b _i _g _ __________________________________________W__A_____i__l__n_______________ _ DW_TAG_catch_block DW_AT_abstract_origin DW_AT_high_pc DW_AT_low_pc DW_AT_segment D __ _T _s _b _i _g _ __________________________________________W__A_____i__l__n_______________ _ D W _ A T _ d e c l _ c o l u m n, D W _ A T _ d e c l _ f i l e, D W _ A T _ d e c l _ l i n e.

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

87

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _________________________________________________________________________ TAG N AM _ ____________E__________________________AP P______BLE_ATT__IB__TES_____ ____ LICA ____ ____ R __U ____ DECL D W _ T A G _ c l a s s _ t y p e DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_start_scope _______________________________________D_____T__v__s__b__l__t____________ _W _A __ _i _i _i _i _y D W _ T A G _ c o m m o n _ b l o c k DECL DW_AT_declaration DW_AT_location DW_AT_name DW_AT_sibling ______________________________________D_____T__v__s__b__l__t____________ _ _W _A __ _i _i _i _i _y DECL D W _ T A G _ c o m m o n _ i n c l u s i o n DW_AT_common_reference DW_AT_declaration DW_AT_sibling D_____T__v__s__b__l__t____________ W _A __ _i _i _i _i _y ________________________________________ DW_AT_base_types DW _ TA G _ co m pi l e _u n i t DW_AT_comp_dir DW_AT_identifier_case DW_AT_high_pc DW_AT_language DW_AT_low_pc DW_AT_macro_info DW_AT_name DW_AT_producer DW_AT_sibling _______________________________________D_____T__s__m_____i__t____________ _W _A __ _t _t _l _s _ DW_AT_sibling DW_TAG_const_type ______________________________________D_____T__t__p_____________________ _ _W _A__ _y _e

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

88

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ ______________________________________________________________________ _ TAG_N____________________________________LI_____________R____________ AP P __CABLE ATT _ IBU TES _ ____ _ AME _ DECL D W _ T A G _ c o n s t a n t DW_AT_accessibility DW_AT_constant_value DW_AT_declaration DW_AT_external DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type _______________________________________W__A_____i__i__i__i__y_________ D __ _T _v _s _b _l _t _ _ _ DW_AT_address_class D W _ T A G _ e n t r y _ p o i n t DW_AT_low_pc DW_AT_name DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_static_link D__ _T _t _p _ _ _______________________________________W__A_____y__e__________________ _ D W _ T A G _ e n u m e r a t i o n _ t y p e DECL DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_start_scope D __ _T _v _s _b _l _t _ _ _______________________________________W__A_____i__i__i__i__y_________ _ DW _ TA G _ en u me r a to r DECL DW_AT_const_value DW_AT_name D __ _T _s _b _i _g _ _______________________________________W__A_____i__l__n_______________ _ DECL DW_TAG_file_type DW_AT_abstract_origin DW_AT_byte_size DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type _ D __ _T _v _s _b _l _t _ _ _______________________________________W__A_____i__i__i__i__y_________

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

89

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _____________________________________________________________________________________ TAG N AM _ ____________E________________________________AP P______BLE_ATT__IB__TES ___________ ____ LICA ____ ____ R __U ____ DECL D W _ T A G _ f o r m a l _ p a r a m e t e r DW_AT_abstract_origin DW_AT_artificial DW_AT_default_value DW_AT_is_optional DW_AT_location DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_type D_____T__v__r__a__l_____a__a__e__e______ W _A __ _a _i _b _e _p _r _m _t _r ______________________________________________ DECL D W _ T A G _ f r i e n d DW_AT_abstract_origin DW_AT_friend ____________________________________________D_____T__s__b__i__g_____________________ _ _W _A __ _i _l _n _ DECL D W _ T A G _ i m p o r t e d _ d e c l a r a t i o n DW_AT_accessibility DW_AT_import DW_AT_name DW_AT_sibling _____________________________________________D_____T__s__a__t__s__o__e_______________ _W _A __ _t _r __ _c _p _ DECL D W _ T A G _ i n h e r i t a n c e DW_AT_accessibility DW_AT_data_member_location DW_AT_sibling DW_AT_type _____________________________________________D_____T__v__r__u__l__t__________________ _W _A __ _i _t _a _i _y D W _ T A G _ i n l i n e d _ s u b r o u t i n e DECL DW_AT_abstract_origin DW_AT_high_pc DW_AT_low_pc DW_AT_segment DW_AT_sibling DW_AT_return_addr _____________________________________________D_____T__s__a__t__s__o__e_______________ _W _A __ _t _r __ _c _p _ DW_AT_abstract_origin DW_TAG_label DW_AT_low_pc DW_AT_name DW_AT_segment DW_AT_start_scope _____________________________________________D_____T__s__b__i__g_____________________ _W _A __ _i _l _n _
Tool Interface Standards ( TIS) D WARF S pecication, Version 2.0

90

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ _________________________________________________________________________ _ TAG_N___________________________AP P______BLE_ATT__IB__TES___________ _ ____ _ AME _ ____ LICA ____ ____ R __U ____ DW_AT_abstract_origin D W _ T A G _ l e x i c a l _ b l o c k DW_AT_high_pc DW_AT_low_pc DW_AT_name DW_AT_segment _ _________________________________D_____T__s__b__i__g_____________________ _ _W _A__ _i _l _n _ DECL D W _ T A G _ m e m b e r DW_AT_accessibility DW_AT_byte_size DW_AT_bit_offset DW_AT_bit_size DW_AT_data_member_location DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_type _ _________________________________D_____T__v__s__b__l__t__________________ _ _W _A __ _i _i _i _i _y D W _ T A G _ m o d u l e DECL DW_AT_accessibility DW_AT_declaration DW_AT_high_pc DW_AT_low_pc DW_AT_name DW_AT_priority DW_AT_segment DW_AT_sibling _ _________________________________D_____T__v__s__b__l__t__________________ _ _W _A __ _i _i _i _i _y D W _ T A G _ n a m e l i s t DECL DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_sibling _ _________________________________D_____T__v__s__b__l__t__________________ _ _W _A __ _i _i _i _i _y DW_TAG_namelist_item DECL DW_AT_namelist_item _ _________________________________D_____T__s__b__i__g_____________________ _ _W _A__ _i _l _n _ DW_TAG_packed_type DW_AT_sibling __________________________________D_____T__t__p___________________________ W _A __ _y _e _ _

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

91

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ _________________________________________________________________________ _ TAG_N_______________________________________LI_____________R____________ AP P __CABLE ATT _ IBU TES _ ____ _ AME _ DW_AT_address_class D W _ T A G _ p o i n t e r _ t y p e DW_AT_sibling D __ _T _t _p _ _ __________________________________________W__A_____y__e__________________ _ D W _ T A G _ p t r _ t o _ m e m b e r _ t y p e DECL DW_AT_abstract_origin DW_AT_address_class DW_AT_containing_type DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_type DW_AT_use_location D __ _T _v _s _b _l _t _ _ __________________________________________W__A_____i__i__i__i__y_________ _ D W _ T A G _ r e f e r e n c e _ t y p e DW_AT_address_class DW_AT_sibling D __ _T _t _p _ _ __________________________________________W__A_____y__e__________________ _ D W _ T A G _ s e t _ t y p e DECL DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_start_scope DW_AT_sibling DW_AT_type D __ _T _v _s _b _l _t _ _ __________________________________________W__A_____i__i__i__i__y_________ _ DW_TAG_string_type DECL DW_AT_accessibility DW_AT_abstract_origin DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_start_scope DW_AT_string_length D __ _T _v _s _b _l _t _ _ __________________________________________W__A_____i__i__i__i__y_________ _

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

92

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value ____________________________________________________________________________ TAG N AM _ ____________E_______________________AP P______BLE_ATT__IB__TES___________ ____ LICA ____ ____ R __U ____ DECL D W _ T A G _ s t r u c t u r e _ t y p e DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_start_scope ____________________________________D_____T__v__s__b__l__t__________________ _W _A __ _i_i _i _i _y D W _ T A G _ s u b p r o g r a m DECL DW_AT_abstract_origin DW_AT_accessibility DW_AT_address_class DW_AT_artificial DW_AT_calling_convention DW_AT_declaration DW_AT_external DW_AT_frame_base DW_AT_high_pc DW_AT_inline DW_AT_low_pc DW_AT_name DW_AT_prototyped DW_AT_return_addr DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_static_link DW_AT_type DW_AT_visibility DW_AT_virtuality ____________________________________D_____T__v__a__l_____l__m__l__c__t__o___ _W _A __ _t _b _e _e _e __ _o _a _i _n

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

93

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ ____________________________________________________________________________ _ ____ _ AME AP P __CABLE ATT _ IBU TES _TAG_N__________________________________________LI_____________R____________ _ DECL D W _ T A G _ s u b r a n g e _ t y p e DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_count DW_AT_declaration DW_AT_lower_bound DW_AT_name DW_AT_sibling DW_AT_type DW_AT_upper_bound D __ _T _v _s _b _l _t _ _ _____________________________________________W__A_____i__i__i__i__y_________ _ DECL D W _ T A G _ s u b r o u t i n e _ t y p e DW_AT_abstract_origin DW_AT_accessibility DW_AT_address_class DW_AT_declaration DW_AT_name DW_AT_prototyped DW_AT_sibling DW_AT_start_scope DW_AT_type D __ _T _v _s _b _l _t _ _ _____________________________________________W__A_____i__i__i__i__y_________ _ D W _ T A G _ t e m p l a t e _ t y p e _ p a r a m DECL DW_AT_name DW_AT_sibling D __ _T _t _p _ _ _____________________________________________W__A_____y__e__________________ _ D W _ T A G _ t e m p l a t e _ v a l u e _ p a r a m DECL DW_AT_name DW_AT_const_value DW_AT_sibling D __ _T _t _p _ _ _____________________________________________W__A_____y__e__________________ _ DW _ TA G _ th r ow n _ ty p e DECL DW_AT_sibling D __ _T _t _p _ _ _____________________________________________W__A_____y__e__________________ _ DW_AT_abstract_origin DW_TAG_try_block DW_AT_high_pc DW_AT_low_pc DW_AT_segment D __ _T _s _b _i _g _ _____________________________________________W__A_____i__l__n_______________ _

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

94

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ _______________________________________________________________________________ _ TAG_N_____________________________________________LI_____________R____________ AP P __CABLE ATT _ IBU TES _ ____ _ AME _ DECL D W _ T A G _ t y p e d e f DW_AT_abstract_origin DW_AT_accessibility DW_AT_declaration DW_AT_name DW_AT_sibling DW_AT_start_scope DW_AT_type D __ _T _v _s _b _l _t _ _ ________________________________________________W__A_____i__i__i__i__y_________ _ D W _ T A G _ u n i o n _ t y p e DECL DW_AT_abstract_origin DW_AT_accessibility DW_AT_byte_size DW_AT_declaration DW_AT_friends DW_AT_name DW_AT_sibling DW_AT_start_scope D __ _T _v _s _b _l _t _ _ ________________________________________________W__A_____i__i__i__i__y_________ _ D W _ T A G _ u n s p e c i f i e d _ p a r a m e t e r s DECL DW_AT_abstract_origin DW_AT_artificial D __ _T _s _b _i _g ________________________________________________W__A_____i__l__n_______________ _ _ DW_TAG_variable DECL DW_AT_accessibility DW_AT_constant_value DW_AT_declaration DW_AT_external DW_AT_location DW_AT_name DW_AT_segment DW_AT_sibling DW_AT_specification DW_AT_start_scope DW_AT_type D __ _T _v _s _b _l _t _ _ ________________________________________________W__A_____i__i__i__i__y_________ _

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

95

--

--

DWARF D ebugging Information Format

Appendix 1 ( c ontd) - - Current Attributes by Tag Value _ ___________________________________________________________________ _ TAG_N_________________________________LI_____________R____________ AP P __CABLE ATT _ IBU TES _ ____ _ AME _ DECL D W _ T A G _ v a r i a n t DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_discr_list DW_AT_discr_value D __ _T _s _b _i _g _ ____________________________________W__A_____i__l__n_______________ _ D W _ T A G _ v a r i a n t _ p a r t DECL DW_AT_accessibility DW_AT_abstract_origin DW_AT_declaration DW_AT_discr DW_AT_sibling D __ _T _t _p _ _ ____________________________________W__A_____y__e__________________ _ DW _ TA G _ vo l at i l e_ t y pe DW_AT_sibling D __ _T _t _p _ _ ____________________________________W__A_____y__e__________________ _ DW_TAG_with_statement DW_AT_accessibility DW_AT_address_class DW_AT_declaration DW_AT_high_pc DW_AT_location DW_AT_low_pc DW_AT_segment DW_AT_sibling DW_AT_type D __ _T _v _s _b _l _t _ _ ____________________________________W__A_____i__i__i__i__y_________ _

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

96

--

--

DWARF D ebugging Information Format

Appendix 2 - - Organization of Debugging Information


T he f ollowing d ia gr a m depict s t he r ela t ionsh ip of t he a bbr evia t ion t a b les cont a ined in t he . d e b u g _ a b b r e v sect ion t o t he infor m a t ion cont a ined in t h e . d e b u g _ i n f o sect ion. Va lu es a r e given in sym bolic for m , wher e possible .
C ompila t ion U n it 1 - .d eb ug_info
lengt h 2 a1 ( abbrevi at ion t abl e off set ) 4 1 "myfile.c" "Best Compiler Corp: Version 1 .3" "mymachine:/home/mydir/src:" DW_LANG_C89 0x0 0x55 DW_FORM_data4 0x0 e1: 2 "char" DW_ATE_unsigned_char 1 e2: 3 e1 4 "POINTER" e2 0

A bbr evia t ion T a b le - .d eb ug_a bbr ev


a1: 1 DW_TAG_compile_unit DW_CHILDREN_yes DW_AT_name DW_AT_producer DW_AT_compdir DW_AT_language DW_AT_low_poc DW_AT_high_pc DW_AT_stmt_list 0 2 DW_TAG_base_type DW_CHILDREN_no DW_AT_name DW_AT_encoding DW_AT_byte_size 0

DW_FORM_string DW_FORM_string DW_FORM_string DW_FORM_data1 DW_FORM_addr DW_FORM_addr DW_FORM_indirect 0

DW_FORM_string DW_FORM_data1 DW_FORM_data1 0

3 DW_TAG_pointer_type DW_CHILDREN_no DW_AT_type DW_FORM_ref4 0 0 4 DW_TAG_typedef DW_CHILDREN_no DW_AT_name DW_AT_type 0 0

C ompila t ion U n it 2 - .d eb ug_info


lengt h 2 a1 ( abbrevi at ion t abl e off set ) 4 ... 4 "strp" e2 ...

DW_FORM_string DW_FORM_ref4 0

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

97

--

--

DWARF D ebugging Information Format

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

98

--

--

DWARF D ebugging Information Format

Appendix 3 - - S tatement P rogram Ex amples


C onsider t h is simple sour ce le a nd t he r esult in g ma chine code for t he I nt el 8086 pr ocessor :
1: 2: int main() 0x239: push pb 0x23a: mov bp,sp { printf("Omit needless words\n"); 0x23c: mov ax,0xaa 0x23f: push ax 0x240: call _printf 0x243: pop cx exit(0); 0x244: xor ax,ax 0x246: push ax 0x247: call _exit 0x24a: pop cx } 0x24b: pop bp 0x24c: ret 0x24d:

3: 4:

5:

6:

7:

I f t he sta t emen t pr ogr a m pr ologue species t he following:


minimum_instruction_length opcode_base line_base line_range 1 10 1 15

T hen one encoding of t he st a t em en t pr ogr a m would occu py 12 b yt es ( t h e opcode S P E C I A L (m, n) indica t es t h e specia l opcode gener a t ed for a line incr emen t of m a nd a n a d dr ess incr emen t of n) :
O________________________________per a n d_______________Byt e_S_r ea m __________ O ______ _ pcode _ ____ _t _____ DW_LNS_advance_pc LEB128(0x239) 0 x2, 0 xb9, 0x04 SPECIAL(2, 0) 0 xb SPECIAL(2, 3) 0 x38 SPECIAL(1, 8) 0 x82 SPECIAL(1, 7) 0 x73 DW_LNS_advance_pc LEB128(2) 0x2, 0 x2 DW_LNE_end_sequence 0x0, 0x1, 0x1

A n a lt er na t e encoding of t he sa me pr ogr a m u sing st a n da r d opcodes t o a dva nce t he progr a m count er would occu py 22 byt es:

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

99

--

--

DWARF D ebugging Information Format

Op___________________________________O______d ________________________ ___code _ per a n _ Byt e S t r ea m DW_LNS_fixed_advance_pc 0x239 0x9, 0x39, 0x2 SPECIAL(2, 0) 0 xb DW_LNS_fixed_advance_pc 0x3 0x9, 0 x3, 0 x0 SPECIAL(2, 0) 0 xb DW_LNS_fixed_advance_pc 0x8 0x9, 0 x8, 0 x0 SPECIAL(1, 0) 0 xa DW_LNS_fixed_advance_pc 0x7 0x9, 0 x7, 0 x0 SPECIAL(1, 0) 0 xa DW_LNS_fixed_advance_pc 0x2 0x9, 0 x2, 0 x0 DW_LNE_end_sequence 0x0, 0x1, 0x1

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

100

--

--

DWARF D ebugging Information Format

Appendix 4 - - Encoding and decoding variable length data


H er e a r e a lgor it h ms expr essed in a C - like pseu d o-code t o encode a nd decode signed a nd u n signed n u m ber s in L E B128: Enc ode an unsigned integer:
do { byte = low order 7 bits of v a lue; value >>= 7; if ( v alue != 0) / * more bytes to c ome */ set h igh o rder b it of byte; emit byte; } while (value ! = 0);

Enc ode a signed integer:


more = 1; negative = (value < 0 ); size = no. of bits in s igned integer; while(more) { byte = low order 7 bits of v a lue; value >>= 7; /* t h e following is u nnecessary if t h e implementation of >>= * uses an a rithmetic rather than logical s hift for a s igned * left operand */ if ( n egative) /* s i gn e x tend * / value |= - (1 << ( size - 7)); /* s i gn b i t of b y te is 2nd h i gh o r der b i t (0x40) * / if ( ( value == 0 & & sign bit o f byte is c l ear) || (value == -1 && s ign b it of b yte i s set)) more = 0; else set h igh o rder b it of byte; emit byte; }

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

101

--

--

DWARF D ebugging Information Format

Decode unsigned LEB128 number:


result = 0 ; shift = 0; while(true) { byte = next byte in i n put; result |= (low o rder 7 bits of b y te << s hift); if ( h igh o rder b it of byte = = 0) break; shift += 7 ; }

Decode signed LEB128 number:


result = 0 ; shift = 0; size = no. of bits in s igned integer; while(true) { byte = next byte in i n put; result |= (low o rder 7 bits of b y te << s hift); shift += 7 ; /* s i gn b i t of b y te is 2nd h i gh o r der b i t (0x40) * / if ( h igh o rder b it of byte = = 0) break; } if ( ( shift < size) && (sign bit o f byte is s e t)) /* s i gn e x tend * / result |= - (1 << shift);

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

102

--

--

DWARF D ebugging Information Format

Appendix 5 - - Call Frame Information Examples


T he f ollowing exa m ple u ses a h yp ot h et ica l R I SC ma ch ine in t he style of t he M ot or ola 88000.

M em or y is byt e a ddr essed . I n st r uct ions a r e a ll 4- b yt es ea ch a n d wor d a lign ed . I n st r uct ion oper a nds a r e t ypica lly of t he f or m : < dest ina t ion r eg> < sour ce r eg> < const a n t>

T he a ddr ess for t h e loa d a nd st or e in str uct ions is compu t ed b y a d d ing t h e cont en t s of t he sour ce r egist er wit h t he const a n t . T her e a r e 8 4- byt e r e gist er s: R 0 a lwa ys 0 R 1 h olds r e t ur n a ddr ess on ca ll R 2- R 3 t em p r e gist er s ( not pr eser ved on ca ll) R 4- R 6 pr eser ved on ca ll R 7 st a ck point er .

T he sta ck gr ows in t he nega t ive dir ect ion.

T he f ollowing a r e t wo code fr a gm ent s fr om a su br out ine ca lled f o o t ha t u ses a fr a me point er ( in a d d it ion t o t he st a ck point er .) T he r st column va lues a r e byt e a ddr esses.
foo foo+4 foo+8 foo+12 foo+16 ;; s t art p rologue s ub R7, R7, < fsize> ; Allocate frame store R1, R7, ( <fsize>-4) ; Save the return address store R6, R7, ( <fsize>-8) ; Save R6 add R6, R 7, 0 ; R6 is n ow the Frame ptr store R4, R6, (<fsize>-12) ; S ave a preserve r eg. ;; T h is s u broutine d oes n o t change R5 ... ;; S t art e pilogue ( R 7 has b een r eturned to entry value) load R4, R6, ( <fsize>-12) ; Restore R4 load R6, R7, ( <fsize>-8) ; Restore R6 load R1, R7, ( <fsize>-4) ; Restore return address add R7, R 7, <fsize> ; Deallocate frame jump R

foo+64 foo+68 foo+72 foo+76 foo+80 foo+84

; R eturn

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

103

--

--

DWARF D ebugging Information Format

T he t a ble for t he f o o subr ou t ine is a s f ollows. I t is f ollowed by t he cor r espond ing fr a gmen t s fr om t he . d e b u g _ f r a m e sect ion.
Loc C FA foo [ R7]+0 foo+4 [R7]+fsize foo+8 [R7]+fsize foo+12 [R7]+fsize foo+16 [R6]+fsize foo+20 [R6]+fsize foo+64 [R6]+fsize foo+68 [R6]+fsize foo+72 [R7]+fsize foo+76 [R7]+fsize foo+80 [R7]+0 not es: 1. R 8 is t h e r et u r n a d d r ess 2. s = sa m e_va lu e r u le 3. u = u nden ed r u le 4. r N = r egist er ( N ) r u le 5. cN = offset ( N ) r u le R0 s s s s s s s s s s s R1 u u u u u u u u u u u R2 u u u u u u u u u u u R3 u u u u u u u u u u u R4 s s s s s c12 c12 s s s s R5 s s s s s s s s s s s R6 s s s c8 c8 c8 c8 c8 s s s R7 s s s s s s s s s s s R8 r1 r1 c4 c4 c4 c4 c4 c4 c4 r1 r1

C ommon I nfor m a t ion E n t r y ( C I E ) :


cie cie+4 cie+8 cie+9 cie+10 cie+11 cie+12 cie+13 cie+16 cie+18 cie+20 cie+22 cie+24 cie+26 cie+28 cie+30 cie+32 cie+35 cie+36 32 0xffffffff 1 0 4 4 8 DW_CFA_def_cfa (7, 0) DW_CFA_same_value (0) DW_CFA_undefined (1) DW_CFA_undefined (2) DW_CFA_undefined (3) DW_CFA_same_value (4) DW_CFA_same_value (5) DW_CFA_same_value (6) DW_CFA_same_value (7) DW_CFA_register ( 8, 1) DW_CFA_nop ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; length C IE_id v ersion a ugmentation code_alignment_factor data_alignment_factor R8 is t he return a ddr. CFA = [ R7]+0 R0 not modified (=0) R1 scratch R2 scratch R3 scratch R4 preserve R5 preserve R6 preserve R7 preserve R8 is in R1 padding

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

104

--

--

DWARF D ebugging Information Format

F r a m e D escr ipt ion E n t r y ( F D E ) :


fde fde+4 fde+8 fde+12 fde+16 fde+17 fde+19 fde+20 fde+22 fde+23 fde+25 fde+26 fde+28 fde+29 fde+31 fde+32 fde+33 fde+34 fde+35 fde+37 fde+38 fde+39 fde+40 fde+42 fde+43 fde+44 40 cie foo 84 DW_CFA_advance_loc(1) DW_CFA_def_cfa_offset(<fsize>/4) DW_CFA_advance_loc(1) DW_CFA_offset(8,1) DW_CFA_advance_loc(1) DW_CFA_offset(6,2) DW_CFA_advance_loc(1) DW_CFA_def_cfa_register(6) DW_CFA_advance_loc(1) DW_CFA_offset(4,3) DW_CFA_advance_loc(11) DW_CFA_restore(4) DW_CFA_advance_loc(1) DW_CFA_restore(6) DW_CFA_def_cfa_register(7) DW_CFA_advance_loc(1) DW_CFA_restore(8) DW_CFA_advance_loc(1) DW_CFA_def_cfa_offset(0) DW_CFA_nop DW_CFA_nop ; ; ; ; ; ; length CIE_ptr initial_location address_range instructions assuming < fsize> < 512

; padding ; padding

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

105

--

--

Tool Interface Standards ( TIS)

D WARF S pecication, Version 2.0

106

--

--

IN DEX

A
a bbr evia t ions t a b le 4, 66 67 A BI 10, 60 a cceler a t ed a ccess 49 a ccess decla r a t ions 41 a ccessibilit y 18, 41, 74 a ct iva t ions 5, 59 a ddr ess spa ce cont igu ous 23, 26 a t 19 mu lt iple 13 segm en t ed 5, 19, 26, 33, 50, 66 a ddr esses cla ss 19, 26, 38, 75 offset por t ion 19, 50, 66, 77 size of 50, 66, 77 a n onym ous t ypes 30 a n onym ous u n ions 33, 41 a r r a ys 5, 39 dim ensions 39 or der ing 39, 77 st r ide 39 a r t icia l en t r ies 19 a t t r ib u t es 3, 7, 67 a ddr esses 8, 67 blocks 8, 67 const a n t s 8, 68 a gs 8, 69 for m s 4, 7, 67 na m es 4, 7, 67 or der ing 9, 27 r efer ences 8, 69 st r in gs 9, 70 va lu es 4, 7, 66

inst r u ct ions 62, 78 r egist er r u les 61 st r u ct ur e 60 usa ge 64 ca llin g convent ions 26, 65, 76 ca t ch blocks 32 cla sses 33, 40 der ived 40 fr ien d s 41 incomplet e 40 vir t u a l ba se 41 common b locks 27, 35 compa t ib ilit y 3, 65 compila t ion u n it s 23, 28, 44, 66 hea d er 66 const a n t s 33 34

D
.debug 4 . d e b u g _ a b b r e v 66 67, 79 . d e b u g _ a r a n g e s 49, 77, 79 . d e b u g _ f r a m e 61, 79 . d e b u g _ i n f o 3 4, 7, 49 50, 66, 79 . d e b u g _ l i n e 4, 50, 79 . d e b u g _ l o c 17, 79 . d e b u g _ m a c i n f o 57, 79 . d e b u g _ p u b n a m e s 49, 77, 79 . d e b u g _ s t r 70, 79 deb u ggin g infor m a t ion en t r ies 3, 7, 9, 66 ch ild en t r ies 4, 9, 67 nu ll en t r ies 9, 66 67 siblin gs 4, 9, 67 decla r a t ions a ccessibilit y 18, 74 coor d ina t es 20, 28, 30, 44 den ing 20, 33, 40, 43 ext er na l 25, 33 impor t ed 35 non- d enin g 4, 20, 26, 33, 38, 40 scope 34, 37 t ypes of 4, 18 visibilit y 18, 75 discr imina n t s 44, 77 discr imina t ed u n ions 40, 44, 77

B
ba se t ypes 18, 24, 37, 65, 74 bit elds 42

C
C 3, 26, 33, 39 40, 45, 47, 57 C + + 3, 5, 18 19, 21, 28, 32 33,
57 40 41 , 43, 47 , 49,

ca ll fr a m e infor m a t ion 5, 59, 65, 78 C om m on I n for m a t ion E nt r y 61 F r a m e D escr ipt ion E n t r y 62

I N -1

--

--

E
ent r y point s 25 decla r a t ions owned by loca t ions 26 r et u r n t ypes 26 enu m er a t ions 5, 39, 45 er r or va lu es 65 except ions 5, 28, 32
27

r egist er na m e oper a t or s specia l oper a t ions 15 st a ck 11 12, 15 looku p by a d dr ess 49, 77 by na me 49, 77

10

M
ma cr o infor ma t ion 4, 24, 57, 78 ba se sour ce en t r ies 58 comma nd line opt ions 58 den e a n d u nd en e en t r ies 57 end le en t r ies 58 st a r t le en t r ies 58 ven d or ext ensions 58 ma in pr ogr a m s 26 mem ber s 30 bit elds 42 da t a 40 41 fu nct ions 25, 40, 43 loca t ions 11, 43 point er s t o 47 st a t ic da t a 33, 40, 49 M odu la 2 3, 18, 25, 32 modu les 25 den it ion 25 pr ior it y 25

F
le t ypes 48 a t a d dr ess spa ce 19 F or t r a n 3, 27, 35, 46 47 F O R T R A N 77 3 F or t r a n90 3, 34 35 fr ien d s 41

I
iden t ier s ca se 24, 76 na m es 21, 49 impor t s 35 inh er it a nce 40

L
la bels 31 la ngu a ges 3, 23, 75 L E B128 8, 51, 68, 70 lexica l b locks 31 line n u m ber infor ma t ion 4, 20, 23, 50, 77 den it ions 51, 77 ext en ded opcodes 52, 56, 78 gener a l r u les 59 pr ologue 52 specia l opcodes 52, 54 st a n d a r d opcodes 52, 55, 78 st a t e ma ch in e r eg ist er s 51 loca t ions a r it h met ic oper a t ions 13 cont r ol ow oper a t ions 14 descr ipt ions 4, 10, 19, 41, 72 exa m ples 15 16 expr essions 10, 41, 65, 72 list s 4, 10, 17, 74 lit er a l encodings 11 logica l oper a t ions 13 r egist er ba sed a ddr essing 12

N
na m elist s
35

O
opt im ized code
10 , 18, 33

P
pa r a met er s defa u lt va lu e 34 for m a l 27, 32 33, 45 opt iona l 34 unspecied 27, 32, 46 va r ia ble 34 P a sca l 3, 32, 40, 46, 48 point er s t o m em b er s 47 pr e-pr ocessor 4, 57

I N -2

--

--

R
r ecor ds
40

U
u n ions 33, 40, 42 a n onym ous 33, 41 incomplet e 40 user -den ed t ypes 18

S
scope 34, 37 segm en t ed a ddr ess spa ce 5, 19, 26, 33, 50, 66 set t ypes 46 sour ce colum n s 20, 51 les 20, 23, 51, 53, 56, 58, 78 lines 20, 51, 57 st r ing t a ble 70 st r ing t ypes 46 st r u ct ur es 33, 40 der ived 40 incomplet e 40 subr a nges 39, 46 subr out ines 19, 25 decla r a t ions owned by 27 fr a m e ba se 12, 27 inline 28, 76 inlin ed 29 loca t ions 26 mem ber s 25, 43 nest ed 27 ou t -of-lin e 30 pr ot ot ypes 26, 45 r et u r n a ddr esses 27 r et u r n t ypes 26, 45 t ypes 19, 45

V
va r ia ble len gt h da t a 4, 8, 68, 70 va r ia bles 33 va r ia nt s 40, 44, 77 ven d or ext ensions 4, 58, 60, 65 Ver sion 1 3 4, 10, 66 Ver sion 2 3, 10, 66, 78 vir t u a l fu nct ions 3, 19, 43 vir t u a lit y 19, 41, 43, 75 visibilit y 18, 75

W
wit h st a t em en t s
32

T
t a gs 4, 7, 65, 67 t em pla t es 5, 28, 43 t r y b locks 32 t ype modier s 18, 38 t yped efs 38 t ypes ba se 18, 24, 37, 65, 74 const a n t 18, 38 modier s 18, 38 pa ck ed 18, 38 point er 18 19, 38 r efer ence 18 19, 38 user -den ed 18 vola t ile 18, 38

I N -3

You might also like