From 7195e6f018c7928c8b7be37e56b4df2656402618 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 4 Jul 2013 18:10:04 +0000 Subject: [PATCH] Use allocate_optimized_out_value instead of set_value_optimized_out. Allocate the value as optimized out from the start rather than allocating a value with contents, and then marking it optimized out. gdb/ 2013-07-04 Pedro Alves * findvar.c (value_of_register): Use allocate_optimized_out_value if the register has been optimized out, instead of set_value_optimized_out. * frame-unwind.c (frame_unwind_got_optimized): Use allocate_optimized_out_value. --- gdb/ChangeLog | 8 ++++++++ gdb/findvar.c | 8 ++++++-- gdb/frame-unwind.c | 6 ++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2353e71e9eb..eb0eb4bd306 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2013-07-04 Pedro Alves + + * findvar.c (value_of_register): Use allocate_optimized_out_value + if the register has been optimized out, instead of + set_value_optimized_out. + * frame-unwind.c (frame_unwind_got_optimized): Use + allocate_optimized_out_value. + 2013-07-04 Pedro Alves * value.c (value_bits_valid): If the value is not lval_computed, diff --git a/gdb/findvar.c b/gdb/findvar.c index fdce436baac..f586ce24efe 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -266,6 +266,7 @@ value_of_register (int regnum, struct frame_info *frame) int optim; int unavail; struct value *reg_val; + struct type *reg_type; int realnum; gdb_byte raw_buffer[MAX_REGISTER_SIZE]; enum lval_type lval; @@ -279,7 +280,11 @@ value_of_register (int regnum, struct frame_info *frame) frame_register (frame, regnum, &optim, &unavail, &lval, &addr, &realnum, raw_buffer); - reg_val = allocate_value (register_type (gdbarch, regnum)); + reg_type = register_type (gdbarch, regnum); + if (optim) + reg_val = allocate_optimized_out_value (reg_type); + else + reg_val = allocate_value (reg_type); if (!optim && !unavail) memcpy (value_contents_raw (reg_val), raw_buffer, @@ -291,7 +296,6 @@ value_of_register (int regnum, struct frame_info *frame) VALUE_LVAL (reg_val) = lval; set_value_address (reg_val, addr); VALUE_REGNUM (reg_val) = regnum; - set_value_optimized_out (reg_val, optim); if (unavail) mark_value_bytes_unavailable (reg_val, 0, register_size (gdbarch, regnum)); VALUE_FRAME_ID (reg_val) = get_frame_id (frame); diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index b66febff639..ce2f6da8313 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -162,11 +162,9 @@ struct value * frame_unwind_got_optimized (struct frame_info *frame, int regnum) { struct gdbarch *gdbarch = frame_unwind_arch (frame); - struct value *reg_val; + struct type *reg_type = register_type (gdbarch, regnum); - reg_val = value_zero (register_type (gdbarch, regnum), not_lval); - set_value_optimized_out (reg_val, 1); - return reg_val; + return allocate_optimized_out_value (reg_type); } /* Return a value which indicates that FRAME copied REGNUM into -- 2.30.2