+2005-07-12 Mark Kettenis <kettenis@openbsd.localdomain>
+
+ * dwarf2expr.h: Tweak comment.
+ (struct dwarf_expr_context): Use `gdb_byte *' in read_mem and
+ get_frame_base function pointers.
+ (read_uleb128, read_sleb128): Change return type and types of
+ first two arguments to `gdb_byte *'.
+ (dwarf2_read_address): Change types of first two arguments to
+ `gdb_byte *'.
+ * dwarf2expr.c: Tweak comment.
+ (dwarf_expr_eval): Change type of second argument to `gdb_byte *'.
+ (read_uleb128, read_sleb128): Change return type and types of
+ first two arguments to `gdb_byte *'.
+ (dwarf2_read_address): Change types of first two arguments to
+ `gdb_byte *'.
+ (execute_stack_op): Change types of last two arguments to
+ `gdb_byte *'. Use `gdb_byte *' for byte buffers.
+ * dwarf2loc.h: Tweak comment.
+ (struct dwarf2_locexpr_baton, struct dwarf2_loclist_baton): Use
+ `gdb_byte *' for byte buffers.
+ * dwarf2loc.c (find_location_expression): Change return type to
+ `gdb_byte *'. Use `gdb_byte *' for byte buffers. Change length
+ to `unsigned int'.
+ (dwarf_expr_read_reg): Use `gdb_byte *' for byte buffer. Remove
+ bogus cast.
+ (dwarf_expr_read_mem): Change type of second argument to
+ `gdb_byte *'.
+ (dwarf_expr_frame_base): Change type of second argument to
+ `gdb_byte **'.
+ (dwarf2_evaluate_loc_desc): Change type of third argument to
+ `gdb_byte *'.
+ (needs_frame_read_mem): Change type of second argument to
+ `gdb_byte *'.
+ (needs_frame_frame_base): Change type of second argument
+ `gdb_byte **'. Use gdb_byte for lit0.
+ (dwarf2_tracepoint_var_ref): Change type of fourth argument to
+ `gdb_byte *'. Use `gdb_byte *' for byte buffer.
+ (loclist_read_variable, loclist_tracepoint_var_ref): Use `gdb_byte
+ *' for byte buffer.
+ * dwarf2-frame.c (struct dwarf2_cie, struct dwarf2_fde)
+ (struct dwarf2_frame_state): Use gdb_byte instead of `unsigned
+ char'.
+ (read_reg): Use `gdb_byte *' for byte buffers. Remove redundant
+ cast.
+ (read_mem): Change second argument to `gdb_byte *'.
+ (no_get_frame_base): Change second argument to `gdb_byte **'.
+ (execute_stack_op): Change first argument to `gdb_byte *'.
+ (execute_cfa_program): Change first two arguments to `gdb_byte *'.
+ Use gdb_byte instead of `unsigned int'. Use temprorary variable
+ to store result of read_uleb128.
+ (struct comp_unit): Use `gdb_byte *' for byte buffers.
+ (read_1_byte, read_4_bytes, read_8_bytes): Change last argument to
+ `gdb_byte *'.
+ (read_unsigned_leb128, read_signed_leb128): Change second argument
+ to `gdb_byte *'. Use gdb_byte instead of `unsigned char'.
+ (read_initial_length): Change second argument to `gdb_byte *'.
+ Remove redundant casts.
+ (read_encoded_value): Use gdb_byte instead of `unsigned char'.
+ Remove bogus casts.
+ (decode_frame_entry_1): Change return type and second argument to
+ `gdb_byte *'. Use `gdb_byte *' for byte buffers. Use gdb_byte
+ instead of `unsigned char'.
+ (decode_frame_entry): Change return type and second argument to
+ `gdb_byte *'. Use `gdb_byte *' for byte buffers.
+ (dwarf2_build_frame_info): Use `gdb_byte *' for byte buffers.
+
2005-07-12 Mark Kettenis <kettenis@gnu.org>
* objc-lang.c (print_object_command): Use gdb_byte for c.
ULONGEST return_address_register;
/* Instruction sequence to initialize a register set. */
- unsigned char *initial_instructions;
- unsigned char *end;
+ gdb_byte *initial_instructions;
+ gdb_byte *end;
/* Encoding of addresses. */
- unsigned char encoding;
+ gdb_byte encoding;
/* True if a 'z' augmentation existed. */
unsigned char saw_z_augmentation;
CORE_ADDR address_range;
/* Instruction sequence. */
- unsigned char *instructions;
- unsigned char *end;
+ gdb_byte *instructions;
+ gdb_byte *end;
struct dwarf2_fde *next;
};
LONGEST cfa_offset;
ULONGEST cfa_reg;
- unsigned char *cfa_exp;
+ gdb_byte *cfa_exp;
enum {
CFA_UNSET,
CFA_REG_OFFSET,
struct frame_info *next_frame = (struct frame_info *) baton;
struct gdbarch *gdbarch = get_frame_arch (next_frame);
int regnum;
- char *buf;
+ gdb_byte *buf;
regnum = DWARF2_REG_TO_REGNUM (reg);
- buf = (char *) alloca (register_size (gdbarch, regnum));
+ buf = alloca (register_size (gdbarch, regnum));
frame_unwind_register (next_frame, regnum, buf);
return extract_typed_address (buf, builtin_type_void_data_ptr);
}
static void
-read_mem (void *baton, char *buf, CORE_ADDR addr, size_t len)
+read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
{
read_memory (addr, buf, len);
}
static void
-no_get_frame_base (void *baton, unsigned char **start, size_t *length)
+no_get_frame_base (void *baton, gdb_byte **start, size_t *length)
{
internal_error (__FILE__, __LINE__,
_("Support for DW_OP_fbreg is unimplemented"));
}
static CORE_ADDR
-execute_stack_op (unsigned char *exp, ULONGEST len,
+execute_stack_op (gdb_byte *exp, ULONGEST len,
struct frame_info *next_frame, CORE_ADDR initial)
{
struct dwarf_expr_context *ctx;
\f
static void
-execute_cfa_program (unsigned char *insn_ptr, unsigned char *insn_end,
+execute_cfa_program (gdb_byte *insn_ptr, gdb_byte *insn_end,
struct frame_info *next_frame,
struct dwarf2_frame_state *fs)
{
while (insn_ptr < insn_end && fs->pc <= pc)
{
- unsigned char insn = *insn_ptr++;
+ gdb_byte insn = *insn_ptr++;
ULONGEST utmp, reg;
LONGEST offset;
break;
case DW_CFA_def_cfa_offset:
- insn_ptr = read_uleb128 (insn_ptr, insn_end, &fs->cfa_offset);
+ insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
+ fs->cfa_offset = utmp;
/* cfa_how deliberately not set. */
break;
struct dwarf2_cie *cie;
/* Pointer to the .debug_frame section loaded into memory. */
- char *dwarf_frame_buffer;
+ gdb_byte *dwarf_frame_buffer;
/* Length of the loaded .debug_frame section. */
unsigned long dwarf_frame_size;
const struct objfile_data *dwarf2_frame_objfile_data;
static unsigned int
-read_1_byte (bfd *bfd, char *buf)
+read_1_byte (bfd *abfd, gdb_byte *buf)
{
- return bfd_get_8 (abfd, (bfd_byte *) buf);
+ return bfd_get_8 (abfd, buf);
}
static unsigned int
-read_4_bytes (bfd *abfd, char *buf)
+read_4_bytes (bfd *abfd, gdb_byte *buf)
{
- return bfd_get_32 (abfd, (bfd_byte *) buf);
+ return bfd_get_32 (abfd, buf);
}
static ULONGEST
-read_8_bytes (bfd *abfd, char *buf)
+read_8_bytes (bfd *abfd, gdb_byte *buf)
{
- return bfd_get_64 (abfd, (bfd_byte *) buf);
+ return bfd_get_64 (abfd, buf);
}
static ULONGEST
-read_unsigned_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
{
ULONGEST result;
unsigned int num_read;
int shift;
- unsigned char byte;
+ gdb_byte byte;
result = 0;
shift = 0;
}
static LONGEST
-read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
{
LONGEST result;
int shift;
unsigned int num_read;
- unsigned char byte;
+ gdb_byte byte;
result = 0;
shift = 0;
}
static ULONGEST
-read_initial_length (bfd *abfd, char *buf, unsigned int *bytes_read_ptr)
+read_initial_length (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
{
LONGEST result;
- result = bfd_get_32 (abfd, (bfd_byte *) buf);
+ result = bfd_get_32 (abfd, buf);
if (result == 0xffffffff)
{
- result = bfd_get_64 (abfd, (bfd_byte *) buf + 4);
+ result = bfd_get_64 (abfd, buf + 4);
*bytes_read_ptr = 12;
}
else
position in the FDE, ...). Bit 7, indicates that the address
should be dereferenced. */
-static unsigned char
+static gdb_byte
encoding_for_size (unsigned int size)
{
switch (size)
}
static unsigned int
-size_of_encoded_value (unsigned char encoding)
+size_of_encoded_value (gdb_byte encoding)
{
if (encoding == DW_EH_PE_omit)
return 0;
}
static CORE_ADDR
-read_encoded_value (struct comp_unit *unit, unsigned char encoding,
- unsigned char *buf, unsigned int *bytes_read_ptr)
+read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
+ gdb_byte *buf, unsigned int *bytes_read_ptr)
{
int ptr_len = size_of_encoded_value (DW_EH_PE_absptr);
ptrdiff_t offset;
break;
case DW_EH_PE_pcrel:
base = bfd_get_section_vma (unit->bfd, unit->dwarf_frame_section);
- base += ((char *) buf - unit->dwarf_frame_buffer);
+ base += (buf - unit->dwarf_frame_buffer);
break;
case DW_EH_PE_datarel:
base = unit->dbase;
break;
case DW_EH_PE_aligned:
base = 0;
- offset = (char *) buf - unit->dwarf_frame_buffer;
+ offset = buf - unit->dwarf_frame_buffer;
if ((offset % ptr_len) != 0)
{
*bytes_read_ptr = ptr_len - (offset % ptr_len);
case DW_EH_PE_uleb128:
{
ULONGEST value;
- unsigned char *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
+ gdb_byte *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
*bytes_read_ptr += read_uleb128 (buf, end_buf, &value) - buf;
return base + value;
}
case DW_EH_PE_sleb128:
{
LONGEST value;
- char *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
+ gdb_byte *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
*bytes_read_ptr += read_sleb128 (buf, end_buf, &value) - buf;
return base + value;
}
#define DW64_CIE_ID ~0
#endif
-static char *decode_frame_entry (struct comp_unit *unit, char *start,
- int eh_frame_p);
+static gdb_byte *decode_frame_entry (struct comp_unit *unit, gdb_byte *start,
+ int eh_frame_p);
/* Decode the next CIE or FDE. Return NULL if invalid input, otherwise
the next byte to be processed. */
-static char *
-decode_frame_entry_1 (struct comp_unit *unit, char *start, int eh_frame_p)
+static gdb_byte *
+decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_frame_p)
{
- char *buf;
+ gdb_byte *buf, *end;
LONGEST length;
unsigned int bytes_read;
int dwarf64_p;
ULONGEST cie_id;
ULONGEST cie_pointer;
- char *end;
buf = start;
length = read_initial_length (unit->abfd, buf, &bytes_read);
buf += 1;
/* Interpret the interesting bits of the augmentation. */
- augmentation = buf;
- buf = augmentation + strlen (augmentation) + 1;
+ augmentation = (char *) buf;
+ buf += (strlen (augmentation) + 1);
/* The GCC 2.x "eh" augmentation has a pointer immediately
following the augmentation string, so it must be handled
else if (*augmentation == 'P')
{
/* Skip. Avoid indirection since we throw away the result. */
- unsigned char encoding = (*buf++) & ~DW_EH_PE_indirect;
+ gdb_byte encoding = (*buf++) & ~DW_EH_PE_indirect;
read_encoded_value (unit, encoding, buf, &bytes_read);
buf += bytes_read;
augmentation++;
}
/* Read a CIE or FDE in BUF and decode it. */
-static char *
-decode_frame_entry (struct comp_unit *unit, char *start, int eh_frame_p)
+static gdb_byte *
+decode_frame_entry (struct comp_unit *unit, gdb_byte *start, int eh_frame_p)
{
enum { NONE, ALIGN4, ALIGN8, FAIL } workaround = NONE;
- char *ret;
+ gdb_byte *ret;
const char *msg;
ptrdiff_t start_offset;
dwarf2_build_frame_info (struct objfile *objfile)
{
struct comp_unit unit;
- char *frame_ptr;
+ gdb_byte *frame_ptr;
/* Build a minimal decoding of the DWARF2 compilation unit. */
unit.abfd = objfile->obfd;
-/* Dwarf2 Expression Evaluator
- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+/* DWARF 2 Expression Evaluator.
+
+ Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+
Contributed by Daniel Berlin (dan@dberlin.org)
This file is part of GDB.
/* Local prototypes. */
static void execute_stack_op (struct dwarf_expr_context *,
- unsigned char *, unsigned char *);
+ gdb_byte *, gdb_byte *);
/* Create a new context for the expression evaluator. */
CTX. */
void
-dwarf_expr_eval (struct dwarf_expr_context *ctx, unsigned char *addr,
- size_t len)
+dwarf_expr_eval (struct dwarf_expr_context *ctx, gdb_byte *addr, size_t len)
{
execute_stack_op (ctx, addr, addr + len);
}
by R, and return the new value of BUF. Verify that it doesn't extend
past BUF_END. */
-unsigned char *
-read_uleb128 (unsigned char *buf, unsigned char *buf_end, ULONGEST * r)
+gdb_byte *
+read_uleb128 (gdb_byte *buf, gdb_byte *buf_end, ULONGEST * r)
{
unsigned shift = 0;
ULONGEST result = 0;
- unsigned char byte;
+ gdb_byte byte;
while (1)
{
by R, and return the new value of BUF. Verify that it doesn't extend
past BUF_END. */
-unsigned char *
-read_sleb128 (unsigned char *buf, unsigned char *buf_end, LONGEST * r)
+gdb_byte *
+read_sleb128 (gdb_byte *buf, gdb_byte *buf_end, LONGEST * r)
{
unsigned shift = 0;
LONGEST result = 0;
- unsigned char byte;
+ gdb_byte byte;
while (1)
{
number of bytes read from BUF. */
CORE_ADDR
-dwarf2_read_address (unsigned char *buf, unsigned char *buf_end, int *bytes_read)
+dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end, int *bytes_read)
{
CORE_ADDR result;
evaluate the expression between OP_PTR and OP_END. */
static void
-execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
- unsigned char *op_end)
+execute_stack_op (struct dwarf_expr_context *ctx,
+ gdb_byte *op_ptr, gdb_byte *op_end)
{
ctx->in_reg = 0;
break;
case DW_OP_fbreg:
{
- unsigned char *datastart;
+ gdb_byte *datastart;
size_t datalen;
unsigned int before_stack_len;
{
case DW_OP_deref:
{
- char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
+ gdb_byte *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
int bytes_read;
(ctx->read_mem) (ctx->baton, buf, result,
case DW_OP_deref_size:
{
- char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
+ gdb_byte *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
int bytes_read;
(ctx->read_mem) (ctx->baton, buf, result, *op_ptr++);
-/* Dwarf2 Expression Evaluator
- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
- Contributed by Daniel Berlin (dan@dberlin.org)
+/* DWARF 2 Expression Evaluator.
+
+ Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+
+ Contributed by Daniel Berlin <dan@dberlin.org>.
+
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
CORE_ADDR (*read_reg) (void *baton, int regnum);
/* Read LENGTH bytes at ADDR into BUF. */
- void (*read_mem) (void *baton, char *buf, CORE_ADDR addr,
- size_t length);
+ void (*read_mem) (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t length);
/* Return the location expression for the frame base attribute, in
START and LENGTH. The result must be live until the current
expression evaluation is complete. */
- void (*get_frame_base) (void *baton, unsigned char **start,
- size_t *length);
+ void (*get_frame_base) (void *baton, gdb_byte **start, size_t *length);
/* Return the thread-local storage address for
DW_OP_GNU_push_tls_address. */
CORE_ADDR dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n);
-unsigned char *read_uleb128 (unsigned char *buf, unsigned char *buf_end,
- ULONGEST * r);
-unsigned char *read_sleb128 (unsigned char *buf, unsigned char *buf_end,
- LONGEST * r);
-CORE_ADDR dwarf2_read_address (unsigned char *buf, unsigned char *buf_end,
+gdb_byte *read_uleb128 (gdb_byte *buf, gdb_byte *buf_end, ULONGEST * r);
+gdb_byte *read_sleb128 (gdb_byte *buf, gdb_byte *buf_end, LONGEST * r);
+CORE_ADDR dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end,
int *bytes_read);
-#endif
+#endif /* dwarf2expr.h */
For now, only return the first matching location expression; there
can be more than one in the list. */
-static char *
+static gdb_byte *
find_location_expression (struct dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
CORE_ADDR low, high;
- char *loc_ptr, *buf_end;
- unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length;
+ gdb_byte *loc_ptr, *buf_end;
+ int length;
+ unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT;
CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
/* Adjust base_address for relocatable objects. */
CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets,
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
CORE_ADDR result, save_addr;
enum lval_type lval_type;
- char *buf;
+ gdb_byte *buf;
int optimized, regnum, realnum, regsize;
regnum = DWARF2_REG_TO_REGNUM (dwarf_regnum);
regsize = register_size (current_gdbarch, regnum);
- buf = (char *) alloca (regsize);
+ buf = alloca (regsize);
frame_register (debaton->frame, regnum, &optimized, &lval_type, &save_addr,
&realnum, buf);
/* Read memory at ADDR (length LEN) into BUF. */
static void
-dwarf_expr_read_mem (void *baton, char *buf, CORE_ADDR addr, size_t len)
+dwarf_expr_read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
{
read_memory (addr, buf, len);
}
describing the frame base. Return a pointer to it in START and
its length in LENGTH. */
static void
-dwarf_expr_frame_base (void *baton, unsigned char **start, size_t * length)
+dwarf_expr_frame_base (void *baton, 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
of FRAME. */
static struct value *
dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
- unsigned char *data, unsigned short size,
+ gdb_byte *data, unsigned short size,
struct objfile *objfile)
{
struct gdbarch *arch = get_frame_arch (frame);
/* Reads from memory do not require a frame. */
static void
-needs_frame_read_mem (void *baton, char *buf, CORE_ADDR addr, size_t len)
+needs_frame_read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
{
memset (buf, 0, len);
}
/* Frame-relative accesses do require a frame. */
static void
-needs_frame_frame_base (void *baton, unsigned char **start, size_t * length)
+needs_frame_frame_base (void *baton, gdb_byte **start, size_t * length)
{
- static char lit0 = DW_OP_lit0;
+ static gdb_byte lit0 = DW_OP_lit0;
struct needs_frame_baton *nf_baton = baton;
*start = &lit0;
requires a frame to evaluate. */
static int
-dwarf2_loc_desc_needs_frame (unsigned char *data, unsigned short size)
+dwarf2_loc_desc_needs_frame (gdb_byte *data, unsigned short size)
{
struct needs_frame_baton baton;
struct dwarf_expr_context *ctx;
}
static void
-dwarf2_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
- struct axs_value * value, unsigned char *data,
+dwarf2_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
+ struct axs_value *value, gdb_byte *data,
int size)
{
if (size == 0)
as above. */
int frame_reg;
LONGEST frame_offset;
- unsigned char *buf_end;
+ gdb_byte *buf_end;
buf_end = read_sleb128 (data + 1, data + size, &frame_offset);
if (buf_end != data + size)
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
struct value *val;
- unsigned char *data;
+ gdb_byte *data;
size_t size;
data = find_location_expression (dlbaton, &size,
struct axs_value * value)
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
- unsigned char *data;
+ gdb_byte *data;
size_t size;
data = find_location_expression (dlbaton, &size, ax->scope);
-/* Dwarf2 location expression support for GDB.
- Copyright 2003 Free Software Foundation, Inc.
+/* DWARF 2 location expression support for GDB.
+
+ Copyright 2003, 2005 Free Software Foundation, Inc.
This file is part of GDB.
struct dwarf2_locexpr_baton
{
/* Pointer to the start of the location expression. */
- unsigned char *data;
+ gdb_byte *data;
/* Length of the location expression. */
unsigned short size;
CORE_ADDR base_address;
/* Pointer to the start of the location list. */
- unsigned char *data;
+ gdb_byte *data;
/* Length of the location list. */
unsigned short size;
extern const struct symbol_ops dwarf2_locexpr_funcs;
extern const struct symbol_ops dwarf2_loclist_funcs;
-#endif
+#endif /* dwarf2loc.h */