2002-02-10 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / gdb / corefile.c
index 51a3b03568b48af3b5d2aead0d9c7a8b45c1cb0d..7acbd6eb5670493b2cd44174bf719b62cde975a2 100644 (file)
@@ -260,18 +260,42 @@ dis_asm_print_address (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 (CORE_ADDR memaddr, char *myaddr, int len)
+/* Read an integer from debugged memory, given address and number of bytes.  */
+
+struct captured_read_memory_integer_arguments
 {
-  int status;
+  CORE_ADDR memaddr;
+  int len;
+  LONGEST result;
+};
 
-  status = target_write_memory (memaddr, myaddr, len);
-  if (status != 0)
-    memory_error (status, memaddr);
+static int
+do_captured_read_memory_integer (void *data)
+{
+  struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
+  CORE_ADDR memaddr = args->memaddr;
+  int len = args->len;
+
+  args->result = read_memory_integer (memaddr, len);
+
+  return 0;
 }
 
-/* Read an integer from debugged memory, given address and number of bytes.  */
+int
+safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
+{
+  int status;
+  struct captured_read_memory_integer_arguments args;
+  args.memaddr = memaddr;
+  args.len = len;
+
+  status = catch_errors (do_captured_read_memory_integer, &args,
+                        "", RETURN_MASK_ALL);
+  if (!status)
+    *return_value = args.result;
+
+  return status;
+}
 
 LONGEST
 read_memory_integer (CORE_ADDR memaddr, int len)
@@ -317,6 +341,36 @@ read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len)
        break;
     }
 }
+
+/* Same as target_write_memory, but report an error if can't write.  */
+void
+write_memory (CORE_ADDR memaddr, char *myaddr, int len)
+{
+  int status;
+
+  status = target_write_memory (memaddr, myaddr, len);
+  if (status != 0)
+    memory_error (status, memaddr);
+}
+
+/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
+void
+write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
+{
+  char *buf = alloca (len);
+  store_unsigned_integer (buf, len, value);
+  write_memory (addr, buf, len);
+}
+
+/* Store VALUE at ADDR in the inferior as a LEN-byte signed integer.  */
+void
+write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
+{
+  char *buf = alloca (len);
+  store_signed_integer (buf, len, value);
+  write_memory (addr, buf, len);
+}
+
 \f
 
 #if 0
@@ -394,7 +448,7 @@ No arg means have no core file.  This command has been superseded by the\n\
                   "Set the current BFD target.\n\
 Use `set gnutarget auto' to specify automatic detection.",
                   &setlist);
-  c->function.sfunc = set_gnutarget_command;
+  set_cmd_sfunc (c, set_gnutarget_command);
   add_show_from_set (c, &showlist);
 
   if (getenv ("GNUTARGET"))
This page took 0.02587 seconds and 4 git commands to generate.