* server.c (handle_general_set): Make static.
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
CommitLineData
4c2df51b 1/* DWARF 2 location expression support for GDB.
feb13ab0 2
4c38e0a4
JB
3 Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
feb13ab0 5
4c2df51b
DJ
6 Contributed by Daniel Jacobowitz, MontaVista Software, Inc.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7
JB
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
4c2df51b 14
a9762ec7
JB
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
4c2df51b
DJ
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
4c2df51b
DJ
22
23#include "defs.h"
24#include "ui-out.h"
25#include "value.h"
26#include "frame.h"
27#include "gdbcore.h"
28#include "target.h"
29#include "inferior.h"
a55cc764
DJ
30#include "ax.h"
31#include "ax-gdb.h"
e4adbba9 32#include "regcache.h"
c3228f12 33#include "objfiles.h"
93ad78a7 34#include "exceptions.h"
edb3359d 35#include "block.h"
4c2df51b 36
fa8f86ff 37#include "dwarf2.h"
4c2df51b
DJ
38#include "dwarf2expr.h"
39#include "dwarf2loc.h"
e7802207 40#include "dwarf2-frame.h"
4c2df51b
DJ
41
42#include "gdb_string.h"
eff4f95e 43#include "gdb_assert.h"
4c2df51b 44
0936ad1d
SS
45static void
46dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
47 gdb_byte **start, size_t *length);
48
0d53c4c4
DJ
49/* A helper function for dealing with location lists. Given a
50 symbol baton (BATON) and a pc value (PC), find the appropriate
51 location expression, set *LOCEXPR_LENGTH, and return a pointer
52 to the beginning of the expression. Returns NULL on failure.
53
54 For now, only return the first matching location expression; there
55 can be more than one in the list. */
56
852483bc 57static gdb_byte *
0d53c4c4 58find_location_expression (struct dwarf2_loclist_baton *baton,
b6b08ebf 59 size_t *locexpr_length, CORE_ADDR pc)
0d53c4c4 60{
0d53c4c4 61 CORE_ADDR low, high;
852483bc
MK
62 gdb_byte *loc_ptr, *buf_end;
63 int length;
ae0d2f24 64 struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
f7fd4728 65 struct gdbarch *gdbarch = get_objfile_arch (objfile);
e17a4113 66 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ae0d2f24 67 unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
0d53c4c4 68 CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
8edfa926 69 /* Adjust base_address for relocatable objects. */
ae0d2f24
UW
70 CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
71 SECT_OFF_TEXT (objfile));
8edfa926 72 CORE_ADDR base_address = baton->base_address + base_offset;
0d53c4c4
DJ
73
74 loc_ptr = baton->data;
75 buf_end = baton->data + baton->size;
76
77 while (1)
78 {
b5758fe4
UW
79 if (buf_end - loc_ptr < 2 * addr_size)
80 error (_("find_location_expression: Corrupted DWARF expression."));
0d53c4c4 81
b5758fe4
UW
82 low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
83 loc_ptr += addr_size;
0d53c4c4
DJ
84
85 /* A base-address-selection entry. */
b5758fe4 86 if (low == base_mask)
0d53c4c4 87 {
b5758fe4
UW
88 base_address = dwarf2_read_address (gdbarch,
89 loc_ptr, buf_end, addr_size);
90 loc_ptr += addr_size;
0d53c4c4
DJ
91 continue;
92 }
93
b5758fe4
UW
94 high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
95 loc_ptr += addr_size;
96
97 /* An end-of-list entry. */
98 if (low == 0 && high == 0)
99 return NULL;
100
0d53c4c4
DJ
101 /* Otherwise, a location expression entry. */
102 low += base_address;
103 high += base_address;
104
e17a4113 105 length = extract_unsigned_integer (loc_ptr, 2, byte_order);
0d53c4c4
DJ
106 loc_ptr += 2;
107
108 if (pc >= low && pc < high)
109 {
110 *locexpr_length = length;
111 return loc_ptr;
112 }
113
114 loc_ptr += length;
115 }
116}
117
4c2df51b
DJ
118/* This is the baton used when performing dwarf2 expression
119 evaluation. */
120struct dwarf_expr_baton
121{
122 struct frame_info *frame;
123 struct objfile *objfile;
124};
125
126/* Helper functions for dwarf2_evaluate_loc_desc. */
127
4bc9efe1 128/* Using the frame specified in BATON, return the value of register
0b2b0195 129 REGNUM, treated as a pointer. */
4c2df51b 130static CORE_ADDR
61fbb938 131dwarf_expr_read_reg (void *baton, int dwarf_regnum)
4c2df51b 132{
4c2df51b 133 struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
5e2b427d 134 struct gdbarch *gdbarch = get_frame_arch (debaton->frame);
e5192dd8 135 CORE_ADDR result;
0b2b0195 136 int regnum;
e4adbba9 137
5e2b427d
UW
138 regnum = gdbarch_dwarf2_reg_to_regnum (gdbarch, dwarf_regnum);
139 result = address_from_register (builtin_type (gdbarch)->builtin_data_ptr,
0b2b0195 140 regnum, debaton->frame);
4c2df51b
DJ
141 return result;
142}
143
144/* Read memory at ADDR (length LEN) into BUF. */
145
146static void
852483bc 147dwarf_expr_read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
4c2df51b
DJ
148{
149 read_memory (addr, buf, len);
150}
151
152/* Using the frame specified in BATON, find the location expression
153 describing the frame base. Return a pointer to it in START and
154 its length in LENGTH. */
155static void
852483bc 156dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length)
4c2df51b 157{
da62e633
AC
158 /* FIXME: cagney/2003-03-26: This code should be using
159 get_frame_base_address(), and then implement a dwarf2 specific
160 this_base method. */
4c2df51b 161 struct symbol *framefunc;
4c2df51b 162 struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
0d53c4c4 163
edb3359d
DJ
164 /* Use block_linkage_function, which returns a real (not inlined)
165 function, instead of get_frame_function, which may return an
166 inlined function. */
167 framefunc = block_linkage_function (get_frame_block (debaton->frame, NULL));
0d53c4c4 168
eff4f95e
JG
169 /* If we found a frame-relative symbol then it was certainly within
170 some function associated with a frame. If we can't find the frame,
171 something has gone wrong. */
172 gdb_assert (framefunc != NULL);
173
0936ad1d
SS
174 dwarf_expr_frame_base_1 (framefunc,
175 get_frame_address_in_block (debaton->frame),
176 start, length);
177}
178
179static void
180dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
181 gdb_byte **start, size_t *length)
182{
edb3359d
DJ
183 if (SYMBOL_LOCATION_BATON (framefunc) == NULL)
184 *start = NULL;
185 else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_loclist_funcs)
0d53c4c4
DJ
186 {
187 struct dwarf2_loclist_baton *symbaton;
22c6caba 188
0d53c4c4 189 symbaton = SYMBOL_LOCATION_BATON (framefunc);
0936ad1d 190 *start = find_location_expression (symbaton, length, pc);
0d53c4c4
DJ
191 }
192 else
193 {
194 struct dwarf2_locexpr_baton *symbaton;
195 symbaton = SYMBOL_LOCATION_BATON (framefunc);
ebd3bcc1
JK
196 if (symbaton != NULL)
197 {
198 *length = symbaton->size;
199 *start = symbaton->data;
200 }
201 else
202 *start = NULL;
0d53c4c4
DJ
203 }
204
205 if (*start == NULL)
8a3fe4f8 206 error (_("Could not find the frame base for \"%s\"."),
0d53c4c4 207 SYMBOL_NATURAL_NAME (framefunc));
4c2df51b
DJ
208}
209
e7802207
TT
210/* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for
211 the frame in BATON. */
212
213static CORE_ADDR
214dwarf_expr_frame_cfa (void *baton)
215{
216 struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
217 return dwarf2_frame_cfa (debaton->frame);
218}
219
4c2df51b
DJ
220/* Using the objfile specified in BATON, find the address for the
221 current thread's thread-local storage with offset OFFSET. */
222static CORE_ADDR
223dwarf_expr_tls_address (void *baton, CORE_ADDR offset)
224{
225 struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
4c2df51b 226
9e35dae4 227 return target_translate_tls_address (debaton->objfile, offset);
4c2df51b
DJ
228}
229
052b9502
NF
230struct piece_closure
231{
232 /* The number of pieces used to describe this variable. */
233 int n_pieces;
234
6063c216
UW
235 /* The target address size, used only for DWARF_VALUE_STACK. */
236 int addr_size;
cec03d70 237
052b9502
NF
238 /* The pieces themselves. */
239 struct dwarf_expr_piece *pieces;
240};
241
242/* Allocate a closure for a value formed from separately-described
243 PIECES. */
244
245static struct piece_closure *
cec03d70 246allocate_piece_closure (int n_pieces, struct dwarf_expr_piece *pieces,
6063c216 247 int addr_size)
052b9502
NF
248{
249 struct piece_closure *c = XZALLOC (struct piece_closure);
250
251 c->n_pieces = n_pieces;
6063c216 252 c->addr_size = addr_size;
052b9502
NF
253 c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece);
254
255 memcpy (c->pieces, pieces, n_pieces * sizeof (struct dwarf_expr_piece));
256
257 return c;
258}
259
260static void
261read_pieced_value (struct value *v)
262{
263 int i;
264 long offset = 0;
265 gdb_byte *contents;
266 struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
267 struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (v));
268
269 contents = value_contents_raw (v);
270 for (i = 0; i < c->n_pieces; i++)
271 {
272 struct dwarf_expr_piece *p = &c->pieces[i];
cec03d70 273 switch (p->location)
052b9502 274 {
cec03d70
TT
275 case DWARF_VALUE_REGISTER:
276 {
277 struct gdbarch *arch = get_frame_arch (frame);
cec03d70 278 int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch,
44353522 279 p->v.expr.value);
dcbf108f
UW
280 int reg_offset = 0;
281
282 if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
283 && p->size < register_size (arch, gdb_regnum))
284 /* Big-endian, and we want less than full size. */
285 reg_offset = register_size (arch, gdb_regnum) - p->size;
286
287 get_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
288 contents + offset);
cec03d70
TT
289 }
290 break;
291
292 case DWARF_VALUE_MEMORY:
44353522
DE
293 if (p->v.expr.in_stack_memory)
294 read_stack (p->v.expr.value, contents + offset, p->size);
295 else
296 read_memory (p->v.expr.value, contents + offset, p->size);
cec03d70
TT
297 break;
298
299 case DWARF_VALUE_STACK:
300 {
6063c216
UW
301 struct gdbarch *gdbarch = get_type_arch (value_type (v));
302 size_t n = p->size;
303 if (n > c->addr_size)
304 n = c->addr_size;
05566b3b 305 store_unsigned_integer (contents + offset, n,
6063c216 306 gdbarch_byte_order (gdbarch),
05566b3b 307 p->v.expr.value);
cec03d70
TT
308 }
309 break;
310
311 case DWARF_VALUE_LITERAL:
312 {
313 size_t n = p->size;
314 if (n > p->v.literal.length)
315 n = p->v.literal.length;
316 memcpy (contents + offset, p->v.literal.data, n);
317 }
318 break;
319
320 default:
321 internal_error (__FILE__, __LINE__, _("invalid location type"));
052b9502
NF
322 }
323 offset += p->size;
324 }
325}
326
327static void
328write_pieced_value (struct value *to, struct value *from)
329{
330 int i;
331 long offset = 0;
332 gdb_byte *contents;
333 struct piece_closure *c = (struct piece_closure *) value_computed_closure (to);
334 struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (to));
335
336 if (frame == NULL)
337 {
338 set_value_optimized_out (to, 1);
339 return;
340 }
341
342 contents = value_contents_raw (from);
343 for (i = 0; i < c->n_pieces; i++)
344 {
345 struct dwarf_expr_piece *p = &c->pieces[i];
cec03d70 346 switch (p->location)
052b9502 347 {
cec03d70
TT
348 case DWARF_VALUE_REGISTER:
349 {
350 struct gdbarch *arch = get_frame_arch (frame);
44353522 351 int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.expr.value);
dcbf108f
UW
352 int reg_offset = 0;
353
354 if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
355 && p->size < register_size (arch, gdb_regnum))
356 /* Big-endian, and we want less than full size. */
357 reg_offset = register_size (arch, gdb_regnum) - p->size;
358
359 put_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
360 contents + offset);
cec03d70
TT
361 }
362 break;
363 case DWARF_VALUE_MEMORY:
44353522 364 write_memory (p->v.expr.value, contents + offset, p->size);
cec03d70
TT
365 break;
366 default:
367 set_value_optimized_out (to, 1);
368 return;
052b9502
NF
369 }
370 offset += p->size;
371 }
372}
373
374static void *
375copy_pieced_value_closure (struct value *v)
376{
377 struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
378
6063c216 379 return allocate_piece_closure (c->n_pieces, c->pieces, c->addr_size);
052b9502
NF
380}
381
382static void
383free_pieced_value_closure (struct value *v)
384{
385 struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
386
387 xfree (c->pieces);
388 xfree (c);
389}
390
391/* Functions for accessing a variable described by DW_OP_piece. */
392static struct lval_funcs pieced_value_funcs = {
393 read_pieced_value,
394 write_pieced_value,
395 copy_pieced_value_closure,
396 free_pieced_value_closure
397};
398
4c2df51b
DJ
399/* Evaluate a location description, starting at DATA and with length
400 SIZE, to find the current location of variable VAR in the context
401 of FRAME. */
402static struct value *
403dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
852483bc 404 gdb_byte *data, unsigned short size,
ae0d2f24 405 struct dwarf2_per_cu_data *per_cu)
4c2df51b 406{
4c2df51b
DJ
407 struct value *retval;
408 struct dwarf_expr_baton baton;
409 struct dwarf_expr_context *ctx;
4a227398 410 struct cleanup *old_chain;
4c2df51b 411
0d53c4c4
DJ
412 if (size == 0)
413 {
414 retval = allocate_value (SYMBOL_TYPE (var));
415 VALUE_LVAL (retval) = not_lval;
feb13ab0 416 set_value_optimized_out (retval, 1);
10fb19b6 417 return retval;
0d53c4c4
DJ
418 }
419
4c2df51b 420 baton.frame = frame;
ae0d2f24 421 baton.objfile = dwarf2_per_cu_objfile (per_cu);
4c2df51b
DJ
422
423 ctx = new_dwarf_expr_context ();
4a227398
TT
424 old_chain = make_cleanup_free_dwarf_expr_context (ctx);
425
f7fd4728 426 ctx->gdbarch = get_objfile_arch (baton.objfile);
ae0d2f24 427 ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
4c2df51b
DJ
428 ctx->baton = &baton;
429 ctx->read_reg = dwarf_expr_read_reg;
430 ctx->read_mem = dwarf_expr_read_mem;
431 ctx->get_frame_base = dwarf_expr_frame_base;
e7802207 432 ctx->get_frame_cfa = dwarf_expr_frame_cfa;
4c2df51b
DJ
433 ctx->get_tls_address = dwarf_expr_tls_address;
434
435 dwarf_expr_eval (ctx, data, size);
87808bd6
JB
436 if (ctx->num_pieces > 0)
437 {
052b9502
NF
438 struct piece_closure *c;
439 struct frame_id frame_id = get_frame_id (frame);
440
6063c216
UW
441 c = allocate_piece_closure (ctx->num_pieces, ctx->pieces,
442 ctx->addr_size);
052b9502
NF
443 retval = allocate_computed_value (SYMBOL_TYPE (var),
444 &pieced_value_funcs,
445 c);
446 VALUE_FRAME_ID (retval) = frame_id;
87808bd6 447 }
4c2df51b
DJ
448 else
449 {
cec03d70
TT
450 switch (ctx->location)
451 {
452 case DWARF_VALUE_REGISTER:
453 {
454 struct gdbarch *arch = get_frame_arch (frame);
455 CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
456 int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum);
457 retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame);
458 }
459 break;
460
461 case DWARF_VALUE_MEMORY:
462 {
463 CORE_ADDR address = dwarf_expr_fetch (ctx, 0);
44353522 464 int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
cec03d70
TT
465
466 retval = allocate_value (SYMBOL_TYPE (var));
467 VALUE_LVAL (retval) = lval_memory;
468 set_value_lazy (retval, 1);
44353522
DE
469 if (in_stack_memory)
470 set_value_stack (retval, 1);
cec03d70
TT
471 set_value_address (retval, address);
472 }
473 break;
474
475 case DWARF_VALUE_STACK:
476 {
cec03d70
TT
477 ULONGEST value = (ULONGEST) dwarf_expr_fetch (ctx, 0);
478 bfd_byte *contents;
479 size_t n = ctx->addr_size;
480
cec03d70
TT
481 retval = allocate_value (SYMBOL_TYPE (var));
482 contents = value_contents_raw (retval);
483 if (n > TYPE_LENGTH (SYMBOL_TYPE (var)))
484 n = TYPE_LENGTH (SYMBOL_TYPE (var));
05566b3b
TT
485 store_unsigned_integer (contents, n,
486 gdbarch_byte_order (ctx->gdbarch),
487 value);
cec03d70
TT
488 }
489 break;
490
491 case DWARF_VALUE_LITERAL:
492 {
493 bfd_byte *contents;
494 size_t n = ctx->len;
495
496 retval = allocate_value (SYMBOL_TYPE (var));
497 contents = value_contents_raw (retval);
498 if (n > TYPE_LENGTH (SYMBOL_TYPE (var)))
499 n = TYPE_LENGTH (SYMBOL_TYPE (var));
500 memcpy (contents, ctx->data, n);
501 }
502 break;
503
504 default:
505 internal_error (__FILE__, __LINE__, _("invalid location type"));
506 }
4c2df51b
DJ
507 }
508
42be36b3
CT
509 set_value_initialized (retval, ctx->initialized);
510
4a227398 511 do_cleanups (old_chain);
4c2df51b
DJ
512
513 return retval;
514}
4c2df51b
DJ
515\f
516/* Helper functions and baton for dwarf2_loc_desc_needs_frame. */
517
518struct needs_frame_baton
519{
520 int needs_frame;
521};
522
523/* Reads from registers do require a frame. */
524static CORE_ADDR
61fbb938 525needs_frame_read_reg (void *baton, int regnum)
4c2df51b
DJ
526{
527 struct needs_frame_baton *nf_baton = baton;
528 nf_baton->needs_frame = 1;
529 return 1;
530}
531
532/* Reads from memory do not require a frame. */
533static void
852483bc 534needs_frame_read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
4c2df51b
DJ
535{
536 memset (buf, 0, len);
537}
538
539/* Frame-relative accesses do require a frame. */
540static void
852483bc 541needs_frame_frame_base (void *baton, gdb_byte **start, size_t * length)
4c2df51b 542{
852483bc 543 static gdb_byte lit0 = DW_OP_lit0;
4c2df51b
DJ
544 struct needs_frame_baton *nf_baton = baton;
545
546 *start = &lit0;
547 *length = 1;
548
549 nf_baton->needs_frame = 1;
550}
551
e7802207
TT
552/* CFA accesses require a frame. */
553
554static CORE_ADDR
555needs_frame_frame_cfa (void *baton)
556{
557 struct needs_frame_baton *nf_baton = baton;
558 nf_baton->needs_frame = 1;
559 return 1;
560}
561
4c2df51b
DJ
562/* Thread-local accesses do require a frame. */
563static CORE_ADDR
564needs_frame_tls_address (void *baton, CORE_ADDR offset)
565{
566 struct needs_frame_baton *nf_baton = baton;
567 nf_baton->needs_frame = 1;
568 return 1;
569}
570
571/* Return non-zero iff the location expression at DATA (length SIZE)
572 requires a frame to evaluate. */
573
574static int
ae0d2f24
UW
575dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size,
576 struct dwarf2_per_cu_data *per_cu)
4c2df51b
DJ
577{
578 struct needs_frame_baton baton;
579 struct dwarf_expr_context *ctx;
f630a401 580 int in_reg;
4a227398 581 struct cleanup *old_chain;
4c2df51b
DJ
582
583 baton.needs_frame = 0;
584
585 ctx = new_dwarf_expr_context ();
4a227398
TT
586 old_chain = make_cleanup_free_dwarf_expr_context (ctx);
587
f7fd4728 588 ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (per_cu));
ae0d2f24 589 ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
4c2df51b
DJ
590 ctx->baton = &baton;
591 ctx->read_reg = needs_frame_read_reg;
592 ctx->read_mem = needs_frame_read_mem;
593 ctx->get_frame_base = needs_frame_frame_base;
e7802207 594 ctx->get_frame_cfa = needs_frame_frame_cfa;
4c2df51b
DJ
595 ctx->get_tls_address = needs_frame_tls_address;
596
597 dwarf_expr_eval (ctx, data, size);
598
cec03d70 599 in_reg = ctx->location == DWARF_VALUE_REGISTER;
f630a401 600
87808bd6
JB
601 if (ctx->num_pieces > 0)
602 {
603 int i;
604
605 /* If the location has several pieces, and any of them are in
606 registers, then we will need a frame to fetch them from. */
607 for (i = 0; i < ctx->num_pieces; i++)
cec03d70 608 if (ctx->pieces[i].location == DWARF_VALUE_REGISTER)
87808bd6
JB
609 in_reg = 1;
610 }
611
4a227398 612 do_cleanups (old_chain);
4c2df51b 613
f630a401 614 return baton.needs_frame || in_reg;
4c2df51b
DJ
615}
616
08922a10
SS
617/* This struct keeps track of the pieces that make up a multi-location
618 object, for use in agent expression generation. It is
619 superficially similar to struct dwarf_expr_piece, but
620 dwarf_expr_piece is designed for use in immediate evaluation, and
621 does not, for example, have a way to record both base register and
622 offset. */
623
624struct axs_var_loc
0d53c4c4 625{
08922a10
SS
626 /* Memory vs register, etc */
627 enum axs_lvalue_kind kind;
628
629 /* If non-zero, number of bytes in this fragment */
630 unsigned bytes;
631
632 /* (GDB-numbered) reg, or base reg if >= 0 */
633 int reg;
634
635 /* offset from reg */
636 LONGEST offset;
637};
638
639static gdb_byte *
640dwarf2_tracepoint_var_loc (struct symbol *symbol,
641 struct agent_expr *ax,
642 struct axs_var_loc *loc,
643 struct gdbarch *gdbarch,
644 gdb_byte *data, gdb_byte *end)
645{
646 if (data[0] >= DW_OP_reg0 && data[0] <= DW_OP_reg31)
0d53c4c4 647 {
08922a10
SS
648 loc->kind = axs_lvalue_register;
649 loc->reg = gdbarch_dwarf2_reg_to_regnum (gdbarch, data[0] - DW_OP_reg0);
650 data += 1;
0d53c4c4
DJ
651 }
652 else if (data[0] == DW_OP_regx)
653 {
654 ULONGEST reg;
08922a10
SS
655 data = read_uleb128 (data + 1, end, &reg);
656 loc->kind = axs_lvalue_register;
657 loc->reg = gdbarch_dwarf2_reg_to_regnum (gdbarch, reg);
0d53c4c4
DJ
658 }
659 else if (data[0] == DW_OP_fbreg)
660 {
0936ad1d
SS
661 struct block *b;
662 struct symbol *framefunc;
663 int frame_reg = 0;
0d53c4c4 664 LONGEST frame_offset;
0936ad1d
SS
665 gdb_byte *base_data;
666 size_t base_size;
667 LONGEST base_offset = 0;
668
669 b = block_for_pc (ax->scope);
670
671 if (!b)
672 error (_("No block found for address"));
673
674 framefunc = block_linkage_function (b);
675
676 if (!framefunc)
677 error (_("No function found for block"));
678
679 dwarf_expr_frame_base_1 (framefunc, ax->scope,
680 &base_data, &base_size);
681
08922a10 682 if (base_data[0] >= DW_OP_breg0 && base_data[0] <= DW_OP_breg31)
0936ad1d 683 {
08922a10
SS
684 gdb_byte *buf_end;
685
0936ad1d 686 frame_reg = base_data[0] - DW_OP_breg0;
08922a10
SS
687 buf_end = read_sleb128 (base_data + 1,
688 base_data + base_size, &base_offset);
0936ad1d
SS
689 if (buf_end != base_data + base_size)
690 error (_("Unexpected opcode after DW_OP_breg%u for symbol \"%s\"."),
691 frame_reg, SYMBOL_PRINT_NAME (symbol));
692 }
08922a10
SS
693 else if (base_data[0] >= DW_OP_reg0 && base_data[0] <= DW_OP_reg31)
694 {
695 /* The frame base is just the register, with no offset. */
696 frame_reg = base_data[0] - DW_OP_reg0;
697 base_offset = 0;
698 }
0936ad1d
SS
699 else
700 {
701 /* We don't know what to do with the frame base expression,
702 so we can't trace this variable; give up. */
08922a10
SS
703 error (_("Cannot generate expression to collect symbol \"%s\"; DWARF 2 encoding not handled, first opcode in base data is 0x%x."),
704 SYMBOL_PRINT_NAME (symbol), base_data[0]);
0936ad1d 705 }
0d53c4c4 706
08922a10 707 data = read_sleb128 (data + 1, end, &frame_offset);
4c2df51b 708
08922a10
SS
709 loc->kind = axs_lvalue_memory;
710 loc->reg = gdbarch_dwarf2_reg_to_regnum (gdbarch, frame_reg);
711 loc->offset = base_offset + frame_offset;
9c238357 712 }
08922a10 713 else if (data[0] >= DW_OP_breg0 && data[0] <= DW_OP_breg31)
9c238357
RC
714 {
715 unsigned int reg;
716 LONGEST offset;
9c238357
RC
717
718 reg = data[0] - DW_OP_breg0;
08922a10 719 data = read_sleb128 (data + 1, end, &offset);
9c238357 720
08922a10
SS
721 loc->kind = axs_lvalue_memory;
722 loc->reg = gdbarch_dwarf2_reg_to_regnum (gdbarch, reg);
723 loc->offset = offset;
0d53c4c4
DJ
724 }
725 else
9c238357
RC
726 error (_("Unsupported DWARF opcode 0x%x in the location of \"%s\"."),
727 data[0], SYMBOL_PRINT_NAME (symbol));
08922a10
SS
728
729 return data;
0d53c4c4 730}
08922a10
SS
731
732/* Given the location of a piece, issue bytecodes that will access it. */
733
734static void
735dwarf2_tracepoint_var_access (struct agent_expr *ax,
736 struct axs_value *value,
737 struct axs_var_loc *loc)
738{
739 value->kind = loc->kind;
740
741 switch (loc->kind)
742 {
743 case axs_lvalue_register:
744 value->u.reg = loc->reg;
745 break;
746
747 case axs_lvalue_memory:
748 ax_reg (ax, loc->reg);
749 if (loc->offset)
750 {
751 ax_const_l (ax, loc->offset);
752 ax_simple (ax, aop_add);
753 }
754 break;
755
756 default:
757 internal_error (__FILE__, __LINE__, _("Unhandled value kind in dwarf2_tracepoint_var_access"));
758 }
759}
760
761static void
762dwarf2_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
763 struct agent_expr *ax, struct axs_value *value,
764 gdb_byte *data, int size)
765{
766 gdb_byte *end = data + size;
767 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
768 /* In practice, a variable is not going to be spread across
769 dozens of registers or memory locations. If someone comes up
770 with a real-world example, revisit this. */
771#define MAX_FRAGS 16
772 struct axs_var_loc fragments[MAX_FRAGS];
773 int nfrags = 0, frag;
774 int length = 0;
775 int piece_ok = 0;
776 int bad = 0;
777 int first = 1;
778
779 if (!data || size == 0)
780 {
781 value->optimized_out = 1;
782 return;
783 }
784
785 while (data < end)
786 {
787 if (!piece_ok)
788 {
789 if (nfrags == MAX_FRAGS)
790 error (_("Too many pieces in location for \"%s\"."),
791 SYMBOL_PRINT_NAME (symbol));
792
793 fragments[nfrags].bytes = 0;
794 data = dwarf2_tracepoint_var_loc (symbol, ax, &fragments[nfrags],
795 gdbarch, data, end);
796 nfrags++;
797 piece_ok = 1;
798 }
799 else if (data[0] == DW_OP_piece)
800 {
801 ULONGEST bytes;
802
803 data = read_uleb128 (data + 1, end, &bytes);
804 /* Only deal with 4 byte fragments for now. */
805 if (bytes != 4)
806 error (_("DW_OP_piece %s not supported in location for \"%s\"."),
807 pulongest (bytes), SYMBOL_PRINT_NAME (symbol));
808 fragments[nfrags - 1].bytes = bytes;
809 length += bytes;
810 piece_ok = 0;
811 }
812 else
813 {
814 bad = 1;
815 break;
816 }
817 }
818
819 if (bad || data > end)
820 error (_("Corrupted DWARF expression for \"%s\"."),
821 SYMBOL_PRINT_NAME (symbol));
822
823 /* If single expression, no pieces, convert to external format. */
824 if (length == 0)
825 {
826 dwarf2_tracepoint_var_access (ax, value, &fragments[0]);
827 return;
828 }
829
830 if (length != TYPE_LENGTH (value->type))
831 error (_("Inconsistent piece information for \"%s\"."),
832 SYMBOL_PRINT_NAME (symbol));
833
834 /* Emit bytecodes to assemble the pieces into a single stack entry. */
835
836 for ((frag = (byte_order == BFD_ENDIAN_BIG ? 0 : nfrags - 1));
837 nfrags--;
838 (frag += (byte_order == BFD_ENDIAN_BIG ? 1 : -1)))
839 {
840 if (!first)
841 {
842 /* shift the previous fragment up 32 bits */
843 ax_const_l (ax, 32);
844 ax_simple (ax, aop_lsh);
845 }
846
847 dwarf2_tracepoint_var_access (ax, value, &fragments[frag]);
848
849 switch (value->kind)
850 {
851 case axs_lvalue_register:
852 ax_reg (ax, value->u.reg);
853 break;
854
855 case axs_lvalue_memory:
856 {
857 extern int trace_kludge; /* Ugh. */
858
859 gdb_assert (fragments[frag].bytes == 4);
860 if (trace_kludge)
861 ax_trace_quick (ax, 4);
862 ax_simple (ax, aop_ref32);
863 }
864 break;
865 }
866
867 if (!first)
868 {
869 /* or the new fragment into the previous */
870 ax_zero_ext (ax, 32);
871 ax_simple (ax, aop_bit_or);
872 }
873 first = 0;
874 }
875 value->kind = axs_rvalue;
876}
877
4c2df51b
DJ
878\f
879/* Return the value of SYMBOL in FRAME using the DWARF-2 expression
880 evaluator to calculate the location. */
881static struct value *
882locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
883{
884 struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
885 struct value *val;
886 val = dwarf2_evaluate_loc_desc (symbol, frame, dlbaton->data, dlbaton->size,
ae0d2f24 887 dlbaton->per_cu);
4c2df51b
DJ
888
889 return val;
890}
891
892/* Return non-zero iff we need a frame to evaluate SYMBOL. */
893static int
894locexpr_read_needs_frame (struct symbol *symbol)
895{
896 struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
ae0d2f24
UW
897 return dwarf2_loc_desc_needs_frame (dlbaton->data, dlbaton->size,
898 dlbaton->per_cu);
4c2df51b
DJ
899}
900
08922a10
SS
901/* Describe a single piece of a location, returning an updated
902 position in the bytecode sequence. */
903
904static gdb_byte *
905locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream,
906 CORE_ADDR addr, struct objfile *objfile,
907 gdb_byte *data, int size, unsigned int addr_size)
4c2df51b 908{
08922a10
SS
909 struct gdbarch *gdbarch = get_objfile_arch (objfile);
910 int regno;
911
912 if (data[0] >= DW_OP_reg0 && data[0] <= DW_OP_reg31)
913 {
914 regno = gdbarch_dwarf2_reg_to_regnum (gdbarch, data[0] - DW_OP_reg0);
915 fprintf_filtered (stream, _("a variable in $%s"),
916 gdbarch_register_name (gdbarch, regno));
917 data += 1;
918 }
919 else if (data[0] == DW_OP_regx)
920 {
921 ULONGEST reg;
4c2df51b 922
08922a10
SS
923 data = read_uleb128 (data + 1, data + size, &reg);
924 regno = gdbarch_dwarf2_reg_to_regnum (gdbarch, reg);
925 fprintf_filtered (stream, _("a variable in $%s"),
926 gdbarch_register_name (gdbarch, regno));
927 }
928 else if (data[0] == DW_OP_fbreg)
4c2df51b 929 {
08922a10
SS
930 struct block *b;
931 struct symbol *framefunc;
932 int frame_reg = 0;
933 LONGEST frame_offset;
934 gdb_byte *base_data;
935 size_t base_size;
936 LONGEST base_offset = 0;
937
938 b = block_for_pc (addr);
939
940 if (!b)
941 error (_("No block found for address for symbol \"%s\"."),
942 SYMBOL_PRINT_NAME (symbol));
943
944 framefunc = block_linkage_function (b);
945
946 if (!framefunc)
947 error (_("No function found for block for symbol \"%s\"."),
948 SYMBOL_PRINT_NAME (symbol));
949
950 dwarf_expr_frame_base_1 (framefunc, addr, &base_data, &base_size);
951
952 if (base_data[0] >= DW_OP_breg0 && base_data[0] <= DW_OP_breg31)
953 {
954 gdb_byte *buf_end;
955
956 frame_reg = base_data[0] - DW_OP_breg0;
957 buf_end = read_sleb128 (base_data + 1,
958 base_data + base_size, &base_offset);
959 if (buf_end != base_data + base_size)
960 error (_("Unexpected opcode after DW_OP_breg%u for symbol \"%s\"."),
961 frame_reg, SYMBOL_PRINT_NAME (symbol));
962 }
963 else if (base_data[0] >= DW_OP_reg0 && base_data[0] <= DW_OP_reg31)
964 {
965 /* The frame base is just the register, with no offset. */
966 frame_reg = base_data[0] - DW_OP_reg0;
967 base_offset = 0;
968 }
969 else
970 {
971 /* We don't know what to do with the frame base expression,
972 so we can't trace this variable; give up. */
973 error (_("Cannot describe location of symbol \"%s\"; "
974 "DWARF 2 encoding not handled, "
975 "first opcode in base data is 0x%x."),
976 SYMBOL_PRINT_NAME (symbol), base_data[0]);
977 }
978
979 regno = gdbarch_dwarf2_reg_to_regnum (gdbarch, frame_reg);
980
981 data = read_sleb128 (data + 1, data + size, &frame_offset);
982
983 fprintf_filtered (stream, _("a variable at frame base reg $%s offset %s+%s"),
984 gdbarch_register_name (gdbarch, regno),
985 plongest (base_offset), plongest (frame_offset));
986 }
987 else if (data[0] >= DW_OP_breg0 && data[0] <= DW_OP_breg31)
988 {
989 LONGEST offset;
990
991 regno = gdbarch_dwarf2_reg_to_regnum (gdbarch, data[0] - DW_OP_breg0);
992
993 data = read_sleb128 (data + 1, data + size, &offset);
994
4c2df51b 995 fprintf_filtered (stream,
08922a10
SS
996 _("a variable at offset %s from base reg $%s"),
997 plongest (offset),
5e2b427d 998 gdbarch_register_name (gdbarch, regno));
4c2df51b
DJ
999 }
1000
c3228f12
EZ
1001 /* The location expression for a TLS variable looks like this (on a
1002 64-bit LE machine):
1003
1004 DW_AT_location : 10 byte block: 3 4 0 0 0 0 0 0 0 e0
1005 (DW_OP_addr: 4; DW_OP_GNU_push_tls_address)
1006
1007 0x3 is the encoding for DW_OP_addr, which has an operand as long
1008 as the size of an address on the target machine (here is 8
1009 bytes). 0xe0 is the encoding for DW_OP_GNU_push_tls_address.
1010 The operand represents the offset at which the variable is within
1011 the thread local storage. */
1012
08922a10
SS
1013 else if (size > 1
1014 && data[size - 1] == DW_OP_GNU_push_tls_address
1015 && data[0] == DW_OP_addr)
1016 {
1017 CORE_ADDR offset = dwarf2_read_address (gdbarch,
1018 data + 1,
1019 data + size - 1,
1020 addr_size);
1021 fprintf_filtered (stream,
1022 _("a thread-local variable at offset %s "
1023 "in the thread-local storage for `%s'"),
1024 paddress (gdbarch, offset), objfile->name);
1025
1026 data += 1 + addr_size + 1;
1027 }
1028 else
1029 fprintf_filtered (stream,
1030 _("a variable with complex or multiple locations (DWARF2)"));
c3228f12 1031
08922a10 1032 return data;
4c2df51b
DJ
1033}
1034
08922a10
SS
1035/* Describe a single location, which may in turn consist of multiple
1036 pieces. */
a55cc764 1037
08922a10
SS
1038static void
1039locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr,
1040 struct ui_file *stream, gdb_byte *data, int size,
1041 struct objfile *objfile, unsigned int addr_size)
1042{
1043 gdb_byte *end = data + size;
1044 int piece_done = 0, first_piece = 1, bad = 0;
1045
1046 /* A multi-piece description consists of multiple sequences of bytes
1047 each followed by DW_OP_piece + length of piece. */
1048 while (data < end)
1049 {
1050 if (!piece_done)
1051 {
1052 if (first_piece)
1053 first_piece = 0;
1054 else
1055 fprintf_filtered (stream, _(", and "));
1056
1057 data = locexpr_describe_location_piece (symbol, stream, addr, objfile,
1058 data, size, addr_size);
1059 piece_done = 1;
1060 }
1061 else if (data[0] == DW_OP_piece)
1062 {
1063 ULONGEST bytes;
1064
1065 data = read_uleb128 (data + 1, end, &bytes);
1066
1067 fprintf_filtered (stream, _(" [%s-byte piece]"), pulongest (bytes));
1068
1069 piece_done = 0;
1070 }
1071 else
1072 {
1073 bad = 1;
1074 break;
1075 }
1076 }
1077
1078 if (bad || data > end)
1079 error (_("Corrupted DWARF2 expression for \"%s\"."),
1080 SYMBOL_PRINT_NAME (symbol));
1081}
1082
1083/* Print a natural-language description of SYMBOL to STREAM. This
1084 version is for a symbol with a single location. */
a55cc764 1085
08922a10
SS
1086static void
1087locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr,
1088 struct ui_file *stream)
1089{
1090 struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1091 struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
1092 unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
1093
1094 locexpr_describe_location_1 (symbol, addr, stream, dlbaton->data, dlbaton->size,
1095 objfile, addr_size);
1096}
1097
1098/* Describe the location of SYMBOL as an agent value in VALUE, generating
1099 any necessary bytecode in AX. */
a55cc764 1100
0d53c4c4 1101static void
505e835d
UW
1102locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
1103 struct agent_expr *ax, struct axs_value *value)
a55cc764
DJ
1104{
1105 struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1106
505e835d
UW
1107 dwarf2_tracepoint_var_ref (symbol, gdbarch, ax, value,
1108 dlbaton->data, dlbaton->size);
a55cc764
DJ
1109}
1110
4c2df51b
DJ
1111/* The set of location functions used with the DWARF-2 expression
1112 evaluator. */
768a979c 1113const struct symbol_computed_ops dwarf2_locexpr_funcs = {
4c2df51b
DJ
1114 locexpr_read_variable,
1115 locexpr_read_needs_frame,
1116 locexpr_describe_location,
a55cc764 1117 locexpr_tracepoint_var_ref
4c2df51b 1118};
0d53c4c4
DJ
1119
1120
1121/* Wrapper functions for location lists. These generally find
1122 the appropriate location expression and call something above. */
1123
1124/* Return the value of SYMBOL in FRAME using the DWARF-2 expression
1125 evaluator to calculate the location. */
1126static struct value *
1127loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
1128{
1129 struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1130 struct value *val;
852483bc 1131 gdb_byte *data;
b6b08ebf 1132 size_t size;
0d53c4c4
DJ
1133
1134 data = find_location_expression (dlbaton, &size,
22c6caba
JW
1135 frame ? get_frame_address_in_block (frame)
1136 : 0);
0d53c4c4 1137 if (data == NULL)
806048c6
DJ
1138 {
1139 val = allocate_value (SYMBOL_TYPE (symbol));
1140 VALUE_LVAL (val) = not_lval;
1141 set_value_optimized_out (val, 1);
1142 }
1143 else
1144 val = dwarf2_evaluate_loc_desc (symbol, frame, data, size,
ae0d2f24 1145 dlbaton->per_cu);
0d53c4c4
DJ
1146
1147 return val;
1148}
1149
1150/* Return non-zero iff we need a frame to evaluate SYMBOL. */
1151static int
1152loclist_read_needs_frame (struct symbol *symbol)
1153{
1154 /* If there's a location list, then assume we need to have a frame
1155 to choose the appropriate location expression. With tracking of
1156 global variables this is not necessarily true, but such tracking
1157 is disabled in GCC at the moment until we figure out how to
1158 represent it. */
1159
1160 return 1;
1161}
1162
08922a10
SS
1163/* Print a natural-language description of SYMBOL to STREAM. This
1164 version applies when there is a list of different locations, each
1165 with a specified address range. */
1166
1167static void
1168loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
1169 struct ui_file *stream)
0d53c4c4 1170{
08922a10
SS
1171 struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1172 CORE_ADDR low, high;
1173 gdb_byte *loc_ptr, *buf_end;
1174 int length, first = 1;
1175 struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
1176 struct gdbarch *gdbarch = get_objfile_arch (objfile);
1177 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1178 unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
1179 CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
1180 /* Adjust base_address for relocatable objects. */
1181 CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
1182 SECT_OFF_TEXT (objfile));
1183 CORE_ADDR base_address = dlbaton->base_address + base_offset;
1184
1185 loc_ptr = dlbaton->data;
1186 buf_end = dlbaton->data + dlbaton->size;
1187
1188 fprintf_filtered (stream, _("multi-location ("));
1189
1190 /* Iterate through locations until we run out. */
1191 while (1)
1192 {
1193 if (buf_end - loc_ptr < 2 * addr_size)
1194 error (_("Corrupted DWARF expression for symbol \"%s\"."),
1195 SYMBOL_PRINT_NAME (symbol));
1196
1197 low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
1198 loc_ptr += addr_size;
1199
1200 /* A base-address-selection entry. */
1201 if (low == base_mask)
1202 {
1203 base_address = dwarf2_read_address (gdbarch,
1204 loc_ptr, buf_end, addr_size);
1205 fprintf_filtered (stream, _("[base address %s]"),
1206 paddress (gdbarch, base_address));
1207 loc_ptr += addr_size;
1208 continue;
1209 }
1210
1211 high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
1212 loc_ptr += addr_size;
1213
1214 /* An end-of-list entry. */
1215 if (low == 0 && high == 0)
1216 {
1217 /* Indicate the end of the list, for readability. */
1218 fprintf_filtered (stream, _(")"));
1219 return;
1220 }
1221
1222 /* Otherwise, a location expression entry. */
1223 low += base_address;
1224 high += base_address;
1225
1226 length = extract_unsigned_integer (loc_ptr, 2, byte_order);
1227 loc_ptr += 2;
1228
1229 /* Separate the different locations with a semicolon. */
1230 if (first)
1231 first = 0;
1232 else
1233 fprintf_filtered (stream, _("; "));
1234
1235 /* (It would improve readability to print only the minimum
1236 necessary digits of the second number of the range.) */
1237 fprintf_filtered (stream, _("range %s-%s, "),
1238 paddress (gdbarch, low), paddress (gdbarch, high));
1239
1240 /* Now describe this particular location. */
1241 locexpr_describe_location_1 (symbol, low, stream, loc_ptr, length,
1242 objfile, addr_size);
1243
1244 loc_ptr += length;
1245 }
0d53c4c4
DJ
1246}
1247
1248/* Describe the location of SYMBOL as an agent value in VALUE, generating
1249 any necessary bytecode in AX. */
1250static void
505e835d
UW
1251loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
1252 struct agent_expr *ax, struct axs_value *value)
0d53c4c4
DJ
1253{
1254 struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
852483bc 1255 gdb_byte *data;
b6b08ebf 1256 size_t size;
0d53c4c4
DJ
1257
1258 data = find_location_expression (dlbaton, &size, ax->scope);
0d53c4c4 1259
505e835d 1260 dwarf2_tracepoint_var_ref (symbol, gdbarch, ax, value, data, size);
0d53c4c4
DJ
1261}
1262
1263/* The set of location functions used with the DWARF-2 expression
1264 evaluator and location lists. */
768a979c 1265const struct symbol_computed_ops dwarf2_loclist_funcs = {
0d53c4c4
DJ
1266 loclist_read_variable,
1267 loclist_read_needs_frame,
1268 loclist_describe_location,
1269 loclist_tracepoint_var_ref
1270};
This page took 0.553784 seconds and 4 git commands to generate.