From 0f2c5ba5c5457819f3089c6ad9cd7fced6bc0538 Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 24 May 2000 17:25:39 +0000 Subject: 2000-05-24 Michael Snyder * findvar.c (value_from_register): Factor code, simplify logic. --- gdb/findvar.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'gdb/findvar.c') diff --git a/gdb/findvar.c b/gdb/findvar.c index 8f19608..7edbcea 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -1476,7 +1476,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i } /* Return a value of type TYPE, stored in register REGNUM, in frame - FRAME. + FRAME. NOTE: returns NULL if register value is not available. Caller will check return value or die! */ @@ -1500,7 +1500,8 @@ value_from_register (type, regnum, frame) CHECK_TYPEDEF (type); len = TYPE_LENGTH (type); - /* Pointers on D10V are really only 16 bits, but we lie to gdb elsewhere... */ + /* Pointers on D10V are really only 16 bits, + but we lie to gdb elsewhere... */ if (GDB_TARGET_IS_D10V && TYPE_CODE (type) == TYPE_CODE_PTR) len = 2; @@ -1703,25 +1704,20 @@ value_from_register (type, regnum, frame) } if (GDB_TARGET_IS_D10V - && TYPE_CODE (type) == TYPE_CODE_PTR - && TYPE_TARGET_TYPE (type) - && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)) + && TYPE_CODE (type) == TYPE_CODE_PTR) { - /* pointer to function */ unsigned long num; unsigned short snum; - snum = (unsigned short) extract_unsigned_integer (VALUE_CONTENTS_RAW (v), 2); - num = D10V_MAKE_IADDR (snum); - store_address (VALUE_CONTENTS_RAW (v), 4, num); - } - else if (GDB_TARGET_IS_D10V - && TYPE_CODE (type) == TYPE_CODE_PTR) - { - /* pointer to data */ - unsigned long num; - unsigned short snum; - snum = (unsigned short) extract_unsigned_integer (VALUE_CONTENTS_RAW (v), 2); - num = D10V_MAKE_DADDR (snum); + + snum = (unsigned short) + extract_unsigned_integer (VALUE_CONTENTS_RAW (v), 2); + + if (TYPE_TARGET_TYPE (type) /* pointer to function */ + && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)) + num = D10V_MAKE_IADDR (snum); + else /* pointer to data */ + num = D10V_MAKE_DADDR (snum); + store_address (VALUE_CONTENTS_RAW (v), 4, num); } -- cgit v1.1