aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-06-04 13:46:37 +0000
committerAndrew Cagney <cagney@redhat.com>2000-06-04 13:46:37 +0000
commitac2e2ef7e2214be3672096ea7e6641d6a0651fd7 (patch)
tree7205cea8571355be893617fae45005b4ab5901a7
parent0b5454486cd4b2e34f4ac7eb51092ef55fa97b07 (diff)
downloadbinutils-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.zip
binutils-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.tar.gz
binutils-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.tar.bz2
Add host_pointer_to_address() and address_to_host_pointer(). Add
signed_pointer_to_address() etc. Rename generic_pointer_to_address() to unsigned_pointer_to_address() etc.
-rw-r--r--gdb/ChangeLog29
-rw-r--r--gdb/TODO9
-rw-r--r--gdb/config/mips/tm-mips.h5
-rw-r--r--gdb/defs.h3
-rw-r--r--gdb/findvar.c14
-rw-r--r--gdb/gdbarch.c8
-rw-r--r--gdb/gdbarch.h12
-rwxr-xr-xgdb/gdbarch.sh4
-rw-r--r--gdb/inferior.h9
-rw-r--r--gdb/irix5-nat.c21
-rw-r--r--gdb/procfs.c5
-rw-r--r--gdb/utils.c23
12 files changed, 104 insertions, 38 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 247183e..6e28bc1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,32 @@
+Wed May 31 21:41:37 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Change buf
+ to a void pointer. Update initial values.
+ * gdbarch.h, gdbarch.c: Re-generate.
+
+ * findvar.c (address_to_signed_pointer,
+ signed_pointer_to_address): New functions.
+ * inferior.h (signed_pointer_to_address,
+ signed_address_to_pointer): Declare.
+
+ * inferior.h, findvar.c (unsigned_pointer_to_address,
+ address_to_unsigned_pointer): Rename generic_address_to_pointer
+ and generic_pointer_to_address. Update signatures to match
+ gdbarch changes.
+
+ * config/mips/tm-mips.h (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER):
+ Define. MIPS has signed pointers.
+
+ * defs.h, utils.c (host_pointer_to_address,
+ address_to_host_pointer): New functions.
+ * irix5-nat.c (next_link_map_member, first_link_map_member),
+ procfs.c (proc_set_watchpoint, proc_iterate_over_mappings): Use.
+
+ * irix5-nat.c (solib_map_sections, symbol_add_stub): Change
+ function signature to match catch_errors_ftype.
+
+ * TODO: Update. GDB builds using the IRIX native compiler.
+
Sat Jun 3 20:43:59 2000 Andrew Cagney <cagney@b1.cygnus.com>
* defs.h (strsignal, safe_strsignal): Delete declarations.
diff --git a/gdb/TODO b/gdb/TODO
index eac1855..d70a891 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -15,15 +15,6 @@ release.
--
-GDB requires GCC to build under IRIX
-
-IRIX, being more pedantic than GCC reports as errors certain
-assignments that GCC treats as warnings.
-
-This can be worked around by building GDB with the GCC compiler.
-
---
-
The BFD directory requires bug-fixed AUTOMAKE et.al.
AUTOMAKE 1.4 incorrectly set the TEXINPUTS environment variable. It
diff --git a/gdb/config/mips/tm-mips.h b/gdb/config/mips/tm-mips.h
index c5cc63a..9d07e87 100644
--- a/gdb/config/mips/tm-mips.h
+++ b/gdb/config/mips/tm-mips.h
@@ -587,3 +587,8 @@ typedef unsigned long t_inst; /* Integer big enough to hold an instruction */
/* Command to set the processor type. */
extern void mips_set_processor_type_command (char *, int);
+
+
+/* MIPS sign extends addresses */
+#define POINTER_TO_ADDRESS(TYPE,BUF) (signed_pointer_to_address (TYPE, BUF))
+#define ADDRESS_TO_POINTER(TYPE,BUF,ADDR) (address_to_signed_pointer (TYPE, BUF, ADDR))
diff --git a/gdb/defs.h b/gdb/defs.h
index e918271..400f630 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -369,6 +369,9 @@ extern void mfree (PTR, PTR);
extern void init_page_info (void);
+extern CORE_ADDR host_pointer_to_address (void *ptr);
+extern void *address_to_host_pointer (CORE_ADDR addr);
+
/* From demangle.c */
extern void set_demangling_style (char *);
diff --git a/gdb/findvar.c b/gdb/findvar.c
index adf7ddb..5571ede 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -1210,20 +1210,30 @@ write_fp (val)
/* Given a pointer of type TYPE in target form in BUF, return the
address it represents. */
CORE_ADDR
-generic_pointer_to_address (struct type *type, char *buf)
+unsigned_pointer_to_address (struct type *type, void *buf)
{
return extract_address (buf, TYPE_LENGTH (type));
}
+CORE_ADDR
+signed_pointer_to_address (struct type *type, void *buf)
+{
+ return extract_signed_integer (buf, TYPE_LENGTH (type));
+}
/* Given an address, store it as a pointer of type TYPE in target
format in BUF. */
void
-generic_address_to_pointer (struct type *type, char *buf, CORE_ADDR addr)
+unsigned_address_to_pointer (struct type *type, void *buf, CORE_ADDR addr)
{
store_address (buf, TYPE_LENGTH (type), addr);
}
+void
+address_to_signed_pointer (struct type *type, void *buf, CORE_ADDR addr)
+{
+ store_signed_integer (buf, TYPE_LENGTH (type), addr);
+}
/* Will calling read_var_value or locate_var_value on SYM end
up caring what frame it is being evaluated relative to? SYM must
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 2c90782..55afe11 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -383,8 +383,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->call_dummy_stack_adjust_p = -1;
gdbarch->coerce_float_to_double = default_coerce_float_to_double;
gdbarch->register_convertible = generic_register_convertible_not;
- gdbarch->pointer_to_address = generic_pointer_to_address;
- gdbarch->address_to_pointer = generic_address_to_pointer;
+ gdbarch->pointer_to_address = unsigned_pointer_to_address;
+ gdbarch->address_to_pointer = unsigned_address_to_pointer;
gdbarch->return_value_on_stack = generic_return_value_on_stack_not;
gdbarch->prologue_frameless_p = generic_prologue_frameless_p;
gdbarch->breakpoint_from_pc = legacy_breakpoint_from_pc;
@@ -2134,7 +2134,7 @@ set_gdbarch_register_convert_to_raw (struct gdbarch *gdbarch,
}
CORE_ADDR
-gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, char *buf)
+gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, void *buf)
{
if (gdbarch->pointer_to_address == 0)
internal_error ("gdbarch: gdbarch_pointer_to_address invalid");
@@ -2151,7 +2151,7 @@ set_gdbarch_pointer_to_address (struct gdbarch *gdbarch,
}
void
-gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, char *buf, CORE_ADDR addr)
+gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, void *buf, CORE_ADDR addr)
{
if (gdbarch->address_to_pointer == 0)
internal_error ("gdbarch: gdbarch_address_to_pointer invalid");
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index d4a7849..1875774 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -592,11 +592,11 @@ extern void set_gdbarch_register_convert_to_raw (struct gdbarch *gdbarch, gdbarc
/* Default (function) for non- multi-arch platforms. */
#if (GDB_MULTI_ARCH == 0) && !defined (POINTER_TO_ADDRESS)
-#define POINTER_TO_ADDRESS(type, buf) (generic_pointer_to_address (type, buf))
+#define POINTER_TO_ADDRESS(type, buf) (unsigned_pointer_to_address (type, buf))
#endif
-typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct type *type, char *buf);
-extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, char *buf);
+typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct type *type, void *buf);
+extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, void *buf);
extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address);
#if GDB_MULTI_ARCH
#if (GDB_MULTI_ARCH > 1) || !defined (POINTER_TO_ADDRESS)
@@ -606,11 +606,11 @@ extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_poi
/* Default (function) for non- multi-arch platforms. */
#if (GDB_MULTI_ARCH == 0) && !defined (ADDRESS_TO_POINTER)
-#define ADDRESS_TO_POINTER(type, buf, addr) (generic_address_to_pointer (type, buf, addr))
+#define ADDRESS_TO_POINTER(type, buf, addr) (unsigned_address_to_pointer (type, buf, addr))
#endif
-typedef void (gdbarch_address_to_pointer_ftype) (struct type *type, char *buf, CORE_ADDR addr);
-extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, char *buf, CORE_ADDR addr);
+typedef void (gdbarch_address_to_pointer_ftype) (struct type *type, void *buf, CORE_ADDR addr);
+extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, void *buf, CORE_ADDR addr);
extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer);
#if GDB_MULTI_ARCH
#if (GDB_MULTI_ARCH > 1) || !defined (ADDRESS_TO_POINTER)
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 318bbfd..bf7b47c 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -333,8 +333,8 @@ f:1:REGISTER_CONVERTIBLE:int:register_convertible:int nr:nr:::generic_register_c
f:2:REGISTER_CONVERT_TO_VIRTUAL:void:register_convert_to_virtual:int regnum, struct type *type, char *from, char *to:regnum, type, from, to:::0::0
f:2:REGISTER_CONVERT_TO_RAW:void:register_convert_to_raw:struct type *type, int regnum, char *from, char *to:type, regnum, from, to:::0::0
#
-f:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, char *buf:type, buf:::generic_pointer_to_address::0
-f:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, char *buf, CORE_ADDR addr:type, buf, addr:::generic_address_to_pointer::0
+f:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, void *buf:type, buf:::unsigned_pointer_to_address::0
+f:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, void *buf, CORE_ADDR addr:type, buf, addr:::unsigned_address_to_pointer::0
#
f:2:RETURN_VALUE_ON_STACK:int:return_value_on_stack:struct type *type:type:::generic_return_value_on_stack_not::0
f:2:EXTRACT_RETURN_VALUE:void:extract_return_value:struct type *type, char *regbuf, char *valbuf:type, regbuf, valbuf::0:0
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 8e17202..26798a5 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -160,10 +160,13 @@ extern void write_fp (CORE_ADDR);
extern void generic_target_write_fp (CORE_ADDR);
-extern CORE_ADDR generic_pointer_to_address (struct type *type, char *buf);
+extern CORE_ADDR unsigned_pointer_to_address (struct type *type, void *buf);
-extern void generic_address_to_pointer (struct type *type, char *buf,
- CORE_ADDR addr);
+extern void unsigned_address_to_pointer (struct type *type, void *buf,
+ CORE_ADDR addr);
+extern CORE_ADDR signed_pointer_to_address (struct type *type, void *buf);
+extern void address_to_signed_pointer (struct type *type, void *buf,
+ CORE_ADDR addr);
extern void wait_for_inferior (void);
diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c
index 12907c5..ea37b8c 100644
--- a/gdb/irix5-nat.c
+++ b/gdb/irix5-nat.c
@@ -352,7 +352,7 @@ static int disable_break (void);
static void info_sharedlibrary_command (char *, int);
-static int symbol_add_stub (char *);
+static int symbol_add_stub (void *);
static struct so_list *find_solib (struct so_list *);
@@ -364,7 +364,7 @@ static void xfer_link_map_member (struct so_list *, struct link_map *);
static CORE_ADDR locate_base (void);
-static int solib_map_sections (char *);
+static int solib_map_sections (void *);
/*
@@ -394,8 +394,7 @@ static int solib_map_sections (char *);
*/
static int
-solib_map_sections (arg)
- char *arg;
+solib_map_sections (void *arg)
{
struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
char *filename;
@@ -460,6 +459,7 @@ solib_map_sections (arg)
/* Free the file names, close the file now. */
do_cleanups (old_chain);
+ /* must be non-zero */
return (1);
}
@@ -564,12 +564,13 @@ first_link_map_member ()
return NULL;
/* Get first list entry. */
- lladdr = (CORE_ADDR) listp;
+ /* The MIPS Sign extends addresses. */
+ lladdr = host_pointer_to_address (listp);
read_memory (lladdr, (char *) &list_old, sizeof (struct obj_list));
/* The first entry in the list is the object file we are debugging,
so skip it. */
- next_lladdr = (CORE_ADDR) list_old.next;
+ next_lladdr = host_pointer_to_address (list_old.next);
#ifdef HANDLE_NEW_OBJ_LIST
if (list_old.data == NEW_OBJ_INFO_MAGIC)
@@ -629,7 +630,7 @@ next_link_map_member (so_list_ptr)
status = target_read_memory (lm->l_lladdr,
(char *) &list_old,
sizeof (struct obj_list));
- next_lladdr = (CORE_ADDR) list_old.next;
+ next_lladdr = host_pointer_to_address (list_old.next);
}
#ifdef HANDLE_NEW_OBJ_LIST
else if (lm->l_variant == OBJ_LIST_32)
@@ -682,7 +683,7 @@ xfer_link_map_member (so_list_ptr, lm)
new_lm->l_variant = OBJ_LIST_OLD;
new_lm->l_lladdr = lladdr;
- new_lm->l_next = (CORE_ADDR) list_old.next;
+ new_lm->l_next = host_pointer_to_address (list_old.next);
#ifdef HANDLE_NEW_OBJ_LIST
if (list_old.data == NEW_OBJ_INFO_MAGIC)
@@ -818,8 +819,7 @@ find_solib (so_list_ptr)
/* A small stub to get us past the arg-passing pinhole of catch_errors. */
static int
-symbol_add_stub (arg)
- char *arg;
+symbol_add_stub (void *arg)
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
CORE_ADDR text_addr = 0;
@@ -848,6 +848,7 @@ symbol_add_stub (arg)
section_addrs.other[0].addr = text_addr;
so->objfile = symbol_file_add (so->so_name, so->from_tty,
&section_addrs, 0, 0);
+ /* must be non-zero */
return (1);
}
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 71e41b7..b127c5f 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -2562,7 +2562,7 @@ proc_set_watchpoint (pi, addr, len, wflags)
prwatch_t *pwatch;
pwatch = (prwatch_t *) &arg.watch;
- pwatch->pr_vaddr = addr;
+ pwatch->pr_vaddr = address_to_host_pointer (addr);
pwatch->pr_size = len;
pwatch->pr_wflags = wflags;
#if defined(NEW_PROC_API) && defined (PCWATCH)
@@ -2683,7 +2683,8 @@ proc_iterate_over_mappings (func)
not a problem. */
/* Stop looping if the callback returns non-zero. */
- if ((funcstat = (*func) (fd, (CORE_ADDR) map[i].pr_vaddr)) != 0)
+ funcstat = (*func) (fd, host_pointer_to_address (map[i].pr_vaddr));
+ if (funcstat != 0)
break;
}
#endif
diff --git a/gdb/utils.c b/gdb/utils.c
index f5088af..b3a3ad9 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -50,6 +50,8 @@
#include "language.h"
#include "annotate.h"
+#include "inferior.h" /* for signed_pointer_to_address */
+
#include <readline/readline.h>
#undef XMALLOC
@@ -2962,3 +2964,24 @@ phex_nz (ULONGEST l, int sizeof_l)
}
return str;
}
+
+
+/* Convert to / from the hosts pointer to GDB's internal CORE_ADDR
+ using the target's conversion routines. */
+CORE_ADDR
+host_pointer_to_address (void *ptr)
+{
+ if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr))
+ internal_error ("core_addr_to_void_ptr: bad cast");
+ return POINTER_TO_ADDRESS (builtin_type_ptr, &ptr);
+}
+
+void *
+address_to_host_pointer (CORE_ADDR addr)
+{
+ void *ptr;
+ if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr))
+ internal_error ("core_addr_to_void_ptr: bad cast");
+ ADDRESS_TO_POINTER (builtin_type_ptr, &ptr, addr);
+ return ptr;
+}