1/*
2
3  Copyright (C) 2000-2010 Silicon Graphics, Inc.  All Rights Reserved.
4  Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
5  Portions Copyright 2008-2016 David Anderson. All rights reserved.
6  Portions Copyright 2008-2010 Arxan Technologies, Inc. All rights reserved.
7  Portions Copyright 2010-2012 SN Systems Ltd. All rights reserved.
8
9  This program is free software; you can redistribute it and/or modify it
10  under the terms of version 2.1 of the GNU Lesser General Public License
11  as published by the Free Software Foundation.
12
13  This program is distributed in the hope that it would be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17  Further, this software is distributed without any warranty that it is
18  free of the rightful claim of any third person regarding infringement
19  or the like.  Any license provided herein, whether implied or
20  otherwise, applies only to this software file.  Patent licenses, if
21  any, provided herein do not apply to combinations of this program with
22  other software, or any other product whatsoever.
23
24  You should have received a copy of the GNU Lesser General Public
25  License along with this program; if not, write the Free Software
26  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
27  USA.
28
29*/
30
31
32#ifndef _LIBDWARF_H
33#define _LIBDWARF_H
34#ifdef __cplusplus
35extern "C" {
36#endif
37/*
38    libdwarf.h
39    $Revision: #9 $ $Date: 2008/01/17 $
40
41    For libdwarf producers and consumers
42
43    The interface is defined as having 8-byte signed and unsigned
44    values so it can handle 64-or-32bit target on 64-or-32bit host.
45    Dwarf_Ptr is the native size: it represents pointers on
46    the host machine (not the target!).
47
48    This contains declarations for types and all producer
49    and consumer functions.
50
51    Function declarations are written on a single line each here
52    so one can use grep  to each declaration in its entirety.
53    The declarations are a little harder to read this way, but...
54
55    The seeming duplication of the Elf typedef allows
56    both verification we have the right struct name (when
57    libelf.h included before this) and
58    creation of a local handle so we have the struct pointer
59    here (if libelf.h is not included before this file).
60
61*/
62
63typedef struct Elf Elf;
64typedef struct Elf* dwarf_elf_handle;
65
66/* To enable printing with printf regardless of the
67   actual underlying data type, we define the DW_PR_xxx macros.
68   To ensure uses of DW_PR_DUx or DW_PR_DSx look the way you want
69   ensure the right DW_PR_XZEROS define is uncommented.
70*/
71/*#define DW_PR_XZEROS "" */
72#define DW_PR_XZEROS "08"
73#if (_MIPS_SZLONG == 64)
74/* Special case for MIPS, so -64 (LP64) build gets simple -long-.
75   Non-MIPS LP64 or ILP64 environments should probably ensure
76   _MIPS_SZLONG set to 64 everywhere this header is #included.
77*/
78typedef int             Dwarf_Bool;         /* boolean type */
79typedef unsigned long   Dwarf_Off;          /* 4 or 8 byte file offset */
80typedef unsigned long   Dwarf_Unsigned;     /* 4 or 8 byte unsigned value */
81typedef unsigned short  Dwarf_Half;         /* 2 byte unsigned value */
82typedef unsigned char   Dwarf_Small;        /* 1 byte unsigned value */
83typedef signed   long   Dwarf_Signed;       /* 4 or 8 byte signed value */
84typedef unsigned long   Dwarf_Addr;         /* target memory address */
85#define  DW_PR_DUx  "lx"
86#define  DW_PR_DSx  "lx"
87#define  DW_PR_DUu  "lu"
88#define  DW_PR_DSd  "ld"
89
90#else /* 32-bit */
91/* This is for ILP32, allowing i/o of 64bit dwarf info.
92   Also should be fine for LP64 and ILP64 cases.
93*/
94typedef int                 Dwarf_Bool;     /* boolean type */
95typedef unsigned long long  Dwarf_Off;      /* 8 byte file offset */
96typedef unsigned long long  Dwarf_Unsigned; /* 8 byte unsigned value*/
97typedef unsigned short      Dwarf_Half;     /* 2 byte unsigned value */
98typedef unsigned char       Dwarf_Small;    /* 1 byte unsigned value */
99typedef signed   long long  Dwarf_Signed;   /* 8 byte signed value */
100typedef unsigned long long  Dwarf_Addr;     /* target memory address */
101#define  DW_PR_DUx  "llx"
102#define  DW_PR_DSx  "llx"
103#define  DW_PR_DUu  "llu"
104#define  DW_PR_DSd  "lld"
105#endif
106#ifdef HAVE_NONSTANDARD_PRINTF_64_FORMAT
107/* Windows does not use std C formatting, so allow it. */
108#undef DW_PR_DUx
109#undef DW_PR_DSx
110#undef DW_PR_DUu
111#undef DW_PR_DSd
112#define  DW_PR_DUx  "I64x"
113#define  DW_PR_DSx  "I64x"
114#define  DW_PR_DUu  "I64u"
115#define  DW_PR_DSd  "I64d"
116#endif /* HAVE_NONSTANDARD_FORMAT */
117
118typedef void*        Dwarf_Ptr;          /* host machine pointer */
119
120/* Used for DW_FORM_ref_sig8 and DW_AT_dwo_id.
121   It is not a string, it
122   is 8 bytes of a signature one would use to find
123   a type unit. See dwarf_formsig8()
124
125   Sometimes it is used in calculations as
126   Dwarf_Unsigned, but that is hidden in libdwarf.
127*/
128struct Dwarf_Sig8_s  {
129    char signature[8];
130};
131typedef struct Dwarf_Sig8_s Dwarf_Sig8;
132
133/* Contains info on an uninterpreted block of data
134   Used with certain frame information functions.
135*/
136typedef struct {
137    Dwarf_Unsigned  bl_len;         /* length of block bl_data points at */
138    Dwarf_Ptr       bl_data;        /* uninterpreted data */
139
140    /*  0 if location description,
141        1 if .debug_info loclist,
142        2 if .debug_info.dwo split dwarf loclist. */
143    Dwarf_Small     bl_from_loclist;
144
145    /* Section (not CU) offset which 'data' comes from. */
146    Dwarf_Unsigned  bl_section_offset;
147} Dwarf_Block;
148
149
150/*  NEW October 2015.  */
151/*  Dwarf_Loc_c_s,Dwarf_Locdesc_c_s, and Dwarf_Loc_Head_c_s
152    are not defined publically. */
153struct Dwarf_Loc_c_s;
154typedef struct Dwarf_Loc_c_s * Dwarf_Loc_c;
155
156/*  NEW October 2015.  */
157/*  This provides access to Dwarf_Loc_c, a single location operator */
158struct Dwarf_Locdesc_c_s;
159typedef struct Dwarf_Locdesc_c_s * Dwarf_Locdesc_c;
160
161/*  NEW October 2015.  */
162/*  This provides access to Dwarf_Locdesc_c, a single
163    location list entry (or for a locexpr, the fake
164    Loc_Head for the locexpr) */
165struct Dwarf_Loc_Head_c_s;
166typedef struct Dwarf_Loc_Head_c_s * Dwarf_Loc_Head_c;
167
168/* NEW November 2015. For DWARF5 .debug_macro section */
169struct Dwarf_Macro_Context_s;
170typedef struct Dwarf_Macro_Context_s * Dwarf_Loc_Macro_Context;
171
172/*  NEW September 2016. Allows easy access to DW_AT_discr_list
173    array of discriminant values. Input in blockpointer
174    is a block with a list of uleb or sleb numbers
175    (all one or the other, lebunsignedflag instructs
176    how to read the leb values properly) */
177typedef struct Dwarf_Dsc_Head_s * Dwarf_Dsc_Head;
178
179/*  Location record. Records up to 2 operand values.
180    Not usable with DWARF5 or DWARF4 with location
181    operator  extensions. */
182typedef struct {
183    Dwarf_Small     lr_atom;        /* location operation */
184    Dwarf_Unsigned  lr_number;      /* operand */
185    Dwarf_Unsigned  lr_number2;     /* for OP_BREGx  and DW_OP_GNU_const_type*/
186    Dwarf_Unsigned  lr_offset;      /* offset in locexpr for OP_BRA etc */
187} Dwarf_Loc;
188
189
190/* Location description. DWARF 2,3,4.
191   When this is from a split-dwarf loclist (.debug_loc.dwo)
192   and no tied object is present
193   then ld_lowpc and ld_highpc are actually indices in
194   the .debug_addr section of the tied object).
195   If there is a tied object then these fields are actuall
196   addresses and DW_AT_addr_base in the skeleton CU DIE applies to
197   that .debug_addr.
198
199   Location record. Records up to 2 operand values.
200   Not usable with DWARF5 or DWARF4 with extensions.
201
202   If from DWARF2,3,4 non-split dwarf then things operate as
203   in DWARF2.
204   See dwarf_get_loclist_b() and the other related
205   new functions that
206   avoid using public structures Dwarf_Loc and Dwarf_Locdesc.
207*/
208typedef struct {
209    /*  Beginning of active range. This is actually an offset
210        of an applicable base address, not a pc value.  */
211    Dwarf_Addr      ld_lopc;
212
213    /*  End of active range. This is actually an offset
214        of an applicable base address, not a pc value.  */
215    Dwarf_Addr      ld_hipc;
216
217    Dwarf_Half      ld_cents;       /* count of location records */
218    Dwarf_Loc*      ld_s;           /* pointer to list of same */
219
220    /*  non-0 if loclist, 1 if non-split (dwarf 2,3,4) */
221    Dwarf_Small     ld_from_loclist;
222
223    Dwarf_Unsigned  ld_section_offset; /* Section (not CU) offset
224        where loc-expr begins*/
225} Dwarf_Locdesc;
226
227/*  First appears in DWARF3.
228    The dwr_addr1/addr2 data is either an offset (DW_RANGES_ENTRY)
229    or an address (dwr_addr2 in DW_RANGES_ADDRESS_SELECTION) or
230    both are zero (DW_RANGES_END).
231*/
232enum Dwarf_Ranges_Entry_Type { DW_RANGES_ENTRY,
233    DW_RANGES_ADDRESS_SELECTION,
234    DW_RANGES_END
235};
236typedef struct {
237    Dwarf_Addr dwr_addr1;
238    Dwarf_Addr dwr_addr2;
239    enum Dwarf_Ranges_Entry_Type  dwr_type;
240} Dwarf_Ranges;
241
242/* Frame description instructions expanded.
243*/
244typedef struct {
245    Dwarf_Small     fp_base_op;
246    Dwarf_Small     fp_extended_op;
247    Dwarf_Half      fp_register;
248
249    /*  Value may be signed, depends on op.
250        Any applicable data_alignment_factor has
251        not been applied, this is the  raw offset. */
252    Dwarf_Unsigned  fp_offset;
253    Dwarf_Off       fp_instr_offset;
254} Dwarf_Frame_Op; /* DWARF2 */
255
256typedef struct {
257    Dwarf_Small     fp_base_op;
258    Dwarf_Small     fp_extended_op;
259    Dwarf_Half      fp_register;
260
261    /*  Value may be signed, depends on op.
262        Any applicable data_alignment_factor has
263        not been applied, this is the  raw offset. */
264    Dwarf_Unsigned  fp_offset_or_block_len;
265    Dwarf_Small     *fp_expr_block;
266
267    Dwarf_Off       fp_instr_offset;
268} Dwarf_Frame_Op3;  /* DWARF3 and DWARF2 compatible */
269
270/*  ***IMPORTANT NOTE, TARGET DEPENDENCY ****
271    DW_REG_TABLE_SIZE must be at least as large as
272    the number of registers
273    (DW_FRAME_LAST_REG_NUM) as defined in dwarf.h
274    Preferably identical to DW_FRAME_LAST_REG_NUM.
275    Ensure [0-DW_REG_TABLE_SIZE] does not overlap
276    DW_FRAME_UNDEFINED_VAL or DW_FRAME_SAME_VAL.
277    Also ensure DW_FRAME_REG_INITIAL_VALUE is set to what
278    is appropriate to your cpu.
279    For various CPUs  DW_FRAME_UNDEFINED_VAL is correct
280    as the value for DW_FRAME_REG_INITIAL_VALUE.
281
282    For consumer apps, this can be set dynamically: see
283    dwarf_set_frame_rule_table_size(); */
284#ifndef DW_REG_TABLE_SIZE
285#define DW_REG_TABLE_SIZE  66
286#endif
287
288/* For MIPS, DW_FRAME_SAME_VAL is the correct default value
289   for a frame register value. For other CPUS another value
290   may be better, such as DW_FRAME_UNDEFINED_VAL.
291   See dwarf_set_frame_rule_table_size
292*/
293#ifndef DW_FRAME_REG_INITIAL_VALUE
294#define DW_FRAME_REG_INITIAL_VALUE DW_FRAME_SAME_VAL
295#endif
296
297/* Taken as meaning 'undefined value', this is not
298   a column or register number.
299   Only present at libdwarf runtime in the consumer
300   interfaces. Never on disk.
301   DW_FRAME_* Values present on disk are in dwarf.h
302   Ensure this is > DW_REG_TABLE_SIZE (the reg table
303   size is changeable at runtime with the *reg3() interfaces,
304   and this value must be greater than the reg table size).
305*/
306#define DW_FRAME_UNDEFINED_VAL          1034
307
308/* Taken as meaning 'same value' as caller had, not a column
309   or register number.
310   Only present at libdwarf runtime in the consumer
311   interfaces. Never on disk.
312   DW_FRAME_* Values present on disk are in dwarf.h
313   Ensure this is > DW_REG_TABLE_SIZE (the reg table
314   size is changeable at runtime with the *reg3() interfaces,
315   and this value must be greater than the reg table size).
316*/
317#define DW_FRAME_SAME_VAL               1035
318
319/* For DWARF3 consumer interfaces, make the CFA a column with no
320   real table number.  This is what should have been done
321   for the DWARF2 interfaces.  This actually works for
322   both DWARF2 and DWARF3, but see the libdwarf documentation
323   on Dwarf_Regtable3 and  dwarf_get_fde_info_for_reg3()
324   and  dwarf_get_fde_info_for_all_regs3()
325   Do NOT use this with the older dwarf_get_fde_info_for_reg()
326   or dwarf_get_fde_info_for_all_regs() consumer interfaces.
327   Must be higher than any register count for *any* ABI
328   (ensures maximum applicability with minimum effort).
329   Ensure this is > DW_REG_TABLE_SIZE (the reg table
330   size is changeable at runtime with the *reg3() interfaces,
331   and this value must be greater than the reg table size).
332   Only present at libdwarf runtime in the consumer
333   interfaces. Never on disk.
334*/
335#define DW_FRAME_CFA_COL3               1436
336
337/* The following are all needed to evaluate DWARF3 register rules.
338*/
339#define DW_EXPR_OFFSET 0  /* DWARF2 only sees this. */
340#define DW_EXPR_VAL_OFFSET 1
341#define DW_EXPR_EXPRESSION 2
342#define DW_EXPR_VAL_EXPRESSION 3
343
344typedef struct Dwarf_Regtable_Entry_s {
345    /*  For each index i (naming a hardware register with dwarf number
346        i) the following is true and defines the value of that register:
347
348        If dw_regnum is Register DW_FRAME_UNDEFINED_VAL
349            it is not DWARF register number but
350            a place holder indicating the register has no defined value.
351        If dw_regnum is Register DW_FRAME_SAME_VAL
352            it  is not DWARF register number but
353            a place holder indicating the register has the same
354            value in the previous frame.
355
356            DW_FRAME_UNDEFINED_VAL, DW_FRAME_SAME_VAL are
357            only present at libdwarf runtime. Never on disk.
358            DW_FRAME_* Values present on disk are in dwarf.h
359
360        Otherwise: the register number is a DWARF register number
361            (see ABI documents for how this translates to hardware/
362            software register numbers in the machine hardware)
363            and the following applies:
364
365            if dw_value_type == DW_EXPR_OFFSET (the only case for dwarf2):
366                If dw_offset_relevant is non-zero, then
367                    the value is stored at at the address CFA+N where
368                    N is a signed offset.
369                    Rule: Offset(N)
370                If dw_offset_relevant is zero, then the value of the register
371                    is the value of (DWARF) register number dw_regnum.
372                    Rule: register(F)
373            Other values of dw_value_type are an error.
374    */
375    Dwarf_Small         dw_offset_relevant;
376
377    /* For DWARF2, always 0 */
378    Dwarf_Small         dw_value_type;
379
380    Dwarf_Half          dw_regnum;
381
382    /*  The data type here should  the larger of Dwarf_Addr
383        and Dwarf_Unsigned and Dwarf_Signed. */
384    Dwarf_Addr          dw_offset;
385} Dwarf_Regtable_Entry;
386
387typedef struct Dwarf_Regtable_s {
388    struct Dwarf_Regtable_Entry_s rules[DW_REG_TABLE_SIZE];
389} Dwarf_Regtable;
390
391/* opaque type. Functional interface shown later. */
392struct Dwarf_Reg_value3_s;
393typedef struct Dwarf_Reg_value3_s Dwarf_Reg_Value3;
394
395typedef struct Dwarf_Regtable_Entry3_s {
396/*  For each index i (naming a hardware register with dwarf number
397    i) the following is true and defines the value of that register:
398
399        If dw_regnum is Register DW_FRAME_UNDEFINED_VAL
400            it is not DWARF register number but
401            a place holder indicating the register has no defined value.
402        If dw_regnum is Register DW_FRAME_SAME_VAL
403            it  is not DWARF register number but
404            a place holder indicating the register has the same
405            value in the previous frame.
406
407            DW_FRAME_UNDEFINED_VAL, DW_FRAME_SAME_VAL and
408            DW_FRAME_CFA_COL3 are only present at libdwarf runtime.
409            Never on disk.
410            DW_FRAME_* Values present on disk are in dwarf.h
411            Because DW_FRAME_SAME_VAL and DW_FRAME_UNDEFINED_VAL
412            and DW_FRAME_CFA_COL3 are definable at runtime
413            consider the names symbolic in this comment, not absolute.
414
415        Otherwise: the register number is a DWARF register number
416            (see ABI documents for how this translates to hardware/
417            software register numbers in the machine hardware)
418            and the following applies:
419
420        In a cfa-defining entry (rt3_cfa_rule) the regnum is the
421        CFA 'register number'. Which is some 'normal' register,
422        not DW_FRAME_CFA_COL3, nor DW_FRAME_SAME_VAL, nor
423        DW_FRAME_UNDEFINED_VAL.
424
425        If dw_value_type == DW_EXPR_OFFSET (the only  possible case for
426        dwarf2):
427            If dw_offset_relevant is non-zero, then
428                the value is stored at at the address
429                CFA+N where N is a signed offset.
430                dw_regnum is the cfa register rule which means
431                one ignores dw_regnum and uses the CFA appropriately.
432                So dw_offset_or_block_len is a signed value, really,
433                and must be printed/evaluated as such.
434                Rule: Offset(N)
435            If dw_offset_relevant is zero, then the value of the register
436                is the value of (DWARF) register number dw_regnum.
437                Rule: register(R)
438        If dw_value_type  == DW_EXPR_VAL_OFFSET
439            the  value of this register is CFA +N where N is a signed offset.
440            dw_regnum is the cfa register rule which means
441            one ignores dw_regnum and uses the CFA appropriately.
442            Rule: val_offset(N)
443        If dw_value_type  == DW_EXPR_EXPRESSION
444            The value of the register is the value at the address
445            computed by evaluating the DWARF expression E.
446            Rule: expression(E)
447            The expression E byte stream is pointed to by dw_block_ptr.
448            The expression length in bytes is given by
449            dw_offset_or_block_len.
450        If dw_value_type  == DW_EXPR_VAL_EXPRESSION
451            The value of the register is the value
452            computed by evaluating the DWARF expression E.
453            Rule: val_expression(E)
454            The expression E byte stream is pointed to by dw_block_ptr.
455            The expression length in bytes is given by
456            dw_offset_or_block_len.
457        Other values of dw_value_type are an error.
458*/
459    Dwarf_Small         dw_offset_relevant;
460    Dwarf_Small         dw_value_type;
461    Dwarf_Half          dw_regnum;
462    Dwarf_Unsigned      dw_offset_or_block_len;
463    Dwarf_Ptr           dw_block_ptr;
464
465}Dwarf_Regtable_Entry3;
466
467/*  For the DWARF3 version, moved the DW_FRAME_CFA_COL
468    out of the array and into its own struct.
469    Having it part of the array is not very easy to work
470    with from a portability point of view: changing
471    the number for every architecture is a pain (if one fails
472    to set it correctly a register rule gets clobbered when
473    setting CFA).  With MIPS it just happened to be easy to use
474    DW_FRAME_CFA_COL (it was wrong conceptually but it was easy...).
475
476    rt3_rules and rt3_reg_table_size must be filled in before
477    calling libdwarf.  Filled in with a pointer to an array
478    (pointer and array  set up by the calling application)
479    of rt3_reg_table_size Dwarf_Regtable_Entry3_s structs.
480    libdwarf does not allocate or deallocate space for the
481    rules, you must do so.   libdwarf will initialize the
482    contents rules array, you do not need to do so (though
483    if you choose to initialize the array somehow that is ok:
484    libdwarf will overwrite your initializations with its own).
485
486*/
487typedef struct Dwarf_Regtable3_s {
488    struct Dwarf_Regtable_Entry3_s   rt3_cfa_rule;
489
490    Dwarf_Half                       rt3_reg_table_size;
491    struct Dwarf_Regtable_Entry3_s * rt3_rules;
492} Dwarf_Regtable3;
493
494
495/*  Use for DW_EPXR_STANDARD., DW_EXPR_VAL_OFFSET.
496    Returns DW_DLV_OK if the value is available.
497    If DW_DLV_OK returns the regnum and offset thru the pointers
498    (which the consumer must use appropriately).
499*/
500int dwarf_frame_get_reg_register(struct Dwarf_Regtable_Entry3_s *reg_in,
501    Dwarf_Small *offset_relevant,
502    Dwarf_Half *regnum_out,
503    Dwarf_Signed *offset_out);
504
505/*  Use for DW_EXPR_EXPRESSION, DW_EXPR_VAL_EXPRESSION.
506    Returns DW_DLV_OK if the value is available.
507    The caller must pass in the address of a valid
508    Dwarf_Block (the caller need not initialize it).
509*/
510int dwarf_frame_get_reg_expression(struct Dwarf_Regtable_Entry3_s *reg_in,
511    Dwarf_Block *block_out);
512
513
514/*  For DW_DLC_SYMBOLIC_RELOCATIONS output to caller
515    v2, adding drd_length: some relocations are 4 and
516    some 8 bytes (pointers are 8, section offsets 4) in
517    some dwarf environments. (MIPS relocations are all one
518    size in any given ABI.) Changing drd_type to an unsigned char
519    to keep struct size down.
520*/
521enum Dwarf_Rel_Type {
522    dwarf_drt_none,        /* Should not get to caller */
523    dwarf_drt_data_reloc,  /* Simple normal relocation. */
524    dwarf_drt_segment_rel, /* Special reloc, exceptions. */
525    /* dwarf_drt_first_of_length_pair  and drt_second
526        are for for the  .word end - begin case. */
527    dwarf_drt_first_of_length_pair,
528    dwarf_drt_second_of_length_pair
529};
530
531typedef struct Dwarf_P_Marker_s * Dwarf_P_Marker;
532struct Dwarf_P_Marker_s {
533    Dwarf_Unsigned ma_marker;
534    Dwarf_Unsigned ma_offset;
535};
536
537typedef struct Dwarf_Relocation_Data_s  * Dwarf_Relocation_Data;
538struct Dwarf_Relocation_Data_s {
539    unsigned char drd_type;   /* Cast to/from Dwarf_Rel_Type
540        to keep size small in struct. */
541    unsigned char drd_length; /* Length in bytes of data being
542        relocated. 4 for 32bit data,
543        8 for 64bit data. */
544    Dwarf_Unsigned       drd_offset; /* Where the data to reloc is. */
545    Dwarf_Unsigned       drd_symbol_index;
546};
547
548typedef struct Dwarf_P_String_Attr_s  * Dwarf_P_String_Attr;
549struct Dwarf_P_String_Attr_s {
550    Dwarf_Unsigned        sa_offset;  /* Offset of string attribute data */
551    Dwarf_Unsigned        sa_nbytes;
552};
553
554
555/* Opaque types for Consumer Library. */
556typedef struct Dwarf_Debug_s*      Dwarf_Debug;
557typedef struct Dwarf_Die_s*        Dwarf_Die;
558typedef struct Dwarf_Line_s*       Dwarf_Line;
559typedef struct Dwarf_Global_s*     Dwarf_Global;
560typedef struct Dwarf_Func_s*       Dwarf_Func;
561typedef struct Dwarf_Type_s*       Dwarf_Type;
562typedef struct Dwarf_Var_s*        Dwarf_Var;
563typedef struct Dwarf_Weak_s*       Dwarf_Weak;
564typedef struct Dwarf_Error_s*      Dwarf_Error;
565typedef struct Dwarf_Attribute_s*  Dwarf_Attribute;
566typedef struct Dwarf_Abbrev_s*     Dwarf_Abbrev;
567typedef struct Dwarf_Fde_s*        Dwarf_Fde;
568typedef struct Dwarf_Cie_s*        Dwarf_Cie;
569typedef struct Dwarf_Arange_s*     Dwarf_Arange;
570typedef struct Dwarf_Gdbindex_s*   Dwarf_Gdbindex;
571struct Dwarf_Xu_Index_Header_s;
572typedef struct Dwarf_Xu_Index_Header_s* Dwarf_Xu_Index_Header;
573struct Dwarf_Line_Context_s;
574typedef struct Dwarf_Line_Context_s *Dwarf_Line_Context;
575struct Dwarf_Macro_Context_s;
576typedef struct Dwarf_Macro_Context_s *Dwarf_Macro_Context;
577
578
579/* Opaque types for Producer Library. */
580typedef struct Dwarf_P_Debug_s*       Dwarf_P_Debug;
581typedef struct Dwarf_P_Die_s*         Dwarf_P_Die;
582typedef struct Dwarf_P_Attribute_s*   Dwarf_P_Attribute;
583typedef struct Dwarf_P_Fde_s*         Dwarf_P_Fde;
584typedef struct Dwarf_P_Expr_s*        Dwarf_P_Expr;
585typedef Dwarf_Unsigned                Dwarf_Tag;
586
587
588/* error handler function
589*/
590typedef void  (*Dwarf_Handler)(Dwarf_Error /*error*/, Dwarf_Ptr /*errarg*/);
591
592
593/* Begin libdwarf Object File Interface declarations.
594
595As of February 2008 there are multiple dwarf_reader object access
596initialization methods available:
597The traditional dwarf_elf_init() and dwarf_init()  and dwarf_finish()
598    which assume libelf and POSIX file access.
599An object-file and library agnostic dwarf_object_init() and dwarf_object_finish()
600    which allow the coder to provide object access routines
601    abstracting away the elf interface.  So there is no dependence in the
602    reader code on the object format and no dependence on libelf.
603    See the code in dwarf_elf_access.c  and dwarf_original_elf_init.c
604    to see an example of initializing the structures mentioned below.
605
606Projects using dwarf_elf_init() or dwarf_init() can ignore
607the Dwarf_Obj_Access* structures entirely as all these details
608are completed for you.
609
610*/
611
612typedef struct Dwarf_Obj_Access_Interface_s   Dwarf_Obj_Access_Interface;
613typedef struct Dwarf_Obj_Access_Methods_s     Dwarf_Obj_Access_Methods;
614typedef struct Dwarf_Obj_Access_Section_s     Dwarf_Obj_Access_Section;
615
616
617/*  Used in the get_section interface function
618    in Dwarf_Obj_Access_Section_s.  Since libdwarf
619    depends on standard DWARF section names an object
620    format that has no such names (but has some
621    method of setting up 'sections equivalents')
622    must arrange to return standard DWARF section
623    names in the 'name' field.  libdwarf does
624    not free the strings in 'name'. */
625struct Dwarf_Obj_Access_Section_s {
626    /*  addr is the virtual address of the first byte of
627        the section data.  Usually zero when the address
628        makes no sense for a given section. */
629    Dwarf_Addr     addr;
630
631    /* Section type. */
632    Dwarf_Unsigned type;
633
634    /* Size in bytes of the section. */
635    Dwarf_Unsigned size;
636
637    /*  Having an accurate section name makes debugging of libdwarf easier.
638        and is essential to find the .debug_ sections.  */
639    const char*    name;
640    /*  Set link to zero if it is meaningless.  If non-zero
641        it should be a link to a rela section or from symtab
642        to strtab.  In Elf it is sh_link. */
643    Dwarf_Unsigned link;
644
645    /*  The section header index of the section to which the
646        relocation applies. In Elf it is sh_info. */
647    Dwarf_Unsigned info;
648
649    /*  Elf sections that are tables have a non-zero entrysize so
650        the count of entries can be calculated even without
651        the right structure definition. If your object format
652        does not have this data leave this zero. */
653    Dwarf_Unsigned entrysize;
654};
655
656/*  Returned by the get_endianness function in
657    Dwarf_Obj_Access_Methods_s. */
658typedef enum {
659    DW_OBJECT_MSB,
660    DW_OBJECT_LSB
661} Dwarf_Endianness;
662
663/*  The functions we need to access object data from libdwarf are declared here.
664
665    In these function pointer declarations
666    'void *obj' is intended to be a pointer (the object field in
667    Dwarf_Obj_Access_Interface_s)
668    that hides the library-specific and object-specific data that makes
669    it possible to handle multiple object formats and multiple libraries.
670    It's not required that one handles multiple such in a single libdwarf
671    archive/shared-library (but not ruled out either).
672    See  dwarf_elf_object_access_internals_t and dwarf_elf_access.c
673    for an example.
674
675*/
676struct Dwarf_Obj_Access_Methods_s {
677    /*
678        get_section_info
679
680        Get address, size, and name info about a section.
681
682        Parameters
683        section_index - Zero-based index.
684        return_section - Pointer to a structure in which section info
685            will be placed.   Caller must provide a valid pointer to a
686            structure area.  The structure's contents will be overwritten
687            by the call to get_section_info.
688        error - A pointer to an integer in which an error code may be stored.
689
690        Return
691        DW_DLV_OK - Everything ok.
692        DW_DLV_ERROR - Error occurred. Use 'error' to determine the
693            libdwarf defined error.
694        DW_DLV_NO_ENTRY - No such section.  */
695    int    (*get_section_info)(void* obj, Dwarf_Half section_index,
696        Dwarf_Obj_Access_Section* return_section, int* error);
697    /*
698        get_byte_order
699
700        Get whether the object file represented by this interface is big-endian
701        (DW_OBJECT_MSB) or little endian (DW_OBJECT_LSB).
702
703        Parameters
704        obj - Equivalent to 'this' in OO languages.
705
706        Return
707        Endianness of object. Cannot fail.  */
708    Dwarf_Endianness  (*get_byte_order)(void* obj);
709    /*
710        get_length_size
711
712        Get the size of a length field in the underlying object file.
713        libdwarf currently supports * 4 and 8 byte sizes, but may
714        support larger in the future.
715        Perhaps the return type should be an enumeration?
716
717        Parameters
718        obj - Equivalent to 'this' in OO languages.
719
720        Return
721        Size of length. Cannot fail.  */
722    Dwarf_Small   (*get_length_size)(void* obj);
723    /*
724        get_pointer_size
725
726        Get the size of a pointer field in the underlying object file.
727        libdwarf currently supports  4 and 8 byte sizes.
728        Perhaps the return type should be an enumeration?
729
730        Return
731        Size of pointer. Cannot fail.  */
732    Dwarf_Small   (*get_pointer_size)(void* obj);
733    /*
734        get_section_count
735
736        Get the number of sections in the object file.
737
738        Parameters
739
740        Return
741        Number of sections */
742    Dwarf_Unsigned  (*get_section_count)(void* obj);
743    /*
744        load_section
745
746        Get a pointer to an array of bytes that represent the section.
747
748        Parameters
749        section_index - Zero-based index.
750        return_data - The address of a pointer to which the section data block
751            will be assigned.
752        error - Pointer to an integer for returning libdwarf-defined
753            error numbers.
754
755        Return
756        DW_DLV_OK - No error.
757        DW_DLV_ERROR - Error. Use 'error' to indicate a libdwarf-defined
758            error number.
759        DW_DLV_NO_ENTRY - No such section.  */
760    int    (*load_section)(void* obj, Dwarf_Half section_index,
761        Dwarf_Small** return_data, int* error);
762
763    /**
764        relocate_a_section
765        If relocations are not supported leave this pointer NULL.
766
767        Get a pointer to an array of bytes that represent the section.
768
769        Parameters
770        section_index - Zero-based index of the section to be relocated.
771        error - Pointer to an integer for returning libdwarf-defined
772            error numbers.
773
774        Return
775        DW_DLV_OK - No error.
776        DW_DLV_ERROR - Error. Use 'error' to indicate a libdwarf-defined
777            error number.
778        DW_DLV_NO_ENTRY - No such section.  */
779    int    (*relocate_a_section)(void* obj, Dwarf_Half section_index,
780        Dwarf_Debug dbg,
781        int* error);
782
783};
784
785
786
787/*  These structures are allocated and deallocated by your code
788    when you are using the libdwarf Object File Interface
789    [dwarf_object_init() and dwarf_object_finish()] directly.
790    dwarf_object_finish() does not free
791    struct Dwarf_Obj_Access_Interface_s or its content.
792    (libdwarf does record a pointer to this struct: you must
793    ensure that pointer remains valid for as long as
794    a libdwarf instance is open (meaning
795    after dwarf_init() and before dwarf_finish()).
796
797    If you are reading Elf objects and libelf use dwarf_init()
798    or dwarf_elf_init() which take care of these details.
799*/
800struct Dwarf_Obj_Access_Interface_s {
801    /*  object is a void* as it hides the data the object access routines
802        need (which varies by library in use and object format).
803    */
804    void* object;
805    const Dwarf_Obj_Access_Methods * methods;
806};
807
808/* End libdwarf Object File Interface */
809
810/*
811    Dwarf_dealloc() alloc_type arguments.
812    Argument points to:
813*/
814#define DW_DLA_STRING          0x01     /* char* */
815#define DW_DLA_LOC             0x02     /* Dwarf_Loc */
816#define DW_DLA_LOCDESC         0x03     /* Dwarf_Locdesc */
817#define DW_DLA_ELLIST          0x04     /* Dwarf_Ellist (not used)*/
818#define DW_DLA_BOUNDS          0x05     /* Dwarf_Bounds (not used) */
819#define DW_DLA_BLOCK           0x06     /* Dwarf_Block */
820#define DW_DLA_DEBUG           0x07     /* Dwarf_Debug */
821#define DW_DLA_DIE             0x08     /* Dwarf_Die */
822#define DW_DLA_LINE            0x09     /* Dwarf_Line */
823#define DW_DLA_ATTR            0x0a     /* Dwarf_Attribute */
824#define DW_DLA_TYPE            0x0b     /* Dwarf_Type  (not used) */
825#define DW_DLA_SUBSCR          0x0c     /* Dwarf_Subscr (not used) */
826#define DW_DLA_GLOBAL          0x0d     /* Dwarf_Global */
827#define DW_DLA_ERROR           0x0e     /* Dwarf_Error */
828#define DW_DLA_LIST            0x0f     /* a list */
829#define DW_DLA_LINEBUF         0x10     /* Dwarf_Line* (not used) */
830#define DW_DLA_ARANGE          0x11     /* Dwarf_Arange */
831#define DW_DLA_ABBREV          0x12     /* Dwarf_Abbrev */
832#define DW_DLA_FRAME_OP        0x13     /* Dwarf_Frame_Op */
833#define DW_DLA_CIE             0x14     /* Dwarf_Cie */
834#define DW_DLA_FDE             0x15     /* Dwarf_Fde */
835#define DW_DLA_LOC_BLOCK       0x16     /* Dwarf_Loc */
836#define DW_DLA_FRAME_BLOCK     0x17     /* Dwarf_Frame Block (not used) */
837#define DW_DLA_FUNC            0x18     /* Dwarf_Func */
838#define DW_DLA_TYPENAME        0x19     /* Dwarf_Type */
839#define DW_DLA_VAR             0x1a     /* Dwarf_Var */
840#define DW_DLA_WEAK            0x1b     /* Dwarf_Weak */
841#define DW_DLA_ADDR            0x1c     /* Dwarf_Addr sized entries */
842#define DW_DLA_RANGES          0x1d     /* Dwarf_Ranges */
843
844/* 0x1e (30) to 0x36 (54) reserved for internal to libdwarf types. */
845
846#define DW_DLA_GDBINDEX        0x37     /* Dwarf_Gdbindex */
847#define DW_DLA_XU_INDEX        0x38     /* Dwarf_Xu_Index_Header */
848#define DW_DLA_LOC_BLOCK_C     0x39     /* Dwarf_Loc_c*/
849#define DW_DLA_LOCDESC_C       0x3a     /* Dwarf_Locdesc_c */
850#define DW_DLA_LOC_HEAD_C      0x3b     /* Dwarf_Loc_Head_c */
851#define DW_DLA_MACRO_CONTEXT   0x3c     /* Dwarf_Macro_Context */
852/*  0x3d (61) is for libdwarf internal use.               */
853#define DW_DLA_DSC_HEAD        0x3e     /* Dwarf_Dsc_Head */
854
855/* The augmenter string for CIE */
856#define DW_CIE_AUGMENTER_STRING_V0              "z"
857
858/* dwarf_init() access arguments
859*/
860#define DW_DLC_READ        0        /* read only access */
861#define DW_DLC_WRITE       1        /* write only access */
862#define DW_DLC_RDWR        2        /* read/write access NOT SUPPORTED*/
863
864/* dwarf_producer_init*() access flag modifiers
865   No longer depends on compile-time settings for
866   how to produce 64bit offset. See DW_DLC_IRIX_OFFSET64.
867   Historic  versions. One of
868   If DW_DLC_POINTER64 is not set DW_DLC_POINTER32 is assumed.
869   If DW_DLC_OFFSET64 or DW_DLC_IRIX_OFFSET64 is not
870   set 32bit offset DWARF is assumed.
871   Non-MIPS Non IA64 should use DW_DLC_SYMBOLIC_RELOCATIONS
872   and handle the relocation creation for the target
873   itself using the symbolic relocations to do so, those
874   use the Dwarf_Rel_Type enum relocation indicators.
875
876*/
877/*  The first three are traditional dwarf producer names.
878    These names still work.
879    Newer names below.
880*/
881#define DW_DLC_SIZE_64              0x40000000 /* 64-bit address-size target */
882#define DW_DLC_SIZE_32              0x20000000 /* 32-bit address-size target */
883#define DW_DLC_OFFSET_SIZE_64       0x10000000 /* 64-bit offset-size DWARF */
884
885/* dwarf_producer_init*() access flag modifiers
886   Some new April 2014.
887   If DW_DLC_STREAM_RELOCATIONS is set the
888   DW_DLC_ISA_* flags are ignored. See the Dwarf_Rel_Type enum.
889*/
890
891/* Old style Elf binary relocation (.rel) records. The default. */
892#define DW_DLC_STREAM_RELOCATIONS   0x02000000
893
894#define DW_DLC_OFFSET32             0x00010000 /* use 32-bit sec offsets */
895/* The following 3 are new sensible names. Old names above with same values. */
896#define DW_DLC_OFFSET64             0x10000000 /* use 64-bit sec offsets */
897#define DW_DLC_POINTER32            0x20000000 /* use 4 for address_size */
898#define DW_DLC_POINTER64            0x40000000 /* use 8 for address_size */
899/* Special for IRIX only */
900#define DW_DLC_IRIX_OFFSET64        0x00200000 /* use non-std IRIX 64bitoffset headers  */
901
902/*  Usable with assembly output because it is up to the producer to
903    deal with locations in whatever manner the calling producer
904    code wishes.  For example, when the libdwarf caller wishes
905    to produce relocations differently than the binary
906    relocation bits that libdwarf Stream Relocations generate.
907    */
908#define DW_DLC_SYMBOLIC_RELOCATIONS 0x04000000
909
910
911#define DW_DLC_TARGET_BIGENDIAN     0x08000000 /* Big    endian target */
912#define DW_DLC_TARGET_LITTLEENDIAN  0x00100000 /* Little endian target */
913
914
915/* dwarf_pcline() slide arguments
916*/
917#define DW_DLS_BACKWARD   -1       /* slide backward to find line */
918#define DW_DLS_NOSLIDE     0       /* match exactly without sliding */
919#define DW_DLS_FORWARD     1       /* slide forward to find line */
920
921/* libdwarf error numbers
922*/
923#define DW_DLE_NE          0     /* no error */
924#define DW_DLE_VMM         1     /* dwarf format/library version mismatch */
925#define DW_DLE_MAP         2     /* memory map failure */
926#define DW_DLE_LEE         3     /* libelf error */
927#define DW_DLE_NDS         4     /* no debug section */
928#define DW_DLE_NLS         5     /* no line section */
929#define DW_DLE_ID          6     /* invalid descriptor for query */
930#define DW_DLE_IOF         7     /* I/O failure */
931#define DW_DLE_MAF         8     /* memory allocation failure */
932#define DW_DLE_IA          9     /* invalid argument */
933#define DW_DLE_MDE         10     /* mangled debugging entry */
934#define DW_DLE_MLE         11     /* mangled line number entry */
935#define DW_DLE_FNO         12     /* file not open */
936#define DW_DLE_FNR         13     /* file not a regular file */
937#define DW_DLE_FWA         14     /* file open with wrong access */
938#define DW_DLE_NOB         15     /* not an object file */
939#define DW_DLE_MOF         16     /* mangled object file header */
940#define DW_DLE_EOLL        17     /* end of location list entries */
941#define DW_DLE_NOLL        18     /* no location list section */
942#define DW_DLE_BADOFF      19     /* Invalid offset */
943#define DW_DLE_EOS         20     /* end of section  */
944#define DW_DLE_ATRUNC      21     /* abbreviations section appears truncated*/
945#define DW_DLE_BADBITC     22     /* Address size passed to dwarf bad*/
946                    /* It is not an allowed size (64 or 32) */
947    /* Error codes defined by the current Libdwarf Implementation. */
948#define DW_DLE_DBG_ALLOC                        23
949#define DW_DLE_FSTAT_ERROR                      24
950#define DW_DLE_FSTAT_MODE_ERROR                 25
951#define DW_DLE_INIT_ACCESS_WRONG                26
952#define DW_DLE_ELF_BEGIN_ERROR                  27
953#define DW_DLE_ELF_GETEHDR_ERROR                28
954#define DW_DLE_ELF_GETSHDR_ERROR                29
955#define DW_DLE_ELF_STRPTR_ERROR                 30
956#define DW_DLE_DEBUG_INFO_DUPLICATE             31
957#define DW_DLE_DEBUG_INFO_NULL                  32
958#define DW_DLE_DEBUG_ABBREV_DUPLICATE           33
959#define DW_DLE_DEBUG_ABBREV_NULL                34
960#define DW_DLE_DEBUG_ARANGES_DUPLICATE          35
961#define DW_DLE_DEBUG_ARANGES_NULL               36
962#define DW_DLE_DEBUG_LINE_DUPLICATE             37
963#define DW_DLE_DEBUG_LINE_NULL                  38
964#define DW_DLE_DEBUG_LOC_DUPLICATE              39
965#define DW_DLE_DEBUG_LOC_NULL                   40
966#define DW_DLE_DEBUG_MACINFO_DUPLICATE          41
967#define DW_DLE_DEBUG_MACINFO_NULL               42
968#define DW_DLE_DEBUG_PUBNAMES_DUPLICATE         43
969#define DW_DLE_DEBUG_PUBNAMES_NULL              44
970#define DW_DLE_DEBUG_STR_DUPLICATE              45
971#define DW_DLE_DEBUG_STR_NULL                   46
972#define DW_DLE_CU_LENGTH_ERROR                  47
973#define DW_DLE_VERSION_STAMP_ERROR              48
974#define DW_DLE_ABBREV_OFFSET_ERROR              49
975#define DW_DLE_ADDRESS_SIZE_ERROR               50
976#define DW_DLE_DEBUG_INFO_PTR_NULL              51
977#define DW_DLE_DIE_NULL                         52
978#define DW_DLE_STRING_OFFSET_BAD                53
979#define DW_DLE_DEBUG_LINE_LENGTH_BAD            54
980#define DW_DLE_LINE_PROLOG_LENGTH_BAD           55
981#define DW_DLE_LINE_NUM_OPERANDS_BAD            56
982#define DW_DLE_LINE_SET_ADDR_ERROR              57 /* No longer used. */
983#define DW_DLE_LINE_EXT_OPCODE_BAD              58
984#define DW_DLE_DWARF_LINE_NULL                  59
985#define DW_DLE_INCL_DIR_NUM_BAD                 60
986#define DW_DLE_LINE_FILE_NUM_BAD                61
987#define DW_DLE_ALLOC_FAIL                       62
988#define DW_DLE_NO_CALLBACK_FUNC                 63
989#define DW_DLE_SECT_ALLOC                       64
990#define DW_DLE_FILE_ENTRY_ALLOC                 65
991#define DW_DLE_LINE_ALLOC                       66
992#define DW_DLE_FPGM_ALLOC                       67
993#define DW_DLE_INCDIR_ALLOC                     68
994#define DW_DLE_STRING_ALLOC                     69
995#define DW_DLE_CHUNK_ALLOC                      70
996#define DW_DLE_BYTEOFF_ERR                      71
997#define DW_DLE_CIE_ALLOC                        72
998#define DW_DLE_FDE_ALLOC                        73
999#define DW_DLE_REGNO_OVFL                       74
1000#define DW_DLE_CIE_OFFS_ALLOC                   75
1001#define DW_DLE_WRONG_ADDRESS                    76
1002#define DW_DLE_EXTRA_NEIGHBORS                  77
1003#define DW_DLE_WRONG_TAG                        78
1004#define DW_DLE_DIE_ALLOC                        79
1005#define DW_DLE_PARENT_EXISTS                    80
1006#define DW_DLE_DBG_NULL                         81
1007#define DW_DLE_DEBUGLINE_ERROR                  82
1008#define DW_DLE_DEBUGFRAME_ERROR                 83
1009#define DW_DLE_DEBUGINFO_ERROR                  84
1010#define DW_DLE_ATTR_ALLOC                       85
1011#define DW_DLE_ABBREV_ALLOC                     86
1012#define DW_DLE_OFFSET_UFLW                      87
1013#define DW_DLE_ELF_SECT_ERR                     88
1014#define DW_DLE_DEBUG_FRAME_LENGTH_BAD           89
1015#define DW_DLE_FRAME_VERSION_BAD                90
1016#define DW_DLE_CIE_RET_ADDR_REG_ERROR           91
1017#define DW_DLE_FDE_NULL                         92
1018#define DW_DLE_FDE_DBG_NULL                     93
1019#define DW_DLE_CIE_NULL                         94
1020#define DW_DLE_CIE_DBG_NULL                     95
1021#define DW_DLE_FRAME_TABLE_COL_BAD              96
1022#define DW_DLE_PC_NOT_IN_FDE_RANGE              97
1023#define DW_DLE_CIE_INSTR_EXEC_ERROR             98
1024#define DW_DLE_FRAME_INSTR_EXEC_ERROR           99
1025#define DW_DLE_FDE_PTR_NULL                    100
1026#define DW_DLE_RET_OP_LIST_NULL                101
1027#define DW_DLE_LINE_CONTEXT_NULL               102
1028#define DW_DLE_DBG_NO_CU_CONTEXT               103
1029#define DW_DLE_DIE_NO_CU_CONTEXT               104
1030#define DW_DLE_FIRST_DIE_NOT_CU                105
1031#define DW_DLE_NEXT_DIE_PTR_NULL               106
1032#define DW_DLE_DEBUG_FRAME_DUPLICATE           107
1033#define DW_DLE_DEBUG_FRAME_NULL                108
1034#define DW_DLE_ABBREV_DECODE_ERROR             109
1035#define DW_DLE_DWARF_ABBREV_NULL               110
1036#define DW_DLE_ATTR_NULL                       111
1037#define DW_DLE_DIE_BAD                         112
1038#define DW_DLE_DIE_ABBREV_BAD                  113
1039#define DW_DLE_ATTR_FORM_BAD                   114
1040#define DW_DLE_ATTR_NO_CU_CONTEXT              115
1041#define DW_DLE_ATTR_FORM_SIZE_BAD              116
1042#define DW_DLE_ATTR_DBG_NULL                   117
1043#define DW_DLE_BAD_REF_FORM                    118
1044#define DW_DLE_ATTR_FORM_OFFSET_BAD            119
1045#define DW_DLE_LINE_OFFSET_BAD                 120
1046#define DW_DLE_DEBUG_STR_OFFSET_BAD            121
1047#define DW_DLE_STRING_PTR_NULL                 122
1048#define DW_DLE_PUBNAMES_VERSION_ERROR          123
1049#define DW_DLE_PUBNAMES_LENGTH_BAD             124
1050#define DW_DLE_GLOBAL_NULL                     125
1051#define DW_DLE_GLOBAL_CONTEXT_NULL             126
1052#define DW_DLE_DIR_INDEX_BAD                   127
1053#define DW_DLE_LOC_EXPR_BAD                    128
1054#define DW_DLE_DIE_LOC_EXPR_BAD                129
1055#define DW_DLE_ADDR_ALLOC                      130
1056#define DW_DLE_OFFSET_BAD                      131
1057#define DW_DLE_MAKE_CU_CONTEXT_FAIL            132
1058#define DW_DLE_REL_ALLOC                       133
1059#define DW_DLE_ARANGE_OFFSET_BAD               134
1060#define DW_DLE_SEGMENT_SIZE_BAD                135
1061#define DW_DLE_ARANGE_LENGTH_BAD               136
1062#define DW_DLE_ARANGE_DECODE_ERROR             137
1063#define DW_DLE_ARANGES_NULL                    138
1064#define DW_DLE_ARANGE_NULL                     139
1065#define DW_DLE_NO_FILE_NAME                    140
1066#define DW_DLE_NO_COMP_DIR                     141
1067#define DW_DLE_CU_ADDRESS_SIZE_BAD             142
1068#define DW_DLE_INPUT_ATTR_BAD                  143
1069#define DW_DLE_EXPR_NULL                       144
1070#define DW_DLE_BAD_EXPR_OPCODE                 145
1071#define DW_DLE_EXPR_LENGTH_BAD                 146
1072#define DW_DLE_MULTIPLE_RELOC_IN_EXPR          147
1073#define DW_DLE_ELF_GETIDENT_ERROR              148
1074#define DW_DLE_NO_AT_MIPS_FDE                  149
1075#define DW_DLE_NO_CIE_FOR_FDE                  150
1076#define DW_DLE_DIE_ABBREV_LIST_NULL            151
1077#define DW_DLE_DEBUG_FUNCNAMES_DUPLICATE       152
1078#define DW_DLE_DEBUG_FUNCNAMES_NULL            153
1079#define DW_DLE_DEBUG_FUNCNAMES_VERSION_ERROR   154
1080#define DW_DLE_DEBUG_FUNCNAMES_LENGTH_BAD      155
1081#define DW_DLE_FUNC_NULL                       156
1082#define DW_DLE_FUNC_CONTEXT_NULL               157
1083#define DW_DLE_DEBUG_TYPENAMES_DUPLICATE       158
1084#define DW_DLE_DEBUG_TYPENAMES_NULL            159
1085#define DW_DLE_DEBUG_TYPENAMES_VERSION_ERROR   160
1086#define DW_DLE_DEBUG_TYPENAMES_LENGTH_BAD      161
1087#define DW_DLE_TYPE_NULL                       162
1088#define DW_DLE_TYPE_CONTEXT_NULL               163
1089#define DW_DLE_DEBUG_VARNAMES_DUPLICATE        164
1090#define DW_DLE_DEBUG_VARNAMES_NULL             165
1091#define DW_DLE_DEBUG_VARNAMES_VERSION_ERROR    166
1092#define DW_DLE_DEBUG_VARNAMES_LENGTH_BAD       167
1093#define DW_DLE_VAR_NULL                        168
1094#define DW_DLE_VAR_CONTEXT_NULL                169
1095#define DW_DLE_DEBUG_WEAKNAMES_DUPLICATE       170
1096#define DW_DLE_DEBUG_WEAKNAMES_NULL            171
1097#define DW_DLE_DEBUG_WEAKNAMES_VERSION_ERROR   172
1098#define DW_DLE_DEBUG_WEAKNAMES_LENGTH_BAD      173
1099#define DW_DLE_WEAK_NULL                       174
1100#define DW_DLE_WEAK_CONTEXT_NULL               175
1101#define DW_DLE_LOCDESC_COUNT_WRONG             176
1102#define DW_DLE_MACINFO_STRING_NULL             177
1103#define DW_DLE_MACINFO_STRING_EMPTY            178
1104#define DW_DLE_MACINFO_INTERNAL_ERROR_SPACE    179
1105#define DW_DLE_MACINFO_MALLOC_FAIL             180
1106#define DW_DLE_DEBUGMACINFO_ERROR              181
1107#define DW_DLE_DEBUG_MACRO_LENGTH_BAD          182
1108#define DW_DLE_DEBUG_MACRO_MAX_BAD             183
1109#define DW_DLE_DEBUG_MACRO_INTERNAL_ERR        184
1110#define DW_DLE_DEBUG_MACRO_MALLOC_SPACE        185
1111#define DW_DLE_DEBUG_MACRO_INCONSISTENT        186
1112#define DW_DLE_DF_NO_CIE_AUGMENTATION          187
1113#define DW_DLE_DF_REG_NUM_TOO_HIGH             188
1114#define DW_DLE_DF_MAKE_INSTR_NO_INIT           189
1115#define DW_DLE_DF_NEW_LOC_LESS_OLD_LOC         190
1116#define DW_DLE_DF_POP_EMPTY_STACK              191
1117#define DW_DLE_DF_ALLOC_FAIL                   192
1118#define DW_DLE_DF_FRAME_DECODING_ERROR         193
1119#define DW_DLE_DEBUG_LOC_SECTION_SHORT         194
1120#define DW_DLE_FRAME_AUGMENTATION_UNKNOWN      195
1121#define DW_DLE_PUBTYPE_CONTEXT                 196 /* Unused. */
1122#define DW_DLE_DEBUG_PUBTYPES_LENGTH_BAD       197
1123#define DW_DLE_DEBUG_PUBTYPES_VERSION_ERROR    198
1124#define DW_DLE_DEBUG_PUBTYPES_DUPLICATE        199
1125#define DW_DLE_FRAME_CIE_DECODE_ERROR          200
1126#define DW_DLE_FRAME_REGISTER_UNREPRESENTABLE  201
1127#define DW_DLE_FRAME_REGISTER_COUNT_MISMATCH   202
1128#define DW_DLE_LINK_LOOP                       203
1129#define DW_DLE_STRP_OFFSET_BAD                 204
1130#define DW_DLE_DEBUG_RANGES_DUPLICATE          205
1131#define DW_DLE_DEBUG_RANGES_OFFSET_BAD         206
1132#define DW_DLE_DEBUG_RANGES_MISSING_END        207
1133#define DW_DLE_DEBUG_RANGES_OUT_OF_MEM         208
1134#define DW_DLE_DEBUG_SYMTAB_ERR                209
1135#define DW_DLE_DEBUG_STRTAB_ERR                210
1136#define DW_DLE_RELOC_MISMATCH_INDEX            211
1137#define DW_DLE_RELOC_MISMATCH_RELOC_INDEX      212
1138#define DW_DLE_RELOC_MISMATCH_STRTAB_INDEX     213
1139#define DW_DLE_RELOC_SECTION_MISMATCH          214
1140#define DW_DLE_RELOC_SECTION_MISSING_INDEX     215
1141#define DW_DLE_RELOC_SECTION_LENGTH_ODD        216
1142#define DW_DLE_RELOC_SECTION_PTR_NULL          217
1143#define DW_DLE_RELOC_SECTION_MALLOC_FAIL       218
1144#define DW_DLE_NO_ELF64_SUPPORT                219
1145#define DW_DLE_MISSING_ELF64_SUPPORT           220
1146#define DW_DLE_ORPHAN_FDE                      221
1147#define DW_DLE_DUPLICATE_INST_BLOCK            222
1148#define DW_DLE_BAD_REF_SIG8_FORM               223
1149#define DW_DLE_ATTR_EXPRLOC_FORM_BAD           224
1150#define DW_DLE_FORM_SEC_OFFSET_LENGTH_BAD      225
1151#define DW_DLE_NOT_REF_FORM                    226
1152#define DW_DLE_DEBUG_FRAME_LENGTH_NOT_MULTIPLE 227
1153#define DW_DLE_REF_SIG8_NOT_HANDLED            228
1154#define DW_DLE_DEBUG_FRAME_POSSIBLE_ADDRESS_BOTCH 229
1155#define DW_DLE_LOC_BAD_TERMINATION             230
1156#define DW_DLE_SYMTAB_SECTION_LENGTH_ODD       231
1157#define DW_DLE_RELOC_SECTION_SYMBOL_INDEX_BAD  232
1158#define DW_DLE_RELOC_SECTION_RELOC_TARGET_SIZE_UNKNOWN  233
1159#define DW_DLE_SYMTAB_SECTION_ENTRYSIZE_ZERO   234
1160#define DW_DLE_LINE_NUMBER_HEADER_ERROR        235
1161#define DW_DLE_DEBUG_TYPES_NULL                236
1162#define DW_DLE_DEBUG_TYPES_DUPLICATE           237
1163#define DW_DLE_DEBUG_TYPES_ONLY_DWARF4         238
1164#define DW_DLE_DEBUG_TYPEOFFSET_BAD            239
1165#define DW_DLE_GNU_OPCODE_ERROR                240
1166#define DW_DLE_DEBUGPUBTYPES_ERROR             241
1167#define DW_DLE_AT_FIXUP_NULL                   242
1168#define DW_DLE_AT_FIXUP_DUP                    243
1169#define DW_DLE_BAD_ABINAME                     244
1170#define DW_DLE_TOO_MANY_DEBUG                  245
1171#define DW_DLE_DEBUG_STR_OFFSETS_DUPLICATE     246
1172#define DW_DLE_SECTION_DUPLICATION             247
1173#define DW_DLE_SECTION_ERROR                   248
1174#define DW_DLE_DEBUG_ADDR_DUPLICATE            249
1175#define DW_DLE_DEBUG_CU_UNAVAILABLE_FOR_FORM   250
1176#define DW_DLE_DEBUG_FORM_HANDLING_INCOMPLETE  251
1177#define DW_DLE_NEXT_DIE_PAST_END               252
1178#define DW_DLE_NEXT_DIE_WRONG_FORM             253
1179#define DW_DLE_NEXT_DIE_NO_ABBREV_LIST         254
1180#define DW_DLE_NESTED_FORM_INDIRECT_ERROR      255
1181#define DW_DLE_CU_DIE_NO_ABBREV_LIST           256
1182#define DW_DLE_MISSING_NEEDED_DEBUG_ADDR_SECTION 257
1183#define DW_DLE_ATTR_FORM_NOT_ADDR_INDEX        258
1184#define DW_DLE_ATTR_FORM_NOT_STR_INDEX         259
1185#define DW_DLE_DUPLICATE_GDB_INDEX             260
1186#define DW_DLE_ERRONEOUS_GDB_INDEX_SECTION     261
1187#define DW_DLE_GDB_INDEX_COUNT_ERROR           262
1188#define DW_DLE_GDB_INDEX_COUNT_ADDR_ERROR      263
1189#define DW_DLE_GDB_INDEX_INDEX_ERROR           264
1190#define DW_DLE_GDB_INDEX_CUVEC_ERROR           265
1191#define DW_DLE_DUPLICATE_CU_INDEX              266
1192#define DW_DLE_DUPLICATE_TU_INDEX              267
1193#define DW_DLE_XU_TYPE_ARG_ERROR               268
1194#define DW_DLE_XU_IMPOSSIBLE_ERROR             269
1195#define DW_DLE_XU_NAME_COL_ERROR               270
1196#define DW_DLE_XU_HASH_ROW_ERROR               271
1197#define DW_DLE_XU_HASH_INDEX_ERROR             272
1198/* ..._FAILSAFE_ERRVAL is an aid when out of memory. */
1199#define DW_DLE_FAILSAFE_ERRVAL                 273
1200#define DW_DLE_ARANGE_ERROR                    274
1201#define DW_DLE_PUBNAMES_ERROR                  275
1202#define DW_DLE_FUNCNAMES_ERROR                 276
1203#define DW_DLE_TYPENAMES_ERROR                 277
1204#define DW_DLE_VARNAMES_ERROR                  278
1205#define DW_DLE_WEAKNAMES_ERROR                 279
1206#define DW_DLE_RELOCS_ERROR                    280
1207#define DW_DLE_ATTR_OUTSIDE_SECTION            281
1208#define DW_DLE_FISSION_INDEX_WRONG             282
1209#define DW_DLE_FISSION_VERSION_ERROR           283
1210#define DW_DLE_NEXT_DIE_LOW_ERROR              284
1211#define DW_DLE_CU_UT_TYPE_ERROR                285
1212#define DW_DLE_NO_SUCH_SIGNATURE_FOUND         286
1213#define DW_DLE_SIGNATURE_SECTION_NUMBER_WRONG  287
1214#define DW_DLE_ATTR_FORM_NOT_DATA8             288
1215#define DW_DLE_SIG_TYPE_WRONG_STRING           289
1216#define DW_DLE_MISSING_REQUIRED_TU_OFFSET_HASH 290
1217#define DW_DLE_MISSING_REQUIRED_CU_OFFSET_HASH 291
1218#define DW_DLE_DWP_MISSING_DWO_ID              292
1219#define DW_DLE_DWP_SIBLING_ERROR               293
1220#define DW_DLE_DEBUG_FISSION_INCOMPLETE        294
1221#define DW_DLE_FISSION_SECNUM_ERR              295
1222#define DW_DLE_DEBUG_MACRO_DUPLICATE           296
1223#define DW_DLE_DEBUG_NAMES_DUPLICATE           297
1224#define DW_DLE_DEBUG_LINE_STR_DUPLICATE        298
1225#define DW_DLE_DEBUG_SUP_DUPLICATE             299
1226#define DW_DLE_NO_SIGNATURE_TO_LOOKUP          300
1227#define DW_DLE_NO_TIED_ADDR_AVAILABLE          301
1228#define DW_DLE_NO_TIED_SIG_AVAILABLE           302
1229#define DW_DLE_STRING_NOT_TERMINATED           303
1230#define DW_DLE_BAD_LINE_TABLE_OPERATION        304
1231#define DW_DLE_LINE_CONTEXT_BOTCH              305
1232#define DW_DLE_LINE_CONTEXT_INDEX_WRONG        306
1233#define DW_DLE_NO_TIED_STRING_AVAILABLE        307
1234#define DW_DLE_NO_TIED_FILE_AVAILABLE          308
1235#define DW_DLE_CU_TYPE_MISSING                 309
1236#define DW_DLE_LLE_CODE_UNKNOWN                310
1237#define DW_DLE_LOCLIST_INTERFACE_ERROR         311
1238#define DW_DLE_LOCLIST_INDEX_ERROR             312
1239#define DW_DLE_INTERFACE_NOT_SUPPORTED         313
1240#define DW_DLE_ZDEBUG_REQUIRES_ZLIB            314
1241#define DW_DLE_ZDEBUG_INPUT_FORMAT_ODD         315
1242#define DW_DLE_ZLIB_BUF_ERROR                  316
1243#define DW_DLE_ZLIB_DATA_ERROR                 317
1244#define DW_DLE_MACRO_OFFSET_BAD                318
1245#define DW_DLE_MACRO_OPCODE_BAD                319
1246#define DW_DLE_MACRO_OPCODE_FORM_BAD           320
1247#define DW_DLE_UNKNOWN_FORM                    321
1248#define DW_DLE_BAD_MACRO_HEADER_POINTER        322
1249#define DW_DLE_BAD_MACRO_INDEX                 323
1250#define DW_DLE_MACRO_OP_UNHANDLED              324
1251#define DW_DLE_MACRO_PAST_END                  325
1252#define DW_DLE_LINE_STRP_OFFSET_BAD            326
1253#define DW_DLE_STRING_FORM_IMPROPER            327
1254#define DW_DLE_ELF_FLAGS_NOT_AVAILABLE         328
1255#define DW_DLE_LEB_IMPROPER                    329
1256#define DW_DLE_DEBUG_LINE_RANGE_ZERO           330
1257#define DW_DLE_READ_LITTLEENDIAN_ERROR         331
1258#define DW_DLE_READ_BIGENDIAN_ERROR            332
1259#define DW_DLE_RELOC_INVALID                   333
1260#define DW_DLE_INFO_HEADER_ERROR               334
1261#define DW_DLE_ARANGES_HEADER_ERROR            335
1262#define DW_DLE_LINE_OFFSET_WRONG_FORM          336
1263#define DW_DLE_FORM_BLOCK_LENGTH_ERROR         337
1264#define DW_DLE_ZLIB_SECTION_SHORT              338
1265#define DW_DLE_CIE_INSTR_PTR_ERROR             339
1266#define DW_DLE_FDE_INSTR_PTR_ERROR             340
1267#define DW_DLE_FISSION_ADDITION_ERROR          341
1268#define DW_DLE_HEADER_LEN_BIGGER_THAN_SECSIZE  342
1269#define DW_DLE_LOCEXPR_OFF_SECTION_END         343
1270#define DW_DLE_POINTER_SECTION_UNKNOWN         344
1271#define DW_DLE_ERRONEOUS_XU_INDEX_SECTION      345
1272#define DW_DLE_DIRECTORY_FORMAT_COUNT_VS_DIRECTORIES_MISMATCH 346
1273#define DW_DLE_COMPRESSED_EMPTY_SECTION        347
1274#define DW_DLE_SIZE_WRAPAROUND                 348
1275#define DW_DLE_ILLOGICAL_TSEARCH               349
1276#define DW_DLE_BAD_STRING_FORM                 350
1277#define DW_DLE_DEBUGSTR_ERROR                  351
1278#define DW_DLE_DEBUGSTR_UNEXPECTED_REL         352
1279#define DW_DLE_DISCR_ARRAY_ERROR               353
1280#define DW_DLE_LEB_OUT_ERROR                   354
1281#define DW_DLE_SIBLING_LIST_IMPROPER           355
1282#define DW_DLE_LOCLIST_OFFSET_BAD              356
1283#define DW_DLE_LINE_TABLE_BAD                  357
1284#define DW_DLE_DEBUG_LOClISTS_DUPLICATE        358
1285#define DW_DLE_DEBUG_RNGLISTS_DUPLICATE        359
1286#define DW_DLE_ABBREV_OFF_END                  360
1287#define DW_DLE_FORM_STRING_BAD_STRING          361
1288#define DW_DLE_AUGMENTATION_STRING_OFF_END     362
1289#define DW_DLE_STRING_OFF_END_PUBNAMES_LIKE    363
1290#define DW_DLE_LINE_STRING_BAD                 364
1291#define DW_DLE_DEFINE_FILE_STRING_BAD          365
1292#define DW_DLE_MACRO_STRING_BAD                366
1293#define DW_DLE_MACINFO_STRING_BAD              367
1294#define DW_DLE_ZLIB_UNCOMPRESS_ERROR           368
1295
1296    /* LAST MUST EQUAL LAST ERROR NUMBER */
1297#define DW_DLE_LAST        368
1298#define DW_DLE_LO_USER     0x10000
1299
1300    /*  Taken as meaning 'undefined value', this is not
1301        a column or register number.
1302        Only present at libdwarf runtime. Never on disk.
1303        DW_FRAME_* Values present on disk are in dwarf.h
1304    */
1305#define DW_FRAME_UNDEFINED_VAL          1034
1306
1307    /*  Taken as meaning 'same value' as caller had, not a column
1308        or register number
1309        Only present at libdwarf runtime. Never on disk.
1310        DW_FRAME_* Values present on disk are in dwarf.h
1311    */
1312#define DW_FRAME_SAME_VAL               1035
1313
1314
1315
1316/* error return values
1317*/
1318#define DW_DLV_BADADDR     (~(Dwarf_Addr)0)
1319    /* for functions returning target address */
1320
1321#define DW_DLV_NOCOUNT     ((Dwarf_Signed)-1)
1322    /* for functions returning count */
1323
1324#define DW_DLV_BADOFFSET   (~(Dwarf_Off)0)
1325    /* for functions returning offset */
1326
1327/* standard return values for functions */
1328#define DW_DLV_NO_ENTRY -1
1329#define DW_DLV_OK        0
1330#define DW_DLV_ERROR     1
1331
1332/* Special values for offset_into_exception_table field of dwarf fde's. */
1333/* The following value indicates that there is no Exception table offset
1334   associated with a dwarf frame. */
1335#define DW_DLX_NO_EH_OFFSET         (-1LL)
1336/* The following value indicates that the producer was unable to analyse the
1337   source file to generate Exception tables for this function. */
1338#define DW_DLX_EH_OFFSET_UNAVAILABLE  (-2LL)
1339
1340/* The dwarf specification separates FORMs into
1341different classes.  To do the seperation properly
1342requires 4 pieces of data as of DWARF4 (thus the
1343function arguments listed here).
1344The DWARF4 specification class definition suffices to
1345describe all DWARF versions.
1346See section 7.5.4, Attribute Encodings.
1347A return of DW_FORM_CLASS_UNKNOWN means we could not properly figure
1348out what form-class it is.
1349
1350    DW_FORM_CLASS_FRAMEPTR is MIPS/IRIX only, and refers
1351    to the DW_AT_MIPS_fde attribute (a reference to the
1352    .debug_frame section).
1353
1354    DWARF5:
1355    DW_FORM_CLASS_LOCLISTSPTR  is like DW_FORM_CLASS_LOCLIST
1356    except that LOCLISTSPTR is aways a section offset,
1357    never an index, and LOCLISTSPTR is only referenced
1358    by DW_AT_loclists_base.
1359    Note DW_FORM_CLASS_LOCLISTSPTR spelling to distinguish
1360    from DW_FORM_CLASS_LOCLISTPTR.
1361
1362    DWARF5:
1363    DW_FORM_CLASS_RNGLISTSPTR  is like DW_FORM_CLASS_RNGLIST
1364    except that RNGLISTSPTR is aways a section offset,
1365    never an index. DW_FORM_CLASS_RNGLISTSPTR is only
1366    referenced by DW_AT_ranges_base.
1367*/
1368enum Dwarf_Form_Class {
1369    DW_FORM_CLASS_UNKNOWN,   DW_FORM_CLASS_ADDRESS,
1370    DW_FORM_CLASS_BLOCK,     DW_FORM_CLASS_CONSTANT,
1371    DW_FORM_CLASS_EXPRLOC,   DW_FORM_CLASS_FLAG,
1372    DW_FORM_CLASS_LINEPTR,
1373    DW_FORM_CLASS_LOCLISTPTR,   /* DWARF2,3,4 only */
1374    DW_FORM_CLASS_MACPTR,       /* DWARF2,3,4 only */
1375    DW_FORM_CLASS_RANGELISTPTR, /* DWARF2,3,4 only */
1376    DW_FORM_CLASS_REFERENCE,
1377    DW_FORM_CLASS_STRING,
1378    DW_FORM_CLASS_FRAMEPTR,      /* MIPS/IRIX DWARF2 only */
1379    DW_FORM_CLASS_MACROPTR,      /* DWARF5 */
1380    DW_FORM_CLASS_ADDRPTR,       /* DWARF5 */
1381    DW_FORM_CLASS_LOCLIST,       /* DWARF5 */
1382    DW_FORM_CLASS_LOCLISTSPTR,   /* DWARF5 */
1383    DW_FORM_CLASS_RNGLIST,       /* DWARF5 */
1384    DW_FORM_CLASS_RNGLISTSPTR,   /* DWARF5 */
1385    DW_FORM_CLASS_STROFFSETSPTR, /* DWARF5 */
1386};
1387
1388
1389/*===========================================================================*/
1390/*  Dwarf consumer interface initialization and termination operations */
1391
1392/* Initialization based on Unix open fd (using libelf internally). */
1393int dwarf_init(int    /*fd*/,
1394    Dwarf_Unsigned    /*access*/,
1395    Dwarf_Handler     /*errhand*/,
1396    Dwarf_Ptr         /*errarg*/,
1397    Dwarf_Debug*      /*dbg*/,
1398    Dwarf_Error*      /*error*/);
1399
1400/* Initialization based on libelf/sgi-fastlibelf open pointer. */
1401int dwarf_elf_init(dwarf_elf_handle /*elf*/,
1402    Dwarf_Unsigned    /*access*/,
1403    Dwarf_Handler     /*errhand*/,
1404    Dwarf_Ptr         /*errarg*/,
1405    Dwarf_Debug*      /*dbg*/,
1406    Dwarf_Error*      /*error*/);
1407
1408/* Undocumented function for memory allocator. */
1409void dwarf_print_memory_stats(Dwarf_Debug  /*dbg*/);
1410
1411int dwarf_get_elf(Dwarf_Debug /*dbg*/,
1412    dwarf_elf_handle* /*return_elfptr*/,
1413    Dwarf_Error*      /*error*/);
1414
1415int dwarf_finish(Dwarf_Debug /*dbg*/, Dwarf_Error* /*error*/);
1416
1417
1418int dwarf_object_init(Dwarf_Obj_Access_Interface* /*obj*/,
1419    Dwarf_Handler /*errhand*/,
1420    Dwarf_Ptr     /*errarg*/,
1421    Dwarf_Debug*  /*dbg*/,
1422    Dwarf_Error*  /*error*/);
1423
1424int dwarf_set_tied_dbg(Dwarf_Debug /*basedbg*/,
1425    Dwarf_Debug /*tied_dbg*/,
1426    Dwarf_Error*  /*error*/);
1427
1428/*  Likely not very useful.? */
1429int dwarf_get_tied_dbg(Dwarf_Debug /*dbg*/,
1430    Dwarf_Debug * /*tieddbg_out*/,
1431    Dwarf_Error * /*error*/);
1432
1433int dwarf_object_finish(Dwarf_Debug /*dbg*/,
1434    Dwarf_Error* /*error*/);
1435
1436/*  Section name access.  Because sections might
1437    now end with .dwo or be .zdebug  or might not.
1438*/
1439int
1440dwarf_get_die_section_name(Dwarf_Debug /*dbg*/,
1441    Dwarf_Bool    /*is_info*/,
1442    const char ** /*sec_name*/,
1443    Dwarf_Error * /*error*/);
1444int
1445dwarf_get_die_section_name_b(Dwarf_Die /*die*/,
1446    const char ** /*sec_name*/,
1447    Dwarf_Error * /*error*/);
1448
1449
1450/*  dwarf_next_cu_header_d() traverses debug_types CU headers.
1451    New in May, 2015.
1452    */
1453int dwarf_next_cu_header_d(Dwarf_Debug /*dbg*/,
1454    Dwarf_Bool      /*is_info*/,
1455    Dwarf_Unsigned* /*cu_header_length*/,
1456    Dwarf_Half*     /*version_stamp*/,
1457    Dwarf_Off*      /*abbrev_offset*/,
1458    Dwarf_Half*     /*address_size*/,
1459    Dwarf_Half*     /*length_size*/,
1460    Dwarf_Half*     /*extension_size*/,
1461    Dwarf_Sig8*     /*type signature*/,
1462    Dwarf_Unsigned* /*typeoffset*/,
1463    Dwarf_Unsigned* /*next_cu_header_offset*/,
1464    Dwarf_Half    * /*header_cu_type*/,
1465    Dwarf_Error*    /*error*/);
1466
1467/*  Die traversal operations.
1468    dwarf_next_cu_header_b() traverses debug_info CU headers.
1469    Obsolete but supported.
1470    */
1471int dwarf_next_cu_header_b(Dwarf_Debug /*dbg*/,
1472    Dwarf_Unsigned* /*cu_header_length*/,
1473    Dwarf_Half*     /*version_stamp*/,
1474    Dwarf_Off*      /*abbrev_offset*/,
1475    Dwarf_Half*     /*address_size*/,
1476    Dwarf_Half*     /*length_size*/,
1477    Dwarf_Half*     /*extension_size*/,
1478    Dwarf_Unsigned* /*next_cu_header_offset*/,
1479    Dwarf_Error*    /*error*/);
1480
1481/*  dwarf_next_cu_header_types() traverses debug_types CU headers.
1482    New in October, 2011. Obsolete but supported May 2015.
1483    */
1484int dwarf_next_cu_header_c(Dwarf_Debug /*dbg*/,
1485    Dwarf_Bool      /*is_info*/,
1486    Dwarf_Unsigned* /*cu_header_length*/,
1487    Dwarf_Half*     /*version_stamp*/,
1488    Dwarf_Off*      /*abbrev_offset*/,
1489    Dwarf_Half*     /*address_size*/,
1490    Dwarf_Half*     /*length_size*/,
1491    Dwarf_Half*     /*extension_size*/,
1492    Dwarf_Sig8*     /*type signature*/,
1493    Dwarf_Unsigned* /*typeoffset*/,
1494    Dwarf_Unsigned* /*next_cu_header_offset*/,
1495    Dwarf_Error*    /*error*/);
1496/* The following is obsolete, though supported. November 2009. */
1497int dwarf_next_cu_header(Dwarf_Debug /*dbg*/,
1498    Dwarf_Unsigned* /*cu_header_length*/,
1499    Dwarf_Half*     /*version_stamp*/,
1500    Dwarf_Off*      /*abbrev_offset*/,
1501    Dwarf_Half*     /*address_size*/,
1502    Dwarf_Unsigned* /*next_cu_header_offset*/,
1503    Dwarf_Error*    /*error*/);
1504
1505int dwarf_siblingof(Dwarf_Debug /*dbg*/,
1506    Dwarf_Die        /*die*/,
1507    Dwarf_Die*       /*return_siblingdie*/,
1508    Dwarf_Error*     /*error*/);
1509/* dwarf_siblingof_b new October 2011. */
1510int dwarf_siblingof_b(Dwarf_Debug /*dbg*/,
1511    Dwarf_Die        /*die*/,
1512    Dwarf_Bool       /*is_info*/,
1513    Dwarf_Die*       /*return_siblingdie*/,
1514    Dwarf_Error*     /*error*/);
1515
1516/* New 27 April 2015. */
1517int dwarf_die_from_hash_signature(Dwarf_Debug /*dbg*/,
1518    Dwarf_Sig8 *     /*hash_sig*/,
1519    const char *     /*sig_type: "tu" or "cu"*/,
1520    Dwarf_Die*       /*returned_CU_die */,
1521    Dwarf_Error*     /*error*/);
1522
1523int dwarf_child(Dwarf_Die /*die*/,
1524    Dwarf_Die*       /*return_childdie*/,
1525    Dwarf_Error*     /*error*/);
1526
1527/*  Finding die given global (not CU-relative) offset.
1528    Applies only to debug_info. */
1529int dwarf_offdie(Dwarf_Debug /*dbg*/,
1530    Dwarf_Off        /*offset*/,
1531    Dwarf_Die*       /*return_die*/,
1532    Dwarf_Error*     /*error*/);
1533
1534/*  dwarf_offdie_b() new October 2011 */
1535/*  Finding die given global (not CU-relative) offset.
1536    Applies to debug_info (is_info true) or debug_types (is_info false). */
1537int dwarf_offdie_b(Dwarf_Debug /*dbg*/,
1538    Dwarf_Off        /*offset*/,
1539    Dwarf_Bool       /*is_info*/,
1540    Dwarf_Die*       /*return_die*/,
1541    Dwarf_Error*     /*error*/);
1542
1543/*  Returns the is_info flag through the pointer if the function returns
1544    DW_DLV_OK. Needed so client software knows if a DIE is in debug_info
1545    or debug_types.
1546    New October 2011. */
1547Dwarf_Bool dwarf_get_die_infotypes_flag(Dwarf_Die /*die*/);
1548
1549/*  New March 2016.
1550    So we can associate a DIE's abbreviations with the contents
1551    the abbreviations section. */
1552int dwarf_die_abbrev_global_offset(Dwarf_Die /*die*/,
1553    Dwarf_Off       * /*abbrev_offset*/,
1554    Dwarf_Unsigned  * /*abbrev_count*/,
1555    Dwarf_Error*      /*error*/);
1556
1557/*  operations on DIEs */
1558int dwarf_tag(Dwarf_Die /*die*/,
1559    Dwarf_Half*      /*return_tag*/,
1560    Dwarf_Error*     /*error*/);
1561
1562/*  dwarf_dieoffset returns the global debug_info
1563    section offset, not the CU relative offset. */
1564int dwarf_dieoffset(Dwarf_Die /*die*/,
1565    Dwarf_Off*       /*return_offset*/,
1566    Dwarf_Error*     /*error*/);
1567
1568/*  NEW October 2015. DWARF5.
1569    The DIE here can be any DIE in the relevant CU.
1570    index is an index into .debug_addr.
1571    This will look first for .debug_addr
1572    in the dbg object DIE
1573    and if not there (because the dbg object is
1574    a dwo or dwp split dwarf object)
1575    will look in the tied object if tied is available. */
1576int
1577dwarf_debug_addr_index_to_addr(Dwarf_Die /*die*/,
1578    Dwarf_Unsigned  /*index*/,
1579    Dwarf_Addr    * /*return_addr*/,
1580    Dwarf_Error   * /*error*/);
1581
1582
1583/*  dwarf_CU_dieoffset_given_die returns
1584    the global debug_info section offset of the CU die
1585    that is the CU containing the given_die
1586    (the passed in DIE can be any DIE).
1587    This information makes it possible for a consumer to
1588    find and print CU context information for any die.
1589    See also dwarf_get_cu_die_offset_given_cu_header_offset(). */
1590int dwarf_CU_dieoffset_given_die(Dwarf_Die /*given_die*/,
1591    Dwarf_Off*       /*return_offset*/,
1592    Dwarf_Error*     /*error*/);
1593
1594/*  dwarf_die_CU_offset returns the CU relative offset
1595    not the global debug_info section offset, given
1596    any DIE in the CU.  See also dwarf_CU_dieoffset_given_die().
1597    */
1598int dwarf_die_CU_offset(Dwarf_Die /*die*/,
1599    Dwarf_Off*       /*return_offset*/,
1600    Dwarf_Error*     /*error*/);
1601
1602int dwarf_die_CU_offset_range(Dwarf_Die /*die*/,
1603    Dwarf_Off*       /*return_CU_header_offset*/,
1604    Dwarf_Off*       /*return_CU_length_bytes*/,
1605    Dwarf_Error*     /*error*/);
1606
1607int dwarf_attr (Dwarf_Die /*die*/,
1608    Dwarf_Half        /*attr*/,
1609    Dwarf_Attribute * /*returned_attr*/,
1610    Dwarf_Error*      /*error*/);
1611
1612int dwarf_die_text(Dwarf_Die /*die*/,
1613    Dwarf_Half    /*attr*/,
1614    char       ** /*ret_name*/,
1615    Dwarf_Error * /*error*/);
1616
1617int dwarf_diename(Dwarf_Die /*die*/,
1618    char   **        /*diename*/,
1619    Dwarf_Error*     /*error*/);
1620
1621/* Returns the  abbrev code of the die. Cannot fail. */
1622int dwarf_die_abbrev_code(Dwarf_Die /*die */);
1623
1624/*  Returns a flag through ab_has_child. Non-zero if
1625    the DIE has children, zero if it does not.   */
1626int dwarf_die_abbrev_children_flag(Dwarf_Die /*die*/,
1627    Dwarf_Half * /*ab_has_child*/);
1628
1629/* Validate the sibling DIE. This only makes sense to call
1630   if the sibling's DIEs have been travsersed and
1631   dwarf_child() called on each,
1632   so that the last DIE dwarf_child saw was the last.
1633   Essentially ensuring that (after such traversal) that we
1634   are in the same place a sibling attribute would identify.
1635   In case we return DW_DLV_ERROR, the global offset of the last
1636   DIE traversed by dwarf_child is returned through *offset */
1637int dwarf_validate_die_sibling(Dwarf_Die /*sibling*/,Dwarf_Off* /*offset*/);
1638
1639/* convenience functions, alternative to using dwarf_attrlist() */
1640int dwarf_hasattr(Dwarf_Die /*die*/,
1641    Dwarf_Half   /*attr*/,
1642    Dwarf_Bool * /*returned_bool*/,
1643    Dwarf_Error* /*error*/);
1644
1645/* Returns the children offsets for the given offset */
1646int dwarf_offset_list(Dwarf_Debug /*dbg*/,
1647    Dwarf_Off         /*offset*/,
1648    Dwarf_Bool        /*is_info*/,
1649    Dwarf_Off      ** /*offbuf*/,
1650    Dwarf_Unsigned *  /*offcnt*/,
1651    Dwarf_Error    *  /*error*/);
1652
1653/*  BEGIN: loclist_c interfaces
1654    NEW October 2015.
1655    This works for any attribute that identifies
1656    a loclist or a locexpr. When the attribute is a locexpr
1657    a single loclist (created by libdwarf)
1658    is attached to loclist_head. */
1659int dwarf_get_loclist_c (Dwarf_Attribute /*attr*/,
1660   Dwarf_Loc_Head_c * /*loclist_head*/,
1661   Dwarf_Unsigned   * /*locCount*/,
1662   Dwarf_Error      * /*error*/);
1663
1664int dwarf_get_locdesc_entry_c(Dwarf_Loc_Head_c /*loclist_head*/,
1665   Dwarf_Unsigned    /*index*/,
1666
1667   /* identifies type of locdesc entry*/
1668   Dwarf_Small    *  /*lle_value_out*/,
1669   Dwarf_Addr     *  /*lowpc_out*/,
1670   Dwarf_Addr     *  /*hipc_out*/,
1671   Dwarf_Unsigned *  /*loclist_count_out*/,
1672   Dwarf_Locdesc_c * /*locentry_out*/,
1673   Dwarf_Small    *  /*loclist_source_out*/, /* 0,1, or 2 */
1674   Dwarf_Unsigned *  /*expression_offset_out*/,
1675   Dwarf_Unsigned *  /*locdesc_offset_out*/,
1676   Dwarf_Error    *  /*error*/);
1677
1678int dwarf_get_location_op_value_c(Dwarf_Locdesc_c /*locdesc*/,
1679   Dwarf_Unsigned   /*index*/,
1680   Dwarf_Small    * /*atom_out*/,
1681   Dwarf_Unsigned * /*operand1*/,
1682   Dwarf_Unsigned * /*operand2*/,
1683   Dwarf_Unsigned * /*operand3*/,
1684   Dwarf_Unsigned * /*offset_for_branch*/,
1685   Dwarf_Error*     /*error*/);
1686
1687int dwarf_loclist_from_expr_c(Dwarf_Debug /*dbg*/,
1688    Dwarf_Ptr      /*expression_in*/,
1689    Dwarf_Unsigned /*expression_length*/,
1690    Dwarf_Half     /*address_size*/,
1691    Dwarf_Half     /*offset_size*/,
1692    Dwarf_Small    /*dwarf_version*/,
1693    Dwarf_Loc_Head_c* /*loc_head*/,
1694    Dwarf_Unsigned  * /*listlen*/,
1695    Dwarf_Error     * /*error*/);
1696
1697/* This frees all memory allocated by the applicable
1698    dwarf_get_loclist_c() */
1699void dwarf_loc_head_c_dealloc(Dwarf_Loc_Head_c /*loclist_head*/);
1700
1701/* END: loclist_c interfaces */
1702
1703
1704/*  As of 2015 the preferred interface
1705    is dwarf_get_loclist_c()
1706    and only dwarf_get_loclist_c() will work
1707    for DWARF5 (and also all earlier versions).  */
1708int dwarf_loclist_n(Dwarf_Attribute /*attr*/,
1709    Dwarf_Locdesc*** /*llbuf*/,
1710    Dwarf_Signed *   /*locCount*/,
1711    Dwarf_Error*     /*error*/);
1712
1713/*  The original interfaces.  Please do not use this. */
1714int dwarf_loclist(Dwarf_Attribute /*attr*/,  /* inflexible! */
1715    Dwarf_Locdesc**  /*llbuf*/,
1716    Dwarf_Signed *   /*locCount*/,
1717    Dwarf_Error*     /*error*/);
1718
1719/* Extracts a dwarf expression from an expression byte stream.
1720   Useful to get expressions from DW_CFA_def_cfa_expression
1721   DW_CFA_expression DW_CFA_val_expression expression bytes.
1722   27 April 2009: dwarf_loclist_from_expr() interface with
1723   no addr_size is obsolete but supported,
1724   use dwarf_loclist_from_expr_a() instead.
1725*/
1726int dwarf_loclist_from_expr(Dwarf_Debug /*dbg*/,
1727    Dwarf_Ptr      /* expression_in*/,
1728    Dwarf_Unsigned /* expression_length*/,
1729    Dwarf_Locdesc ** /* llbuf*/,
1730    Dwarf_Signed * /*listlen*/,
1731    Dwarf_Error *  /* error*/ );
1732
1733/*  dwarf_loclist_from_expr_a() new 27 Apr 2009:
1734    added addr_size argument. */
1735int dwarf_loclist_from_expr_a(Dwarf_Debug /*dbg*/,
1736    Dwarf_Ptr      /*expression_in*/,
1737    Dwarf_Unsigned /*expression_length*/,
1738    Dwarf_Half     /*addr_size*/,
1739    Dwarf_Locdesc ** /*llbuf*/,
1740    Dwarf_Signed * /*listlen*/,
1741    Dwarf_Error *  /*error*/);
1742
1743/*  dwarf_loclist_from_expr_b() new 13 Nov 2012:
1744    added dwarf_version (DWARF version number
1745    of the applicable compilation unit)
1746    and offset_size arguments. Added for
1747    DW_OP_GNU_implicit_pointer. */
1748int dwarf_loclist_from_expr_b(Dwarf_Debug /*dbg*/,
1749    Dwarf_Ptr      /*expression_in*/ ,
1750    Dwarf_Unsigned /*expression_length*/ ,
1751    Dwarf_Half     /*addr_size*/ ,
1752    Dwarf_Half     /*offset_size*/ ,
1753    Dwarf_Small    /*dwarf_version*/ ,
1754    Dwarf_Locdesc ** /*llbuf*/ ,
1755    Dwarf_Signed * /*listlen*/ ,
1756    Dwarf_Error *  /*error*/ );
1757
1758int dwarf_lowpc(Dwarf_Die /*die*/,
1759    Dwarf_Addr  *    /*returned_addr*/,
1760    Dwarf_Error*     /*error*/);
1761
1762/*  When the highpc attribute is of class  'constant'
1763    it is not an address, it is an offset from the
1764    base address (such as lowpc) of the function.
1765    This is therefore a required interface for DWARF4
1766    style DW_AT_highpc.  */
1767int dwarf_highpc_b(Dwarf_Die /*die*/,
1768    Dwarf_Addr  *           /*return_value*/,
1769    Dwarf_Half  *           /*return_form*/,
1770    enum Dwarf_Form_Class * /*return_class*/,
1771    Dwarf_Error *           /*error*/);
1772
1773/*  This works for DWARF2 and DWARF3 styles of DW_AT_highpc,
1774    but not for the DWARF4 class constant forms.
1775    If the FORM is of class constant this returns an error */
1776int dwarf_highpc(Dwarf_Die /*die*/,
1777    Dwarf_Addr  *    /*returned_addr*/,
1778    Dwarf_Error*     /*error*/);
1779
1780/*  New January 2016. */
1781int dwarf_dietype_offset(Dwarf_Die /*die*/,
1782    Dwarf_Off   * /*return_off*/,
1783    Dwarf_Error * /*error*/);
1784
1785int dwarf_bytesize(Dwarf_Die /*die*/,
1786    Dwarf_Unsigned * /*returned_size*/,
1787    Dwarf_Error*     /*error*/);
1788
1789int dwarf_bitsize(Dwarf_Die /*die*/,
1790    Dwarf_Unsigned * /*returned_size*/,
1791    Dwarf_Error*     /*error*/);
1792
1793int dwarf_bitoffset(Dwarf_Die /*die*/,
1794    Dwarf_Unsigned * /*returned_offset*/,
1795    Dwarf_Error*     /*error*/);
1796
1797int dwarf_srclang(Dwarf_Die /*die*/,
1798    Dwarf_Unsigned * /*returned_lang*/,
1799    Dwarf_Error*     /*error*/);
1800
1801int dwarf_arrayorder(Dwarf_Die /*die*/,
1802    Dwarf_Unsigned * /*returned_order*/,
1803    Dwarf_Error*     /*error*/);
1804
1805/* end of convenience function list */
1806
1807/* this is the main interface to attributes of a DIE */
1808int dwarf_attrlist(Dwarf_Die /*die*/,
1809    Dwarf_Attribute** /*attrbuf*/,
1810    Dwarf_Signed   * /*attrcount*/,
1811    Dwarf_Error*     /*error*/);
1812
1813/* query operations for attributes */
1814int dwarf_hasform(Dwarf_Attribute /*attr*/,
1815    Dwarf_Half       /*form*/,
1816    Dwarf_Bool *     /*returned_bool*/,
1817    Dwarf_Error*     /*error*/);
1818
1819int dwarf_whatform(Dwarf_Attribute /*attr*/,
1820    Dwarf_Half *     /*returned_final_form*/,
1821    Dwarf_Error*     /*error*/);
1822
1823int dwarf_whatform_direct(Dwarf_Attribute /*attr*/,
1824    Dwarf_Half *     /*returned_initial_form*/,
1825    Dwarf_Error*     /*error*/);
1826
1827int dwarf_whatattr(Dwarf_Attribute /*attr*/,
1828    Dwarf_Half *     /*returned_attr_num*/,
1829    Dwarf_Error*     /*error*/);
1830
1831/*
1832    The following are concerned with the Primary Interface: getting
1833    the actual data values. One function per 'kind' of FORM.
1834*/
1835/*  dwarf_formref returns, thru return_offset, a CU-relative offset
1836    and does not allow DW_FORM_ref_addr*/
1837int dwarf_formref(Dwarf_Attribute /*attr*/,
1838    Dwarf_Off*       /*return_offset*/,
1839    Dwarf_Error*     /*error*/);
1840/*  dwarf_global_formref returns, thru return_offset,
1841    a debug_info-relative offset and does allow all reference forms*/
1842int dwarf_global_formref(Dwarf_Attribute /*attr*/,
1843    Dwarf_Off*       /*return_offset*/,
1844    Dwarf_Error*     /*error*/);
1845
1846/*  dwarf_formsig8 returns in the caller-provided 8 byte area
1847    the 8 bytes of a DW_FORM_ref_sig8.  Not a string.  */
1848int dwarf_formsig8(Dwarf_Attribute /*attr*/,
1849    Dwarf_Sig8 * /*returned sig bytes*/,
1850    Dwarf_Error*     /*error*/);
1851/*  dwarf_formsig8_b returns in the caller-provided 8 byte area
1852    the 8 bytes of a form const (DW_FORM_data8).  Not a string.  */
1853int dwarf_formsig8_const(Dwarf_Attribute /*attr*/,
1854    Dwarf_Sig8 * /*returned sig bytes*/,
1855    Dwarf_Error*     /*error*/);
1856
1857int dwarf_formaddr(Dwarf_Attribute /*attr*/,
1858    Dwarf_Addr   *   /*returned_addr*/,
1859    Dwarf_Error*     /*error*/);
1860
1861/*  Part of DebugFission.  So a consumer can get the index when
1862    the object with the actual .debug_addr section is
1863    elsewhere. And so a print application can
1864    print the index.  New May 2014*/
1865int dwarf_get_debug_addr_index(Dwarf_Attribute /*attr*/,
1866    Dwarf_Unsigned * /*return_index*/,
1867    Dwarf_Error * /*error*/);
1868
1869int dwarf_formflag(Dwarf_Attribute /*attr*/,
1870    Dwarf_Bool *     /*returned_bool*/,
1871    Dwarf_Error*     /*error*/);
1872
1873int dwarf_formudata(Dwarf_Attribute /*attr*/,
1874    Dwarf_Unsigned  * /*returned_val*/,
1875    Dwarf_Error*     /*error*/);
1876
1877int dwarf_formsdata(Dwarf_Attribute     /*attr*/,
1878    Dwarf_Signed  *  /*returned_val*/,
1879    Dwarf_Error*     /*error*/);
1880
1881int dwarf_formblock(Dwarf_Attribute /*attr*/,
1882    Dwarf_Block    ** /*returned_block*/,
1883    Dwarf_Error*     /*error*/);
1884
1885int dwarf_formstring(Dwarf_Attribute /*attr*/,
1886    char   **        /*returned_string*/,
1887    Dwarf_Error*     /*error*/);
1888
1889/* DebugFission.  So a DWARF print application can
1890   get the string index (DW_FORM_strx) and print it.
1891   A convenience function.
1892   New May 2014. */
1893int
1894dwarf_get_debug_str_index(Dwarf_Attribute /*attr*/,
1895    Dwarf_Unsigned * /*return_index*/,
1896    Dwarf_Error * /*error*/);
1897
1898
1899int dwarf_formexprloc(Dwarf_Attribute /*attr*/,
1900    Dwarf_Unsigned * /*return_exprlen*/,
1901    Dwarf_Ptr  * /*block_ptr*/,
1902    Dwarf_Error * /*error*/);
1903
1904
1905/* end attribute query operations. */
1906
1907/* Start line number operations */
1908/* dwarf_srclines  is the original interface from 1993. */
1909int dwarf_srclines(Dwarf_Die /*die*/,
1910    Dwarf_Line**     /*linebuf*/,
1911    Dwarf_Signed *   /*linecount*/,
1912    Dwarf_Error*     /*error*/);
1913
1914
1915/* If we have two-level line tables, this will return the
1916   logicals table in linebuf and the actuals table in
1917   linebuf_actuals. For old-style (one-level) tables, it
1918   will return the single table through linebuf, and the
1919   value returned through linecount_actuals will be 0.
1920   The actual version number is returned through version.
1921   For two-level line tables, the version returned will
1922   be 0xf006. This interface can return data from two-level
1923   line tables, which are experimental.
1924   Most users will not wish to use dwarf_srclines_two_level() */
1925int dwarf_srclines_two_level(Dwarf_Die /*die*/,
1926    Dwarf_Unsigned * /*version*/,
1927    Dwarf_Line**     /*linebuf*/,
1928    Dwarf_Signed *   /*linecount*/,
1929    Dwarf_Line**     /*linebuf_actuals*/,
1930    Dwarf_Signed *   /*linecount_actuals*/,
1931    Dwarf_Error*     /*error*/);
1932
1933/* dwarf_srclines_dealloc, created July 2005, is the
1934   appropriate method for deallocating what dwarf_srclines()
1935   and dwarf_srclines_two_level() return.
1936   More complete free than using dwarf_dealloc directly.
1937
1938   When dwarf_srclines_two_level returns two line tables
1939   user code should call dwarf_srclines_dealloc()
1940   once on each linebuf returned by dwarf_srclines_two_level()
1941   first on linebuf_actuals and then on linebuf{_logicals}.   */
1942
1943void dwarf_srclines_dealloc(Dwarf_Debug /*dbg*/,
1944    Dwarf_Line*       /*linebuf*/,
1945    Dwarf_Signed      /*count */);
1946
1947
1948/*  New October 2015, must be used to deallocating
1949    what is allocated by dwarf_srclines_b() and
1950    dwarf_srclines_from_linecontext()  use.
1951    Works for DWARF2,3,4,5 and for experimental line tables.
1952    New work should use the new Dwarf_Line_Context
1953    interfaces.
1954    This also opens a Dwarf_Line_Context struct which
1955    is used by dwarf_srcfiles_b()
1956    This interface only reads the line table header, so
1957    it takes relatively little time.
1958    *is_single_table will be set non-zero for all standard dwarf line sections.
1959    *is_single_table will be set zero for line sections with the
1960    two_level line table extension (which will have *version_out 0xf006).  */
1961int dwarf_srclines_b(Dwarf_Die /*die*/,
1962    Dwarf_Unsigned     * /* version_out*/,
1963    Dwarf_Small        * /* table_count */,
1964    Dwarf_Line_Context * /* linecontext*/,
1965    Dwarf_Error        * /* error*/);
1966
1967/*  Functions passing in a Dwarf_Line_Context  are only
1968    available if dwarf_srclines_b() was used to access
1969    line table information.  */
1970/*  New October 2015.  Returns line details.
1971    Works for DWARF2,3,4,5.  If linecount
1972    returned is zero this is a line table with no lines.*/
1973int dwarf_srclines_from_linecontext(
1974    Dwarf_Line_Context /*line_context*/,
1975    Dwarf_Line  **   /*linebuf*/,
1976    Dwarf_Signed *   /*linecount*/,
1977    Dwarf_Error  *   /* error*/);
1978
1979/*  New October 2015.  Returns line details.
1980    Works for DWARF2,3,4,5 and for experimental
1981    two-level line tables. A single level table will
1982    have *linebuf_actuals and *linecount_actuals set
1983    to 0. */
1984int dwarf_srclines_two_level_from_linecontext(
1985    Dwarf_Line_Context /*line_context*/,
1986    Dwarf_Line  **   /*linebuf */,
1987    Dwarf_Signed *   /*linecount*/,
1988    Dwarf_Line  **   /*linebuf_actuals*/,
1989    Dwarf_Signed *   /*linecount_actuals*/,
1990    Dwarf_Error  *   /* error*/);
1991
1992/* dwarf_srclines_dealloc_b(), created October 2015, is the
1993   appropriate method for deallocating everything
1994   and dwarf_srclines_from_linecontext(),
1995   dwarf_srclines_twolevel_from_linecontext(),
1996   and dwarf_srclines_b()  allocate.  */
1997void dwarf_srclines_dealloc_b(Dwarf_Line_Context /*line_context*/);
1998
1999/*  New October 2015. */
2000/*    The offset is in the relevent .debug_line or .debug_line.dwo
2001    section (and in a split dwarf package file includes)
2002    the base line table offset). */
2003int dwarf_srclines_table_offset(Dwarf_Line_Context /*line_context*/,
2004    Dwarf_Unsigned * /*offset*/,
2005    Dwarf_Error  * /* error*/);
2006
2007/*  New October 2015. */
2008/*  Compilation Directory name for the current CU.
2009    section (and in a split dwarf package file includes)
2010    the base line table offset).  Do not free() the string,
2011    it is in a dwarf section. */
2012int dwarf_srclines_comp_dir(Dwarf_Line_Context /*line_context*/,
2013    const char ** /*compilation_directory*/,
2014    Dwarf_Error  *  /*error*/);
2015
2016/*  New October 2015.  Part of the two-level line table extension. */
2017/*  Count is the real count of suprogram array entries. */
2018int dwarf_srclines_subprog_count(Dwarf_Line_Context /*line_context*/,
2019    Dwarf_Signed * /*count*/,
2020    Dwarf_Error  * /* error*/);
2021
2022/*  New October 2015. */
2023/*  Index starts with 1, last is 'count' */
2024int dwarf_srclines_subprog_data(Dwarf_Line_Context /*line_context*/,
2025    Dwarf_Signed     /*index*/,
2026    const char **    /*name*/,
2027    Dwarf_Unsigned * /*decl_file*/,
2028    Dwarf_Unsigned * /*decl_line*/,
2029    Dwarf_Error   *  /*error*/);
2030
2031/*  New October 2015. */
2032/*  Count is the real count of files array entries. */
2033int dwarf_srclines_files_count(Dwarf_Line_Context /*line_context*/,
2034    Dwarf_Signed  *  /*count*/,
2035    Dwarf_Error   *  /*error*/);
2036
2037/*  New October 2015. */
2038/*  Unlike dwarf_srcfiles() this returns the raw file table
2039    strings without the directory being prefixed.
2040    Index starts with 1, last is 'count' */
2041int dwarf_srclines_files_data(Dwarf_Line_Context /*line_context*/,
2042    Dwarf_Signed     /*index*/,
2043    const char **    /*name*/,
2044    Dwarf_Unsigned * /*directory_index*/,
2045    Dwarf_Unsigned * /*last_mod_time*/,
2046    Dwarf_Unsigned * /*file_length*/,
2047    Dwarf_Error    * /* error*/);
2048
2049/*  New October 2015. */
2050/*  Count is the real count of include array entries. */
2051int dwarf_srclines_include_dir_count(Dwarf_Line_Context /*line_context*/,
2052    Dwarf_Signed *  /*count*/,
2053    Dwarf_Error  * /* error*/);
2054
2055/*  New October 2015. */
2056/*  Index starts with 1, last is 'count' */
2057int dwarf_srclines_include_dir_data(Dwarf_Line_Context /*line_context*/,
2058    Dwarf_Signed    /*index*/,
2059    const char **   /*name*/,
2060    Dwarf_Error   * /* error*/);
2061
2062/*  New October 2015. */
2063/*  The DWARF version number of this compile-unit
2064    in the .debug_lines section and the number of
2065    actual tables:0 (header with no lines),
2066    1 (standard table), or 2 (experimental). */
2067int dwarf_srclines_version(Dwarf_Line_Context /*line_context*/,
2068    Dwarf_Unsigned * /*version*/,
2069    Dwarf_Small    * /*table_count*/,
2070    Dwarf_Error    * /*error*/);
2071
2072
2073int dwarf_get_line_section_name_from_die(Dwarf_Die /*die*/,
2074    const char ** /*section_name_out*/,
2075    Dwarf_Error * /*error*/);
2076
2077
2078/*  While 'filecount' is signed, the value
2079    returned through the pointer is never negative.
2080    Original libdwarf from 199x.  */
2081int dwarf_srcfiles(Dwarf_Die /*die*/,
2082    char***          /*srcfiles*/,
2083    Dwarf_Signed *   /*filecount*/,
2084    Dwarf_Error*     /*error*/);
2085
2086/*  New October 2015.
2087    Returns the same data as
2088    dwarf_srcfiles, but is based on
2089    a Dwarf_Line_Context created by
2090    dwarf_srclines_b(). Using this avoids
2091    rereading the line table header for this CU. */
2092int dwarf_srcfiles_b(Dwarf_Line_Context /*context*/,
2093    Dwarf_Unsigned *   /*version*/,
2094    char           *** /*srcfiles*/,
2095    Dwarf_Signed   *   /*filecount*/,
2096    Dwarf_Error    *   /*error*/);
2097
2098int dwarf_linebeginstatement(Dwarf_Line /*line*/,
2099    Dwarf_Bool  *    /*returned_bool*/,
2100    Dwarf_Error*     /*error*/);
2101
2102int dwarf_lineendsequence(Dwarf_Line /*line*/,
2103    Dwarf_Bool  *    /*returned_bool*/,
2104    Dwarf_Error*     /*error*/);
2105
2106int dwarf_lineno(Dwarf_Line /*line*/,
2107    Dwarf_Unsigned * /*returned_lineno*/,
2108    Dwarf_Error*     /*error*/);
2109
2110int dwarf_line_srcfileno(Dwarf_Line /*line*/,
2111    Dwarf_Unsigned * /*ret_fileno*/,
2112    Dwarf_Error *    /*error*/);
2113
2114/* Is the line address from DW_LNS_set_address? */
2115int dwarf_line_is_addr_set(Dwarf_Line /*line*/,
2116    Dwarf_Bool *     /*is_addr_set*/,
2117    Dwarf_Error *    /*error*/);
2118
2119int dwarf_lineaddr(Dwarf_Line /*line*/,
2120    Dwarf_Addr *     /*returned_addr*/,
2121    Dwarf_Error*     /*error*/);
2122
2123/* dwarf_lineoff() is OBSOLETE as of December 2011. Do not use. */
2124int dwarf_lineoff(Dwarf_Line /*line*/,
2125    Dwarf_Signed  *  /*returned_lineoffset*/,
2126    Dwarf_Error*     /*error*/);
2127
2128/*  dwarf_lineoff_b() correctly returns an unsigned column number
2129    through the pointer returned_lineoffset.
2130    dwarf_lineoff_b() is new in December 2011.  */
2131int dwarf_lineoff_b(Dwarf_Line /*line*/,
2132    Dwarf_Unsigned * /*returned_lineoffset*/,
2133    Dwarf_Error*     /*error*/);
2134
2135int dwarf_linesrc(Dwarf_Line /*line*/,
2136    char   **        /*returned_name*/,
2137    Dwarf_Error*     /*error*/);
2138
2139int dwarf_lineblock(Dwarf_Line /*line*/,
2140    Dwarf_Bool  *    /*returned_bool*/,
2141    Dwarf_Error*     /*error*/);
2142
2143/* We gather these into one call as it's likely one
2144   will want all or none of them.  */
2145int dwarf_prologue_end_etc(Dwarf_Line /* line */,
2146    Dwarf_Bool  *    /*prologue_end*/,
2147    Dwarf_Bool  *    /*eplogue_begin*/,
2148    Dwarf_Unsigned * /* isa */,
2149    Dwarf_Unsigned * /* discriminator */,
2150    Dwarf_Error *    /*error*/);
2151/* End line table operations */
2152
2153/* Two-level line tables:
2154   When reading from an actuals table, dwarf_line_logical()
2155   returns the logical row number for the line. */
2156int dwarf_linelogical(Dwarf_Line /*line*/,
2157    Dwarf_Unsigned * /*returned_logical*/,
2158    Dwarf_Error*     /*error*/);
2159
2160/* Two-level line tables:
2161   When reading from a logicals table, dwarf_linecontext()
2162   returns the logical row number corresponding the the
2163   calling context for an inlined call. */
2164int dwarf_linecontext(Dwarf_Line /*line*/,
2165    Dwarf_Unsigned * /*returned_context*/,
2166    Dwarf_Error*     /*error*/);
2167
2168/* Two-level line tables:
2169   When reading from a logicals table, dwarf_linesubprogno()
2170   returns the index in the subprograms table of the inlined
2171   subprogram. */
2172int dwarf_line_subprogno(Dwarf_Line /*line*/,
2173    Dwarf_Unsigned * /*ret_subprogno*/,
2174    Dwarf_Error *    /*error*/);
2175
2176/* Two-level line tables:
2177   When reading from a logicals table, dwarf_linesubprog()
2178   returns the name of the inlined subprogram, its declaration
2179   filename, and its declaration line number, if available. */
2180int dwarf_line_subprog(Dwarf_Line /*line*/,
2181    char   **        /*returned_subprog_name*/,
2182    char   **        /*returned_filename*/,
2183    Dwarf_Unsigned * /*returned_lineno*/,
2184    Dwarf_Error *    /*error*/);
2185/* End of line table interfaces. */
2186
2187/* global name space operations (.debug_pubnames access) */
2188int dwarf_get_globals(Dwarf_Debug /*dbg*/,
2189    Dwarf_Global**   /*globals*/,
2190    Dwarf_Signed *   /*number_of_globals*/,
2191    Dwarf_Error*     /*error*/);
2192void dwarf_globals_dealloc(Dwarf_Debug /*dbg*/,
2193    Dwarf_Global*    /*globals*/,
2194    Dwarf_Signed     /*number_of_globals*/);
2195
2196int dwarf_globname(Dwarf_Global /*glob*/,
2197    char   **        /*returned_name*/,
2198    Dwarf_Error*     /*error*/);
2199
2200int dwarf_global_die_offset(Dwarf_Global /*global*/,
2201    Dwarf_Off*       /*return_offset*/,
2202    Dwarf_Error *    /*error*/);
2203
2204/* This returns the CU die global offset if one knows the
2205   CU header global offset.
2206   See also dwarf_CU_dieoffset_given_die(). */
2207int dwarf_get_cu_die_offset_given_cu_header_offset(
2208    Dwarf_Debug      /*dbg*/,
2209    Dwarf_Off        /*in_cu_header_offset*/,
2210    Dwarf_Off *  /*out_cu_die_offset*/,
2211    Dwarf_Error *    /*err*/);
2212
2213/*  The _b form is new October 2011. */
2214int dwarf_get_cu_die_offset_given_cu_header_offset_b(
2215    Dwarf_Debug      /*dbg*/,
2216    Dwarf_Off        /*in_cu_header_offset*/,
2217    Dwarf_Bool       /*is_info. True means look in debug_Info,
2218        false use debug_types.*/,
2219    Dwarf_Off *  /*out_cu_die_offset*/,
2220    Dwarf_Error *    /*err*/);
2221
2222#ifdef __sgi /* pragma is sgi MIPS only */
2223#pragma optional dwarf_get_cu_die_offset_given_cu_header_offset
2224#endif
2225
2226int dwarf_global_cu_offset(Dwarf_Global /*global*/,
2227    Dwarf_Off*       /*return_offset*/,
2228    Dwarf_Error*     /*error*/);
2229
2230int dwarf_global_name_offsets(Dwarf_Global /*global*/,
2231    char   **        /*returned_name*/,
2232    Dwarf_Off*       /*die_offset*/,
2233    Dwarf_Off*       /*cu_offset*/,
2234    Dwarf_Error*     /*error*/);
2235
2236/* Static function name operations.  */
2237int dwarf_get_funcs(Dwarf_Debug    /*dbg*/,
2238    Dwarf_Func**     /*funcs*/,
2239    Dwarf_Signed *   /*number_of_funcs*/,
2240    Dwarf_Error*     /*error*/);
2241void dwarf_funcs_dealloc(Dwarf_Debug /*dbg*/,
2242    Dwarf_Func*      /*funcs*/,
2243    Dwarf_Signed     /*number_of_funcs*/);
2244
2245int dwarf_funcname(Dwarf_Func /*func*/,
2246    char   **        /*returned_name*/,
2247    Dwarf_Error*     /*error*/);
2248
2249int dwarf_func_die_offset(Dwarf_Func /*func*/,
2250    Dwarf_Off*       /*return_offset*/,
2251    Dwarf_Error*     /*error*/);
2252
2253int dwarf_func_cu_offset(Dwarf_Func /*func*/,
2254    Dwarf_Off*       /*return_offset*/,
2255    Dwarf_Error*     /*error*/);
2256
2257int dwarf_func_name_offsets(Dwarf_Func /*func*/,
2258    char   **        /*returned_name*/,
2259    Dwarf_Off*       /*die_offset*/,
2260    Dwarf_Off*       /*cu_offset*/,
2261    Dwarf_Error*     /*error*/);
2262
2263/* User-defined type name operations, SGI IRIX .debug_typenames section.
2264   Same content as DWARF3 .debug_pubtypes, but defined years before
2265   .debug_pubtypes was defined.   SGI IRIX only. */
2266int dwarf_get_types(Dwarf_Debug    /*dbg*/,
2267    Dwarf_Type**     /*types*/,
2268    Dwarf_Signed *   /*number_of_types*/,
2269    Dwarf_Error*     /*error*/);
2270void dwarf_types_dealloc(Dwarf_Debug /*dbg*/,
2271    Dwarf_Type*      /*types*/,
2272    Dwarf_Signed     /*number_of_types*/);
2273
2274
2275int dwarf_typename(Dwarf_Type /*type*/,
2276    char   **        /*returned_name*/,
2277    Dwarf_Error*     /*error*/);
2278
2279int dwarf_type_die_offset(Dwarf_Type /*type*/,
2280    Dwarf_Off*       /*return_offset*/,
2281    Dwarf_Error*     /*error*/);
2282
2283int dwarf_type_cu_offset(Dwarf_Type /*type*/,
2284    Dwarf_Off*       /*return_offset*/,
2285    Dwarf_Error*     /*error*/);
2286
2287int dwarf_type_name_offsets(Dwarf_Type    /*type*/,
2288    char   **        /*returned_name*/,
2289    Dwarf_Off*       /*die_offset*/,
2290    Dwarf_Off*       /*cu_offset*/,
2291    Dwarf_Error*     /*error*/);
2292
2293/* User-defined type name operations, DWARF3  .debug_pubtypes section.
2294*/
2295int dwarf_get_pubtypes(Dwarf_Debug    /*dbg*/,
2296    Dwarf_Type**     /*types*/,
2297    Dwarf_Signed *   /*number_of_types*/,
2298    Dwarf_Error*     /*error*/);
2299void dwarf_pubtypes_dealloc(Dwarf_Debug /*dbg*/,
2300    Dwarf_Type*      /*pubtypes*/,
2301    Dwarf_Signed     /*number_of_pubtypes*/);
2302
2303
2304int dwarf_pubtypename(Dwarf_Type /*type*/,
2305    char   **        /*returned_name*/,
2306    Dwarf_Error*     /*error*/);
2307
2308int dwarf_pubtype_type_die_offset(Dwarf_Type /*type*/,
2309    Dwarf_Off*       /*return_offset*/,
2310    Dwarf_Error*     /*error*/);
2311
2312int dwarf_pubtype_cu_offset(Dwarf_Type /*type*/,
2313    Dwarf_Off*       /*return_offset*/,
2314    Dwarf_Error*     /*error*/);
2315
2316int dwarf_pubtype_name_offsets(Dwarf_Type    /*type*/,
2317    char   **        /*returned_name*/,
2318    Dwarf_Off*       /*die_offset*/,
2319    Dwarf_Off*       /*cu_offset*/,
2320    Dwarf_Error*     /*error*/);
2321
2322/* File-scope static variable name operations.  */
2323int dwarf_get_vars(Dwarf_Debug    /*dbg*/,
2324    Dwarf_Var**      /*vars*/,
2325    Dwarf_Signed *   /*number_of_vars*/,
2326    Dwarf_Error*     /*error*/);
2327void dwarf_vars_dealloc(Dwarf_Debug /*dbg*/,
2328    Dwarf_Var*       /*vars*/,
2329    Dwarf_Signed     /*number_of_vars*/);
2330
2331
2332int dwarf_varname(Dwarf_Var /*var*/,
2333    char   **        /*returned_name*/,
2334    Dwarf_Error*     /*error*/);
2335
2336int dwarf_var_die_offset(Dwarf_Var /*var*/,
2337    Dwarf_Off*       /*return_offset*/,
2338    Dwarf_Error*     /*error*/);
2339
2340int dwarf_var_cu_offset(Dwarf_Var /*var*/,
2341    Dwarf_Off*       /*return_offset*/,
2342    Dwarf_Error*     /*error*/);
2343
2344int dwarf_var_name_offsets(Dwarf_Var /*var*/,
2345    char   **        /*returned_name*/,
2346    Dwarf_Off*       /*die_offset*/,
2347    Dwarf_Off*       /*cu_offset*/,
2348    Dwarf_Error*     /*error*/);
2349
2350/* weak name operations.  */
2351int dwarf_get_weaks(Dwarf_Debug    /*dbg*/,
2352    Dwarf_Weak**     /*weaks*/,
2353    Dwarf_Signed *   /*number_of_weaks*/,
2354    Dwarf_Error*     /*error*/);
2355void dwarf_weaks_dealloc(Dwarf_Debug /*dbg*/,
2356    Dwarf_Weak*      /*weaks*/,
2357    Dwarf_Signed     /*number_of_weaks*/);
2358
2359
2360int dwarf_weakname(Dwarf_Weak /*weak*/,
2361    char   **        /*returned_name*/,
2362    Dwarf_Error*     /*error*/);
2363
2364int dwarf_weak_die_offset(Dwarf_Weak /*weak*/,
2365    Dwarf_Off*       /*return_offset*/,
2366    Dwarf_Error*     /*error*/);
2367
2368int dwarf_weak_cu_offset(Dwarf_Weak /*weak*/,
2369    Dwarf_Off*       /*return_offset*/,
2370    Dwarf_Error*     /*error*/);
2371
2372int dwarf_weak_name_offsets(Dwarf_Weak    /*weak*/,
2373    char   **        /*returned_name*/,
2374    Dwarf_Off*       /*die_offset*/,
2375    Dwarf_Off*       /*cu_offset*/,
2376    Dwarf_Error*     /*error*/);
2377
2378/* location list section operation.  (.debug_loc access) */
2379int dwarf_get_loclist_entry(Dwarf_Debug /*dbg*/,
2380    Dwarf_Unsigned   /*offset*/,
2381    Dwarf_Addr*      /*hipc*/,
2382    Dwarf_Addr*      /*lopc*/,
2383    Dwarf_Ptr*       /*data*/,
2384    Dwarf_Unsigned*  /*entry_len*/,
2385    Dwarf_Unsigned*  /*next_entry*/,
2386    Dwarf_Error*     /*error*/);
2387
2388/* abbreviation section operations */
2389int dwarf_get_abbrev(Dwarf_Debug /*dbg*/,
2390    Dwarf_Unsigned   /*offset*/,
2391    Dwarf_Abbrev  *  /*returned_abbrev*/,
2392    Dwarf_Unsigned*  /*length*/,
2393    Dwarf_Unsigned*  /*attr_count*/,
2394    Dwarf_Error*     /*error*/);
2395
2396int dwarf_get_abbrev_tag(Dwarf_Abbrev /*abbrev*/,
2397    Dwarf_Half*      /*return_tag_number*/,
2398    Dwarf_Error*     /*error*/);
2399int dwarf_get_abbrev_code(Dwarf_Abbrev /*abbrev*/,
2400    Dwarf_Unsigned*  /*return_code_number*/,
2401    Dwarf_Error*     /*error*/);
2402/* See comments in dwarf_abbrev.c. Not an entirely safe function. */
2403int dwarf_get_abbrev_count(Dwarf_Debug /*dbg*/);
2404
2405int dwarf_get_abbrev_children_flag(Dwarf_Abbrev /*abbrev*/,
2406    Dwarf_Signed*    /*return_flag*/,
2407    Dwarf_Error*     /*error*/);
2408
2409int dwarf_get_abbrev_entry(Dwarf_Abbrev /*abbrev*/,
2410    Dwarf_Signed     /*index*/,
2411    Dwarf_Half  *    /*returned_attr_num*/,
2412    Dwarf_Signed*    /*form*/,
2413    Dwarf_Off*       /*offset*/,
2414    Dwarf_Error*     /*error*/);
2415
2416int dwarf_get_string_section_name(Dwarf_Debug /*dbg*/,
2417    const char ** /*section_name_out*/,
2418    Dwarf_Error * /*error*/);
2419
2420/* consumer string section operation */
2421int dwarf_get_str(Dwarf_Debug /*dbg*/,
2422    Dwarf_Off        /*offset*/,
2423    char**           /*string*/,
2424    Dwarf_Signed *   /*strlen_of_string*/,
2425    Dwarf_Error*     /*error*/);
2426
2427/* New November 2015 */
2428int dwarf_get_frame_section_name(Dwarf_Debug /*dbg*/,
2429   const char ** /*section_name_out*/,
2430   Dwarf_Error * /*error*/);
2431
2432/* New November 2015 */
2433int dwarf_get_frame_section_name_eh_gnu(Dwarf_Debug /*dbg*/,
2434   const char ** /*section_name_out*/,
2435   Dwarf_Error * /*error*/);
2436
2437/* Consumer op on  gnu .eh_frame info */
2438int dwarf_get_fde_list_eh(
2439    Dwarf_Debug      /*dbg*/,
2440    Dwarf_Cie**      /*cie_data*/,
2441    Dwarf_Signed*    /*cie_element_count*/,
2442    Dwarf_Fde**      /*fde_data*/,
2443    Dwarf_Signed*    /*fde_element_count*/,
2444    Dwarf_Error*     /*error*/);
2445
2446
2447/* consumer operations on frame info: .debug_frame */
2448int dwarf_get_fde_list(Dwarf_Debug /*dbg*/,
2449    Dwarf_Cie**      /*cie_data*/,
2450    Dwarf_Signed*    /*cie_element_count*/,
2451    Dwarf_Fde**      /*fde_data*/,
2452    Dwarf_Signed*    /*fde_element_count*/,
2453    Dwarf_Error*     /*error*/);
2454
2455/* Release storage gotten by dwarf_get_fde_list_eh() or
2456   dwarf_get_fde_list() */
2457void dwarf_fde_cie_list_dealloc(Dwarf_Debug /*dbg*/,
2458    Dwarf_Cie *  /*cie_data*/,
2459    Dwarf_Signed /*cie_element_count*/,
2460    Dwarf_Fde *  /*fde_data*/,
2461    Dwarf_Signed /*fde_element_count*/);
2462
2463
2464
2465int dwarf_get_fde_range(Dwarf_Fde /*fde*/,
2466    Dwarf_Addr*      /*low_pc*/,
2467    Dwarf_Unsigned*  /*func_length*/,
2468    Dwarf_Ptr*       /*fde_bytes*/,
2469    Dwarf_Unsigned*  /*fde_byte_length*/,
2470    Dwarf_Off*       /*cie_offset*/,
2471    Dwarf_Signed*    /*cie_index*/,
2472    Dwarf_Off*       /*fde_offset*/,
2473    Dwarf_Error*     /*error*/);
2474
2475/*  Useful for IRIX only:  see dwarf_get_cie_augmentation_data()
2476    dwarf_get_fde_augmentation_data() for GNU .eh_frame. */
2477int dwarf_get_fde_exception_info(Dwarf_Fde /*fde*/,
2478    Dwarf_Signed*    /* offset_into_exception_tables */,
2479    Dwarf_Error*     /*error*/);
2480
2481
2482int dwarf_get_cie_of_fde(Dwarf_Fde /*fde*/,
2483    Dwarf_Cie *      /*cie_returned*/,
2484    Dwarf_Error*     /*error*/);
2485
2486int dwarf_get_cie_info_b(Dwarf_Cie /*cie*/,
2487    Dwarf_Unsigned * /*bytes_in_cie*/,
2488    Dwarf_Small*     /*version*/,
2489    char        **   /*augmenter*/,
2490    Dwarf_Unsigned*  /*code_alignment_factor*/,
2491    Dwarf_Signed*    /*data_alignment_factor*/,
2492    Dwarf_Half*      /*return_address_register_rule*/,
2493    Dwarf_Ptr*       /*initial_instructions*/,
2494    Dwarf_Unsigned*  /*initial_instructions_length*/,
2495    Dwarf_Half*      /*offset_size*/,
2496    Dwarf_Error*     /*error*/);
2497int dwarf_get_cie_info(Dwarf_Cie /*cie*/,
2498    Dwarf_Unsigned * /*bytes_in_cie*/,
2499    Dwarf_Small*     /*version*/,
2500    char        **   /*augmenter*/,
2501    Dwarf_Unsigned*  /*code_alignment_factor*/,
2502    Dwarf_Signed*    /*data_alignment_factor*/,
2503    Dwarf_Half*      /*return_address_register_rule*/,
2504    Dwarf_Ptr*       /*initial_instructions*/,
2505    Dwarf_Unsigned*  /*initial_instructions_length*/,
2506    Dwarf_Error*     /*error*/);
2507
2508/* dwarf_get_cie_index new September 2009. */
2509int dwarf_get_cie_index(
2510    Dwarf_Cie /*cie*/,
2511    Dwarf_Signed* /*index*/,
2512    Dwarf_Error* /*error*/ );
2513
2514
2515int dwarf_get_fde_instr_bytes(Dwarf_Fde /*fde*/,
2516    Dwarf_Ptr *      /*outinstrs*/, Dwarf_Unsigned * /*outlen*/,
2517    Dwarf_Error *    /*error*/);
2518
2519int dwarf_get_fde_info_for_all_regs(Dwarf_Fde /*fde*/,
2520    Dwarf_Addr       /*pc_requested*/,
2521    Dwarf_Regtable*  /*reg_table*/,
2522    Dwarf_Addr*      /*row_pc*/,
2523    Dwarf_Error*     /*error*/);
2524
2525int dwarf_get_fde_info_for_all_regs3(Dwarf_Fde /*fde*/,
2526    Dwarf_Addr       /*pc_requested*/,
2527    Dwarf_Regtable3* /*reg_table*/,
2528    Dwarf_Addr*      /*row_pc*/,
2529    Dwarf_Error*     /*error*/);
2530
2531/* In this older interface DW_FRAME_CFA_COL is a meaningful
2532    column (which does not work well with DWARF3 or
2533    non-MIPS architectures). */
2534int dwarf_get_fde_info_for_reg(Dwarf_Fde /*fde*/,
2535    Dwarf_Half       /*table_column*/,
2536    Dwarf_Addr       /*pc_requested*/,
2537    Dwarf_Signed*    /*offset_relevant*/,
2538    Dwarf_Signed*    /*register*/,
2539    Dwarf_Signed*    /*offset*/,
2540    Dwarf_Addr*      /*row_pc*/,
2541    Dwarf_Error*     /*error*/);
2542
2543/* See discussion of dw_value_type, libdwarf.h.
2544   Use of DW_FRAME_CFA_COL is not meaningful in this interface.
2545   See dwarf_get_fde_info_for_cfa_reg3().
2546*/
2547/* dwarf_get_fde_info_for_reg3 is useful on a single column, but
2548   it is inefficient to iterate across all table_columns using this
2549   function.  Instead call dwarf_get_fde_info_for_all_regs3() and index
2550   into the table it fills in. */
2551int dwarf_get_fde_info_for_reg3(Dwarf_Fde /*fde*/,
2552    Dwarf_Half       /*table_column*/,
2553    Dwarf_Addr       /*pc_requested*/,
2554    Dwarf_Small  *   /*value_type*/,
2555    Dwarf_Signed *   /*offset_relevant*/,
2556    Dwarf_Signed*    /*register*/,
2557    Dwarf_Signed*    /*offset_or_block_len*/,
2558    Dwarf_Ptr   *    /*block_ptr */,
2559    Dwarf_Addr*      /*row_pc_out*/,
2560    Dwarf_Error*     /*error*/);
2561
2562/*  Use this or the next function to get the cfa.
2563    New function, June 11, 2016*/
2564int dwarf_get_fde_info_for_cfa_reg3_b(Dwarf_Fde /*fde*/,
2565    Dwarf_Addr       /*pc_requested*/,
2566    Dwarf_Small  *   /*value_type*/,
2567    Dwarf_Signed *   /*offset_relevant*/,
2568    Dwarf_Signed*    /*register*/,
2569    Dwarf_Signed*    /*offset_or_block_len*/,
2570    Dwarf_Ptr   *    /*block_ptr */,
2571    Dwarf_Addr*      /*row_pc_out*/,
2572    Dwarf_Bool  *    /* has_more_rows */,
2573    Dwarf_Addr  *    /* subsequent_pc */,
2574    Dwarf_Error*     /*error*/);
2575/* Use this to get the cfa. Or the above function. */
2576int dwarf_get_fde_info_for_cfa_reg3(Dwarf_Fde /*fde*/,
2577    Dwarf_Addr       /*pc_requested*/,
2578    Dwarf_Small  *   /*value_type*/,
2579    Dwarf_Signed *   /*offset_relevant*/,
2580    Dwarf_Signed*    /*register*/,
2581    Dwarf_Signed*    /*offset_or_block_len*/,
2582    Dwarf_Ptr   *    /*block_ptr */,
2583    Dwarf_Addr*      /*row_pc_out*/,
2584    Dwarf_Error*     /*error*/);
2585
2586int dwarf_get_fde_for_die(Dwarf_Debug /*dbg*/,
2587    Dwarf_Die        /*subr_die */,
2588    Dwarf_Fde  *     /*returned_fde*/,
2589    Dwarf_Error*     /*error*/);
2590
2591int dwarf_get_fde_n(Dwarf_Fde* /*fde_data*/,
2592    Dwarf_Unsigned   /*fde_index*/,
2593    Dwarf_Fde  *     /*returned_fde*/,
2594    Dwarf_Error*     /*error*/);
2595
2596int dwarf_get_fde_at_pc(Dwarf_Fde* /*fde_data*/,
2597    Dwarf_Addr       /*pc_of_interest*/,
2598    Dwarf_Fde  *     /*returned_fde*/,
2599    Dwarf_Addr*      /*lopc*/,
2600    Dwarf_Addr*      /*hipc*/,
2601    Dwarf_Error*     /*error*/);
2602
2603/* GNU .eh_frame augmentation information, raw form, see
2604   Linux Standard Base Core Specification version 3.0 . */
2605int dwarf_get_cie_augmentation_data(Dwarf_Cie /* cie*/,
2606    Dwarf_Small **   /* augdata */,
2607    Dwarf_Unsigned * /* augdata_len */,
2608    Dwarf_Error*     /*error*/);
2609/* GNU .eh_frame augmentation information, raw form, see
2610   Linux Standard Base Core Specification version 3.0 . */
2611int dwarf_get_fde_augmentation_data(Dwarf_Fde /* fde*/,
2612    Dwarf_Small **   /* augdata */,
2613    Dwarf_Unsigned * /* augdata_len */,
2614    Dwarf_Error*     /*error*/);
2615
2616int dwarf_expand_frame_instructions(Dwarf_Cie /*cie*/,
2617    Dwarf_Ptr        /*instruction*/,
2618    Dwarf_Unsigned   /*i_length*/,
2619    Dwarf_Frame_Op** /*returned_op_list*/,
2620    Dwarf_Signed*    /*op_count*/,
2621    Dwarf_Error*     /*error*/);
2622
2623/* Operations on .debug_aranges. */
2624int dwarf_get_aranges(Dwarf_Debug /*dbg*/,
2625    Dwarf_Arange**   /*aranges*/,
2626    Dwarf_Signed *   /*arange_count*/,
2627    Dwarf_Error*     /*error*/);
2628
2629int dwarf_get_ranges_section_name(Dwarf_Debug /*dbg*/,
2630    const char ** /*section_name_out*/,
2631    Dwarf_Error * /*error*/);
2632
2633int dwarf_get_aranges_section_name(Dwarf_Debug /*dbg*/,
2634    const char ** /*section_name_out*/,
2635    Dwarf_Error * /*error*/);
2636
2637
2638
2639int dwarf_get_arange(
2640    Dwarf_Arange*    /*aranges*/,
2641    Dwarf_Unsigned   /*arange_count*/,
2642    Dwarf_Addr       /*address*/,
2643    Dwarf_Arange *   /*returned_arange*/,
2644    Dwarf_Error*     /*error*/);
2645
2646int dwarf_get_cu_die_offset(
2647    Dwarf_Arange     /*arange*/,
2648    Dwarf_Off*       /*return_offset*/,
2649    Dwarf_Error*     /*error*/);
2650
2651int dwarf_get_arange_cu_header_offset(
2652    Dwarf_Arange     /*arange*/,
2653    Dwarf_Off*       /*return_cu_header_offset*/,
2654    Dwarf_Error*     /*error*/);
2655#ifdef __sgi /* pragma is sgi MIPS only */
2656#pragma optional dwarf_get_arange_cu_header_offset
2657#endif
2658
2659/* DWARF2,3 interface. No longer really adequate (it was never
2660   right for segmented address spaces, please switch
2661   to using dwarf_get_arange_info_b instead.
2662   There is no effective difference between these
2663   functions  if the address space
2664   of the target is not segmented.  */
2665int dwarf_get_arange_info(
2666    Dwarf_Arange     /*arange*/,
2667    Dwarf_Addr*      /*start*/,
2668    Dwarf_Unsigned*  /*length*/,
2669    Dwarf_Off*       /*cu_die_offset*/,
2670    Dwarf_Error*     /*error*/ );
2671
2672/* New for DWARF4, entries may have segment information.
2673   *segment is only meaningful if *segment_entry_size is non-zero. */
2674int dwarf_get_arange_info_b(
2675    Dwarf_Arange     /*arange*/,
2676    Dwarf_Unsigned*  /*segment*/,
2677    Dwarf_Unsigned*  /*segment_entry_size*/,
2678    Dwarf_Addr    *  /*start*/,
2679    Dwarf_Unsigned*  /*length*/,
2680    Dwarf_Off     *  /*cu_die_offset*/,
2681    Dwarf_Error   *  /*error*/ );
2682
2683/*  BEGIN: DWARF5 .debug_macro  interfaces
2684    NEW November 2015.  */
2685int dwarf_get_macro_context(Dwarf_Die /*die*/,
2686    Dwarf_Unsigned      * /*version_out*/,
2687    Dwarf_Macro_Context * /*macro_context*/,
2688    Dwarf_Unsigned      * /*macro_unit_offset_out*/,
2689    Dwarf_Unsigned      * /*macro_ops_count_out*/,
2690    Dwarf_Unsigned      * /*macro_ops_data_length_out*/,
2691    Dwarf_Error         * /*error*/);
2692
2693/*  Just like dwarf_get_macro_context, but instead of using
2694    DW_AT_macros or DW_AT_GNU_macros to get the offset we just
2695    take the offset given. */
2696int dwarf_get_macro_context_by_offset(Dwarf_Die /*die*/,
2697    Dwarf_Unsigned        /*offset*/,
2698    Dwarf_Unsigned      * /*version_out*/,
2699    Dwarf_Macro_Context * /*macro_context*/,
2700    Dwarf_Unsigned      * /*macro_ops_count_out*/,
2701    Dwarf_Unsigned      * /*macro_ops_data_length*/,
2702    Dwarf_Error         * /*error*/);
2703
2704void dwarf_dealloc_macro_context(Dwarf_Macro_Context /*mc*/);
2705int dwarf_get_macro_section_name(Dwarf_Debug /*dbg*/,
2706    const char ** /*sec_name_out*/,
2707    Dwarf_Error * /*err*/);
2708
2709int dwarf_macro_context_head(Dwarf_Macro_Context /*head*/,
2710    Dwarf_Half     * /*version*/,
2711    Dwarf_Unsigned * /*mac_offset*/,
2712    Dwarf_Unsigned * /*mac_len*/,
2713    Dwarf_Unsigned * /*mac_header_len*/,
2714    unsigned       * /*flags*/,
2715    Dwarf_Bool     * /*has_line_offset*/,
2716    Dwarf_Unsigned * /*line_offset*/,
2717    Dwarf_Bool     * /*has_offset_size_64*/,
2718    Dwarf_Bool     * /*has_operands_table*/,
2719    Dwarf_Half     * /*opcode_count*/,
2720    Dwarf_Error    * /*error*/);
2721
2722/*  Returns data from the operands table
2723    in the macro unit header. */
2724int dwarf_macro_operands_table(Dwarf_Macro_Context /*head*/,
2725    Dwarf_Half    /*index*/, /* 0 to opcode_count -1 */
2726    Dwarf_Half  * /*opcode_number*/,
2727    Dwarf_Half  * /*operand_count*/,
2728    const Dwarf_Small ** /*operand_array*/,
2729    Dwarf_Error * /*error*/);
2730
2731/*  Access to the macro operations, 0 to macro_ops_count_out-1
2732    Where the last of these will have macro_operator 0 (which appears
2733    in the ops data and means end-of-ops).
2734    op_start_section_offset is the section offset of
2735    the macro operator (which is a single unsigned byte,
2736    and is followed by the macro operand data). */
2737int dwarf_get_macro_op(Dwarf_Macro_Context /*macro_context*/,
2738    Dwarf_Unsigned   /*op_number*/,
2739    Dwarf_Unsigned * /*op_start_section_offset*/,
2740    Dwarf_Half     * /*macro_operator*/,
2741    Dwarf_Half     * /*forms_count*/,
2742    const Dwarf_Small **  /*formcode_array*/,
2743    Dwarf_Error    * /*error*/);
2744
2745int dwarf_get_macro_defundef(Dwarf_Macro_Context /*macro_context*/,
2746    Dwarf_Unsigned   /*op_number*/,
2747    Dwarf_Unsigned * /*line_number*/,
2748    Dwarf_Unsigned * /*index*/,
2749    Dwarf_Unsigned * /*offset*/,
2750    Dwarf_Half     * /*forms_count*/,
2751    const char    ** /*macro_string*/,
2752    Dwarf_Error    * /*error*/);
2753int dwarf_get_macro_startend_file(Dwarf_Macro_Context /*macro_context*/,
2754    Dwarf_Unsigned   /*op_number*/,
2755    Dwarf_Unsigned * /*line_number*/,
2756    Dwarf_Unsigned * /*name_index_to_line_tab*/,
2757    const char    ** /*src_file_name*/,
2758    Dwarf_Error    * /*error*/);
2759int dwarf_get_macro_import(Dwarf_Macro_Context /*macro_context*/,
2760    Dwarf_Unsigned   /*op_number*/,
2761    Dwarf_Unsigned * /*target_offset*/,
2762    Dwarf_Error    * /*error*/);
2763
2764/*  END: DWARF5 .debug_macro interfaces. */
2765
2766/* consumer .debug_macinfo information interface.
2767*/
2768struct Dwarf_Macro_Details_s {
2769    Dwarf_Off    dmd_offset; /* offset, in the section,
2770        of this macro info */
2771    Dwarf_Small  dmd_type;   /* the type, DW_MACINFO_define etc*/
2772    Dwarf_Signed dmd_lineno; /* the source line number where
2773        applicable and vend_def number if
2774        vendor_extension op */
2775
2776    Dwarf_Signed dmd_fileindex;/* the source file index:
2777        applies to define undef start_file */
2778    char *       dmd_macro;  /* macro name (with value for defineop)
2779        string from vendor ext */
2780};
2781
2782/*  dwarf_print_lines is for use by dwarfdump: it prints
2783    line info to stdout.
2784    The _dwarf name is obsolete. Use dwarf_ instead.
2785    Added extra argnument 2/2009 for better checking.
2786*/
2787int _dwarf_print_lines(Dwarf_Die /*cu_die*/,Dwarf_Error * /*error*/);
2788int dwarf_print_lines(Dwarf_Die /*cu_die*/,Dwarf_Error * /*error*/,
2789   int * /*error_count_out */);
2790
2791/*  As of August 2013, dwarf_print_lines() no longer uses printf.
2792    Instead it calls back to the application using a function pointer
2793    once per line-to-print.  The lines passed back already have any needed
2794    newlines.    The following struct is used to initialize
2795    the callback mechanism.
2796
2797    Failing to call the dwarf_register_printf_callback() function will
2798    prevent the lines from being passed back but such omission
2799    is not an error.
2800    See libdwarf2.1.mm for further documentation.
2801
2802    The return value is the previous set of callback values.
2803*/
2804
2805typedef void (* dwarf_printf_callback_function_type)
2806    (void * /*user_pointer*/, const char * /*linecontent*/);
2807
2808struct Dwarf_Printf_Callback_Info_s {
2809    void *                        dp_user_pointer;
2810    dwarf_printf_callback_function_type dp_fptr;
2811    char *                        dp_buffer;
2812    unsigned int                  dp_buffer_len;
2813    int                           dp_buffer_user_provided;
2814    void *                        dp_reserved;
2815};
2816
2817/*  If called with a NULL newvalues pointer, it simply returns
2818    the current set of values for this Dwarf_Debug. */
2819struct  Dwarf_Printf_Callback_Info_s
2820dwarf_register_printf_callback(Dwarf_Debug /*dbg*/,
2821    struct  Dwarf_Printf_Callback_Info_s * /*newvalues*/);
2822
2823
2824/*  dwarf_check_lineheader lets dwarfdump get detailed messages
2825    about some compiler errors we detect.
2826    We return the count of detected errors through the
2827    pointer.
2828*/
2829void dwarf_check_lineheader(Dwarf_Die /*cu_die*/,int *errcount_out);
2830
2831/*  dwarf_ld_sort_lines helps SGI IRIX ld
2832    rearrange lines in .debug_line in a .o created with a text
2833    section per function.
2834        -OPT:procedure_reorder=ON
2835    where ld-cord (cord(1)ing by ld,
2836    not by cord(1)) may have changed the function order.
2837    The _dwarf name is obsolete. Use dwarf_ instead.
2838*/
2839int _dwarf_ld_sort_lines(
2840    void *         /*orig_buffer*/,
2841    unsigned long  /* buffer_len*/,
2842    int            /*is_64_bit*/,
2843    int *          /*any_change*/,
2844    int *          /*err_code*/);
2845int dwarf_ld_sort_lines(
2846    void *         /*orig_buffer*/,
2847    unsigned long  /*buffer_len*/,
2848    int            /*is_64_bit*/,
2849    int *          /*any_change*/,
2850    int *          /*err_code*/);
2851
2852/* Used by dwarfdump -v to print fde offsets from debugging
2853   info.
2854   The _dwarf name is obsolete. Use dwarf_ instead.
2855*/
2856int _dwarf_fde_section_offset(Dwarf_Debug /*dbg*/,
2857    Dwarf_Fde         /*in_fde*/,
2858    Dwarf_Off *       /*fde_off*/,
2859    Dwarf_Off *       /*cie_off*/,
2860    Dwarf_Error *     /*err*/);
2861
2862int dwarf_fde_section_offset(Dwarf_Debug /*dbg*/,
2863    Dwarf_Fde         /*in_fde*/,
2864    Dwarf_Off *       /*fde_off*/,
2865    Dwarf_Off *       /*cie_off*/,
2866    Dwarf_Error *     /*err*/);
2867
2868/* Used by dwarfdump -v to print cie offsets from debugging
2869   info.
2870   The _dwarf name is obsolete. Use dwarf_ instead.
2871*/
2872int dwarf_cie_section_offset(Dwarf_Debug /*dbg*/,
2873    Dwarf_Cie     /*in_cie*/,
2874    Dwarf_Off *   /*cie_off */,
2875    Dwarf_Error * /*err*/);
2876int _dwarf_cie_section_offset(Dwarf_Debug /*dbg*/,
2877    Dwarf_Cie     /*in_cie*/,
2878    Dwarf_Off *   /*cie_off*/,
2879    Dwarf_Error * /*err*/);
2880
2881typedef struct Dwarf_Macro_Details_s Dwarf_Macro_Details;
2882
2883int dwarf_get_macro(Dwarf_Debug /*dbg*/,
2884    char *        /*requested_macro_name*/,
2885    Dwarf_Addr    /*pc_of_request*/,
2886    char **       /*returned_macro_value*/,
2887    Dwarf_Error * /*error*/);
2888
2889int dwarf_get_all_defined_macros(Dwarf_Debug /*dbg*/,
2890    Dwarf_Addr     /*pc_of_request*/,
2891    Dwarf_Signed * /*returned_count*/,
2892    char ***       /*returned_pointers_to_macros*/,
2893    Dwarf_Error *  /*error*/);
2894
2895char *dwarf_find_macro_value_start(char * /*macro_string*/);
2896
2897int dwarf_get_macro_details(Dwarf_Debug /*dbg*/,
2898    Dwarf_Off            /*macro_offset*/,
2899    Dwarf_Unsigned       /*maximum_count*/,
2900    Dwarf_Signed         * /*entry_count*/,
2901    Dwarf_Macro_Details ** /*details*/,
2902    Dwarf_Error *        /*err*/);
2903
2904
2905/*  dwarf_get_offset_size() New October 2015 */
2906int dwarf_get_offset_size(Dwarf_Debug /*dbg*/,
2907    Dwarf_Half  *    /*offset_size*/,
2908    Dwarf_Error *    /*error*/);
2909int dwarf_get_address_size(Dwarf_Debug /*dbg*/,
2910    Dwarf_Half  *    /*addr_size*/,
2911    Dwarf_Error *    /*error*/);
2912int dwarf_get_die_address_size(Dwarf_Die /*die*/,
2913    Dwarf_Half  *    /*addr_size*/,
2914    Dwarf_Error *    /*error*/);
2915
2916enum Dwarf_Form_Class dwarf_get_form_class(
2917    Dwarf_Half /* dwversion */,
2918    Dwarf_Half /* attrnum */,
2919    Dwarf_Half /*offset_size */,
2920    Dwarf_Half /*form*/);
2921
2922
2923/*   BEGIN gdbindex operations interfaces. */
2924/*  .gdb_index section operations.
2925    A GDB extension.
2926    The section is in some executables and if present
2927    is used to quickly map an address or name to
2928    a skeleton CU or TU.  If present then there are
2929    .dwo or .dwp files somewhere to make detailed
2930    debugging possible (up to user code to
2931    find it/them and deal with them).
2932
2933    Version 8 built by gdb, so type entries are ok as is.
2934    Version 7 built by the 'gold' linker and type index
2935    entries for a CU must be derived othewise, the
2936    type index is not correct... ? FIXME
2937    */
2938
2939/*  Creates a Dwarf_Gdbindex, returning it and
2940    its values through the pointers. */
2941int dwarf_gdbindex_header(Dwarf_Debug /*dbg*/,
2942    Dwarf_Gdbindex * /*gdbindexptr*/,
2943    Dwarf_Unsigned * /*version*/,
2944    Dwarf_Unsigned * /*cu_list_offset*/,
2945    Dwarf_Unsigned * /*types_cu_list_offset*/,
2946    Dwarf_Unsigned * /*address_area_offset*/,
2947    Dwarf_Unsigned * /*symbol_table_offset*/,
2948    Dwarf_Unsigned * /*constant_pool_offset*/,
2949    Dwarf_Unsigned * /*section_size*/,
2950    Dwarf_Unsigned * /*unused_reserved*/,
2951    const char    ** /*section_name*/,
2952    Dwarf_Error    * /*error*/);
2953
2954int dwarf_gdbindex_culist_array(Dwarf_Gdbindex /*gdbindexptr*/,
2955    Dwarf_Unsigned       * /*list_length*/,
2956    Dwarf_Error          * /*error*/);
2957
2958/*  entryindex: 0 to list_length-1 */
2959int dwarf_gdbindex_culist_entry(Dwarf_Gdbindex /*gdbindexptr*/,
2960    Dwarf_Unsigned   /*entryindex*/,
2961    Dwarf_Unsigned * /*cu_offset*/,
2962    Dwarf_Unsigned * /*cu_length*/,
2963    Dwarf_Error    * /*error*/);
2964
2965int dwarf_gdbindex_types_culist_array(Dwarf_Gdbindex /*gdbindexptr*/,
2966    Dwarf_Unsigned            * /*types_list_length*/,
2967    Dwarf_Error               * /*error*/);
2968
2969/*  entryindex: 0 to types_list_length -1 */
2970int dwarf_gdbindex_types_culist_entry(
2971    Dwarf_Gdbindex   /*gdbindexptr*/,
2972    Dwarf_Unsigned   /*entryindex*/,
2973    Dwarf_Unsigned * /*cu_offset*/,
2974    Dwarf_Unsigned * /*tu_offset*/,
2975    Dwarf_Unsigned * /*type_signature*/,
2976    Dwarf_Error    * /*error*/);
2977
2978int dwarf_gdbindex_addressarea(Dwarf_Gdbindex /*gdbindexptr*/,
2979    Dwarf_Unsigned            * /*addressarea_list_length*/,
2980    Dwarf_Error               * /*error*/);
2981
2982/*    entryindex: 0 to addressarea_list_length-1 */
2983int dwarf_gdbindex_addressarea_entry(
2984    Dwarf_Gdbindex   /*gdbindexptr*/,
2985    Dwarf_Unsigned   /*entryindex*/,
2986    Dwarf_Unsigned * /*low_adddress*/,
2987    Dwarf_Unsigned * /*high_address*/,
2988    Dwarf_Unsigned * /*cu_index*/,
2989    Dwarf_Error    * /*error*/);
2990
2991int dwarf_gdbindex_symboltable_array(Dwarf_Gdbindex /*gdbindexptr*/,
2992    Dwarf_Unsigned            * /*symtab_list_length*/,
2993    Dwarf_Error               * /*error*/);
2994
2995/*  entryindex: 0 to symtab_list_length-1 */
2996int dwarf_gdbindex_symboltable_entry(
2997    Dwarf_Gdbindex   /*gdbindexptr*/,
2998    Dwarf_Unsigned   /*entryindex*/,
2999    Dwarf_Unsigned * /*string_offset*/,
3000    Dwarf_Unsigned * /*cu_vector_offset*/,
3001    Dwarf_Error    * /*error*/);
3002
3003int dwarf_gdbindex_cuvector_length(Dwarf_Gdbindex /*gdbindex*/,
3004    Dwarf_Unsigned   /*cuvector_offset*/,
3005    Dwarf_Unsigned * /*innercount*/,
3006    Dwarf_Error    * /*error*/);
3007
3008
3009int dwarf_gdbindex_cuvector_inner_attributes(Dwarf_Gdbindex /*gdbindex*/,
3010    Dwarf_Unsigned   /*cuvector_offset*/,
3011    Dwarf_Unsigned   /*innerindex*/,
3012    /* The attr_value is a field of bits. For expanded version
3013        use  dwarf_gdbindex_cuvector_expand_value() */
3014    Dwarf_Unsigned * /*attr_value*/,
3015    Dwarf_Error    * /*error*/);
3016
3017int dwarf_gdbindex_cuvector_instance_expand_value(Dwarf_Gdbindex /*gdbindex*/,
3018    Dwarf_Unsigned   /*value*/,
3019    Dwarf_Unsigned * /*cu_index*/,
3020    Dwarf_Unsigned * /*reserved1*/,
3021    Dwarf_Unsigned * /*symbol_kind*/,
3022    Dwarf_Unsigned * /*is_static*/,
3023    Dwarf_Error    * /*error*/);
3024
3025
3026/*  The strings in the pool follow (in memory) the cu index
3027    set and are NUL terminated. */
3028
3029int dwarf_gdbindex_string_by_offset(Dwarf_Gdbindex /*gdbindexptr*/,
3030    Dwarf_Unsigned   /*stringoffset*/,
3031    const char    ** /*string_ptr*/,
3032    Dwarf_Error   *  /*error*/);
3033
3034void dwarf_gdbindex_free(Dwarf_Gdbindex /*gdbindexptr*/);
3035
3036/*  END gdbindex/debugfission operations. */
3037
3038/*  START debugfission dwp .debug_cu_index and .debug_tu_index operations. */
3039
3040int dwarf_get_xu_index_header(Dwarf_Debug /*dbg*/,
3041    const char *  section_type, /* "tu" or "cu" */
3042    Dwarf_Xu_Index_Header *     /*xuhdr*/,
3043    Dwarf_Unsigned *            /*version_number*/,
3044    Dwarf_Unsigned *            /*offsets_count L*/,
3045    Dwarf_Unsigned *            /*units_count N*/,
3046    Dwarf_Unsigned *            /*hash_slots_count M*/,
3047    const char     **           /*sect_name*/,
3048    Dwarf_Error *               /*err*/);
3049
3050int dwarf_get_xu_index_section_type(Dwarf_Xu_Index_Header /*xuhdr*/,
3051    /*  the function returns a pointer to
3052        the immutable string "tu" or "cu" via this arg. Do not free.  */
3053    const char ** /*typename*/,
3054    /*  the function returns a pointer to
3055        the immutable section name. Do not free.
3056        .debug_cu_index or .debug_tu_index */
3057    const char ** /*sectionname*/,
3058    Dwarf_Error * /*err*/);
3059
3060/*  Index values 0 to M-1 are valid. */
3061int dwarf_get_xu_hash_entry(Dwarf_Xu_Index_Header /*xuhdr*/,
3062    Dwarf_Unsigned     /*index*/,
3063
3064    /*  Returns the hash value. 64  bits.  */
3065    Dwarf_Sig8 *      /*hash_value*/,
3066
3067    /* returns the index into rows of offset/size tables. */
3068    Dwarf_Unsigned *  /*index_to_sections*/,
3069    Dwarf_Error *     /*err*/);
3070
3071/*  Columns 0 to L-1,  valid. */
3072int dwarf_get_xu_section_names(Dwarf_Xu_Index_Header /*xuhdr*/,
3073    /* Row index defined to be row zero. */
3074    Dwarf_Unsigned  /*column_index*/,
3075    Dwarf_Unsigned* /*DW_SECT_ number*/,
3076    const char **   /*DW_SECT_ name*/,
3077    Dwarf_Error *   /*err*/);
3078
3079    /* Rows 1 to N col 0 to L-1  are valid */
3080int dwarf_get_xu_section_offset(Dwarf_Xu_Index_Header /*xuhdr*/,
3081    Dwarf_Unsigned  /*row_index*/,
3082    Dwarf_Unsigned  /*column_index*/,
3083    Dwarf_Unsigned* /*sec_offset*/,
3084    Dwarf_Unsigned* /*sec_size*/,
3085    Dwarf_Error *   /*err*/);
3086
3087void dwarf_xu_header_free(Dwarf_Xu_Index_Header /*xuhdr*/);
3088
3089/*  Defined larger than necessary. This struct, being visible,
3090    will be difficult to change: binary compatibility. */
3091#define DW_FISSION_SECT_COUNT 12
3092
3093/*  User must allocate this struct, zero it,
3094    and pass a pointer to it
3095    into dwarf_get_debugfission_for_cu .  */
3096struct Dwarf_Debug_Fission_Per_CU_s  {
3097    /*  Do not free the string. It contains "cu" or "tu". */
3098    /*  If this is not set (ie, not a CU/TU in  DWP Package File)
3099        then pcu_type will be NULL.  */
3100    const char   * pcu_type;
3101    /*  pcu_index is the index (range 1 to N )
3102        into the tu/cu table of offsets and the table
3103        of sizes.  1 to N as the zero index is reserved
3104        for special purposes.  Not a value one
3105        actually needs. */
3106    Dwarf_Unsigned pcu_index;
3107    Dwarf_Sig8     pcu_hash;  /* 8 byte  */
3108    /*  [0] has offset and size 0.
3109        [1]-[8] are DW_SECT_* indexes and the
3110        values are  the offset and size
3111        of the respective section contribution
3112        of a single .dwo object. When pcu_size[n] is
3113        zero the corresponding section is not present. */
3114    Dwarf_Unsigned pcu_offset[DW_FISSION_SECT_COUNT];
3115    Dwarf_Unsigned pcu_size[DW_FISSION_SECT_COUNT];
3116    Dwarf_Unsigned unused1;
3117    Dwarf_Unsigned unused2;
3118};
3119typedef struct Dwarf_Debug_Fission_Per_CU_s  Dwarf_Debug_Fission_Per_CU ;
3120/*  For any Dwarf_Die in a compilation unit, return
3121    the debug fission table data through
3122    percu_out.   Usually applications
3123    will pass in the CU die.
3124    Calling code should zero all of the
3125    struct Dwarf_Debug_Fission_Per_CU_s before calling this.
3126    If there is no debugfission data this returns
3127    DW_DLV_NO_ENTRY (only .dwp objects have debugfission data).  */
3128int dwarf_get_debugfission_for_die(Dwarf_Die /* die */,
3129    Dwarf_Debug_Fission_Per_CU * /* percu_out */,
3130    Dwarf_Error * /* err */);
3131
3132/* Given a key (hash signature)  from a .o, find the per-cu information
3133    for the CU with that key. */
3134int dwarf_get_debugfission_for_key(Dwarf_Debug /*dbg*/,
3135    Dwarf_Sig8 *                 /*key, hash signature */,
3136    const char * key_type        /*"cu" or "tu" */,
3137    Dwarf_Debug_Fission_Per_CU * /*percu_out */,
3138    Dwarf_Error *                /*err */);
3139
3140/*  END debugfission dwp .debug_cu_index and .debug_tu_index operations. */
3141
3142
3143/*  Utility operations */
3144Dwarf_Unsigned dwarf_errno(Dwarf_Error     /*error*/);
3145
3146char* dwarf_errmsg(Dwarf_Error    /*error*/);
3147
3148/*  stringcheck zero is default and means do all
3149    string length validity checks.
3150    Call with parameter value 1 to turn off many such checks (and
3151    increase performance).
3152    Call with zero for safest running.
3153    Actual value saved and returned is only 8 bits! Upper bits
3154    ignored by libdwarf (and zero on return).
3155    Returns previous value.  */
3156int dwarf_set_stringcheck(int /*stringcheck*/);
3157
3158/*  'apply' defaults to 1 and means do all
3159    'rela' relocations on reading in a dwarf object section with
3160    such relocations.
3161    Call with parameter value 0 to turn off application of
3162    such relocations.
3163    Since the static linker leaves 'bogus' data in object sections
3164    with a 'rela' relocation section such data cannot be read
3165    sensibly without processing the relocations.  Such relocations
3166    do not exist in executables and shared objects (.so), the
3167    relocations only exist in plain .o relocatable object files.
3168    Actual value saved and returned is only 8 bits! Upper bits
3169    ignored by libdwarf (and zero on return).
3170    Returns previous value.  */
3171int dwarf_set_reloc_application(int /*apply*/);
3172
3173/* Unimplemented */
3174Dwarf_Handler dwarf_seterrhand(Dwarf_Debug /*dbg*/, Dwarf_Handler /*errhand*/);
3175
3176/* Unimplemented */
3177Dwarf_Ptr dwarf_seterrarg(Dwarf_Debug /*dbg*/, Dwarf_Ptr /*errarg*/);
3178
3179void dwarf_dealloc(Dwarf_Debug /*dbg*/, void* /*space*/,
3180    Dwarf_Unsigned /*type*/);
3181
3182
3183/* DWARF Producer Interface */
3184
3185/*  New form June, 2011. Adds user_data argument. */
3186typedef int (*Dwarf_Callback_Func)(
3187    const char*     /*name*/,
3188    int             /*size*/,
3189    Dwarf_Unsigned  /*type*/,
3190    Dwarf_Unsigned  /*flags*/,
3191    Dwarf_Unsigned  /*link*/,
3192    Dwarf_Unsigned  /*info*/,
3193    Dwarf_Unsigned* /*sect_name_index*/,
3194    void *          /*user_data*/,
3195    int*            /*error*/);
3196
3197/*  Returns DW_DLV_OK or DW_DLV_ERROR and
3198    if DW_DLV_OK returns the Dwarf_P_Debug
3199    pointer through the dbg_returned argument. */
3200int dwarf_producer_init(
3201    Dwarf_Unsigned        /*flags*/,
3202    Dwarf_Callback_Func   /*func*/,
3203    Dwarf_Handler         /*errhand*/,
3204    Dwarf_Ptr             /*errarg*/,
3205    void *                /*user_data*/,
3206    const char *isa_name, /* See isa/abi names in pro_init.c */
3207    const char *dwarf_version, /* V2 V3 V4 or V5. */
3208    const char *extra,    /* Extra input strings, comma separated. */
3209    Dwarf_P_Debug *,      /* dbg_returned */
3210    Dwarf_Error *         /*error*/);
3211
3212/*  Returns DW_DLV_OK or DW_DLV_ERROR.
3213    The desired form must be DW_FORM_string (the default)
3214    or DW_FORM_strp.  */
3215int dwarf_pro_set_default_string_form(Dwarf_P_Debug /*dbg*/,
3216    int /*desired_form*/,
3217    Dwarf_Error*     /*error*/);
3218
3219/*  the old interface. Still supported. */
3220Dwarf_Signed dwarf_transform_to_disk_form(Dwarf_P_Debug /*dbg*/,
3221    Dwarf_Error*     /*error*/);
3222/*  New September 2016. The preferred interface. */
3223int dwarf_transform_to_disk_form_a(Dwarf_P_Debug /*dbg*/,
3224    Dwarf_Signed *   /*nbufs_out*/,
3225    Dwarf_Error*     /*error*/);
3226
3227/* New September 2016. Preferred. */
3228int dwarf_get_section_bytes_a(Dwarf_P_Debug /*dbg*/,
3229    Dwarf_Signed     /*dwarf_section*/,
3230    Dwarf_Signed*    /*elf_section_index*/,
3231    Dwarf_Unsigned*  /*length*/,
3232    Dwarf_Ptr     *  /*section_bytes*/,
3233    Dwarf_Error*     /*error*/);
3234
3235/* Original function.  Checking for error is difficult. */
3236Dwarf_Ptr dwarf_get_section_bytes(Dwarf_P_Debug /*dbg*/,
3237    Dwarf_Signed     /*dwarf_section*/,
3238    Dwarf_Signed*    /*elf_section_index*/,
3239    Dwarf_Unsigned*  /*length*/,
3240    Dwarf_Error*     /*error*/);
3241
3242int  dwarf_get_relocation_info_count(
3243    Dwarf_P_Debug    /*dbg*/,
3244    Dwarf_Unsigned * /*count_of_relocation_sections*/,
3245    int *                /*drd_buffer_version*/,
3246    Dwarf_Error*     /*error*/);
3247
3248int dwarf_get_relocation_info(
3249    Dwarf_P_Debug           /*dbg*/,
3250    Dwarf_Signed          * /*elf_section_index*/,
3251    Dwarf_Signed          * /*elf_section_index_link*/,
3252    Dwarf_Unsigned        * /*relocation_buffer_count*/,
3253    Dwarf_Relocation_Data * /*reldata_buffer*/,
3254    Dwarf_Error*            /*error*/);
3255
3256/* v1:  no drd_length field, enum explicit */
3257/* v2:  has the drd_length field, enum value in uchar member */
3258#define DWARF_DRD_BUFFER_VERSION 2
3259
3260/* Markers are not written  to DWARF2/3/4, they are user
3261   defined and may be used for any purpose.
3262*/
3263Dwarf_Signed dwarf_get_die_markers(
3264    Dwarf_P_Debug     /*dbg*/,
3265    Dwarf_P_Marker *  /*marker_list*/,
3266    Dwarf_Unsigned *  /*marker_count*/,
3267    Dwarf_Error *     /*error*/);
3268
3269int dwarf_get_string_attributes_count(Dwarf_P_Debug,
3270    Dwarf_Unsigned *,
3271    int *,
3272    Dwarf_Error *);
3273
3274int dwarf_get_string_attributes_info(Dwarf_P_Debug,
3275    Dwarf_Signed *,
3276    Dwarf_Unsigned *,
3277    Dwarf_P_String_Attr *,
3278    Dwarf_Error *);
3279
3280void dwarf_reset_section_bytes(Dwarf_P_Debug /*dbg*/);
3281
3282Dwarf_Unsigned dwarf_producer_finish(Dwarf_P_Debug /*dbg*/,
3283    Dwarf_Error* /*error*/);
3284int dwarf_producer_finish_a(Dwarf_P_Debug /*dbg*/,
3285    Dwarf_Error* /*error*/);
3286
3287/* Producer attribute addition functions. */
3288Dwarf_P_Attribute dwarf_add_AT_targ_address(Dwarf_P_Debug /*dbg*/,
3289    Dwarf_P_Die     /*ownerdie*/,
3290    Dwarf_Half      /*attr*/,
3291    Dwarf_Unsigned  /*pc_value*/,
3292    Dwarf_Signed    /*sym_index*/,
3293    Dwarf_Error*    /*error*/);
3294
3295Dwarf_P_Attribute dwarf_add_AT_block(Dwarf_P_Debug /*dbg*/,
3296    Dwarf_P_Die     /*ownerdie*/,
3297    Dwarf_Half      /*attr*/,
3298    Dwarf_Small*    /*block_data*/,
3299    Dwarf_Unsigned  /*block_len*/,
3300    Dwarf_Error*    /*error*/);
3301
3302Dwarf_P_Attribute dwarf_add_AT_targ_address_b(Dwarf_P_Debug /*dbg*/,
3303    Dwarf_P_Die     /*ownerdie*/,
3304    Dwarf_Half      /*attr*/,
3305    Dwarf_Unsigned  /*pc_value*/,
3306    Dwarf_Unsigned  /*sym_index*/,
3307    Dwarf_Error*    /*error*/);
3308
3309Dwarf_P_Attribute dwarf_add_AT_ref_address(Dwarf_P_Debug /*dbg*/,
3310    Dwarf_P_Die     /*ownerdie*/,
3311    Dwarf_Half      /*attr*/,
3312    Dwarf_Unsigned  /*pc_value*/,
3313    Dwarf_Unsigned  /*sym_index*/,
3314    Dwarf_Error*    /*error*/);
3315
3316Dwarf_P_Attribute dwarf_add_AT_unsigned_const(Dwarf_P_Debug /*dbg*/,
3317    Dwarf_P_Die     /*ownerdie*/,
3318    Dwarf_Half      /*attr*/,
3319    Dwarf_Unsigned  /*value*/,
3320    Dwarf_Error*    /*error*/);
3321
3322Dwarf_P_Attribute dwarf_add_AT_signed_const(Dwarf_P_Debug /*dbg*/,
3323    Dwarf_P_Die     /*ownerdie*/,
3324    Dwarf_Half      /*attr*/,
3325    Dwarf_Signed    /*value*/,
3326    Dwarf_Error*    /*error*/);
3327
3328Dwarf_P_Attribute dwarf_add_AT_reference(Dwarf_P_Debug /*dbg*/,
3329    Dwarf_P_Die     /*ownerdie*/,
3330    Dwarf_Half      /*attr*/,
3331    Dwarf_P_Die     /*otherdie*/,
3332    Dwarf_Error*    /*error*/);
3333
3334/*  dwarf_add_AT_reference_b allows otherdie to be NULL with
3335    the assumption the caller will then later call
3336    dwarf_fixup_AT_reference_die() with a non-null target die.
3337    New 22 October, 2013
3338*/
3339Dwarf_P_Attribute dwarf_add_AT_reference_b(Dwarf_P_Debug /*dbg*/,
3340    Dwarf_P_Die     /*ownerdie*/,
3341    Dwarf_Half      /*attr*/,
3342    Dwarf_P_Die     /*otherdie*/,
3343    Dwarf_Error*    /*error*/);
3344
3345/* The following is for out-of-order cu-local
3346   references.  Allowing nominating the target Dwarf_P_Die
3347   after calling dwarf_add_AT_reference with a NULL otherdie
3348   after a single pass thru the DIE generation. Needed
3349   for forward-references.
3350   New 22 October, 2013.
3351*/
3352int
3353dwarf_fixup_AT_reference_die(Dwarf_P_Debug /*dbg*/,
3354    Dwarf_Half    /* attrnum */,
3355    Dwarf_P_Die   /* sourcedie*/,
3356    Dwarf_P_Die   /* targetdie*/,
3357    Dwarf_Error * /*error*/);
3358
3359
3360Dwarf_P_Attribute dwarf_add_AT_dataref(
3361    Dwarf_P_Debug   /*dbg*/,
3362    Dwarf_P_Die     /*ownerdie*/,
3363    Dwarf_Half      /*attr*/,
3364    Dwarf_Unsigned  /*pcvalue*/,
3365    Dwarf_Unsigned  /*sym_index*/,
3366    Dwarf_Error*    /*error*/);
3367
3368Dwarf_P_Attribute dwarf_add_AT_const_value_string(Dwarf_P_Die /*ownerdie*/,
3369    char*           /*string_value*/,
3370    Dwarf_Error*    /*error*/);
3371
3372Dwarf_P_Attribute dwarf_add_AT_location_expr(Dwarf_P_Debug /*dbg*/,
3373    Dwarf_P_Die     /*ownerdie*/,
3374    Dwarf_Half      /*attr*/,
3375    Dwarf_P_Expr    /*loc_expr*/,
3376    Dwarf_Error*    /*error*/);
3377
3378Dwarf_P_Attribute dwarf_add_AT_string(Dwarf_P_Debug /*dbg*/,
3379    Dwarf_P_Die     /*ownerdie*/,
3380    Dwarf_Half      /*attr*/,
3381    char*           /*string*/,
3382    Dwarf_Error*     /*error*/);
3383
3384Dwarf_P_Attribute dwarf_add_AT_flag(Dwarf_P_Debug /*dbg*/,
3385    Dwarf_P_Die     /*ownerdie*/,
3386    Dwarf_Half      /*attr*/,
3387    Dwarf_Small     /*flag*/,
3388    Dwarf_Error*    /*error*/);
3389
3390Dwarf_P_Attribute dwarf_add_AT_producer(Dwarf_P_Die /*ownerdie*/,
3391    char*           /*producer_string*/,
3392    Dwarf_Error*    /*error*/);
3393
3394/* August 2013 sleb creator. For any attribute. */
3395Dwarf_P_Attribute dwarf_add_AT_any_value_sleb(Dwarf_P_Die /*ownerdie*/,
3396    Dwarf_Half    /*attrnum*/,
3397    Dwarf_Signed  /*signed_value*/,
3398    Dwarf_Error * /*error*/);
3399
3400/* Original sleb creator. Only for DW_AT_const_value. */
3401Dwarf_P_Attribute dwarf_add_AT_const_value_signedint(Dwarf_P_Die /*ownerdie*/,
3402    Dwarf_Signed    /*signed_value*/,
3403    Dwarf_Error*    /*error*/);
3404
3405/* August 2013 uleb creator. For any attribute. */
3406Dwarf_P_Attribute dwarf_add_AT_any_value_uleb(Dwarf_P_Die /*ownerdie*/,
3407    Dwarf_Half      /*attrnum*/,
3408    Dwarf_Unsigned  /*signed_value*/,
3409    Dwarf_Error *   /*error*/);
3410
3411/* Original uleb creator. Only for DW_AT_const_value. */
3412Dwarf_P_Attribute dwarf_add_AT_const_value_unsignedint(
3413    Dwarf_P_Die     /*ownerdie*/,
3414    Dwarf_Unsigned  /*unsigned_value*/,
3415    Dwarf_Error*    /*error*/);
3416
3417Dwarf_P_Attribute dwarf_add_AT_comp_dir(Dwarf_P_Die /*ownerdie*/,
3418    char*           /*current_working_directory*/,
3419    Dwarf_Error*    /*error*/);
3420
3421Dwarf_P_Attribute dwarf_add_AT_name(Dwarf_P_Die    /*die*/,
3422    char*           /*name*/,
3423    Dwarf_Error*    /*error*/);
3424
3425Dwarf_P_Attribute
3426dwarf_add_AT_with_ref_sig8(
3427   Dwarf_P_Die   /*ownerdie */,
3428   Dwarf_Half    /*attrnum */,
3429   const Dwarf_Sig8 *  /*sig8_in*/,
3430   Dwarf_Error * /*error*/);
3431
3432
3433/* Producer line creation functions (.debug_line) */
3434Dwarf_Unsigned dwarf_add_directory_decl(Dwarf_P_Debug /*dbg*/,
3435    char*           /*name*/,
3436    Dwarf_Error*    /*error*/);
3437
3438Dwarf_Unsigned dwarf_add_file_decl(Dwarf_P_Debug /*dbg*/,
3439    char*           /*name*/,
3440    Dwarf_Unsigned  /*dir_index*/,
3441    Dwarf_Unsigned  /*time_last_modified*/,
3442    Dwarf_Unsigned  /*length*/,
3443    Dwarf_Error*    /*error*/);
3444
3445Dwarf_Unsigned dwarf_add_line_entry_b(Dwarf_P_Debug /*dbg*/,
3446    Dwarf_Unsigned  /*file_index*/,
3447    Dwarf_Addr      /*code_address*/,
3448    Dwarf_Unsigned  /*lineno*/,
3449    Dwarf_Signed    /*column_number*/,
3450    Dwarf_Bool      /*is_source_stmt_begin*/,
3451    Dwarf_Bool      /*is_basic_block_begin*/,
3452    Dwarf_Bool      /*is_epilogue_begin*/,
3453    Dwarf_Bool      /*is_prologue_end*/,
3454    Dwarf_Unsigned  /*isa*/,
3455    Dwarf_Unsigned  /*discriminator*/,
3456    Dwarf_Error*    /*error*/);
3457Dwarf_Unsigned dwarf_add_line_entry(Dwarf_P_Debug /*dbg*/,
3458    Dwarf_Unsigned  /*file_index*/,
3459    Dwarf_Addr      /*code_address*/,
3460    Dwarf_Unsigned  /*lineno*/,
3461    Dwarf_Signed    /*column_number*/,
3462    Dwarf_Bool      /*is_source_stmt_begin*/,
3463    Dwarf_Bool      /*is_basic_block_begin*/,
3464    Dwarf_Error*    /*error*/);
3465
3466Dwarf_Unsigned dwarf_lne_set_address(Dwarf_P_Debug /*dbg*/,
3467    Dwarf_Unsigned  /*offset*/,
3468    Dwarf_Unsigned  /*symbol_index*/,
3469    Dwarf_Error*    /*error*/);
3470
3471Dwarf_Unsigned dwarf_lne_end_sequence(Dwarf_P_Debug /*dbg*/,
3472    Dwarf_Addr      /*end_address*/,
3473    Dwarf_Error*    /*error*/);
3474
3475/* Producer .debug_frame functions */
3476Dwarf_Unsigned dwarf_add_frame_cie(Dwarf_P_Debug /*dbg*/,
3477    char*           /*augmenter*/,
3478    Dwarf_Small     /*code_alignment_factor*/,
3479    Dwarf_Small     /*data_alignment_factor*/,
3480    Dwarf_Small     /*return_address_reg*/,
3481    Dwarf_Ptr       /*initialization_bytes*/,
3482    Dwarf_Unsigned  /*init_byte_len*/,
3483    Dwarf_Error*    /*error*/);
3484
3485Dwarf_Unsigned dwarf_add_frame_fde(
3486    Dwarf_P_Debug   /*dbg*/,
3487    Dwarf_P_Fde     /*fde*/,
3488    Dwarf_P_Die     /*corresponding subprogram die*/,
3489    Dwarf_Unsigned  /*cie_to_use*/,
3490    Dwarf_Unsigned  /*virt_addr_of_described_code*/,
3491    Dwarf_Unsigned  /*length_of_code*/,
3492    Dwarf_Unsigned  /*symbol_index*/,
3493    Dwarf_Error*    /*error*/);
3494
3495Dwarf_Unsigned dwarf_add_frame_fde_b(
3496    Dwarf_P_Debug  /*dbg*/,
3497    Dwarf_P_Fde    /*fde*/,
3498    Dwarf_P_Die    /*die*/,
3499    Dwarf_Unsigned /*cie*/,
3500    Dwarf_Addr     /*virt_addr*/,
3501    Dwarf_Unsigned /*code_len*/,
3502    Dwarf_Unsigned /*sym_idx*/,
3503    Dwarf_Unsigned /*sym_idx_of_end*/,
3504    Dwarf_Addr     /*offset_from_end_sym*/,
3505    Dwarf_Error*   /*error*/);
3506
3507Dwarf_Unsigned dwarf_add_frame_info_b(
3508    Dwarf_P_Debug   /*dbg*/,
3509    Dwarf_P_Fde     /*fde*/,
3510    Dwarf_P_Die     /*die*/,
3511    Dwarf_Unsigned  /*cie*/,
3512    Dwarf_Addr      /*virt_addr*/,
3513    Dwarf_Unsigned  /*code_len*/,
3514    Dwarf_Unsigned  /*symidx*/,
3515    Dwarf_Unsigned  /*end_symbol */,
3516    Dwarf_Addr      /*offset_from_end_symbol */,
3517    Dwarf_Signed    /*offset_into_exception_tables*/,
3518    Dwarf_Unsigned  /*exception_table_symbol*/,
3519    Dwarf_Error*    /*error*/);
3520
3521Dwarf_Unsigned dwarf_add_frame_info(
3522    Dwarf_P_Debug   /*dbg*/,
3523    Dwarf_P_Fde     /*fde*/,
3524    Dwarf_P_Die     /*die*/,
3525    Dwarf_Unsigned  /*cie*/,
3526    Dwarf_Addr      /*virt_addr*/,
3527    Dwarf_Unsigned  /*code_len*/,
3528    Dwarf_Unsigned  /*symidx*/,
3529    Dwarf_Signed    /*offset_into_exception_tables*/,
3530    Dwarf_Unsigned  /*exception_table_symbol*/,
3531    Dwarf_Error*    /*error*/);
3532
3533Dwarf_P_Fde dwarf_add_fde_inst(
3534    Dwarf_P_Fde     /*fde*/,
3535    Dwarf_Small     /*op*/,
3536    Dwarf_Unsigned  /*val1*/,
3537    Dwarf_Unsigned  /*val2*/,
3538    Dwarf_Error*    /*error*/);
3539
3540/* New September 17, 2009 */
3541int dwarf_insert_fde_inst_bytes(
3542    Dwarf_P_Debug  /*dbg*/,
3543    Dwarf_P_Fde    /*fde*/,
3544    Dwarf_Unsigned /*len*/,
3545    Dwarf_Ptr      /*ibytes*/,
3546    Dwarf_Error*   /*error*/);
3547
3548
3549Dwarf_P_Fde dwarf_new_fde(Dwarf_P_Debug    /*dbg*/, Dwarf_Error* /*error*/);
3550
3551Dwarf_P_Fde dwarf_fde_cfa_offset(
3552    Dwarf_P_Fde     /*fde*/,
3553    Dwarf_Unsigned  /*register_number*/,
3554    Dwarf_Signed    /*offset*/,
3555    Dwarf_Error*    /*error*/);
3556
3557/*  die creation & addition routines
3558    dwarf_new_die_a() new September 2016.
3559    Preferred over dwarf_new_die(). */
3560int dwarf_new_die_a(
3561    Dwarf_P_Debug   /*dbg*/,
3562    Dwarf_Tag       /*tag*/,
3563    Dwarf_P_Die     /*parent*/,
3564    Dwarf_P_Die     /*child*/,
3565    Dwarf_P_Die     /*left */,
3566    Dwarf_P_Die     /*right*/,
3567    Dwarf_P_Die   * /*die_out*/,
3568    Dwarf_Error*    /*error*/);
3569Dwarf_P_Die dwarf_new_die(
3570    Dwarf_P_Debug    /*dbg*/,
3571    Dwarf_Tag         /*tag*/,
3572    Dwarf_P_Die     /*parent*/,
3573    Dwarf_P_Die     /*child*/,
3574    Dwarf_P_Die     /*left */,
3575    Dwarf_P_Die     /*right*/,
3576    Dwarf_Error*    /*error*/);
3577
3578/* New September 2016. */
3579int dwarf_add_die_to_debug_a(
3580    Dwarf_P_Debug   /*dbg*/,
3581    Dwarf_P_Die     /*die*/,
3582    Dwarf_Error*    /*error*/);
3583/*  Original form. Still supported. */
3584Dwarf_Unsigned dwarf_add_die_to_debug(
3585    Dwarf_P_Debug   /*dbg*/,
3586    Dwarf_P_Die     /*die*/,
3587    Dwarf_Error*    /*error*/);
3588
3589/* Markers are not written  to DWARF2/3/4, they are user
3590   defined and may be used for any purpose.
3591*/
3592Dwarf_Unsigned dwarf_add_die_marker(
3593    Dwarf_P_Debug   /*dbg*/,
3594    Dwarf_P_Die     /*die*/,
3595    Dwarf_Unsigned  /*marker*/,
3596    Dwarf_Error *   /*error*/);
3597
3598Dwarf_Unsigned dwarf_get_die_marker(
3599    Dwarf_P_Debug   /*dbg*/,
3600    Dwarf_P_Die     /*die*/,
3601    Dwarf_Unsigned *  /*marker*/,
3602    Dwarf_Error *   /*error*/);
3603
3604/*  New September 2016. Preferred version */
3605int dwarf_die_link_a(
3606    Dwarf_P_Die     /*die*/,
3607    Dwarf_P_Die     /*parent*/,
3608    Dwarf_P_Die     /*child*/,
3609    Dwarf_P_Die     /*left*/,
3610    Dwarf_P_Die     /*right*/,
3611    Dwarf_Error*    /*error*/);
3612
3613/*  Original version. Use dwarf_die_link_a() instead. */
3614Dwarf_P_Die dwarf_die_link(
3615    Dwarf_P_Die     /*die*/,
3616    Dwarf_P_Die     /*parent*/,
3617    Dwarf_P_Die     /*child*/,
3618    Dwarf_P_Die     /*left*/,
3619    Dwarf_P_Die     /*right*/,
3620    Dwarf_Error*    /*error*/);
3621
3622void dwarf_dealloc_compressed_block(
3623    Dwarf_P_Debug,
3624    void *
3625);
3626
3627/*  Call this passing in return value from dwarf_uncompress_integer_block()
3628    to free the space the decompression allocated. */
3629void dwarf_dealloc_uncompressed_block(
3630    Dwarf_Debug,
3631    void *
3632);
3633
3634void * dwarf_compress_integer_block(
3635    Dwarf_P_Debug,    /*dbg*/
3636    Dwarf_Bool,       /*signed==true (or unsigned)*/
3637    Dwarf_Small,      /*size of integer units: 8, 16, 32, 64*/
3638    void*,            /*data*/
3639    Dwarf_Unsigned,   /*number of elements*/
3640    Dwarf_Unsigned*,  /*number of bytes in output block*/
3641    Dwarf_Error*      /*error*/
3642);
3643
3644/*  Decode an array of signed leb integers (so of course the
3645    array is not composed of fixed length values, but is instead
3646    a sequence of sleb values).
3647    Returns a DW_DLV_BADADDR on error.
3648    Otherwise returns a pointer to an array of 32bit integers.
3649    The signed argument must be non-zero (the decode
3650    assumes sleb integers in the input data) at this time.
3651    Size of integer units must be 32 (32 bits each) at this time.
3652    Number of bytes in block is a byte count (not array count).
3653    Returns number of units in output block (ie, number of elements
3654    of the array that the return value points to) thru the argument.  */
3655void * dwarf_uncompress_integer_block(
3656    Dwarf_Debug,      /*dbg */
3657    Dwarf_Bool,       /*signed==true (or unsigned) */
3658    Dwarf_Small,      /*size of integer units: 8, 16, 32, 64 */
3659    void*,            /*input data */
3660    Dwarf_Unsigned,   /*number of bytes in input */
3661    Dwarf_Unsigned*,  /*number of units in output block */
3662    Dwarf_Error*      /*error */
3663);
3664
3665/* Operations to create location expressions. */
3666Dwarf_P_Expr dwarf_new_expr(Dwarf_P_Debug /*dbg*/, Dwarf_Error* /*error*/);
3667
3668void dwarf_expr_reset(
3669    Dwarf_P_Expr      /*expr*/,
3670    Dwarf_Error*      /*error*/);
3671
3672Dwarf_Unsigned dwarf_add_expr_gen(
3673    Dwarf_P_Expr      /*expr*/,
3674    Dwarf_Small       /*opcode*/,
3675    Dwarf_Unsigned    /*val1*/,
3676    Dwarf_Unsigned    /*val2*/,
3677    Dwarf_Error*      /*error*/);
3678
3679Dwarf_Unsigned dwarf_add_expr_addr(
3680    Dwarf_P_Expr      /*expr*/,
3681    Dwarf_Unsigned    /*addr*/,
3682    Dwarf_Signed      /*sym_index*/,
3683    Dwarf_Error*      /*error*/);
3684
3685Dwarf_Unsigned dwarf_add_expr_addr_b(
3686    Dwarf_P_Expr      /*expr*/,
3687    Dwarf_Unsigned    /*addr*/,
3688    Dwarf_Unsigned    /*sym_index*/,
3689    Dwarf_Error*      /*error*/);
3690
3691Dwarf_Unsigned dwarf_expr_current_offset(
3692    Dwarf_P_Expr      /*expr*/,
3693    Dwarf_Error*      /*error*/);
3694
3695Dwarf_Addr dwarf_expr_into_block(
3696    Dwarf_P_Expr      /*expr*/,
3697    Dwarf_Unsigned*   /*length*/,
3698    Dwarf_Error*      /*error*/);
3699
3700Dwarf_Unsigned dwarf_add_arange(Dwarf_P_Debug /*dbg*/,
3701    Dwarf_Addr        /*begin_address*/,
3702    Dwarf_Unsigned    /*length*/,
3703    Dwarf_Signed      /*symbol_index*/,
3704    Dwarf_Error*      /*error*/);
3705
3706Dwarf_Unsigned dwarf_add_arange_b(
3707    Dwarf_P_Debug  /*dbg*/,
3708    Dwarf_Addr     /*begin_address*/,
3709    Dwarf_Unsigned /*length*/,
3710    Dwarf_Unsigned /*symbol_index*/,
3711    Dwarf_Unsigned /*end_symbol_index*/,
3712    Dwarf_Addr     /*offset_from_end_symbol*/,
3713    Dwarf_Error *  /*error*/);
3714
3715Dwarf_Unsigned dwarf_add_pubname(
3716    Dwarf_P_Debug      /*dbg*/,
3717    Dwarf_P_Die        /*die*/,
3718    char*              /*pubname_name*/,
3719    Dwarf_Error*       /*error*/);
3720
3721/* Added 17 October 2013.  Introduced in DWARF3. */
3722Dwarf_Unsigned dwarf_add_pubtype(
3723    Dwarf_P_Debug      /*dbg*/,
3724    Dwarf_P_Die        /*die*/,
3725    char*              /*pubtype_name*/,
3726    Dwarf_Error*       /*error*/);
3727
3728
3729Dwarf_Unsigned dwarf_add_funcname(
3730    Dwarf_P_Debug      /*dbg*/,
3731    Dwarf_P_Die        /*die*/,
3732    char*              /*func_name*/,
3733    Dwarf_Error*       /*error*/);
3734
3735Dwarf_Unsigned dwarf_add_typename(
3736    Dwarf_P_Debug     /*dbg*/,
3737    Dwarf_P_Die       /*die*/,
3738    char*             /*type_name*/,
3739    Dwarf_Error*      /*error*/);
3740
3741Dwarf_Unsigned dwarf_add_varname(
3742    Dwarf_P_Debug     /*dbg*/,
3743    Dwarf_P_Die       /*die*/,
3744    char*             /*var_name*/,
3745    Dwarf_Error*      /*error*/);
3746
3747Dwarf_Unsigned dwarf_add_weakname(
3748    Dwarf_P_Debug    /*dbg*/,
3749    Dwarf_P_Die      /*die*/,
3750    char*            /*weak_name*/,
3751    Dwarf_Error*     /*error*/);
3752
3753/*  .debug_macinfo producer functions
3754    Functions must be called in right order: the section is output
3755    In the order these are presented.
3756*/
3757int dwarf_def_macro(Dwarf_P_Debug /*dbg*/,
3758    Dwarf_Unsigned   /*line*/,
3759    char *           /*macname, with (arglist), no space before (*/,
3760    char *           /*macvalue*/,
3761    Dwarf_Error*     /*error*/);
3762
3763int dwarf_undef_macro(Dwarf_P_Debug /*dbg*/,
3764    Dwarf_Unsigned   /*line*/,
3765    char *           /*macname, no arglist, of course*/,
3766    Dwarf_Error*     /*error*/);
3767
3768int dwarf_start_macro_file(Dwarf_P_Debug /*dbg*/,
3769    Dwarf_Unsigned   /*fileindex*/,
3770    Dwarf_Unsigned   /*linenumber*/,
3771    Dwarf_Error*     /*error*/);
3772
3773int dwarf_end_macro_file(Dwarf_P_Debug /*dbg*/,
3774    Dwarf_Error*     /*error*/);
3775
3776int dwarf_vendor_ext(Dwarf_P_Debug /*dbg*/,
3777    Dwarf_Unsigned   /*constant*/,
3778    char *           /*string*/,
3779    Dwarf_Error*     /*error*/);
3780
3781/* end macinfo producer functions */
3782
3783int dwarf_attr_offset(Dwarf_Die /*die*/,
3784    Dwarf_Attribute /*attr of above die*/,
3785    Dwarf_Off     * /*returns offset thru this ptr */,
3786    Dwarf_Error   * /*error*/);
3787
3788/*  This is a hack so clients can verify offsets.
3789    Added April 2005 so that debugger can detect broken offsets
3790    (which happened in an IRIX executable larger than 2GB
3791    with MIPSpro 7.3.1.3 toolchain.).
3792*/
3793int
3794dwarf_get_section_max_offsets(Dwarf_Debug /*dbg*/,
3795    Dwarf_Unsigned * /*debug_info_size*/,
3796    Dwarf_Unsigned * /*debug_abbrev_size*/,
3797    Dwarf_Unsigned * /*debug_line_size*/,
3798    Dwarf_Unsigned * /*debug_loc_size*/,
3799    Dwarf_Unsigned * /*debug_aranges_size*/,
3800    Dwarf_Unsigned * /*debug_macinfo_size*/,
3801    Dwarf_Unsigned * /*debug_pubnames_size*/,
3802    Dwarf_Unsigned * /*debug_str_size*/,
3803    Dwarf_Unsigned * /*debug_frame_size*/,
3804    Dwarf_Unsigned * /*debug_ranges_size*/,
3805    Dwarf_Unsigned * /*debug_pubtypes_size*/);
3806
3807/*  New October 2011., adds .debug_types section to the sizes
3808    returned. */
3809int
3810dwarf_get_section_max_offsets_b(Dwarf_Debug /*dbg*/,
3811
3812    Dwarf_Unsigned * /*debug_info_size*/,
3813    Dwarf_Unsigned * /*debug_abbrev_size*/,
3814    Dwarf_Unsigned * /*debug_line_size*/,
3815    Dwarf_Unsigned * /*debug_loc_size*/,
3816    Dwarf_Unsigned * /*debug_aranges_size*/,
3817    Dwarf_Unsigned * /*debug_macinfo_size*/,
3818    Dwarf_Unsigned * /*debug_pubnames_size*/,
3819    Dwarf_Unsigned * /*debug_str_size*/,
3820    Dwarf_Unsigned * /*debug_frame_size*/,
3821    Dwarf_Unsigned * /*debug_ranges_size*/,
3822    Dwarf_Unsigned * /*debug_pubtypes_size*/,
3823    Dwarf_Unsigned * /*debug_types_size*/);
3824
3825int
3826dwarf_get_section_max_offsets_c(Dwarf_Debug /*dbg*/,
3827    Dwarf_Unsigned * /*debug_info_size*/,
3828    Dwarf_Unsigned * /*debug_abbrev_size*/,
3829    Dwarf_Unsigned * /*debug_line_size*/,
3830    Dwarf_Unsigned * /*debug_loc_size*/,
3831    Dwarf_Unsigned * /*debug_aranges_size*/,
3832    Dwarf_Unsigned * /*debug_macinfo_size*/,
3833    Dwarf_Unsigned * /*debug_pubnames_size*/,
3834    Dwarf_Unsigned * /*debug_str_size*/,
3835    Dwarf_Unsigned * /*debug_frame_size*/,
3836    Dwarf_Unsigned * /*debug_ranges_size*/,
3837    Dwarf_Unsigned * /*debug_pubtypes_size*/,
3838    Dwarf_Unsigned * /*debug_types_size*/,
3839    Dwarf_Unsigned * /*debug_macro_size*/,
3840    Dwarf_Unsigned * /*debug_str_offsets_size*/,
3841    Dwarf_Unsigned * /*debug_sup_size*/,
3842    Dwarf_Unsigned * /*debug_cu_index_size*/,
3843    Dwarf_Unsigned * /*debug_tu_index_size*/);
3844int
3845dwarf_get_section_max_offsets_d(Dwarf_Debug /*dbg*/,
3846    Dwarf_Unsigned * /*debug_info_size*/,
3847    Dwarf_Unsigned * /*debug_abbrev_size*/,
3848    Dwarf_Unsigned * /*debug_line_size*/,
3849    Dwarf_Unsigned * /*debug_loc_size*/,
3850    Dwarf_Unsigned * /*debug_aranges_size*/,
3851    Dwarf_Unsigned * /*debug_macinfo_size*/,
3852    Dwarf_Unsigned * /*debug_pubnames_size*/,
3853    Dwarf_Unsigned * /*debug_str_size*/,
3854    Dwarf_Unsigned * /*debug_frame_size*/,
3855    Dwarf_Unsigned * /*debug_ranges_size*/,
3856    Dwarf_Unsigned * /*debug_pubtypes_size*/,
3857    Dwarf_Unsigned * /*debug_types_size*/,
3858    Dwarf_Unsigned * /*debug_macro_size*/,
3859    Dwarf_Unsigned * /*debug_str_offsets_size*/,
3860    Dwarf_Unsigned * /*debug_sup_size*/,
3861    Dwarf_Unsigned * /*debug_cu_index_size*/,
3862    Dwarf_Unsigned * /*debug_tu_index_size*/,
3863    Dwarf_Unsigned * /*debug_names_size*/,
3864    Dwarf_Unsigned * /*debug_loclists_size*/,
3865    Dwarf_Unsigned * /*debug_rnglists_size*/);
3866
3867
3868/*  The 'set' calls here return the original (before any change
3869    by these set routines) of the respective fields. */
3870/*  Multiple releases spelled 'initial' as 'inital' .
3871    The 'inital' spelling should not be used. */
3872Dwarf_Half dwarf_set_frame_rule_inital_value(Dwarf_Debug /*dbg*/,
3873    Dwarf_Half /*value*/);
3874/*  Additional interface with correct 'initial' spelling. */
3875/*  It is likely you will want to call the following 6 functions
3876    before accessing any frame information.  All are useful
3877    to tailor handling of pseudo-registers needed to turn
3878    frame operation references into simpler forms and to
3879    reflect ABI specific data.  Of course altering libdwarf.h
3880    and dwarf.h allow the same capabilities, but such header changes
3881    do not let one change these values at runtime. */
3882Dwarf_Half dwarf_set_frame_rule_initial_value(Dwarf_Debug /*dbg*/,
3883    Dwarf_Half /*value*/);
3884Dwarf_Half dwarf_set_frame_rule_table_size(Dwarf_Debug /*dbg*/,
3885    Dwarf_Half /*value*/);
3886Dwarf_Half dwarf_set_frame_cfa_value(Dwarf_Debug /*dbg*/,
3887    Dwarf_Half /*value*/);
3888Dwarf_Half dwarf_set_frame_same_value(Dwarf_Debug /*dbg*/,
3889    Dwarf_Half /*value*/);
3890Dwarf_Half dwarf_set_frame_undefined_value(Dwarf_Debug /*dbg*/,
3891    Dwarf_Half /*value*/);
3892/*  dwarf_set_default_address_size only sets 'value' if value is
3893    greater than zero. */
3894Dwarf_Small dwarf_set_default_address_size(Dwarf_Debug /*dbg*/,
3895    Dwarf_Small /* value */);
3896
3897/*  As of April 27, 2009, this version with no diepointer is
3898    obsolete though supported.  Use dwarf_get_ranges_a() instead. */
3899int dwarf_get_ranges(Dwarf_Debug /*dbg*/,
3900    Dwarf_Off /*rangesoffset*/,
3901    Dwarf_Ranges ** /*rangesbuf*/,
3902    Dwarf_Signed * /*listlen*/,
3903    Dwarf_Unsigned * /*bytecount*/,
3904    Dwarf_Error * /*error*/);
3905
3906/* This adds the address_size argument. New April 27, 2009 */
3907int dwarf_get_ranges_a(Dwarf_Debug /*dbg*/,
3908    Dwarf_Off /*rangesoffset*/,
3909    Dwarf_Die  /* diepointer */,
3910    Dwarf_Ranges ** /*rangesbuf*/,
3911    Dwarf_Signed * /*listlen*/,
3912    Dwarf_Unsigned * /*bytecount*/,
3913    Dwarf_Error * /*error*/);
3914
3915void dwarf_ranges_dealloc(Dwarf_Debug /*dbg*/,
3916    Dwarf_Ranges * /*rangesbuf*/,
3917    Dwarf_Signed /*rangecount*/);
3918
3919/* The harmless error list is a circular buffer of
3920   errors we note but which do not stop us from processing
3921   the object.  Created so dwarfdump or other tools
3922   can report such inconsequential errors without causing
3923   anything to stop early. */
3924#define DW_HARMLESS_ERROR_CIRCULAR_LIST_DEFAULT_SIZE 4
3925#define DW_HARMLESS_ERROR_MSG_STRING_SIZE   200
3926/* User code supplies size of array of pointers errmsg_ptrs_array
3927    in count and the array of pointers (the pointers themselves
3928    need not be initialized).
3929    The pointers returned in the array of pointers
3930    are invalidated by ANY call to libdwarf.
3931    Use them before making another libdwarf call!
3932    The array of string pointers passed in always has
3933    a final null pointer, so if there are N pointers the
3934    and M actual strings, then MIN(M,N-1) pointers are
3935    set to point to error strings.  The array of pointers
3936    to strings always terminates with a NULL pointer.
3937    If 'count' is passed in zero then errmsg_ptrs_array
3938    is not touched.
3939
3940    The function returns DW_DLV_NO_ENTRY if no harmless errors
3941    were noted so far.  Returns DW_DLV_OK if there are errors.
3942    Never returns DW_DLV_ERROR.
3943
3944    Each call empties the error list (discarding all current entries).
3945    If newerr_count is non-NULL the count of harmless errors
3946    since the last call is returned through the pointer
3947    (some may have been discarded or not returned, it is a circular
3948    list...).
3949    If DW_DLV_NO_ENTRY is returned none of the arguments
3950    here are touched or used.
3951    */
3952int dwarf_get_harmless_error_list(Dwarf_Debug /*dbg*/,
3953    unsigned  /*count*/,
3954    const char ** /*errmsg_ptrs_array*/,
3955    unsigned * /*newerr_count*/);
3956
3957/*  Insertion is only for testing the harmless error code, it is not
3958    necessarily useful otherwise. */
3959void dwarf_insert_harmless_error(Dwarf_Debug /*dbg*/,
3960    char * /*newerror*/);
3961
3962/*  The size of the circular list of strings may be set
3963    and reset as needed.  If it is shortened excess
3964    messages are simply dropped.  It returns the previous
3965    size. If zero passed in the size is unchanged
3966    and it simply returns the current size  */
3967unsigned dwarf_set_harmless_error_list_size(Dwarf_Debug /*dbg*/,
3968    unsigned /*maxcount*/);
3969/*  The harmless error strings (if any) are freed when the dbg
3970    is dwarf_finish()ed. */
3971
3972/*  When the val_in is known these dwarf_get_TAG_name (etc)
3973    functions return the string corresponding to the val_in passed in
3974    through the pointer s_out and the value returned is DW_DLV_OK.
3975    The strings are in static storage
3976    and must not be freed.
3977    If DW_DLV_NO_ENTRY is returned the val_in is not known and
3978    *s_out is not set.  DW_DLV_ERROR is never returned.*/
3979
3980/* The following copied from a generated dwarf_names.h */
3981
3982/* BEGIN FILE */
3983extern int dwarf_get_ACCESS_name(unsigned int /*val_in*/, const char ** /*s_out */);
3984extern int dwarf_get_ADDR_name(unsigned int /*val_in*/, const char ** /*s_out */);
3985extern int dwarf_get_ATCF_name(unsigned int /*val_in*/, const char ** /*s_out */);
3986extern int dwarf_get_ATE_name(unsigned int /*val_in*/, const char ** /*s_out */);
3987extern int dwarf_get_AT_name(unsigned int /*val_in*/, const char ** /*s_out */);
3988extern int dwarf_get_CC_name(unsigned int /*val_in*/, const char ** /*s_out */);
3989extern int dwarf_get_CFA_name(unsigned int /*val_in*/, const char ** /*s_out */);
3990extern int dwarf_get_children_name(unsigned int /*val_in*/, const char ** /*s_out */);
3991extern int dwarf_get_CHILDREN_name(unsigned int /*val_in*/, const char ** /*s_out */);
3992extern int dwarf_get_DEFAULTED_name(unsigned int /*val_in*/, const char ** /*s_out */);
3993extern int dwarf_get_DSC_name(unsigned int /*val_in*/, const char ** /*s_out */);
3994extern int dwarf_get_DS_name(unsigned int /*val_in*/, const char ** /*s_out */);
3995extern int dwarf_get_EH_name(unsigned int /*val_in*/, const char ** /*s_out */);
3996extern int dwarf_get_END_name(unsigned int /*val_in*/, const char ** /*s_out */);
3997extern int dwarf_get_FORM_name(unsigned int /*val_in*/, const char ** /*s_out */);
3998extern int dwarf_get_FRAME_name(unsigned int /*val_in*/, const char ** /*s_out */);
3999extern int dwarf_get_ID_name(unsigned int /*val_in*/, const char ** /*s_out */);
4000extern int dwarf_get_IDX_name(unsigned int /*val_in*/, const char ** /*s_out */);
4001extern int dwarf_get_INL_name(unsigned int /*val_in*/, const char ** /*s_out */);
4002extern int dwarf_get_ISA_name(unsigned int /*val_in*/, const char ** /*s_out */);
4003extern int dwarf_get_LANG_name(unsigned int /*val_in*/, const char ** /*s_out */);
4004extern int dwarf_get_LLE_name(unsigned int /*val_in*/, const char ** /*s_out */);
4005/*  dwarf_get_LLEX_name is likely just temporary. Not standard. */
4006extern int dwarf_get_LLEX_name(unsigned int /*val_in*/, const char ** /*s_out */);
4007extern int dwarf_get_LNCT_name(unsigned int /*val_in*/, const char ** /*s_out */);
4008extern int dwarf_get_LNE_name(unsigned int /*val_in*/, const char ** /*s_out */);
4009extern int dwarf_get_LNS_name(unsigned int /*val_in*/, const char ** /*s_out */);
4010extern int dwarf_get_MACINFO_name(unsigned int /*val_in*/, const char ** /*s_out */);
4011extern int dwarf_get_MACRO_name(unsigned int /*val_in*/, const char ** /*s_out */);
4012extern int dwarf_get_OP_name(unsigned int /*val_in*/, const char ** /*s_out */);
4013extern int dwarf_get_ORD_name(unsigned int /*val_in*/, const char ** /*s_out */);
4014extern int dwarf_get_RLE_name(unsigned int /*val_in*/, const char ** /*s_out */);
4015extern int dwarf_get_SECT_name(unsigned int /*val_in*/, const char ** /*s_out */);
4016extern int dwarf_get_TAG_name(unsigned int /*val_in*/, const char ** /*s_out */);
4017extern int dwarf_get_UT_name(unsigned int /*val_in*/, const char ** /*s_out */);
4018extern int dwarf_get_VIRTUALITY_name(unsigned int /*val_in*/, const char ** /*s_out */);
4019extern int dwarf_get_VIS_name(unsigned int /*val_in*/, const char ** /*s_out */);
4020/* END FILE */
4021
4022/* Convert local offset into global offset */
4023int dwarf_convert_to_global_offset(Dwarf_Attribute  /*attr*/,
4024    Dwarf_Off        /*offset*/,
4025    Dwarf_Off*       /*ret_offset*/,
4026    Dwarf_Error*     /*error*/);
4027
4028/* Get both offsets (local and global) */
4029int dwarf_die_offsets(Dwarf_Die     /*die*/,
4030    Dwarf_Off*    /*global_offset*/,
4031    Dwarf_Off*    /*local_offset*/,
4032    Dwarf_Error*  /*error*/);
4033
4034/* Giving a section name, get its size and address */
4035int dwarf_get_section_info_by_name(Dwarf_Debug      /*dbg*/,
4036    const char *     /*section_name*/,
4037    Dwarf_Addr*      /*section_addr*/,
4038    Dwarf_Unsigned*  /*section_size*/,
4039    Dwarf_Error*     /*error*/);
4040
4041/* Giving a section index, get its size and address */
4042int dwarf_get_section_info_by_index(Dwarf_Debug      /*dbg*/,
4043    int              /*section_index*/,
4044    const char **    /*section_name*/,
4045    Dwarf_Addr*      /*section_addr*/,
4046    Dwarf_Unsigned*  /*section_size*/,
4047    Dwarf_Error*     /*error*/);
4048
4049/*  Get section count, of object file sections. */
4050int dwarf_get_section_count(Dwarf_Debug /*dbg*/);
4051
4052/*  Get the version and offset size of a CU context.
4053    This is useful as a precursor to
4054    calling dwarf_get_form_class() at times.  */
4055int dwarf_get_version_of_die(Dwarf_Die /*die*/,
4056    Dwarf_Half * /*version*/,
4057    Dwarf_Half * /*offset_size*/);
4058
4059
4060int dwarf_discr_list(Dwarf_Debug /*dbg*/,
4061    Dwarf_Small    * /*blockpointer*/,
4062    Dwarf_Unsigned   /*blocklen*/,
4063    Dwarf_Dsc_Head * /*dsc_head_out*/,
4064    Dwarf_Unsigned * /*dsc_array_length_out*/,
4065    Dwarf_Error    * /*error*/);
4066
4067/*  NEW September 2016. Allows easy access to DW_AT_discr_list
4068    entry. Callers must know which is the appropriate
4069    one of the following two interfaces, though both
4070    will work. */
4071int dwarf_discr_entry_u(Dwarf_Dsc_Head /* dsc */,
4072    Dwarf_Unsigned   /*entrynum*/,
4073    Dwarf_Half     * /*out_type*/,
4074    Dwarf_Unsigned * /*out_discr_low*/,
4075    Dwarf_Unsigned * /*out_discr_high*/,
4076    Dwarf_Error    * /*error*/);
4077
4078/*  NEW September 2016. Allows easy access to DW_AT_discr_list
4079    entry. */
4080int dwarf_discr_entry_s(Dwarf_Dsc_Head /* dsc */,
4081    Dwarf_Unsigned   /*entrynum*/,
4082    Dwarf_Half     * /*out_type*/,
4083    Dwarf_Signed   * /*out_discr_low*/,
4084    Dwarf_Signed   * /*out_discr_high*/,
4085    Dwarf_Error    * /*error*/);
4086
4087/*  These make the  LEB encoding routines visible to libdwarf
4088    callers. Added November, 2012. */
4089int dwarf_encode_leb128(Dwarf_Unsigned /*val*/,
4090    int * /*nbytes*/,
4091    char * /*space*/,
4092    int /*splen*/);
4093int dwarf_encode_signed_leb128(Dwarf_Signed /*val*/,
4094    int * /*nbytes*/,
4095    char * /*space*/,
4096    int /*splen*/);
4097
4098/*  Record some application command line options in libdwarf.
4099    This is not arc/argv processing, just precooked setting
4100    of a flag in libdwarf based on something the application
4101    wants.  check_verbose_mode of TRUE means do more checking
4102    and sometimes print errors (from libdwarf).
4103    Not restricted to a single Dwarf_Debug, it applies
4104    to the libdwarf the executable is using.
4105*/
4106typedef struct {
4107    Dwarf_Bool check_verbose_mode;
4108} Dwarf_Cmdline_Options;
4109extern Dwarf_Cmdline_Options dwarf_cmdline_options;
4110
4111/* Set libdwarf to reflect some application command line options. */
4112void dwarf_record_cmdline_options(Dwarf_Cmdline_Options /*options*/);
4113
4114int dwarf_pro_get_string_stats(Dwarf_P_Debug /*dbg*/,
4115    Dwarf_Unsigned * /*str_count*/,
4116    Dwarf_Unsigned * /*str_total_length*/,
4117    Dwarf_Unsigned * /*count_debug_str*/,
4118    Dwarf_Unsigned * /*len_debug_str*/,
4119    Dwarf_Unsigned * /*reused_count*/,
4120    Dwarf_Unsigned * /*reused_len*/,
4121    Dwarf_Error    * /*error*/);
4122
4123#ifdef __cplusplus
4124}
4125#endif
4126#endif /* _LIBDWARF_H */
4127
4128
4129