15796c8dcSSimon Schubert /* DWARF 2 location expression support for GDB. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 2003-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #if !defined (DWARF2LOC_H) 215796c8dcSSimon Schubert #define DWARF2LOC_H 225796c8dcSSimon Schubert 23*ef5ccd6cSJohn Marino #include "dwarf2expr.h" 24*ef5ccd6cSJohn Marino 255796c8dcSSimon Schubert struct symbol_computed_ops; 265796c8dcSSimon Schubert struct objfile; 275796c8dcSSimon Schubert struct dwarf2_per_cu_data; 28c50c785cSJohn Marino struct dwarf2_loclist_baton; 29c50c785cSJohn Marino struct agent_expr; 30c50c785cSJohn Marino struct axs_value; 315796c8dcSSimon Schubert 325796c8dcSSimon Schubert /* This header is private to the DWARF-2 reader. It is shared between 335796c8dcSSimon Schubert dwarf2read.c and dwarf2loc.c. */ 345796c8dcSSimon Schubert 35a45ae5f8SJohn Marino /* `set debug entry-values' setting. */ 36*ef5ccd6cSJohn Marino extern unsigned int entry_values_debug; 37a45ae5f8SJohn Marino 38cf7f2e2dSJohn Marino /* Return the OBJFILE associated with the compilation unit CU. If CU 39cf7f2e2dSJohn Marino came from a separate debuginfo file, then the master objfile is 40cf7f2e2dSJohn Marino returned. */ 415796c8dcSSimon Schubert struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu); 425796c8dcSSimon Schubert 435796c8dcSSimon Schubert /* Return the address size given in the compilation unit header for CU. */ 44*ef5ccd6cSJohn Marino int dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu); 455796c8dcSSimon Schubert 46a45ae5f8SJohn Marino /* Return the DW_FORM_ref_addr size given in the compilation unit header for 47a45ae5f8SJohn Marino CU. */ 48a45ae5f8SJohn Marino int dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *cu); 49a45ae5f8SJohn Marino 50cf7f2e2dSJohn Marino /* Return the offset size given in the compilation unit header for CU. */ 51cf7f2e2dSJohn Marino int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu); 52cf7f2e2dSJohn Marino 53cf7f2e2dSJohn Marino /* Return the text offset of the CU. The returned offset comes from 54cf7f2e2dSJohn Marino this CU's objfile. If this objfile came from a separate debuginfo 55cf7f2e2dSJohn Marino file, then the offset may be different from the corresponding 56cf7f2e2dSJohn Marino offset in the parent objfile. */ 57cf7f2e2dSJohn Marino CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu); 58cf7f2e2dSJohn Marino 59c50c785cSJohn Marino /* Find a particular location expression from a location list. */ 60c50c785cSJohn Marino const gdb_byte *dwarf2_find_location_expression 61c50c785cSJohn Marino (struct dwarf2_loclist_baton *baton, 62c50c785cSJohn Marino size_t *locexpr_length, 63c50c785cSJohn Marino CORE_ADDR pc); 64c50c785cSJohn Marino 65*ef5ccd6cSJohn Marino struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off 66*ef5ccd6cSJohn Marino (sect_offset offset_in_cu, struct dwarf2_per_cu_data *per_cu, 67c50c785cSJohn Marino CORE_ADDR (*get_frame_pc) (void *baton), 68c50c785cSJohn Marino void *baton); 69c50c785cSJohn Marino 70*ef5ccd6cSJohn Marino struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off 71*ef5ccd6cSJohn Marino (cu_offset offset_in_cu, struct dwarf2_per_cu_data *per_cu, 72*ef5ccd6cSJohn Marino CORE_ADDR (*get_frame_pc) (void *baton), 73*ef5ccd6cSJohn Marino void *baton); 74*ef5ccd6cSJohn Marino 75*ef5ccd6cSJohn Marino struct type *dwarf2_get_die_type (cu_offset die_offset, 76a45ae5f8SJohn Marino struct dwarf2_per_cu_data *per_cu); 77a45ae5f8SJohn Marino 78c50c785cSJohn Marino /* Evaluate a location description, starting at DATA and with length 79c50c785cSJohn Marino SIZE, to find the current location of variable of TYPE in the context 80c50c785cSJohn Marino of FRAME. */ 81c50c785cSJohn Marino 82c50c785cSJohn Marino struct value *dwarf2_evaluate_loc_desc (struct type *type, 83c50c785cSJohn Marino struct frame_info *frame, 84c50c785cSJohn Marino const gdb_byte *data, 85*ef5ccd6cSJohn Marino size_t size, 86c50c785cSJohn Marino struct dwarf2_per_cu_data *per_cu); 87cf7f2e2dSJohn Marino 88*ef5ccd6cSJohn Marino CORE_ADDR dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu, 89*ef5ccd6cSJohn Marino unsigned int addr_index); 90*ef5ccd6cSJohn Marino 915796c8dcSSimon Schubert /* The symbol location baton types used by the DWARF-2 reader (i.e. 925796c8dcSSimon Schubert SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct 935796c8dcSSimon Schubert dwarf2_locexpr_baton" is for a symbol with a single location 945796c8dcSSimon Schubert expression; "struct dwarf2_loclist_baton" is for a symbol with a 955796c8dcSSimon Schubert location list. */ 965796c8dcSSimon Schubert 975796c8dcSSimon Schubert struct dwarf2_locexpr_baton 985796c8dcSSimon Schubert { 99a45ae5f8SJohn Marino /* Pointer to the start of the location expression. Valid only if SIZE is 100a45ae5f8SJohn Marino not zero. */ 101cf7f2e2dSJohn Marino const gdb_byte *data; 1025796c8dcSSimon Schubert 103a45ae5f8SJohn Marino /* Length of the location expression. For optimized out expressions it is 104a45ae5f8SJohn Marino zero. */ 105*ef5ccd6cSJohn Marino size_t size; 1065796c8dcSSimon Schubert 1075796c8dcSSimon Schubert /* The compilation unit containing the symbol whose location 1085796c8dcSSimon Schubert we're computing. */ 1095796c8dcSSimon Schubert struct dwarf2_per_cu_data *per_cu; 1105796c8dcSSimon Schubert }; 1115796c8dcSSimon Schubert 1125796c8dcSSimon Schubert struct dwarf2_loclist_baton 1135796c8dcSSimon Schubert { 1145796c8dcSSimon Schubert /* The initial base address for the location list, based on the compilation 1155796c8dcSSimon Schubert unit. */ 1165796c8dcSSimon Schubert CORE_ADDR base_address; 1175796c8dcSSimon Schubert 1185796c8dcSSimon Schubert /* Pointer to the start of the location list. */ 119cf7f2e2dSJohn Marino const gdb_byte *data; 1205796c8dcSSimon Schubert 1215796c8dcSSimon Schubert /* Length of the location list. */ 122*ef5ccd6cSJohn Marino size_t size; 1235796c8dcSSimon Schubert 1245796c8dcSSimon Schubert /* The compilation unit containing the symbol whose location 1255796c8dcSSimon Schubert we're computing. */ 1265796c8dcSSimon Schubert struct dwarf2_per_cu_data *per_cu; 127*ef5ccd6cSJohn Marino 128*ef5ccd6cSJohn Marino /* Non-zero if the location list lives in .debug_loc.dwo. 129*ef5ccd6cSJohn Marino The format of entries in this section are different. */ 130*ef5ccd6cSJohn Marino unsigned char from_dwo; 1315796c8dcSSimon Schubert }; 1325796c8dcSSimon Schubert 1335796c8dcSSimon Schubert extern const struct symbol_computed_ops dwarf2_locexpr_funcs; 1345796c8dcSSimon Schubert extern const struct symbol_computed_ops dwarf2_loclist_funcs; 1355796c8dcSSimon Schubert 136c50c785cSJohn Marino /* Compile a DWARF location expression to an agent expression. 137c50c785cSJohn Marino 138c50c785cSJohn Marino EXPR is the agent expression we are building. 139c50c785cSJohn Marino LOC is the agent value we modify. 140c50c785cSJohn Marino ARCH is the architecture. 141c50c785cSJohn Marino ADDR_SIZE is the size of addresses, in bytes. 142c50c785cSJohn Marino OP_PTR is the start of the location expression. 143c50c785cSJohn Marino OP_END is one past the last byte of the location expression. 144c50c785cSJohn Marino 145c50c785cSJohn Marino This will throw an exception for various kinds of errors -- for 146c50c785cSJohn Marino example, if the expression cannot be compiled, or if the expression 147c50c785cSJohn Marino is invalid. */ 148c50c785cSJohn Marino 149c50c785cSJohn Marino extern void dwarf2_compile_expr_to_ax (struct agent_expr *expr, 150c50c785cSJohn Marino struct axs_value *loc, 151c50c785cSJohn Marino struct gdbarch *arch, 152c50c785cSJohn Marino unsigned int addr_size, 153c50c785cSJohn Marino const gdb_byte *op_ptr, 154c50c785cSJohn Marino const gdb_byte *op_end, 155c50c785cSJohn Marino struct dwarf2_per_cu_data *per_cu); 156c50c785cSJohn Marino 157a45ae5f8SJohn Marino /* Determined tail calls for constructing virtual tail call frames. */ 158a45ae5f8SJohn Marino 159a45ae5f8SJohn Marino struct call_site_chain 160a45ae5f8SJohn Marino { 161a45ae5f8SJohn Marino /* Initially CALLERS == CALLEES == LENGTH. For partially ambiguous result 162a45ae5f8SJohn Marino CALLERS + CALLEES < LENGTH. */ 163a45ae5f8SJohn Marino int callers, callees, length; 164a45ae5f8SJohn Marino 165a45ae5f8SJohn Marino /* Variably sized array with LENGTH elements. Later [0..CALLERS-1] contain 166a45ae5f8SJohn Marino top (GDB "prev") sites and [LENGTH-CALLEES..LENGTH-1] contain bottom 167a45ae5f8SJohn Marino (GDB "next") sites. One is interested primarily in the PC field. */ 168a45ae5f8SJohn Marino struct call_site *call_site[1]; 169a45ae5f8SJohn Marino }; 170a45ae5f8SJohn Marino 171a45ae5f8SJohn Marino struct call_site_stuff; 172a45ae5f8SJohn Marino extern struct call_site_chain *call_site_find_chain (struct gdbarch *gdbarch, 173a45ae5f8SJohn Marino CORE_ADDR caller_pc, 174a45ae5f8SJohn Marino CORE_ADDR callee_pc); 175a45ae5f8SJohn Marino 1765796c8dcSSimon Schubert #endif /* dwarf2loc.h */ 177