[commit] Yet another get_frame_arch (NULL) call
Ulrich Weigand
uweigand@de.ibm.com
Tue Jan 13 18:04:00 GMT 2009
Hello,
we found another case where get_frame_arch (NULL) was called:
dwarf2_evaluate_loc_desc may be called either for frame-local
variables (in which case it receives a pointer to a frame_info
struct), or for global variables (in which case that pointer
is NULL).
However, the routine currently always calls get_frame_arch on
the pointer it receives -- this is broken in the second case.
The fix is to move the get_frame_arch call down into those
places where the architecture is actually needed, that is for
variables located in registers. (In those cases, we must have
a non-NULL frame, because the dwarf2_loc_desc_needs_frame will
have returned true.)
Tested with no regressions on powerpc-linux.
Committed to mainline.
Bye,
Ulrich
ChangeLog:
* dwarf2loc.c (dwarf2_evaluate_loc_desc): Do not call get_frame_arch
for NULL frame pointers.
Index: gdb/dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.53
diff -c -p -r1.53 dwarf2loc.c
*** gdb/dwarf2loc.c 3 Jan 2009 05:57:51 -0000 1.53
--- gdb/dwarf2loc.c 13 Jan 2009 17:51:38 -0000
*************** dwarf2_evaluate_loc_desc (struct symbol
*** 199,205 ****
gdb_byte *data, unsigned short size,
struct dwarf2_per_cu_data *per_cu)
{
- struct gdbarch *arch = get_frame_arch (frame);
struct value *retval;
struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
--- 199,204 ----
*************** dwarf2_evaluate_loc_desc (struct symbol
*** 238,246 ****
struct dwarf_expr_piece *p = &ctx->pieces[i];
if (p->in_reg)
{
bfd_byte regval[MAX_REGISTER_SIZE];
! int gdb_regnum = gdbarch_dwarf2_reg_to_regnum
! (arch, p->value);
get_frame_register (frame, gdb_regnum, regval);
memcpy (contents + offset, regval, p->size);
}
--- 237,245 ----
struct dwarf_expr_piece *p = &ctx->pieces[i];
if (p->in_reg)
{
+ struct gdbarch *arch = get_frame_arch (frame);
bfd_byte regval[MAX_REGISTER_SIZE];
! int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->value);
get_frame_register (frame, gdb_regnum, regval);
memcpy (contents + offset, regval, p->size);
}
*************** dwarf2_evaluate_loc_desc (struct symbol
*** 253,261 ****
}
else if (ctx->in_reg)
{
CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
! int gdb_regnum = gdbarch_dwarf2_reg_to_regnum
! (arch, dwarf_regnum);
retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame);
}
else
--- 252,260 ----
}
else if (ctx->in_reg)
{
+ struct gdbarch *arch = get_frame_arch (frame);
CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
! int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum);
retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame);
}
else
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
More information about the Gdb-patches
mailing list