Changeset View
Changeset View
Standalone View
Standalone View
contrib/gdb/gdb/dwarf2loc.c
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | find_location_expression (struct dwarf2_loclist_baton *baton, | ||||
char *loc_ptr, *buf_end; | char *loc_ptr, *buf_end; | ||||
unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length; | unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length; | ||||
CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); | CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); | ||||
/* Adjust base_address for relocatable objects. */ | /* Adjust base_address for relocatable objects. */ | ||||
CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets, | CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets, | ||||
SECT_OFF_TEXT (baton->objfile)); | SECT_OFF_TEXT (baton->objfile)); | ||||
CORE_ADDR base_address = baton->base_address + base_offset; | CORE_ADDR base_address = baton->base_address + base_offset; | ||||
loc_ptr = baton->data; | loc_ptr = (char *)(baton->data); | ||||
buf_end = baton->data + baton->size; | buf_end = (char *)(baton->data + baton->size); | ||||
while (1) | while (1) | ||||
{ | { | ||||
low = dwarf2_read_address (loc_ptr, buf_end, &length); | low = dwarf2_read_address ((unsigned char *)loc_ptr, (unsigned char *)buf_end, (int *)&length); | ||||
loc_ptr += length; | loc_ptr += length; | ||||
high = dwarf2_read_address (loc_ptr, buf_end, &length); | high = dwarf2_read_address ((unsigned char *)loc_ptr, (unsigned char *)buf_end, (int *)&length); | ||||
loc_ptr += length; | loc_ptr += length; | ||||
/* An end-of-list entry. */ | /* An end-of-list entry. */ | ||||
if (low == 0 && high == 0) | if (low == 0 && high == 0) | ||||
return NULL; | return NULL; | ||||
/* A base-address-selection entry. */ | /* A base-address-selection entry. */ | ||||
if ((low & base_mask) == base_mask) | if ((low & base_mask) == base_mask) | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | dwarf_expr_frame_base (void *baton, unsigned char **start, size_t * length) | ||||
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton; | struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton; | ||||
framefunc = get_frame_function (debaton->frame); | framefunc = get_frame_function (debaton->frame); | ||||
if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs) | if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs) | ||||
{ | { | ||||
struct dwarf2_loclist_baton *symbaton; | struct dwarf2_loclist_baton *symbaton; | ||||
symbaton = SYMBOL_LOCATION_BATON (framefunc); | symbaton = SYMBOL_LOCATION_BATON (framefunc); | ||||
*start = find_location_expression (symbaton, length, | *start = (unsigned char *)(find_location_expression (symbaton, length, | ||||
get_frame_pc (debaton->frame)); | get_frame_pc (debaton->frame))); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
struct dwarf2_locexpr_baton *symbaton; | struct dwarf2_locexpr_baton *symbaton; | ||||
symbaton = SYMBOL_LOCATION_BATON (framefunc); | symbaton = SYMBOL_LOCATION_BATON (framefunc); | ||||
*length = symbaton->size; | *length = symbaton->size; | ||||
*start = symbaton->data; | *start = symbaton->data; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, | ||||
if (ctx->num_pieces > 0) | if (ctx->num_pieces > 0) | ||||
{ | { | ||||
int i; | int i; | ||||
long offset = 0; | long offset = 0; | ||||
bfd_byte *contents; | bfd_byte *contents; | ||||
retval = allocate_value (SYMBOL_TYPE (var)); | retval = allocate_value (SYMBOL_TYPE (var)); | ||||
contents = VALUE_CONTENTS_RAW (retval); | contents = (bfd_byte *)(VALUE_CONTENTS_RAW (retval)); | ||||
for (i = 0; i < ctx->num_pieces; i++) | for (i = 0; i < ctx->num_pieces; i++) | ||||
{ | { | ||||
struct dwarf_expr_piece *p = &ctx->pieces[i]; | struct dwarf_expr_piece *p = &ctx->pieces[i]; | ||||
if (p->in_reg) | if (p->in_reg) | ||||
{ | { | ||||
bfd_byte regval[MAX_REGISTER_SIZE]; | bfd_byte regval[MAX_REGISTER_SIZE]; | ||||
int gdb_regnum = DWARF2_REG_TO_REGNUM (p->value); | int gdb_regnum = DWARF2_REG_TO_REGNUM (p->value); | ||||
get_frame_register (frame, gdb_regnum, regval); | get_frame_register (frame, gdb_regnum, regval); | ||||
memcpy (contents + offset, regval, p->size); | memcpy (contents + offset, regval, p->size); | ||||
} | } | ||||
else /* In memory? */ | else /* In memory? */ | ||||
{ | { | ||||
read_memory (p->value, contents + offset, p->size); | read_memory (p->value, (char *)(contents + offset), p->size); | ||||
} | } | ||||
offset += p->size; | offset += p->size; | ||||
} | } | ||||
} | } | ||||
else if (ctx->in_reg) | else if (ctx->in_reg) | ||||
{ | { | ||||
int regnum = DWARF2_REG_TO_REGNUM (result); | int regnum = DWARF2_REG_TO_REGNUM (result); | ||||
retval = value_from_register (SYMBOL_TYPE (var), regnum, frame); | retval = value_from_register (SYMBOL_TYPE (var), regnum, frame); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
/* Frame-relative accesses do require a frame. */ | /* Frame-relative accesses do require a frame. */ | ||||
static void | static void | ||||
needs_frame_frame_base (void *baton, unsigned char **start, size_t * length) | needs_frame_frame_base (void *baton, unsigned char **start, size_t * length) | ||||
{ | { | ||||
static char lit0 = DW_OP_lit0; | static char lit0 = DW_OP_lit0; | ||||
struct needs_frame_baton *nf_baton = baton; | struct needs_frame_baton *nf_baton = baton; | ||||
*start = &lit0; | *start = (unsigned char *)&lit0; | ||||
*length = 1; | *length = 1; | ||||
nf_baton->needs_frame = 1; | nf_baton->needs_frame = 1; | ||||
} | } | ||||
/* Thread-local accesses do require a frame. */ | /* Thread-local accesses do require a frame. */ | ||||
static CORE_ADDR | static CORE_ADDR | ||||
needs_frame_tls_address (void *baton, CORE_ADDR offset) | needs_frame_tls_address (void *baton, CORE_ADDR offset) | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | |||||
static struct value * | static struct value * | ||||
loclist_read_variable (struct symbol *symbol, struct frame_info *frame) | loclist_read_variable (struct symbol *symbol, struct frame_info *frame) | ||||
{ | { | ||||
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); | struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); | ||||
struct value *val; | struct value *val; | ||||
unsigned char *data; | unsigned char *data; | ||||
size_t size; | size_t size; | ||||
data = find_location_expression (dlbaton, &size, | data = (unsigned char *)(find_location_expression (dlbaton, &size, | ||||
frame ? get_frame_pc (frame) : 0); | frame ? get_frame_pc (frame) : 0)); | ||||
if (data == NULL) | if (data == NULL) | ||||
{ | { | ||||
val = allocate_value (SYMBOL_TYPE (symbol)); | val = allocate_value (SYMBOL_TYPE (symbol)); | ||||
VALUE_LVAL (val) = not_lval; | VALUE_LVAL (val) = not_lval; | ||||
VALUE_OPTIMIZED_OUT (val) = 1; | VALUE_OPTIMIZED_OUT (val) = 1; | ||||
} | } | ||||
else | else | ||||
val = dwarf2_evaluate_loc_desc (symbol, frame, data, size, | val = dwarf2_evaluate_loc_desc (symbol, frame, data, size, | ||||
Show All 29 Lines | |||||
static void | static void | ||||
loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax, | loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax, | ||||
struct axs_value * value) | struct axs_value * value) | ||||
{ | { | ||||
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); | struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); | ||||
unsigned char *data; | unsigned char *data; | ||||
size_t size; | size_t size; | ||||
data = find_location_expression (dlbaton, &size, ax->scope); | data = (unsigned char *)(find_location_expression (dlbaton, &size, ax->scope)); | ||||
if (data == NULL) | if (data == NULL) | ||||
error ("Variable \"%s\" is not available.", SYMBOL_NATURAL_NAME (symbol)); | error ("Variable \"%s\" is not available.", SYMBOL_NATURAL_NAME (symbol)); | ||||
dwarf2_tracepoint_var_ref (symbol, ax, value, data, size); | dwarf2_tracepoint_var_ref (symbol, ax, value, data, size); | ||||
} | } | ||||
/* The set of location functions used with the DWARF-2 expression | /* The set of location functions used with the DWARF-2 expression | ||||
evaluator and location lists. */ | evaluator and location lists. */ | ||||
const struct symbol_ops dwarf2_loclist_funcs = { | const struct symbol_ops dwarf2_loclist_funcs = { | ||||
loclist_read_variable, | loclist_read_variable, | ||||
loclist_read_needs_frame, | loclist_read_needs_frame, | ||||
loclist_describe_location, | loclist_describe_location, | ||||
loclist_tracepoint_var_ref | loclist_tracepoint_var_ref | ||||
}; | }; |