Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 1 | /* Interfaces for libdw. |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 2 | Copyright (C) 2002-2009 Red Hat, Inc. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 3 | This file is part of Red Hat elfutils. |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 4 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 5 | Red Hat elfutils is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by the |
| 7 | Free Software Foundation; version 2 of the License. |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 8 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 9 | Red Hat elfutils is distributed in the hope that it will be useful, but |
| 10 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along |
| 15 | with Red Hat elfutils; if not, write to the Free Software Foundation, |
Ulrich Drepper | 1e9ef50 | 2006-04-04 22:29:06 +0000 | [diff] [blame] | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 17 | |
| 18 | In addition, as a special exception, Red Hat, Inc. gives You the |
| 19 | additional right to link the code of Red Hat elfutils with code licensed |
| 20 | under any Open Source Initiative certified open source license |
| 21 | (http://www.opensource.org/licenses/index.php) which requires the |
| 22 | distribution of source code with any binary distribution and to |
| 23 | distribute linked combinations of the two. Non-GPL Code permitted under |
| 24 | this exception must only link to the code of Red Hat elfutils through |
| 25 | those well defined interfaces identified in the file named EXCEPTION |
| 26 | found in the source code files (the "Approved Interfaces"). The files |
| 27 | of Non-GPL Code may instantiate templates or use macros or inline |
| 28 | functions from the Approved Interfaces without causing the resulting |
| 29 | work to be covered by the GNU General Public License. Only Red Hat, |
| 30 | Inc. may make changes or additions to the list of Approved Interfaces. |
| 31 | Red Hat's grant of this exception is conditioned upon your not adding |
| 32 | any new exceptions. If you wish to add a new Approved Interface or |
| 33 | exception, please contact Red Hat. You must obey the GNU General Public |
| 34 | License in all respects for all of the Red Hat elfutils code and other |
| 35 | code used in conjunction with Red Hat elfutils except the Non-GPL Code |
| 36 | covered by this exception. If you modify this file, you may extend this |
| 37 | exception to your version of the file, but you are not obligated to do |
| 38 | so. If you do not wish to provide this exception without modification, |
| 39 | you must delete this exception statement from your version and license |
| 40 | this file solely under the GPL without exception. |
| 41 | |
| 42 | Red Hat elfutils is an included package of the Open Invention Network. |
| 43 | An included package of the Open Invention Network is a package for which |
| 44 | Open Invention Network licensees cross-license their patents. No patent |
| 45 | license is granted, either expressly or impliedly, by designation as an |
| 46 | included package. Should you wish to participate in the Open Invention |
| 47 | Network licensing program, please visit www.openinventionnetwork.com |
| 48 | <http://www.openinventionnetwork.com>. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 49 | |
| 50 | #ifndef _LIBDW_H |
| 51 | #define _LIBDW_H 1 |
| 52 | |
| 53 | #include <gelf.h> |
| 54 | #include <stdbool.h> |
| 55 | #include <stddef.h> |
| 56 | |
| 57 | |
| 58 | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) |
| 59 | # define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__))) |
Roland McGrath | e4c22ea | 2007-10-23 13:07:39 +0000 | [diff] [blame] | 60 | # define __deprecated_attribute__ __attribute__ ((__deprecated__)) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 61 | #else |
| 62 | # define __nonnull_attribute__(args...) |
Roland McGrath | e4c22ea | 2007-10-23 13:07:39 +0000 | [diff] [blame] | 63 | # define __deprecated_attribute__ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 64 | #endif |
| 65 | |
Roland McGrath | e4c22ea | 2007-10-23 13:07:39 +0000 | [diff] [blame] | 66 | |
Roland McGrath | 87d4780 | 2007-07-16 22:23:37 +0000 | [diff] [blame] | 67 | #ifdef __GNUC_STDC_INLINE__ |
Ulrich Drepper | b597dfa | 2007-10-16 05:21:27 +0000 | [diff] [blame] | 68 | # define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__)) |
Roland McGrath | 87d4780 | 2007-07-16 22:23:37 +0000 | [diff] [blame] | 69 | #else |
Ulrich Drepper | b597dfa | 2007-10-16 05:21:27 +0000 | [diff] [blame] | 70 | # define __libdw_extern_inline extern __inline |
Roland McGrath | 87d4780 | 2007-07-16 22:23:37 +0000 | [diff] [blame] | 71 | #endif |
| 72 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 73 | |
| 74 | /* Mode for the session. */ |
| 75 | typedef enum |
| 76 | { |
| 77 | DWARF_C_READ, /* Read .. */ |
| 78 | DWARF_C_RDWR, /* Read and write .. */ |
| 79 | DWARF_C_WRITE, /* Write .. */ |
| 80 | } |
| 81 | Dwarf_Cmd; |
| 82 | |
| 83 | |
| 84 | /* Callback results. */ |
| 85 | enum |
| 86 | { |
| 87 | DWARF_CB_OK = 0, |
| 88 | DWARF_CB_ABORT |
| 89 | }; |
| 90 | |
| 91 | |
| 92 | /* Error values. */ |
| 93 | enum |
| 94 | { |
| 95 | DW_TAG_invalid = 0 |
| 96 | #define DW_TAG_invalid DW_TAG_invalid |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | /* Type for offset in DWARF file. */ |
| 101 | typedef GElf_Off Dwarf_Off; |
| 102 | |
| 103 | /* Type for address in DWARF file. */ |
| 104 | typedef GElf_Addr Dwarf_Addr; |
| 105 | |
| 106 | /* Integer types. Big enough to hold any numeric value. */ |
| 107 | typedef GElf_Xword Dwarf_Word; |
| 108 | typedef GElf_Sxword Dwarf_Sword; |
| 109 | /* For the times we know we do not need that much. */ |
| 110 | typedef GElf_Half Dwarf_Half; |
| 111 | |
| 112 | |
| 113 | /* DWARF abbreviation record. */ |
| 114 | typedef struct Dwarf_Abbrev Dwarf_Abbrev; |
| 115 | |
| 116 | /* Returned to show the last DIE has be returned. */ |
| 117 | #define DWARF_END_ABBREV ((Dwarf_Abbrev *) -1l) |
| 118 | |
| 119 | /* Source code line information for CU. */ |
| 120 | typedef struct Dwarf_Lines_s Dwarf_Lines; |
| 121 | |
| 122 | /* One source code line information. */ |
| 123 | typedef struct Dwarf_Line_s Dwarf_Line; |
| 124 | |
| 125 | /* Source file information. */ |
| 126 | typedef struct Dwarf_Files_s Dwarf_Files; |
| 127 | |
| 128 | /* One address range record. */ |
| 129 | typedef struct Dwarf_Arange_s Dwarf_Arange; |
| 130 | |
| 131 | /* Address ranges of a file. */ |
| 132 | typedef struct Dwarf_Aranges_s Dwarf_Aranges; |
| 133 | |
| 134 | /* CU representation. */ |
| 135 | struct Dwarf_CU; |
| 136 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 137 | /* Macro information. */ |
| 138 | typedef struct Dwarf_Macro_s Dwarf_Macro; |
| 139 | |
| 140 | /* Attribute representation. */ |
| 141 | typedef struct |
| 142 | { |
| 143 | unsigned int code; |
| 144 | unsigned int form; |
| 145 | unsigned char *valp; |
| 146 | struct Dwarf_CU *cu; |
| 147 | } Dwarf_Attribute; |
| 148 | |
| 149 | |
| 150 | /* Data block representation. */ |
| 151 | typedef struct |
| 152 | { |
| 153 | Dwarf_Word length; |
| 154 | unsigned char *data; |
| 155 | } Dwarf_Block; |
| 156 | |
| 157 | |
| 158 | /* DIE information. */ |
| 159 | typedef struct |
| 160 | { |
| 161 | /* The offset can be computed from the address. */ |
| 162 | void *addr; |
| 163 | struct Dwarf_CU *cu; |
| 164 | Dwarf_Abbrev *abbrev; |
| 165 | // XXX We'll see what other information will be needed. |
| 166 | long int padding__; |
| 167 | } Dwarf_Die; |
| 168 | |
| 169 | /* Returned to show the last DIE has be returned. */ |
| 170 | #define DWARF_END_DIE ((Dwarf_Die *) -1l) |
| 171 | |
| 172 | |
| 173 | /* Global symbol information. */ |
| 174 | typedef struct |
| 175 | { |
| 176 | Dwarf_Off cu_offset; |
| 177 | Dwarf_Off die_offset; |
| 178 | const char *name; |
| 179 | } Dwarf_Global; |
| 180 | |
| 181 | |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 182 | /* One operation in a DWARF location expression. |
| 183 | A location expression is an array of these. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 184 | typedef struct |
| 185 | { |
| 186 | uint8_t atom; /* Operation */ |
| 187 | Dwarf_Word number; /* Operand */ |
| 188 | Dwarf_Word number2; /* Possible second operand */ |
| 189 | Dwarf_Word offset; /* Offset in location expression */ |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 190 | } Dwarf_Op; |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 191 | |
| 192 | |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 193 | /* This describes one Common Information Entry read from a CFI section. |
| 194 | Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi. */ |
| 195 | typedef struct |
| 196 | { |
| 197 | Dwarf_Off CIE_id; /* Always DW_CIE_ID_64 in Dwarf_CIE structures. */ |
| 198 | |
| 199 | /* Instruction stream describing initial state used by FDEs. If |
| 200 | we did not understand the whole augmentation string and it did |
| 201 | not use 'z', then there might be more augmentation data here |
| 202 | (and in FDEs) before the actual instructions. */ |
| 203 | const uint8_t *initial_instructions; |
| 204 | const uint8_t *initial_instructions_end; |
| 205 | |
| 206 | Dwarf_Word code_alignment_factor; |
| 207 | Dwarf_Sword data_alignment_factor; |
| 208 | Dwarf_Word return_address_register; |
| 209 | |
| 210 | const char *augmentation; /* Augmentation string. */ |
| 211 | |
| 212 | /* Augmentation data, might be NULL. The size is correct only if |
| 213 | we understood the augmentation string sufficiently. */ |
| 214 | const uint8_t *augmentation_data; |
| 215 | size_t augmentation_data_size; |
| 216 | size_t fde_augmentation_data_size; |
| 217 | } Dwarf_CIE; |
| 218 | |
| 219 | /* This describes one Frame Description Entry read from a CFI section. |
| 220 | Pointers here point into the DATA->d_buf block passed to dwarf_next_cfi. */ |
| 221 | typedef struct |
| 222 | { |
| 223 | /* Section offset of CIE this FDE refers to. This will never be |
| 224 | DW_CIE_ID_64 in an FDE. If this value is DW_CIE_ID_64, this is |
| 225 | actually a Dwarf_CIE structure. */ |
| 226 | Dwarf_Off CIE_pointer; |
| 227 | |
| 228 | /* We can't really decode anything further without looking up the CIE |
| 229 | and checking its augmentation string. Here follows the encoded |
| 230 | initial_location and address_range, then any augmentation data, |
| 231 | then the instruction stream. This FDE describes PC locations in |
| 232 | the byte range [initial_location, initial_location+address_range). |
| 233 | When the CIE augmentation string uses 'z', the augmentation data is |
| 234 | a DW_FORM_block (self-sized). Otherwise, when we understand the |
| 235 | augmentation string completely, fde_augmentation_data_size gives |
| 236 | the number of bytes of augmentation data before the instructions. */ |
| 237 | const uint8_t *start; |
| 238 | const uint8_t *end; |
| 239 | } Dwarf_FDE; |
| 240 | |
| 241 | /* Each entry in a CFI section is either a CIE described by Dwarf_CIE or |
| 242 | an FDE described by Dward_FDE. Check CIE_id to see which you have. */ |
| 243 | typedef union |
| 244 | { |
| 245 | Dwarf_Off CIE_id; /* Always DW_CIE_ID_64 in Dwarf_CIE structures. */ |
| 246 | Dwarf_CIE cie; |
| 247 | Dwarf_FDE fde; |
| 248 | } Dwarf_CFI_Entry; |
| 249 | |
| 250 | /* Opaque type representing a frame state described by CFI. */ |
| 251 | typedef struct Dwarf_Frame_s Dwarf_Frame; |
| 252 | |
| 253 | /* Opaque type representing a CFI section found in a DWARF or ELF file. */ |
| 254 | typedef struct Dwarf_CFI_s Dwarf_CFI; |
| 255 | |
| 256 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 257 | /* Handle for debug sessions. */ |
| 258 | typedef struct Dwarf Dwarf; |
| 259 | |
| 260 | |
| 261 | /* Out-Of-Memory handler. */ |
| 262 | #if __GNUC__ < 4 |
| 263 | typedef void (*Dwarf_OOM) (void); |
| 264 | #else |
| 265 | typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void); |
| 266 | #endif |
| 267 | |
| 268 | |
Ulrich Drepper | 3be7447 | 2006-05-27 18:15:40 +0000 | [diff] [blame] | 269 | #ifdef __cplusplus |
| 270 | extern "C" { |
| 271 | #endif |
| 272 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 273 | /* Create a handle for a new debug session. */ |
| 274 | extern Dwarf *dwarf_begin (int fildes, Dwarf_Cmd cmd); |
| 275 | |
| 276 | /* Create a handle for a new debug session for an ELF file. */ |
| 277 | extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp); |
| 278 | |
| 279 | /* Retrieve ELF descriptor used for DWARF access. */ |
| 280 | extern Elf *dwarf_getelf (Dwarf *dwarf); |
| 281 | |
| 282 | /* Release debugging handling context. */ |
| 283 | extern int dwarf_end (Dwarf *dwarf); |
| 284 | |
| 285 | |
| 286 | /* Get the data block for the .debug_info section. */ |
| 287 | extern Elf_Data *dwarf_getscn_info (Dwarf *dwarf); |
| 288 | |
| 289 | /* Read the header for the DWARF CU header. */ |
| 290 | extern int dwarf_nextcu (Dwarf *dwarf, Dwarf_Off off, Dwarf_Off *next_off, |
| 291 | size_t *header_sizep, Dwarf_Off *abbrev_offsetp, |
| 292 | uint8_t *address_sizep, uint8_t *offset_sizep) |
| 293 | __nonnull_attribute__ (3); |
| 294 | |
| 295 | |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 296 | /* Decode one DWARF CFI entry (CIE or FDE) from the raw section data. |
| 297 | The E_IDENT from the originating ELF file indicates the address |
| 298 | size and byte order used in the CFI section contained in DATA; |
| 299 | EH_FRAME_P should be true for .eh_frame format and false for |
| 300 | .debug_frame format. OFFSET is the byte position in the section |
| 301 | to start at; on return *NEXT_OFFSET is filled in with the byte |
| 302 | position immediately after this entry. |
| 303 | |
| 304 | On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to |
| 305 | see whether ENTRY->cie or ENTRY->fde is valid. |
| 306 | |
| 307 | On errors, returns -1. Some format errors will permit safely |
| 308 | skipping to the next CFI entry though the current one is unusable. |
| 309 | In that case, *NEXT_OFF will be updated before a -1 return. |
| 310 | |
| 311 | If there are no more CFI entries left in the section, |
| 312 | returns 1 and sets *NEXT_OFFSET to (Dwarf_Off) -1. */ |
| 313 | extern int dwarf_next_cfi (const unsigned char e_ident[], |
| 314 | Elf_Data *data, bool eh_frame_p, |
| 315 | Dwarf_Off offset, Dwarf_Off *next_offset, |
| 316 | Dwarf_CFI_Entry *entry) |
| 317 | __nonnull_attribute__ (1, 2, 5, 6); |
| 318 | |
| 319 | /* Use the CFI in the DWARF .debug_frame section. |
| 320 | Returns NULL if there is no such section (not an error). |
| 321 | The pointer returned can be used until dwarf_end is called on DWARF, |
| 322 | and must not be passed to dwarf_cfi_end. |
| 323 | Calling this more than once returns the same pointer. */ |
| 324 | extern Dwarf_CFI *dwarf_getcfi (Dwarf *dwarf); |
| 325 | |
| 326 | /* Use the CFI in the ELF file's exception-handling data. |
| 327 | Returns NULL if there is no such data. |
| 328 | The pointer returned can be used until elf_end is called on ELF, |
| 329 | and must be passed to dwarf_cfi_end before then. |
| 330 | Calling this more than once allocates independent data structures. */ |
| 331 | extern Dwarf_CFI *dwarf_getcfi_elf (Elf *elf); |
| 332 | |
| 333 | /* Release resources allocated by dwarf_getcfi_elf. */ |
| 334 | extern int dwarf_cfi_end (Dwarf_CFI *cache); |
| 335 | |
| 336 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 337 | /* Return DIE at given offset. */ |
| 338 | extern Dwarf_Die *dwarf_offdie (Dwarf *dbg, Dwarf_Off offset, |
| 339 | Dwarf_Die *result) __nonnull_attribute__ (3); |
| 340 | |
| 341 | /* Return offset of DIE. */ |
| 342 | extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die); |
| 343 | |
| 344 | /* Return offset of DIE in CU. */ |
| 345 | extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die); |
| 346 | |
Roland McGrath | 07d4f2f | 2005-10-28 06:56:24 +0000 | [diff] [blame] | 347 | /* Return CU DIE containing given DIE. */ |
| 348 | extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result, |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 349 | uint8_t *address_sizep, uint8_t *offset_sizep) |
| 350 | __nonnull_attribute__ (2); |
Roland McGrath | 07d4f2f | 2005-10-28 06:56:24 +0000 | [diff] [blame] | 351 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 352 | /* Return CU DIE containing given address. */ |
| 353 | extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr, |
| 354 | Dwarf_Die *result) __nonnull_attribute__ (3); |
| 355 | |
| 356 | /* Return child of current DIE. */ |
| 357 | extern int dwarf_child (Dwarf_Die *die, Dwarf_Die *result) |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 358 | __nonnull_attribute__ (2); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 359 | |
Ulrich Drepper | 35f08c4 | 2008-01-18 19:59:08 +0000 | [diff] [blame] | 360 | /* Locates the first sibling of DIE and places it in RESULT. |
| 361 | Returns 0 if a sibling was found, -1 if something went wrong. |
| 362 | Returns 1 if no sibling could be found and, if RESULT is not |
| 363 | the same as DIE, it sets RESULT->addr to the address of the |
| 364 | (non-sibling) DIE that follows this one, or NULL if this DIE |
| 365 | was the last one in the cokmpilation unit. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 366 | extern int dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result) |
| 367 | __nonnull_attribute__ (2); |
| 368 | |
| 369 | /* Check whether the DIE has children. */ |
Ulrich Drepper | 4f3d2a2 | 2006-05-22 01:30:56 +0000 | [diff] [blame] | 370 | extern int dwarf_haschildren (Dwarf_Die *die) __nonnull_attribute__ (1); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 371 | |
Ulrich Drepper | 35f08c4 | 2008-01-18 19:59:08 +0000 | [diff] [blame] | 372 | /* Walks the attributes of DIE, starting at the one OFFSET bytes in, |
| 373 | calling the CALLBACK function for each one. Stops if the callback |
| 374 | function ever returns a value other than DWARF_CB_OK and returns the |
| 375 | offset of the offending attribute. If the end of the attributes |
| 376 | is reached 1 is returned. If something goes wrong -1 is returned and |
| 377 | the dwarf error number is set. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 378 | extern ptrdiff_t dwarf_getattrs (Dwarf_Die *die, |
| 379 | int (*callback) (Dwarf_Attribute *, void *), |
Ulrich Drepper | 4f3d2a2 | 2006-05-22 01:30:56 +0000 | [diff] [blame] | 380 | void *arg, ptrdiff_t offset) |
| 381 | __nonnull_attribute__ (2); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 382 | |
| 383 | /* Return tag of given DIE. */ |
Ulrich Drepper | 4f3d2a2 | 2006-05-22 01:30:56 +0000 | [diff] [blame] | 384 | extern int dwarf_tag (Dwarf_Die *die) __nonnull_attribute__ (1); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 385 | |
| 386 | |
| 387 | /* Return specific attribute of DIE. */ |
| 388 | extern Dwarf_Attribute *dwarf_attr (Dwarf_Die *die, unsigned int search_name, |
| 389 | Dwarf_Attribute *result) |
| 390 | __nonnull_attribute__ (3); |
| 391 | |
| 392 | /* Check whether given DIE has specific attribute. */ |
| 393 | extern int dwarf_hasattr (Dwarf_Die *die, unsigned int search_name); |
| 394 | |
| 395 | /* These are the same as dwarf_attr and dwarf_hasattr, respectively, |
| 396 | but they resolve an indirect attribute through DW_AT_abstract_origin. */ |
| 397 | extern Dwarf_Attribute *dwarf_attr_integrate (Dwarf_Die *die, |
| 398 | unsigned int search_name, |
| 399 | Dwarf_Attribute *result) |
| 400 | __nonnull_attribute__ (3); |
| 401 | extern int dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name); |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | /* Check whether given attribute has specific form. */ |
| 407 | extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form); |
| 408 | |
| 409 | /* Return attribute code of given attribute. */ |
| 410 | extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr); |
| 411 | |
| 412 | /* Return form code of given attribute. */ |
| 413 | extern unsigned int dwarf_whatform (Dwarf_Attribute *attr); |
| 414 | |
| 415 | |
| 416 | /* Return string associated with given attribute. */ |
| 417 | extern const char *dwarf_formstring (Dwarf_Attribute *attrp); |
| 418 | |
| 419 | /* Return unsigned constant represented by attribute. */ |
| 420 | extern int dwarf_formudata (Dwarf_Attribute *attr, Dwarf_Word *return_uval) |
| 421 | __nonnull_attribute__ (2); |
| 422 | |
| 423 | /* Return signed constant represented by attribute. */ |
| 424 | extern int dwarf_formsdata (Dwarf_Attribute *attr, Dwarf_Sword *return_uval) |
| 425 | __nonnull_attribute__ (2); |
| 426 | |
| 427 | /* Return address represented by attribute. */ |
| 428 | extern int dwarf_formaddr (Dwarf_Attribute *attr, Dwarf_Addr *return_addr) |
| 429 | __nonnull_attribute__ (2); |
| 430 | |
Roland McGrath | e4c22ea | 2007-10-23 13:07:39 +0000 | [diff] [blame] | 431 | /* This function is deprecated. Always use dwarf_formref_die instead. |
| 432 | Return reference offset represented by attribute. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 433 | extern int dwarf_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset) |
Roland McGrath | e4c22ea | 2007-10-23 13:07:39 +0000 | [diff] [blame] | 434 | __nonnull_attribute__ (2) __deprecated_attribute__; |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 435 | |
| 436 | /* Look up the DIE in a reference-form attribute. */ |
| 437 | extern Dwarf_Die *dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *die_mem) |
| 438 | __nonnull_attribute__ (2); |
| 439 | |
| 440 | /* Return block represented by attribute. */ |
| 441 | extern int dwarf_formblock (Dwarf_Attribute *attr, Dwarf_Block *return_block) |
| 442 | __nonnull_attribute__ (2); |
| 443 | |
| 444 | /* Return flag represented by attribute. */ |
| 445 | extern int dwarf_formflag (Dwarf_Attribute *attr, bool *return_bool) |
| 446 | __nonnull_attribute__ (2); |
| 447 | |
| 448 | |
| 449 | /* Simplified attribute value access functions. */ |
| 450 | |
| 451 | /* Return string in name attribute of DIE. */ |
| 452 | extern const char *dwarf_diename (Dwarf_Die *die); |
| 453 | |
| 454 | /* Return high PC attribute of DIE. */ |
| 455 | extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr) |
| 456 | __nonnull_attribute__ (2); |
| 457 | |
| 458 | /* Return low PC attribute of DIE. */ |
| 459 | extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr) |
| 460 | __nonnull_attribute__ (2); |
| 461 | |
Roland McGrath | 07d4f2f | 2005-10-28 06:56:24 +0000 | [diff] [blame] | 462 | /* Return entry_pc or low_pc attribute of DIE. */ |
| 463 | extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr) |
| 464 | __nonnull_attribute__ (2); |
| 465 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 466 | /* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address, |
| 467 | 0 if not, or -1 for errors. */ |
| 468 | extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc); |
| 469 | |
Roland McGrath | 07d4f2f | 2005-10-28 06:56:24 +0000 | [diff] [blame] | 470 | /* Enumerate the PC address ranges covered by this DIE, covering all |
| 471 | addresses where dwarf_haspc returns true. In the first call OFFSET |
| 472 | should be zero and *BASEP need not be initialized. Returns -1 for |
| 473 | errors, zero when there are no more address ranges to report, or a |
| 474 | nonzero OFFSET value to pass to the next call. Each subsequent call |
| 475 | must preserve *BASEP from the prior call. Successful calls fill in |
| 476 | *STARTP and *ENDP with a contiguous address range. */ |
| 477 | extern ptrdiff_t dwarf_ranges (Dwarf_Die *die, |
| 478 | ptrdiff_t offset, Dwarf_Addr *basep, |
| 479 | Dwarf_Addr *startp, Dwarf_Addr *endp); |
| 480 | |
| 481 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 482 | /* Return byte size attribute of DIE. */ |
| 483 | extern int dwarf_bytesize (Dwarf_Die *die); |
| 484 | |
| 485 | /* Return bit size attribute of DIE. */ |
| 486 | extern int dwarf_bitsize (Dwarf_Die *die); |
| 487 | |
| 488 | /* Return bit offset attribute of DIE. */ |
| 489 | extern int dwarf_bitoffset (Dwarf_Die *die); |
| 490 | |
| 491 | /* Return array order attribute of DIE. */ |
| 492 | extern int dwarf_arrayorder (Dwarf_Die *die); |
| 493 | |
| 494 | /* Return source language attribute of DIE. */ |
| 495 | extern int dwarf_srclang (Dwarf_Die *die); |
| 496 | |
| 497 | |
| 498 | /* Get abbreviation at given offset for given DIE. */ |
| 499 | extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset, |
| 500 | size_t *lengthp); |
| 501 | |
| 502 | /* Get abbreviation at given offset in .debug_abbrev section. */ |
| 503 | extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp, |
| 504 | Dwarf_Abbrev *abbrevp) |
| 505 | __nonnull_attribute__ (4); |
| 506 | |
| 507 | /* Get abbreviation code. */ |
| 508 | extern unsigned int dwarf_getabbrevcode (Dwarf_Abbrev *abbrev); |
| 509 | |
| 510 | /* Get abbreviation tag. */ |
| 511 | extern unsigned int dwarf_getabbrevtag (Dwarf_Abbrev *abbrev); |
| 512 | |
| 513 | /* Return true if abbreviation is children flag set. */ |
| 514 | extern int dwarf_abbrevhaschildren (Dwarf_Abbrev *abbrev); |
| 515 | |
| 516 | /* Get number of attributes of abbreviation. */ |
| 517 | extern int dwarf_getattrcnt (Dwarf_Abbrev *abbrev, size_t *attrcntp) |
| 518 | __nonnull_attribute__ (2); |
| 519 | |
| 520 | /* Get specific attribute of abbreviation. */ |
| 521 | extern int dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, |
| 522 | unsigned int *namep, unsigned int *formp, |
| 523 | Dwarf_Off *offset); |
| 524 | |
| 525 | |
| 526 | /* Get string from-debug_str section. */ |
| 527 | extern const char *dwarf_getstring (Dwarf *dbg, Dwarf_Off offset, |
| 528 | size_t *lenp); |
| 529 | |
| 530 | |
| 531 | /* Get public symbol information. */ |
| 532 | extern ptrdiff_t dwarf_getpubnames (Dwarf *dbg, |
| 533 | int (*callback) (Dwarf *, Dwarf_Global *, |
| 534 | void *), |
| 535 | void *arg, ptrdiff_t offset) |
| 536 | __nonnull_attribute__ (2); |
| 537 | |
| 538 | |
| 539 | /* Get source file information for CU. */ |
| 540 | extern int dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, |
| 541 | size_t *nlines) __nonnull_attribute__ (2, 3); |
| 542 | |
| 543 | /* Return one of the source lines of the CU. */ |
| 544 | extern Dwarf_Line *dwarf_onesrcline (Dwarf_Lines *lines, size_t idx); |
| 545 | |
| 546 | /* Get the file source files used in the CU. */ |
| 547 | extern int dwarf_getsrcfiles (Dwarf_Die *cudie, Dwarf_Files **files, |
| 548 | size_t *nfiles) |
| 549 | __nonnull_attribute__ (2); |
| 550 | |
| 551 | |
| 552 | /* Get source for address in CU. */ |
| 553 | extern Dwarf_Line *dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr); |
| 554 | |
| 555 | /* Get source for file and line number. */ |
| 556 | extern int dwarf_getsrc_file (Dwarf *dbg, const char *fname, int line, int col, |
| 557 | Dwarf_Line ***srcsp, size_t *nsrcs) |
| 558 | __nonnull_attribute__ (2, 5, 6); |
| 559 | |
| 560 | |
| 561 | /* Return line address. */ |
| 562 | extern int dwarf_lineaddr (Dwarf_Line *line, Dwarf_Addr *addrp); |
| 563 | |
| 564 | /* Return line number. */ |
| 565 | extern int dwarf_lineno (Dwarf_Line *line, int *linep) |
| 566 | __nonnull_attribute__ (2); |
| 567 | |
| 568 | /* Return column in line. */ |
| 569 | extern int dwarf_linecol (Dwarf_Line *line, int *colp) |
| 570 | __nonnull_attribute__ (2); |
| 571 | |
| 572 | /* Return true if record is for beginning of a statement. */ |
| 573 | extern int dwarf_linebeginstatement (Dwarf_Line *line, bool *flagp) |
| 574 | __nonnull_attribute__ (2); |
| 575 | |
| 576 | /* Return true if record is for end of sequence. */ |
| 577 | extern int dwarf_lineendsequence (Dwarf_Line *line, bool *flagp) |
| 578 | __nonnull_attribute__ (2); |
| 579 | |
| 580 | /* Return true if record is for beginning of a basic block. */ |
| 581 | extern int dwarf_lineblock (Dwarf_Line *line, bool *flagp) |
| 582 | __nonnull_attribute__ (2); |
| 583 | |
| 584 | /* Return true if record is for end of prologue. */ |
| 585 | extern int dwarf_lineprologueend (Dwarf_Line *line, bool *flagp) |
| 586 | __nonnull_attribute__ (2); |
| 587 | |
| 588 | /* Return true if record is for beginning of epilogue. */ |
| 589 | extern int dwarf_lineepiloguebegin (Dwarf_Line *line, bool *flagp) |
| 590 | __nonnull_attribute__ (2); |
| 591 | |
| 592 | |
| 593 | /* Find line information for address. */ |
| 594 | extern const char *dwarf_linesrc (Dwarf_Line *line, |
| 595 | Dwarf_Word *mtime, Dwarf_Word *length); |
| 596 | |
| 597 | /* Return file information. */ |
| 598 | extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx, |
| 599 | Dwarf_Word *mtime, Dwarf_Word *length); |
| 600 | |
Roland McGrath | 43da989 | 2007-04-16 23:13:37 +0000 | [diff] [blame] | 601 | /* Return the directory list used in the file information extracted. |
| 602 | (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null. |
| 603 | (*RESULT)[0..*NDIRS-1] are the compile-time include directory path |
| 604 | encoded by the compiler. */ |
| 605 | extern int dwarf_getsrcdirs (Dwarf_Files *files, |
| 606 | const char *const **result, size_t *ndirs) |
| 607 | __nonnull_attribute__ (2, 3); |
| 608 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 609 | |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 610 | /* Return location expression, decoded as a list of operations. */ |
| 611 | extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr, |
| 612 | size_t *exprlen) __nonnull_attribute__ (2, 3); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 613 | |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 614 | /* Return location expressions. If the attribute uses a location list, |
| 615 | ADDRESS selects the relevant location expressions from the list. |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 616 | There can be multiple matches, resulting in multiple expressions to |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 617 | return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to |
| 618 | fill in. Returns the number of locations filled in, or -1 for |
| 619 | errors. If EXPRS is a null pointer, stores nothing and returns the |
| 620 | total number of locations. A return value of zero means that the |
| 621 | location list indicated no value is accessible. */ |
| 622 | extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address, |
| 623 | Dwarf_Op **exprs, size_t *exprlens, |
| 624 | size_t nlocs); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 625 | |
| 626 | |
| 627 | /* Return scope DIEs containing PC address. |
| 628 | Sets *SCOPES to a malloc'd array of Dwarf_Die structures, |
| 629 | and returns the number of elements in the array. |
| 630 | (*SCOPES)[0] is the DIE for the innermost scope containing PC, |
| 631 | (*SCOPES)[1] is the DIE for the scope containing that scope, and so on. |
| 632 | Returns -1 for errors or 0 if no scopes match PC. */ |
| 633 | extern int dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, |
| 634 | Dwarf_Die **scopes); |
| 635 | |
Roland McGrath | 71e15a0 | 2005-08-27 10:33:26 +0000 | [diff] [blame] | 636 | /* Return scope DIEs containing the given DIE. |
| 637 | Sets *SCOPES to a malloc'd array of Dwarf_Die structures, |
| 638 | and returns the number of elements in the array. |
| 639 | (*SCOPES)[0] is a copy of DIE. |
| 640 | (*SCOPES)[1] is the DIE for the scope containing that scope, and so on. |
| 641 | Returns -1 for errors or 0 if DIE is not found in any scope entry. */ |
| 642 | extern int dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes); |
| 643 | |
| 644 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 645 | /* Search SCOPES[0..NSCOPES-1] for a variable called NAME. |
| 646 | Ignore the first SKIP_SHADOWS scopes that match the name. |
| 647 | If MATCH_FILE is not null, accept only declaration in that source file; |
| 648 | if MATCH_LINENO or MATCH_LINECOL are also nonzero, accept only declaration |
| 649 | at that line and column. |
| 650 | |
| 651 | If successful, fill in *RESULT with the DIE of the variable found, |
| 652 | and return N where SCOPES[N] is the scope defining the variable. |
| 653 | Return -1 for errors or -2 for no matching variable found. */ |
| 654 | extern int dwarf_getscopevar (Dwarf_Die *scopes, int nscopes, |
| 655 | const char *name, int skip_shadows, |
| 656 | const char *match_file, |
| 657 | int match_lineno, int match_linecol, |
| 658 | Dwarf_Die *result); |
| 659 | |
| 660 | |
| 661 | |
| 662 | /* Return list address ranges. */ |
| 663 | extern int dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges, |
| 664 | size_t *naranges) |
| 665 | __nonnull_attribute__ (2); |
| 666 | |
| 667 | /* Return one of the address range entries. */ |
| 668 | extern Dwarf_Arange *dwarf_onearange (Dwarf_Aranges *aranges, size_t idx); |
| 669 | |
| 670 | /* Return information in address range record. */ |
| 671 | extern int dwarf_getarangeinfo (Dwarf_Arange *arange, Dwarf_Addr *addrp, |
| 672 | Dwarf_Word *lengthp, Dwarf_Off *offsetp); |
| 673 | |
| 674 | /* Get address range which includes given address. */ |
| 675 | extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges, |
| 676 | Dwarf_Addr addr); |
| 677 | |
| 678 | |
| 679 | |
| 680 | /* Get functions in CUDIE. */ |
| 681 | extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie, |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 682 | int (*callback) (Dwarf_Die *, void *), |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 683 | void *arg, ptrdiff_t offset); |
| 684 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 685 | |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 686 | /* Return file name containing definition of the given declaration. */ |
| 687 | extern const char *dwarf_decl_file (Dwarf_Die *decl); |
| 688 | |
| 689 | /* Get line number of beginning of given declaration. */ |
| 690 | extern int dwarf_decl_line (Dwarf_Die *decl, int *linep) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 691 | __nonnull_attribute__ (2); |
| 692 | |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 693 | /* Get column number of beginning of given declaration. */ |
| 694 | extern int dwarf_decl_column (Dwarf_Die *decl, int *colp) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 695 | __nonnull_attribute__ (2); |
| 696 | |
Roland McGrath | 1ecb606 | 2005-08-15 09:53:04 +0000 | [diff] [blame] | 697 | |
| 698 | /* Return nonzero if given function is an abstract inline definition. */ |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 699 | extern int dwarf_func_inline (Dwarf_Die *func); |
Roland McGrath | 1ecb606 | 2005-08-15 09:53:04 +0000 | [diff] [blame] | 700 | |
| 701 | /* Find each concrete inlined instance of the abstract inline definition. */ |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 702 | extern int dwarf_func_inline_instances (Dwarf_Die *func, |
Roland McGrath | 1ecb606 | 2005-08-15 09:53:04 +0000 | [diff] [blame] | 703 | int (*callback) (Dwarf_Die *, void *), |
| 704 | void *arg); |
| 705 | |
| 706 | |
Roland McGrath | 07d4f2f | 2005-10-28 06:56:24 +0000 | [diff] [blame] | 707 | /* Find the appropriate PC location or locations for function entry |
| 708 | breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors. |
| 709 | On success, returns the number of breakpoint locations (never zero) |
| 710 | and sets *BKPTS to a malloc'd vector of addresses. */ |
| 711 | extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts); |
| 712 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 713 | |
| 714 | /* Call callback function for each of the macro information entry for |
| 715 | the CU. */ |
| 716 | extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie, |
| 717 | int (*callback) (Dwarf_Macro *, void *), |
| 718 | void *arg, ptrdiff_t offset) |
| 719 | __nonnull_attribute__ (2); |
| 720 | |
| 721 | /* Return macro opcode. */ |
| 722 | extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep) |
| 723 | __nonnull_attribute__ (2); |
| 724 | |
| 725 | /* Return first macro parameter. */ |
| 726 | extern int dwarf_macro_param1 (Dwarf_Macro *macro, Dwarf_Word *paramp) |
| 727 | __nonnull_attribute__ (2); |
| 728 | |
| 729 | /* Return second macro parameter. */ |
| 730 | extern int dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp, |
| 731 | const char **strp); |
| 732 | |
| 733 | |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 734 | /* Compute what's known about a call frame when the PC is at ADDRESS. |
| 735 | Returns 0 for success or -1 for errors. |
| 736 | On success, *FRAME is a malloc'd pointer. */ |
| 737 | extern int dwarf_cfi_addrframe (Dwarf_CFI *cache, |
| 738 | Dwarf_Addr address, Dwarf_Frame **frame) |
| 739 | __nonnull_attribute__ (3); |
| 740 | |
| 741 | /* Return the DWARF register number used in FRAME to denote |
| 742 | the return address in FRAME's caller frame. The remaining |
| 743 | arguments can be non-null to fill in more information. |
| 744 | |
| 745 | Fill [*START, *END) with the PC range to which FRAME's information applies. |
| 746 | Fill in *SIGNALP to indicate whether this is a signal-handling frame. |
| 747 | If true, this is the implicit call frame that calls a signal handler. |
| 748 | This frame's "caller" is actually the interrupted state, not a call; |
| 749 | its return address is an exact PC, not a PC after a call instruction. */ |
| 750 | extern int dwarf_frame_info (Dwarf_Frame *frame, |
| 751 | Dwarf_Addr *start, Dwarf_Addr *end, bool *signalp); |
| 752 | |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 753 | /* Return a DWARF expression that yields the Canonical Frame Address at |
| 754 | this frame state. Returns -1 for errors, or zero for success, with |
| 755 | *NOPS set to the number of operations stored at *OPS. That pointer |
| 756 | can be used only as long as FRAME is alive and unchanged. *NOPS is |
| 757 | zero if the CFA cannot be determined here. Note that if nonempty, |
| 758 | *OPS is a DWARF expression, not a location description--append |
| 759 | DW_OP_stack_value to a get a location description for the CFA. */ |
| 760 | extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops) |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 761 | __nonnull_attribute__ (2); |
| 762 | |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 763 | /* Deliver a DWARF location description that yields the location or |
| 764 | value of DWARF register number REGNO in the state described by FRAME. |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 765 | |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 766 | Returns -1 for errors or zero for success, setting *NOPS to the |
| 767 | number of operations in the array stored at *OPS. Note the last |
| 768 | operation is DW_OP_stack_value if there is no mutable location but |
| 769 | only a computable value. |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 770 | |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 771 | *NOPS zero with *OPS set to OPS_MEM means CFI says the caller's |
| 772 | REGNO is "undefined", i.e. it's call-clobbered and cannot be recovered. |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 773 | |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 774 | *NOPS zero with *OPS set to a null pointer means CFI says the |
| 775 | caller's REGNO is "same_value", i.e. this frame did not change it; |
| 776 | ask the caller frame where to find it. |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 777 | |
| 778 | For common simple expressions *OPS is OPS_MEM. For arbitrary DWARF |
| 779 | expressions in the CFI, *OPS is an internal pointer that can be used as |
| 780 | long as the Dwarf_CFI used to create FRAME remains alive. */ |
| 781 | extern int dwarf_frame_register (Dwarf_Frame *frame, int regno, |
Roland McGrath | af80014 | 2009-07-22 13:55:50 -0700 | [diff] [blame^] | 782 | Dwarf_Op ops_mem[3], |
Roland McGrath | 3c84db3 | 2009-06-24 17:41:40 -0700 | [diff] [blame] | 783 | Dwarf_Op **ops, size_t *nops) |
| 784 | __nonnull_attribute__ (3, 4, 5); |
| 785 | |
| 786 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 787 | /* Return error code of last failing function call. This value is kept |
| 788 | separately for each thread. */ |
| 789 | extern int dwarf_errno (void); |
| 790 | |
| 791 | /* Return error string for ERROR. If ERROR is zero, return error string |
| 792 | for most recent error or NULL is none occurred. If ERROR is -1 the |
| 793 | behaviour is similar to the last case except that not NULL but a legal |
| 794 | string is returned. */ |
| 795 | extern const char *dwarf_errmsg (int err); |
| 796 | |
| 797 | |
| 798 | /* Register new Out-Of-Memory handler. The old handler is returned. */ |
| 799 | extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler); |
| 800 | |
| 801 | |
| 802 | /* Inline optimizations. */ |
| 803 | #ifdef __OPTIMIZE__ |
| 804 | /* Return attribute code of given attribute. */ |
Ulrich Drepper | b597dfa | 2007-10-16 05:21:27 +0000 | [diff] [blame] | 805 | __libdw_extern_inline unsigned int |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 806 | dwarf_whatattr (Dwarf_Attribute *attr) |
| 807 | { |
| 808 | return attr == NULL ? 0 : attr->code; |
| 809 | } |
| 810 | |
| 811 | /* Return attribute code of given attribute. */ |
Ulrich Drepper | b597dfa | 2007-10-16 05:21:27 +0000 | [diff] [blame] | 812 | __libdw_extern_inline unsigned int |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 813 | dwarf_whatform (Dwarf_Attribute *attr) |
| 814 | { |
| 815 | return attr == NULL ? 0 : attr->form; |
| 816 | } |
| 817 | #endif /* Optimize. */ |
| 818 | |
Ulrich Drepper | 3be7447 | 2006-05-27 18:15:40 +0000 | [diff] [blame] | 819 | #ifdef __cplusplus |
| 820 | } |
| 821 | #endif |
| 822 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 823 | #endif /* libdw.h */ |