* values.c, value.h (modify_field), callers: Make fieldval a LONGEST.
[binutils-gdb.git] / gdb / core.c
index a513dbc1e0a4d45eefd859944f86f46b86a35e83..4ef24d39d20027306716d721943d4c83bc37a9e9 100644 (file)
@@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "inferior.h"
 #include "symtab.h"
 #include "command.h"
+#include "gdbcmd.h"
 #include "bfd.h"
 #include "target.h"
 #include "gdbcore.h"
@@ -161,9 +162,7 @@ read_memory (memaddr, myaddr, len)
     memory_error (status, memaddr);
 }
 
-/* Like target_read_memory, but slightly different parameters. 
-
-   FIXME: not according to it's prototype.  930331 krp. */
+/* Like target_read_memory, but slightly different parameters.  */
 
 int
 dis_asm_read_memory (memaddr, myaddr, len, info)
@@ -172,7 +171,7 @@ dis_asm_read_memory (memaddr, myaddr, len, info)
      int len;
      disassemble_info *info;
 {
-  return target_read_memory (memaddr, myaddr, len);
+  return target_read_memory (memaddr, (char *) myaddr, len);
 }
 
 /* Like memory_error with slightly different parameters.  */
@@ -185,6 +184,15 @@ dis_asm_memory_error (status, memaddr, info)
   memory_error (status, memaddr);
 }
 
+/* Like print_address with slightly different parameters.  */
+void
+dis_asm_print_address (addr, info)
+     bfd_vma addr;
+     struct disassemble_info *info;
+{
+  print_address (addr, info->stream);
+}
+
 /* Same as target_write_memory, but report an error if can't write.  */
 void
 write_memory (memaddr, myaddr, len)
@@ -201,50 +209,35 @@ write_memory (memaddr, myaddr, len)
 
 /* Read an integer from debugged memory, given address and number of bytes.  */
 
-long
+LONGEST
 read_memory_integer (memaddr, len)
      CORE_ADDR memaddr;
      int len;
 {
-  char cbuf;
-  short sbuf;
-  int ibuf;
-  long lbuf;
+  char buf[sizeof (LONGEST)];
 
-  if (len == sizeof (char))
-    {
-      read_memory (memaddr, &cbuf, len);
-      return cbuf;
-    }
-  if (len == sizeof (short))
-    {
-      read_memory (memaddr, (char *)&sbuf, len);
-      SWAP_TARGET_AND_HOST (&sbuf, sizeof (short));
-      return sbuf;
-    }
-  if (len == sizeof (int))
-    {
-      read_memory (memaddr, (char *)&ibuf, len);
-      SWAP_TARGET_AND_HOST (&ibuf, sizeof (int));
-      return ibuf;
-    }
-  if (len == sizeof (lbuf))
-    {
-      read_memory (memaddr, (char *)&lbuf, len);
-      SWAP_TARGET_AND_HOST (&lbuf, sizeof (lbuf));
-      return lbuf;
-    }
-  error ("Cannot handle integers of %d bytes.", len);
-  return -1;   /* for lint */
+  read_memory (memaddr, buf, len);
+  return extract_signed_integer (buf, len);
+}
+
+unsigned LONGEST
+read_memory_unsigned_integer (memaddr, len)
+     CORE_ADDR memaddr;
+     int len;
+{
+  char buf[sizeof (unsigned LONGEST)];
+
+  read_memory (memaddr, buf, len);
+  return extract_unsigned_integer (buf, len);
 }
 \f
 void
 _initialize_core()
 {
-
-  add_com ("core-file", class_files, core_file_command,
-          "Use FILE as core dump for examining memory and registers.\n\
+  struct cmd_list_element *c;
+  c = add_cmd ("core-file", class_files, core_file_command,
+              "Use FILE as core dump for examining memory and registers.\n\
 No arg means have no core file.  This command has been superseded by the\n\
-`target core' and `detach' commands.");
-
+`target core' and `detach' commands.", &cmdlist);
+  c->completer = filename_completer;
 }