gdb/
[platform/upstream/binutils.git] / gdb / dwarf2loc.h
1 /* DWARF 2 location expression support for GDB.
2
3    Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010, 2011
4    Free Software Foundation, Inc.
5
6    This file is part of GDB.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 #if !defined (DWARF2LOC_H)
22 #define DWARF2LOC_H
23
24 struct symbol_computed_ops;
25 struct objfile;
26 struct dwarf2_per_cu_data;
27 struct dwarf2_loclist_baton;
28 struct agent_expr;
29 struct axs_value;
30
31 /* This header is private to the DWARF-2 reader.  It is shared between
32    dwarf2read.c and dwarf2loc.c.  */
33
34 /* `set debug entry-values' setting.  */
35 extern int entry_values_debug;
36
37 /* Return the OBJFILE associated with the compilation unit CU.  If CU
38    came from a separate debuginfo file, then the master objfile is
39    returned.  */
40 struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu);
41
42 /* Return the address size given in the compilation unit header for CU.  */
43 CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu);
44
45 /* Return the DW_FORM_ref_addr size given in the compilation unit header for
46    CU.  */
47 int dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *cu);
48
49 /* Return the offset size given in the compilation unit header for CU.  */
50 int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
51
52 /* Return the text offset of the CU.  The returned offset comes from
53    this CU's objfile.  If this objfile came from a separate debuginfo
54    file, then the offset may be different from the corresponding
55    offset in the parent objfile.  */
56 CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu);
57
58 /* Find a particular location expression from a location list.  */
59 const gdb_byte *dwarf2_find_location_expression
60   (struct dwarf2_loclist_baton *baton,
61    size_t *locexpr_length,
62    CORE_ADDR pc);
63
64 struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block
65   (unsigned int offset, struct dwarf2_per_cu_data *per_cu,
66    CORE_ADDR (*get_frame_pc) (void *baton),
67    void *baton);
68
69 struct type *dwarf2_get_die_type (unsigned int die_offset,
70                                   struct dwarf2_per_cu_data *per_cu);
71
72 /* Evaluate a location description, starting at DATA and with length
73    SIZE, to find the current location of variable of TYPE in the context
74    of FRAME.  */
75
76 struct value *dwarf2_evaluate_loc_desc (struct type *type,
77                                         struct frame_info *frame,
78                                         const gdb_byte *data,
79                                         unsigned short size,
80                                         struct dwarf2_per_cu_data *per_cu);
81
82 /* The symbol location baton types used by the DWARF-2 reader (i.e.
83    SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol).  "struct
84    dwarf2_locexpr_baton" is for a symbol with a single location
85    expression; "struct dwarf2_loclist_baton" is for a symbol with a
86    location list.  */
87
88 struct dwarf2_locexpr_baton
89 {
90   /* Pointer to the start of the location expression.  Valid only if SIZE is
91      not zero.  */
92   const gdb_byte *data;
93
94   /* Length of the location expression.  For optimized out expressions it is
95      zero.  */
96   unsigned long size;
97
98   /* The compilation unit containing the symbol whose location
99      we're computing.  */
100   struct dwarf2_per_cu_data *per_cu;
101 };
102
103 struct dwarf2_loclist_baton
104 {
105   /* The initial base address for the location list, based on the compilation
106      unit.  */
107   CORE_ADDR base_address;
108
109   /* Pointer to the start of the location list.  */
110   const gdb_byte *data;
111
112   /* Length of the location list.  */
113   unsigned long size;
114
115   /* The compilation unit containing the symbol whose location
116      we're computing.  */
117   struct dwarf2_per_cu_data *per_cu;
118 };
119
120 extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
121 extern const struct symbol_computed_ops dwarf2_loclist_funcs;
122
123 /* Compile a DWARF location expression to an agent expression.
124    
125    EXPR is the agent expression we are building.
126    LOC is the agent value we modify.
127    ARCH is the architecture.
128    ADDR_SIZE is the size of addresses, in bytes.
129    OP_PTR is the start of the location expression.
130    OP_END is one past the last byte of the location expression.
131    
132    This will throw an exception for various kinds of errors -- for
133    example, if the expression cannot be compiled, or if the expression
134    is invalid.  */
135
136 extern void dwarf2_compile_expr_to_ax (struct agent_expr *expr,
137                                        struct axs_value *loc,
138                                        struct gdbarch *arch,
139                                        unsigned int addr_size,
140                                        const gdb_byte *op_ptr,
141                                        const gdb_byte *op_end,
142                                        struct dwarf2_per_cu_data *per_cu);
143
144 /* Determined tail calls for constructing virtual tail call frames.  */
145
146 struct call_site_chain
147   {
148     /* Initially CALLERS == CALLEES == LENGTH.  For partially ambiguous result
149        CALLERS + CALLEES < LENGTH.  */
150     int callers, callees, length;
151
152     /* Variably sized array with LENGTH elements.  Later [0..CALLERS-1] contain
153        top (GDB "prev") sites and [LENGTH-CALLEES..LENGTH-1] contain bottom
154        (GDB "next") sites.  One is interested primarily in the PC field.  */
155     struct call_site *call_site[1];
156   };
157
158 struct call_site_stuff;
159 extern struct call_site_chain *call_site_find_chain (struct gdbarch *gdbarch,
160                                                      CORE_ADDR caller_pc,
161                                                      CORE_ADDR callee_pc);
162
163 #endif /* dwarf2loc.h */