OLD | NEW |
1 /* DWARF 2 location expression support for GDB. | 1 /* DWARF 2 location expression support for GDB. |
2 | 2 |
3 Copyright (C) 2003, 2005, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2003, 2005, 2007-2012 Free Software Foundation, Inc. |
4 | 4 |
5 Contributed by Daniel Jacobowitz, MontaVista Software, Inc. | 5 Contributed by Daniel Jacobowitz, MontaVista Software, Inc. |
6 | 6 |
7 This file is part of GDB. | 7 This file is part of GDB. |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 9 This program is free software; you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | 10 it under the terms of the GNU General Public License as published by |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "gdbcmd.h" | 35 #include "gdbcmd.h" |
36 | 36 |
37 #include "dwarf2.h" | 37 #include "dwarf2.h" |
38 #include "dwarf2expr.h" | 38 #include "dwarf2expr.h" |
39 #include "dwarf2loc.h" | 39 #include "dwarf2loc.h" |
40 #include "dwarf2-frame.h" | 40 #include "dwarf2-frame.h" |
41 | 41 |
42 #include "gdb_string.h" | 42 #include "gdb_string.h" |
43 #include "gdb_assert.h" | 43 #include "gdb_assert.h" |
44 | 44 |
| 45 DEF_VEC_I(int); |
| 46 |
45 extern int dwarf2_always_disassemble; | 47 extern int dwarf2_always_disassemble; |
46 | 48 |
47 static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, | 49 static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, |
48 const gdb_byte **start, size_t *length); | 50 const gdb_byte **start, size_t *length); |
49 | 51 |
50 static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs; | 52 static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs; |
51 | 53 |
52 static struct value *dwarf2_evaluate_loc_desc_full (struct type *type, | 54 static struct value *dwarf2_evaluate_loc_desc_full (struct type *type, |
53 struct frame_info *frame, | 55 struct frame_info *frame, |
54 const gdb_byte *data, | 56 const gdb_byte *data, |
55 unsigned short size, | 57 unsigned short size, |
56 struct dwarf2_per_cu_data *per_cu, | 58 struct dwarf2_per_cu_data *per_cu, |
57 LONGEST byte_offset); | 59 LONGEST byte_offset); |
58 | 60 |
| 61 /* Until these have formal names, we define these here. |
| 62 ref: http://gcc.gnu.org/wiki/DebugFission |
| 63 Each entry in .debug_loc.dwo begins with a byte that describes the entry, |
| 64 and is then followed by data specific to that entry. */ |
| 65 |
| 66 enum debug_loc_kind |
| 67 { |
| 68 /* Indicates the end of the list of entries. */ |
| 69 DEBUG_LOC_END_OF_LIST = 0, |
| 70 |
| 71 /* This is followed by an unsigned LEB128 number that is an index into |
| 72 .debug_addr and specifies the base address for all following entries. */ |
| 73 DEBUG_LOC_BASE_ADDRESS = 1, |
| 74 |
| 75 /* This is followed by two unsigned LEB128 numbers that are indices into |
| 76 .debug_addr and specify the beginning and ending addresses, and then |
| 77 a normal location expression as in .debug_loc. */ |
| 78 DEBUG_LOC_START_END = 2, |
| 79 |
| 80 /* This is followed by an unsigned LEB128 number that is an index into |
| 81 .debug_addr and specifies the beginning address, and a 4 byte unsigned |
| 82 number that specifies the length, and then a normal location expression |
| 83 as in .debug_loc. */ |
| 84 DEBUG_LOC_START_LENGTH = 3, |
| 85 |
| 86 /* An internal value indicating there is insufficient data. */ |
| 87 DEBUG_LOC_BUFFER_OVERFLOW = -1, |
| 88 |
| 89 /* An internal value indicating an invalid kind of entry was found. */ |
| 90 DEBUG_LOC_INVALID_ENTRY = -2 |
| 91 }; |
| 92 |
| 93 /* Decode the addresses in a non-dwo .debug_loc entry. |
| 94 A pointer to the next byte to examine is returned in *NEW_PTR. |
| 95 The encoded low,high addresses are return in *LOW,*HIGH. |
| 96 The result indicates the kind of entry found. */ |
| 97 |
| 98 static enum debug_loc_kind |
| 99 decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end, |
| 100 const gdb_byte **new_ptr, |
| 101 CORE_ADDR *low, CORE_ADDR *high, |
| 102 enum bfd_endian byte_order, |
| 103 unsigned int addr_size, |
| 104 int signed_addr_p) |
| 105 { |
| 106 CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); |
| 107 |
| 108 if (buf_end - loc_ptr < 2 * addr_size) |
| 109 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 110 |
| 111 if (signed_addr_p) |
| 112 *low = extract_signed_integer (loc_ptr, addr_size, byte_order); |
| 113 else |
| 114 *low = extract_unsigned_integer (loc_ptr, addr_size, byte_order); |
| 115 loc_ptr += addr_size; |
| 116 |
| 117 if (signed_addr_p) |
| 118 *high = extract_signed_integer (loc_ptr, addr_size, byte_order); |
| 119 else |
| 120 *high = extract_unsigned_integer (loc_ptr, addr_size, byte_order); |
| 121 loc_ptr += addr_size; |
| 122 |
| 123 *new_ptr = loc_ptr; |
| 124 |
| 125 /* A base-address-selection entry. */ |
| 126 if ((*low & base_mask) == base_mask) |
| 127 return DEBUG_LOC_BASE_ADDRESS; |
| 128 |
| 129 /* An end-of-list entry. */ |
| 130 if (*low == 0 && *high == 0) |
| 131 return DEBUG_LOC_END_OF_LIST; |
| 132 |
| 133 return DEBUG_LOC_START_END; |
| 134 } |
| 135 |
| 136 /* Decode the addresses in .debug_loc.dwo entry. |
| 137 A pointer to the next byte to examine is returned in *NEW_PTR. |
| 138 The encoded low,high addresses are return in *LOW,*HIGH. |
| 139 The result indicates the kind of entry found. */ |
| 140 |
| 141 static enum debug_loc_kind |
| 142 decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu, |
| 143 const gdb_byte *loc_ptr, |
| 144 const gdb_byte *buf_end, |
| 145 const gdb_byte **new_ptr, |
| 146 CORE_ADDR *low, CORE_ADDR *high, |
| 147 enum bfd_endian byte_order) |
| 148 { |
| 149 uint64_t low_index, high_index; |
| 150 |
| 151 if (loc_ptr == buf_end) |
| 152 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 153 |
| 154 switch (*loc_ptr++) |
| 155 { |
| 156 case DEBUG_LOC_END_OF_LIST: |
| 157 *new_ptr = loc_ptr; |
| 158 return DEBUG_LOC_END_OF_LIST; |
| 159 case DEBUG_LOC_BASE_ADDRESS: |
| 160 *low = 0; |
| 161 loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index); |
| 162 if (loc_ptr == NULL) |
| 163 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 164 *high = dwarf2_read_addr_index (per_cu, high_index); |
| 165 *new_ptr = loc_ptr; |
| 166 return DEBUG_LOC_BASE_ADDRESS; |
| 167 case DEBUG_LOC_START_END: |
| 168 loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index); |
| 169 if (loc_ptr == NULL) |
| 170 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 171 *low = dwarf2_read_addr_index (per_cu, low_index); |
| 172 loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index); |
| 173 if (loc_ptr == NULL) |
| 174 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 175 *high = dwarf2_read_addr_index (per_cu, high_index); |
| 176 *new_ptr = loc_ptr; |
| 177 return DEBUG_LOC_START_END; |
| 178 case DEBUG_LOC_START_LENGTH: |
| 179 loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index); |
| 180 if (loc_ptr == NULL) |
| 181 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 182 *low = dwarf2_read_addr_index (per_cu, low_index); |
| 183 if (loc_ptr + 4 > buf_end) |
| 184 return DEBUG_LOC_BUFFER_OVERFLOW; |
| 185 *high = *low; |
| 186 *high += extract_unsigned_integer (loc_ptr, 4, byte_order); |
| 187 *new_ptr = loc_ptr + 4; |
| 188 return DEBUG_LOC_START_LENGTH; |
| 189 default: |
| 190 return DEBUG_LOC_INVALID_ENTRY; |
| 191 } |
| 192 } |
| 193 |
59 /* A function for dealing with location lists. Given a | 194 /* A function for dealing with location lists. Given a |
60 symbol baton (BATON) and a pc value (PC), find the appropriate | 195 symbol baton (BATON) and a pc value (PC), find the appropriate |
61 location expression, set *LOCEXPR_LENGTH, and return a pointer | 196 location expression, set *LOCEXPR_LENGTH, and return a pointer |
62 to the beginning of the expression. Returns NULL on failure. | 197 to the beginning of the expression. Returns NULL on failure. |
63 | 198 |
64 For now, only return the first matching location expression; there | 199 For now, only return the first matching location expression; there |
65 can be more than one in the list. */ | 200 can be more than one in the list. */ |
66 | 201 |
67 const gdb_byte * | 202 const gdb_byte * |
68 dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, | 203 dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, |
69 size_t *locexpr_length, CORE_ADDR pc) | 204 size_t *locexpr_length, CORE_ADDR pc) |
70 { | 205 { |
71 CORE_ADDR low, high; | |
72 const gdb_byte *loc_ptr, *buf_end; | |
73 int length; | |
74 struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu); | 206 struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu); |
75 struct gdbarch *gdbarch = get_objfile_arch (objfile); | 207 struct gdbarch *gdbarch = get_objfile_arch (objfile); |
76 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | 208 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
77 unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu); | 209 unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu); |
78 int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd); | 210 int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd); |
79 CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); | |
80 /* Adjust base_address for relocatable objects. */ | 211 /* Adjust base_address for relocatable objects. */ |
81 CORE_ADDR base_offset = dwarf2_per_cu_text_offset (baton->per_cu); | 212 CORE_ADDR base_offset = dwarf2_per_cu_text_offset (baton->per_cu); |
82 CORE_ADDR base_address = baton->base_address + base_offset; | 213 CORE_ADDR base_address = baton->base_address + base_offset; |
| 214 const gdb_byte *loc_ptr, *buf_end; |
83 | 215 |
84 loc_ptr = baton->data; | 216 loc_ptr = baton->data; |
85 buf_end = baton->data + baton->size; | 217 buf_end = baton->data + baton->size; |
86 | 218 |
87 while (1) | 219 while (1) |
88 { | 220 { |
89 if (buf_end - loc_ptr < 2 * addr_size) | 221 CORE_ADDR low = 0, high = 0; /* init for gcc -Wall */ |
90 » error (_("dwarf2_find_location_expression: " | 222 int length; |
91 » » "Corrupted DWARF expression.")); | 223 enum debug_loc_kind kind; |
| 224 const gdb_byte *new_ptr = NULL; /* init for gcc -Wall */ |
92 | 225 |
93 if (signed_addr_p) | 226 if (baton->from_dwo) |
94 » low = extract_signed_integer (loc_ptr, addr_size, byte_order); | 227 » kind = decode_debug_loc_dwo_addresses (baton->per_cu, |
| 228 » » » » » loc_ptr, buf_end, &new_ptr, |
| 229 » » » » » &low, &high, byte_order); |
95 else | 230 else |
96 » low = extract_unsigned_integer (loc_ptr, addr_size, byte_order); | 231 » kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr, |
97 loc_ptr += addr_size; | 232 » » » » » &low, &high, |
98 | 233 » » » » » byte_order, addr_size, |
99 if (signed_addr_p) | 234 » » » » » signed_addr_p); |
100 » high = extract_signed_integer (loc_ptr, addr_size, byte_order); | 235 loc_ptr = new_ptr; |
101 else | 236 switch (kind) |
102 » high = extract_unsigned_integer (loc_ptr, addr_size, byte_order); | |
103 loc_ptr += addr_size; | |
104 | |
105 /* A base-address-selection entry. */ | |
106 if ((low & base_mask) == base_mask) | |
107 { | 237 { |
| 238 case DEBUG_LOC_END_OF_LIST: |
| 239 *locexpr_length = 0; |
| 240 return NULL; |
| 241 case DEBUG_LOC_BASE_ADDRESS: |
108 base_address = high + base_offset; | 242 base_address = high + base_offset; |
109 continue; | 243 continue; |
110 » } | 244 » case DEBUG_LOC_START_END: |
111 | 245 » case DEBUG_LOC_START_LENGTH: |
112 /* An end-of-list entry. */ | 246 » break; |
113 if (low == 0 && high == 0) | 247 » case DEBUG_LOC_BUFFER_OVERFLOW: |
114 » { | 248 » case DEBUG_LOC_INVALID_ENTRY: |
115 » *locexpr_length = 0; | 249 » error (_("dwarf2_find_location_expression: " |
116 » return NULL; | 250 » » "Corrupted DWARF expression.")); |
| 251 » default: |
| 252 » gdb_assert_not_reached ("bad debug_loc_kind"); |
117 } | 253 } |
118 | 254 |
119 /* Otherwise, a location expression entry. */ | 255 /* Otherwise, a location expression entry. */ |
120 low += base_address; | 256 low += base_address; |
121 high += base_address; | 257 high += base_address; |
122 | 258 |
123 length = extract_unsigned_integer (loc_ptr, 2, byte_order); | 259 length = extract_unsigned_integer (loc_ptr, 2, byte_order); |
124 loc_ptr += 2; | 260 loc_ptr += 2; |
125 | 261 |
126 if (low == high && pc == low) | 262 if (low == high && pc == low) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 struct objfile *objfile = dwarf2_per_cu_objfile (debaton->per_cu); | 411 struct objfile *objfile = dwarf2_per_cu_objfile (debaton->per_cu); |
276 | 412 |
277 return target_translate_tls_address (objfile, offset); | 413 return target_translate_tls_address (objfile, offset); |
278 } | 414 } |
279 | 415 |
280 /* Call DWARF subroutine from DW_AT_location of DIE at DIE_OFFSET in | 416 /* Call DWARF subroutine from DW_AT_location of DIE at DIE_OFFSET in |
281 current CU (as is PER_CU). State of the CTX is not affected by the | 417 current CU (as is PER_CU). State of the CTX is not affected by the |
282 call and return. */ | 418 call and return. */ |
283 | 419 |
284 static void | 420 static void |
285 per_cu_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset, | 421 per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset, |
286 struct dwarf2_per_cu_data *per_cu, | 422 struct dwarf2_per_cu_data *per_cu, |
287 CORE_ADDR (*get_frame_pc) (void *baton), | 423 CORE_ADDR (*get_frame_pc) (void *baton), |
288 void *baton) | 424 void *baton) |
289 { | 425 { |
290 struct dwarf2_locexpr_baton block; | 426 struct dwarf2_locexpr_baton block; |
291 | 427 |
292 block = dwarf2_fetch_die_location_block (die_offset, per_cu, | 428 block = dwarf2_fetch_die_location_block (die_offset, per_cu, |
293 get_frame_pc, baton); | 429 get_frame_pc, baton); |
294 | 430 |
295 /* DW_OP_call_ref is currently not supported. */ | 431 /* DW_OP_call_ref is currently not supported. */ |
296 gdb_assert (block.per_cu == per_cu); | 432 gdb_assert (block.per_cu == per_cu); |
297 | 433 |
298 dwarf_expr_eval (ctx, block.data, block.size); | 434 dwarf_expr_eval (ctx, block.data, block.size); |
299 } | 435 } |
300 | 436 |
301 /* Helper interface of per_cu_dwarf_call for dwarf2_evaluate_loc_desc. */ | 437 /* Helper interface of per_cu_dwarf_call for dwarf2_evaluate_loc_desc. */ |
302 | 438 |
303 static void | 439 static void |
304 dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset) | 440 dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset) |
305 { | 441 { |
306 struct dwarf_expr_baton *debaton = ctx->baton; | 442 struct dwarf_expr_baton *debaton = ctx->baton; |
307 | 443 |
308 per_cu_dwarf_call (ctx, die_offset, debaton->per_cu, | 444 per_cu_dwarf_call (ctx, die_offset, debaton->per_cu, |
309 ctx->funcs->get_frame_pc, ctx->baton); | 445 ctx->funcs->get_frame_pc, ctx->baton); |
310 } | 446 } |
311 | 447 |
312 /* Callback function for dwarf2_evaluate_loc_desc. */ | 448 /* Callback function for dwarf2_evaluate_loc_desc. */ |
313 | 449 |
314 static struct type * | 450 static struct type * |
315 dwarf_expr_get_base_type (struct dwarf_expr_context *ctx, size_t die_offset) | 451 dwarf_expr_get_base_type (struct dwarf_expr_context *ctx, |
| 452 » » » cu_offset die_offset) |
316 { | 453 { |
317 struct dwarf_expr_baton *debaton = ctx->baton; | 454 struct dwarf_expr_baton *debaton = ctx->baton; |
318 | 455 |
319 return dwarf2_get_die_type (die_offset, debaton->per_cu); | 456 return dwarf2_get_die_type (die_offset, debaton->per_cu); |
320 } | 457 } |
321 | 458 |
322 /* See dwarf2loc.h. */ | 459 /* See dwarf2loc.h. */ |
323 | 460 |
324 int entry_values_debug = 0; | 461 int entry_values_debug = 0; |
325 | 462 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 assumed frames between them use GDBARCH. Use depth first search so we can | 778 assumed frames between them use GDBARCH. Use depth first search so we can |
642 keep single CHAIN of call_site's back to CALLER_PC. Function recursion | 779 keep single CHAIN of call_site's back to CALLER_PC. Function recursion |
643 would have needless GDB stack overhead. Caller is responsible for xfree of | 780 would have needless GDB stack overhead. Caller is responsible for xfree of |
644 the returned result. Any unreliability results in thrown | 781 the returned result. Any unreliability results in thrown |
645 NO_ENTRY_VALUE_ERROR. */ | 782 NO_ENTRY_VALUE_ERROR. */ |
646 | 783 |
647 static struct call_site_chain * | 784 static struct call_site_chain * |
648 call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, | 785 call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, |
649 CORE_ADDR callee_pc) | 786 CORE_ADDR callee_pc) |
650 { | 787 { |
651 struct func_type *func_specific; | |
652 struct obstack addr_obstack; | 788 struct obstack addr_obstack; |
653 struct cleanup *back_to_retval, *back_to_workdata; | 789 struct cleanup *back_to_retval, *back_to_workdata; |
654 struct call_site_chain *retval = NULL; | 790 struct call_site_chain *retval = NULL; |
655 struct call_site *call_site; | 791 struct call_site *call_site; |
656 | 792 |
657 /* Mark CALL_SITEs so we do not visit the same ones twice. */ | 793 /* Mark CALL_SITEs so we do not visit the same ones twice. */ |
658 htab_t addr_hash; | 794 htab_t addr_hash; |
659 | 795 |
660 /* CHAIN contains only the intermediate CALL_SITEs. Neither CALLER_PC's | 796 /* CHAIN contains only the intermediate CALL_SITEs. Neither CALLER_PC's |
661 call_site nor any possible call_site at CALLEE_PC's function is there. | 797 call_site nor any possible call_site at CALLEE_PC's function is there. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 exception_print (gdb_stdout, e); | 941 exception_print (gdb_stdout, e); |
806 | 942 |
807 return NULL; | 943 return NULL; |
808 } | 944 } |
809 else | 945 else |
810 throw_exception (e); | 946 throw_exception (e); |
811 } | 947 } |
812 return retval; | 948 return retval; |
813 } | 949 } |
814 | 950 |
815 /* Fetch call_site_parameter from caller matching the parameters. FRAME is for | 951 /* Return 1 if KIND and KIND_U match PARAMETER. Return 0 otherwise. */ |
816 callee. See DWARF_REG and FB_OFFSET description at struct | 952 |
817 dwarf_expr_context_funcs->push_dwarf_reg_entry_value. | 953 static int |
| 954 call_site_parameter_matches (struct call_site_parameter *parameter, |
| 955 » » » enum call_site_parameter_kind kind, |
| 956 » » » union call_site_parameter_u kind_u) |
| 957 { |
| 958 if (kind == parameter->kind) |
| 959 switch (kind) |
| 960 { |
| 961 case CALL_SITE_PARAMETER_DWARF_REG: |
| 962 » return kind_u.dwarf_reg == parameter->u.dwarf_reg; |
| 963 case CALL_SITE_PARAMETER_FB_OFFSET: |
| 964 » return kind_u.fb_offset == parameter->u.fb_offset; |
| 965 case CALL_SITE_PARAMETER_PARAM_OFFSET: |
| 966 » return kind_u.param_offset.cu_off == parameter->u.param_offset.cu_off; |
| 967 } |
| 968 return 0; |
| 969 } |
| 970 |
| 971 /* Fetch call_site_parameter from caller matching KIND and KIND_U. |
| 972 FRAME is for callee. |
818 | 973 |
819 Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR | 974 Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR |
820 otherwise. */ | 975 otherwise. */ |
821 | 976 |
822 static struct call_site_parameter * | 977 static struct call_site_parameter * |
823 dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, int dwarf_reg, | 978 dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, |
824 » » » » CORE_ADDR fb_offset, | 979 » » » » enum call_site_parameter_kind kind, |
| 980 » » » » union call_site_parameter_u kind_u, |
825 struct dwarf2_per_cu_data **per_cu_return) | 981 struct dwarf2_per_cu_data **per_cu_return) |
826 { | 982 { |
827 CORE_ADDR func_addr = get_frame_func (frame); | 983 CORE_ADDR func_addr = get_frame_func (frame); |
828 CORE_ADDR caller_pc; | 984 CORE_ADDR caller_pc; |
829 struct gdbarch *gdbarch = get_frame_arch (frame); | 985 struct gdbarch *gdbarch = get_frame_arch (frame); |
830 struct frame_info *caller_frame = get_prev_frame (frame); | 986 struct frame_info *caller_frame = get_prev_frame (frame); |
831 struct call_site *call_site; | 987 struct call_site *call_site; |
832 int iparams; | 988 int iparams; |
833 struct value *val; | |
834 struct dwarf2_locexpr_baton *dwarf_block; | |
835 /* Initialize it just to avoid a GCC false warning. */ | 989 /* Initialize it just to avoid a GCC false warning. */ |
836 struct call_site_parameter *parameter = NULL; | 990 struct call_site_parameter *parameter = NULL; |
837 CORE_ADDR target_addr; | 991 CORE_ADDR target_addr; |
838 | 992 |
839 if (gdbarch != frame_unwind_arch (frame)) | 993 if (gdbarch != frame_unwind_arch (frame)) |
840 { | 994 { |
841 struct minimal_symbol *msym = lookup_minimal_symbol_by_pc (func_addr); | 995 struct minimal_symbol *msym = lookup_minimal_symbol_by_pc (func_addr); |
842 struct gdbarch *caller_gdbarch = frame_unwind_arch (frame); | 996 struct gdbarch *caller_gdbarch = frame_unwind_arch (frame); |
843 | 997 |
844 throw_error (NO_ENTRY_VALUE_ERROR, | 998 throw_error (NO_ENTRY_VALUE_ERROR, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 paddress (gdbarch, func_addr)); | 1033 paddress (gdbarch, func_addr)); |
880 } | 1034 } |
881 | 1035 |
882 /* No entry value based parameters would be reliable if this function can | 1036 /* No entry value based parameters would be reliable if this function can |
883 call itself via tail calls. */ | 1037 call itself via tail calls. */ |
884 func_verify_no_selftailcall (gdbarch, func_addr); | 1038 func_verify_no_selftailcall (gdbarch, func_addr); |
885 | 1039 |
886 for (iparams = 0; iparams < call_site->parameter_count; iparams++) | 1040 for (iparams = 0; iparams < call_site->parameter_count; iparams++) |
887 { | 1041 { |
888 parameter = &call_site->parameter[iparams]; | 1042 parameter = &call_site->parameter[iparams]; |
889 if (parameter->dwarf_reg == -1 && dwarf_reg == -1) | 1043 if (call_site_parameter_matches (parameter, kind, kind_u)) |
890 » { | |
891 » if (parameter->fb_offset == fb_offset) | |
892 » break; | |
893 » } | |
894 else if (parameter->dwarf_reg == dwarf_reg) | |
895 break; | 1044 break; |
896 } | 1045 } |
897 if (iparams == call_site->parameter_count) | 1046 if (iparams == call_site->parameter_count) |
898 { | 1047 { |
899 struct minimal_symbol *msym = lookup_minimal_symbol_by_pc (caller_pc); | 1048 struct minimal_symbol *msym = lookup_minimal_symbol_by_pc (caller_pc); |
900 | 1049 |
901 /* DW_TAG_GNU_call_site_parameter will be missing just if GCC could not | 1050 /* DW_TAG_GNU_call_site_parameter will be missing just if GCC could not |
902 determine its value. */ | 1051 determine its value. */ |
903 throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find matching parameter " | 1052 throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find matching parameter " |
904 "at DW_TAG_GNU_call_site %s at %s"), | 1053 "at DW_TAG_GNU_call_site %s at %s"), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 /* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF | 1090 /* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF |
942 location. Postprocessing of DWARF_VALUE_MEMORY would lose the type from | 1091 location. Postprocessing of DWARF_VALUE_MEMORY would lose the type from |
943 DWARF block. */ | 1092 DWARF block. */ |
944 data = alloca (size + 1); | 1093 data = alloca (size + 1); |
945 memcpy (data, data_src, size); | 1094 memcpy (data, data_src, size); |
946 data[size] = DW_OP_stack_value; | 1095 data[size] = DW_OP_stack_value; |
947 | 1096 |
948 return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu); | 1097 return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu); |
949 } | 1098 } |
950 | 1099 |
951 /* Execute call_site_parameter's DWARF block matching DEREF_SIZE for caller of | 1100 /* Execute DWARF block of call_site_parameter which matches KIND and KIND_U. |
952 the CTX's frame. CTX must be of dwarf_expr_ctx_funcs kind. See DWARF_REG | 1101 Choose DEREF_SIZE value of that parameter. Search caller of the CTX's |
953 and FB_OFFSET description at struct | 1102 frame. CTX must be of dwarf_expr_ctx_funcs kind. |
954 dwarf_expr_context_funcs->push_dwarf_reg_entry_value. | |
955 | 1103 |
956 The CTX caller can be from a different CU - per_cu_dwarf_call implementation | 1104 The CTX caller can be from a different CU - per_cu_dwarf_call implementation |
957 can be more simple as it does not support cross-CU DWARF executions. */ | 1105 can be more simple as it does not support cross-CU DWARF executions. */ |
958 | 1106 |
959 static void | 1107 static void |
960 dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, | 1108 dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, |
961 » » » » int dwarf_reg, CORE_ADDR fb_offset, | 1109 » » » » enum call_site_parameter_kind kind, |
| 1110 » » » » union call_site_parameter_u kind_u, |
962 int deref_size) | 1111 int deref_size) |
963 { | 1112 { |
964 struct dwarf_expr_baton *debaton; | 1113 struct dwarf_expr_baton *debaton; |
965 struct frame_info *frame, *caller_frame; | 1114 struct frame_info *frame, *caller_frame; |
966 struct dwarf2_per_cu_data *caller_per_cu; | 1115 struct dwarf2_per_cu_data *caller_per_cu; |
967 struct dwarf_expr_baton baton_local; | 1116 struct dwarf_expr_baton baton_local; |
968 struct dwarf_expr_context saved_ctx; | 1117 struct dwarf_expr_context saved_ctx; |
969 struct call_site_parameter *parameter; | 1118 struct call_site_parameter *parameter; |
970 const gdb_byte *data_src; | 1119 const gdb_byte *data_src; |
971 size_t size; | 1120 size_t size; |
972 | 1121 |
973 gdb_assert (ctx->funcs == &dwarf_expr_ctx_funcs); | 1122 gdb_assert (ctx->funcs == &dwarf_expr_ctx_funcs); |
974 debaton = ctx->baton; | 1123 debaton = ctx->baton; |
975 frame = debaton->frame; | 1124 frame = debaton->frame; |
976 caller_frame = get_prev_frame (frame); | 1125 caller_frame = get_prev_frame (frame); |
977 | 1126 |
978 parameter = dwarf_expr_reg_to_entry_parameter (frame, dwarf_reg, fb_offset, | 1127 parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, |
979 &caller_per_cu); | 1128 &caller_per_cu); |
980 data_src = deref_size == -1 ? parameter->value : parameter->data_value; | 1129 data_src = deref_size == -1 ? parameter->value : parameter->data_value; |
981 size = deref_size == -1 ? parameter->value_size : parameter->data_value_size; | 1130 size = deref_size == -1 ? parameter->value_size : parameter->data_value_size; |
982 | 1131 |
983 /* DEREF_SIZE size is not verified here. */ | 1132 /* DEREF_SIZE size is not verified here. */ |
984 if (data_src == NULL) | 1133 if (data_src == NULL) |
985 throw_error (NO_ENTRY_VALUE_ERROR, | 1134 throw_error (NO_ENTRY_VALUE_ERROR, |
986 _("Cannot resolve DW_AT_GNU_call_site_data_value")); | 1135 _("Cannot resolve DW_AT_GNU_call_site_data_value")); |
987 | 1136 |
988 baton_local.frame = caller_frame; | 1137 baton_local.frame = caller_frame; |
989 baton_local.per_cu = caller_per_cu; | 1138 baton_local.per_cu = caller_per_cu; |
990 | 1139 |
991 saved_ctx.gdbarch = ctx->gdbarch; | 1140 saved_ctx.gdbarch = ctx->gdbarch; |
992 saved_ctx.addr_size = ctx->addr_size; | 1141 saved_ctx.addr_size = ctx->addr_size; |
993 saved_ctx.offset = ctx->offset; | 1142 saved_ctx.offset = ctx->offset; |
994 saved_ctx.baton = ctx->baton; | 1143 saved_ctx.baton = ctx->baton; |
995 ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (baton_local.per_cu)); | 1144 ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (baton_local.per_cu)); |
996 ctx->addr_size = dwarf2_per_cu_addr_size (baton_local.per_cu); | 1145 ctx->addr_size = dwarf2_per_cu_addr_size (baton_local.per_cu); |
997 ctx->offset = dwarf2_per_cu_text_offset (baton_local.per_cu); | 1146 ctx->offset = dwarf2_per_cu_text_offset (baton_local.per_cu); |
998 ctx->baton = &baton_local; | 1147 ctx->baton = &baton_local; |
999 | 1148 |
1000 dwarf_expr_eval (ctx, data_src, size); | 1149 dwarf_expr_eval (ctx, data_src, size); |
1001 | 1150 |
1002 ctx->gdbarch = saved_ctx.gdbarch; | 1151 ctx->gdbarch = saved_ctx.gdbarch; |
1003 ctx->addr_size = saved_ctx.addr_size; | 1152 ctx->addr_size = saved_ctx.addr_size; |
1004 ctx->offset = saved_ctx.offset; | 1153 ctx->offset = saved_ctx.offset; |
1005 ctx->baton = saved_ctx.baton; | 1154 ctx->baton = saved_ctx.baton; |
1006 } | 1155 } |
1007 | 1156 |
| 1157 /* Callback function for dwarf2_evaluate_loc_desc. |
| 1158 Fetch the address indexed by DW_OP_GNU_addr_index. */ |
| 1159 |
| 1160 static CORE_ADDR |
| 1161 dwarf_expr_get_addr_index (void *baton, unsigned int index) |
| 1162 { |
| 1163 struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton; |
| 1164 |
| 1165 return dwarf2_read_addr_index (debaton->per_cu, index); |
| 1166 } |
| 1167 |
1008 /* VALUE must be of type lval_computed with entry_data_value_funcs. Perform | 1168 /* VALUE must be of type lval_computed with entry_data_value_funcs. Perform |
1009 the indirect method on it, that is use its stored target value, the sole | 1169 the indirect method on it, that is use its stored target value, the sole |
1010 purpose of entry_data_value_funcs.. */ | 1170 purpose of entry_data_value_funcs.. */ |
1011 | 1171 |
1012 static struct value * | 1172 static struct value * |
1013 entry_data_value_coerce_ref (const struct value *value) | 1173 entry_data_value_coerce_ref (const struct value *value) |
1014 { | 1174 { |
1015 struct type *checked_type = check_typedef (value_type (value)); | 1175 struct type *checked_type = check_typedef (value_type (value)); |
1016 struct value *target_val; | 1176 struct value *target_val; |
1017 | 1177 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 NULL, /* write */ | 1214 NULL, /* write */ |
1055 NULL, /* check_validity */ | 1215 NULL, /* check_validity */ |
1056 NULL, /* check_any_valid */ | 1216 NULL, /* check_any_valid */ |
1057 NULL, /* indirect */ | 1217 NULL, /* indirect */ |
1058 entry_data_value_coerce_ref, | 1218 entry_data_value_coerce_ref, |
1059 NULL, /* check_synthetic_pointer */ | 1219 NULL, /* check_synthetic_pointer */ |
1060 entry_data_value_copy_closure, | 1220 entry_data_value_copy_closure, |
1061 entry_data_value_free_closure | 1221 entry_data_value_free_closure |
1062 }; | 1222 }; |
1063 | 1223 |
1064 /* Read parameter of TYPE at (callee) FRAME's function entry. DWARF_REG and | 1224 /* Read parameter of TYPE at (callee) FRAME's function entry. KIND and KIND_U |
1065 FB_OFFSET are used to match DW_AT_location at the caller's | 1225 are used to match DW_AT_location at the caller's |
1066 DW_TAG_GNU_call_site_parameter. See DWARF_REG and FB_OFFSET description at | 1226 DW_TAG_GNU_call_site_parameter. |
1067 struct dwarf_expr_context_funcs->push_dwarf_reg_entry_value. | |
1068 | 1227 |
1069 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it | 1228 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it |
1070 cannot resolve the parameter for any reason. */ | 1229 cannot resolve the parameter for any reason. */ |
1071 | 1230 |
1072 static struct value * | 1231 static struct value * |
1073 value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, | 1232 value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, |
1074 » » » int dwarf_reg, CORE_ADDR fb_offset) | 1233 » » » enum call_site_parameter_kind kind, |
| 1234 » » » union call_site_parameter_u kind_u) |
1075 { | 1235 { |
1076 struct type *checked_type = check_typedef (type); | 1236 struct type *checked_type = check_typedef (type); |
1077 struct type *target_type = TYPE_TARGET_TYPE (checked_type); | 1237 struct type *target_type = TYPE_TARGET_TYPE (checked_type); |
1078 struct frame_info *caller_frame = get_prev_frame (frame); | 1238 struct frame_info *caller_frame = get_prev_frame (frame); |
1079 struct value *outer_val, *target_val, *val; | 1239 struct value *outer_val, *target_val, *val; |
1080 struct call_site_parameter *parameter; | 1240 struct call_site_parameter *parameter; |
1081 struct dwarf2_per_cu_data *caller_per_cu; | 1241 struct dwarf2_per_cu_data *caller_per_cu; |
1082 CORE_ADDR addr; | 1242 CORE_ADDR addr; |
1083 | 1243 |
1084 parameter = dwarf_expr_reg_to_entry_parameter (frame, dwarf_reg, fb_offset, | 1244 parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, |
1085 &caller_per_cu); | 1245 &caller_per_cu); |
1086 | 1246 |
1087 outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, | 1247 outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */, |
1088 type, caller_frame, | 1248 type, caller_frame, |
1089 caller_per_cu); | 1249 caller_per_cu); |
1090 | 1250 |
1091 /* Check if DW_AT_GNU_call_site_data_value cannot be used. If it should be | 1251 /* Check if DW_AT_GNU_call_site_data_value cannot be used. If it should be |
1092 used and it is not available do not fall back to OUTER_VAL - dereferencing | 1252 used and it is not available do not fall back to OUTER_VAL - dereferencing |
1093 TYPE_CODE_REF with non-entry data value would give current value - not the | 1253 TYPE_CODE_REF with non-entry data value would give current value - not the |
1094 entry value. */ | 1254 entry value. */ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 SIZE are DWARF block used to match DW_AT_location at the caller's | 1286 SIZE are DWARF block used to match DW_AT_location at the caller's |
1127 DW_TAG_GNU_call_site_parameter. | 1287 DW_TAG_GNU_call_site_parameter. |
1128 | 1288 |
1129 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it | 1289 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it |
1130 cannot resolve the parameter for any reason. */ | 1290 cannot resolve the parameter for any reason. */ |
1131 | 1291 |
1132 static struct value * | 1292 static struct value * |
1133 value_of_dwarf_block_entry (struct type *type, struct frame_info *frame, | 1293 value_of_dwarf_block_entry (struct type *type, struct frame_info *frame, |
1134 const gdb_byte *block, size_t block_len) | 1294 const gdb_byte *block, size_t block_len) |
1135 { | 1295 { |
1136 int dwarf_reg; | 1296 union call_site_parameter_u kind_u; |
1137 CORE_ADDR fb_offset; | |
1138 | 1297 |
1139 dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len); | 1298 kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len); |
1140 if (dwarf_reg != -1) | 1299 if (kind_u.dwarf_reg != -1) |
1141 return value_of_dwarf_reg_entry (type, frame, dwarf_reg, 0 /* unused */); | 1300 return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_DWARF_REG, |
| 1301 » » » » kind_u); |
1142 | 1302 |
1143 if (dwarf_block_to_fb_offset (block, block + block_len, &fb_offset)) | 1303 if (dwarf_block_to_fb_offset (block, block + block_len, &kind_u.fb_offset)) |
1144 return value_of_dwarf_reg_entry (type, frame, -1, fb_offset); | 1304 return value_of_dwarf_reg_entry (type, frame, CALL_SITE_PARAMETER_FB_OFFSET, |
| 1305 kind_u); |
1145 | 1306 |
1146 /* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message | 1307 /* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message |
1147 suppressed during normal operation. The expression can be arbitrary if | 1308 suppressed during normal operation. The expression can be arbitrary if |
1148 there is no caller-callee entry value binding expected. */ | 1309 there is no caller-callee entry value binding expected. */ |
1149 throw_error (NO_ENTRY_VALUE_ERROR, | 1310 throw_error (NO_ENTRY_VALUE_ERROR, |
1150 _("DWARF-2 expression error: DW_OP_GNU_entry_value is supported " | 1311 _("DWARF-2 expression error: DW_OP_GNU_entry_value is supported " |
1151 "only for single DW_OP_reg* or for DW_OP_fbreg(*)")); | 1312 "only for single DW_OP_reg* or for DW_OP_fbreg(*)")); |
1152 } | 1313 } |
1153 | 1314 |
1154 struct piece_closure | 1315 struct piece_closure |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = | 2093 static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = |
1933 { | 2094 { |
1934 dwarf_expr_read_reg, | 2095 dwarf_expr_read_reg, |
1935 dwarf_expr_read_mem, | 2096 dwarf_expr_read_mem, |
1936 dwarf_expr_frame_base, | 2097 dwarf_expr_frame_base, |
1937 dwarf_expr_frame_cfa, | 2098 dwarf_expr_frame_cfa, |
1938 dwarf_expr_frame_pc, | 2099 dwarf_expr_frame_pc, |
1939 dwarf_expr_tls_address, | 2100 dwarf_expr_tls_address, |
1940 dwarf_expr_dwarf_call, | 2101 dwarf_expr_dwarf_call, |
1941 dwarf_expr_get_base_type, | 2102 dwarf_expr_get_base_type, |
1942 dwarf_expr_push_dwarf_reg_entry_value | 2103 dwarf_expr_push_dwarf_reg_entry_value, |
| 2104 dwarf_expr_get_addr_index |
1943 }; | 2105 }; |
1944 | 2106 |
1945 /* Evaluate a location description, starting at DATA and with length | 2107 /* Evaluate a location description, starting at DATA and with length |
1946 SIZE, to find the current location of variable of TYPE in the | 2108 SIZE, to find the current location of variable of TYPE in the |
1947 context of FRAME. BYTE_OFFSET is applied after the contents are | 2109 context of FRAME. BYTE_OFFSET is applied after the contents are |
1948 computed. */ | 2110 computed. */ |
1949 | 2111 |
1950 static struct value * | 2112 static struct value * |
1951 dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, | 2113 dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, |
1952 const gdb_byte *data, unsigned short size, | 2114 const gdb_byte *data, unsigned short size, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 | 2371 |
2210 /* Thread-local accesses do require a frame. */ | 2372 /* Thread-local accesses do require a frame. */ |
2211 static CORE_ADDR | 2373 static CORE_ADDR |
2212 needs_frame_tls_address (void *baton, CORE_ADDR offset) | 2374 needs_frame_tls_address (void *baton, CORE_ADDR offset) |
2213 { | 2375 { |
2214 struct needs_frame_baton *nf_baton = baton; | 2376 struct needs_frame_baton *nf_baton = baton; |
2215 | 2377 |
2216 nf_baton->needs_frame = 1; | 2378 nf_baton->needs_frame = 1; |
2217 return 1; | 2379 return 1; |
2218 } | 2380 } |
error: old chunk mismatch |
None
OLD | NEW |