aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2006-11-22 13:44:45 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2006-11-22 13:44:45 +0000
commit0b2b0195d1b3b75d9fd0e5313466a0141790071d (patch)
treec685ca6d43e2bb095da319b07c2cfe1c47f1f988 /gdb
parent765dc01564a52c8e8ef896ec4acef04a38d60377 (diff)
downloadfsf-binutils-gdb-0b2b0195d1b3b75d9fd0e5313466a0141790071d.zip
fsf-binutils-gdb-0b2b0195d1b3b75d9fd0e5313466a0141790071d.tar.gz
fsf-binutils-gdb-0b2b0195d1b3b75d9fd0e5313466a0141790071d.tar.bz2
* findvar.c (address_from_register): New function.
* value.h (address_from_register): Add prototype. * dwarf2loc.c (dwarf_expr_read_reg): Use address_from_register.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/dwarf2loc.c15
-rw-r--r--gdb/findvar.c20
-rw-r--r--gdb/value.h3
4 files changed, 33 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6171628..b3f4b41 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-22 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * findvar.c (address_from_register): New function.
+ * value.h (address_from_register): Add prototype.
+ * dwarf2loc.c (dwarf_expr_read_reg): Use address_from_register.
+
2006-11-22 Vladimir Prus <vladimir@codesourcery.com>
* breakpoint.c: Include "memattr.h".
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index f4f725e..1b29dc9 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -115,24 +115,17 @@ struct dwarf_expr_baton
/* Helper functions for dwarf2_evaluate_loc_desc. */
/* Using the frame specified in BATON, return the value of register
- REGNUM, treated as an unsigned integer. */
+ REGNUM, treated as a pointer. */
static CORE_ADDR
dwarf_expr_read_reg (void *baton, int dwarf_regnum)
{
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
CORE_ADDR result;
- gdb_byte *buf;
- int regnum, regsize;
+ int regnum;
regnum = DWARF2_REG_TO_REGNUM (dwarf_regnum);
- regsize = register_size (current_gdbarch, regnum);
- buf = alloca (regsize);
-
- frame_register_read (debaton->frame, regnum, buf);
- /* NOTE: cagney/2003-05-22: This extract is assuming that a DWARF 2
- address is always unsigned. That may or may not be true. */
- result = extract_unsigned_integer (buf, regsize);
-
+ result = address_from_register (builtin_type_void_data_ptr,
+ regnum, debaton->frame);
return result;
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 0cda35e..9edd151 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -728,6 +728,26 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
return v;
}
+/* Return contents of register REGNUM in frame FRAME as address,
+ interpreted as value of type TYPE. Will abort if register
+ value is not available. */
+
+CORE_ADDR
+address_from_register (struct type *type, int regnum, struct frame_info *frame)
+{
+ struct value *value;
+ CORE_ADDR result;
+
+ value = value_from_register (type, regnum, frame);
+ gdb_assert (value);
+
+ result = value_as_address (value);
+ release_value (value);
+ value_free (value);
+
+ return result;
+}
+
/* Given a struct symbol for a variable or function,
and a stack frame id,
diff --git a/gdb/value.h b/gdb/value.h
index 87129d6..001761a 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -282,6 +282,9 @@ extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
extern struct value *value_from_register (struct type *type, int regnum,
struct frame_info *frame);
+extern CORE_ADDR address_from_register (struct type *type, int regnum,
+ struct frame_info *frame);
+
extern struct value *value_of_variable (struct symbol *var, struct block *b);
extern struct value *value_of_register (int regnum, struct frame_info *frame);