static void
dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
- gdb_byte **start, size_t *length);
+ const gdb_byte **start, size_t *length);
/* A helper function for dealing with location lists. Given a
symbol baton (BATON) and a pc value (PC), find the appropriate
For now, only return the first matching location expression; there
can be more than one in the list. */
-static gdb_byte *
+static const gdb_byte *
find_location_expression (struct dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
CORE_ADDR low, high;
- gdb_byte *loc_ptr, *buf_end;
+ const gdb_byte *loc_ptr, *buf_end;
int length;
struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
describing the frame base. Return a pointer to it in START and
its length in LENGTH. */
static void
-dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length)
+dwarf_expr_frame_base (void *baton, const gdb_byte **start, size_t * length)
{
/* FIXME: cagney/2003-03-26: This code should be using
get_frame_base_address(), and then implement a dwarf2 specific
static void
dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
- gdb_byte **start, size_t *length)
+ const gdb_byte **start, size_t *length)
{
if (SYMBOL_LOCATION_BATON (framefunc) == NULL)
*start = NULL;
struct piece_closure
{
+ /* Reference count. */
+ int refc;
+
/* The number of pieces used to describe this variable. */
int n_pieces;
{
struct piece_closure *c = XZALLOC (struct piece_closure);
+ c->refc = 1;
c->n_pieces = n_pieces;
c->addr_size = addr_size;
c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece);
struct dwarf_expr_piece *p = &c->pieces[i];
size_t this_size, this_size_bits;
long dest_offset_bits, source_offset_bits, source_offset;
- gdb_byte *intermediate_buffer;
+ const gdb_byte *intermediate_buffer;
/* Compute size, source, and destination offsets for copying, in
bits. */
{
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
- return allocate_piece_closure (c->n_pieces, c->pieces, c->addr_size);
+ ++c->refc;
+ return c;
}
static void
{
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
- xfree (c->pieces);
- xfree (c);
+ --c->refc;
+ if (c->refc == 0)
+ {
+ xfree (c->pieces);
+ xfree (c);
+ }
}
/* Functions for accessing a variable described by DW_OP_piece. */
static struct value *
dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
- gdb_byte *data, unsigned short size,
+ const gdb_byte *data, unsigned short size,
struct dwarf2_per_cu_data *per_cu)
{
struct value *retval;
/* Frame-relative accesses do require a frame. */
static void
-needs_frame_frame_base (void *baton, gdb_byte **start, size_t * length)
+needs_frame_frame_base (void *baton, const gdb_byte **start, size_t * length)
{
static gdb_byte lit0 = DW_OP_lit0;
struct needs_frame_baton *nf_baton = baton;
requires a frame to evaluate. */
static int
-dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size,
+dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size,
struct dwarf2_per_cu_data *per_cu)
{
struct needs_frame_baton baton;
LONGEST offset;
};
-static gdb_byte *
+static const gdb_byte *
dwarf2_tracepoint_var_loc (struct symbol *symbol,
struct agent_expr *ax,
struct axs_var_loc *loc,
struct gdbarch *gdbarch,
- gdb_byte *data, gdb_byte *end)
+ const gdb_byte *data, const gdb_byte *end)
{
if (data[0] >= DW_OP_reg0 && data[0] <= DW_OP_reg31)
{
struct symbol *framefunc;
int frame_reg = 0;
LONGEST frame_offset;
- gdb_byte *base_data;
+ const gdb_byte *base_data;
size_t base_size;
LONGEST base_offset = 0;
if (base_data[0] >= DW_OP_breg0 && base_data[0] <= DW_OP_breg31)
{
- gdb_byte *buf_end;
-
+ const gdb_byte *buf_end;
+
frame_reg = base_data[0] - DW_OP_breg0;
buf_end = read_sleb128 (base_data + 1,
base_data + base_size, &base_offset);
static void
dwarf2_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
struct agent_expr *ax, struct axs_value *value,
- gdb_byte *data, int size)
+ const gdb_byte *data, int size)
{
- gdb_byte *end = data + size;
+ const gdb_byte *end = data + size;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* In practice, a variable is not going to be spread across
dozens of registers or memory locations. If someone comes up
/* Describe a single piece of a location, returning an updated
position in the bytecode sequence. */
-static gdb_byte *
+static const gdb_byte *
locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream,
CORE_ADDR addr, struct objfile *objfile,
- gdb_byte *data, int size, unsigned int addr_size)
+ const gdb_byte *data, int size,
+ unsigned int addr_size)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
int regno;
struct symbol *framefunc;
int frame_reg = 0;
LONGEST frame_offset;
- gdb_byte *base_data;
+ const gdb_byte *base_data;
size_t base_size;
LONGEST base_offset = 0;
if (base_data[0] >= DW_OP_breg0 && base_data[0] <= DW_OP_breg31)
{
- gdb_byte *buf_end;
+ const gdb_byte *buf_end;
frame_reg = base_data[0] - DW_OP_breg0;
buf_end = read_sleb128 (base_data + 1,
static void
locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr,
- struct ui_file *stream, gdb_byte *data, int size,
+ struct ui_file *stream,
+ const gdb_byte *data, int size,
struct objfile *objfile, unsigned int addr_size)
{
- gdb_byte *end = data + size;
+ const gdb_byte *end = data + size;
int piece_done = 0, first_piece = 1, bad = 0;
/* A multi-piece description consists of multiple sequences of bytes
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
struct value *val;
- gdb_byte *data;
+ const gdb_byte *data;
size_t size;
data = find_location_expression (dlbaton, &size,
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
CORE_ADDR low, high;
- gdb_byte *loc_ptr, *buf_end;
+ const gdb_byte *loc_ptr, *buf_end;
int length, first = 1;
struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct agent_expr *ax, struct axs_value *value)
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
- gdb_byte *data;
+ const gdb_byte *data;
size_t size;
data = find_location_expression (dlbaton, &size, ax->scope);