* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / core.c
index 691637182f633d4ceae437d5d68d4262bd072b4e..36c9ab5e75a05e3319e0117d156732e9c65ab006 100644 (file)
@@ -140,12 +140,14 @@ memory_error (status, memaddr)
     {
       /* Actually, address between memaddr and memaddr + len
         was out of bounds. */
-      error ("Cannot access memory at address %s.", local_hex_string(memaddr));
+      error ("Cannot access memory at address %s.",
+            local_hex_string((unsigned long) memaddr));
     }
   else
     {
       error ("Error accessing memory address %s: %s.",
-            local_hex_string (memaddr), safe_strerror (status));
+            local_hex_string ((unsigned long) memaddr),
+            safe_strerror (status));
     }
 }
 
@@ -209,81 +211,61 @@ 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 long
+unsigned LONGEST
 read_memory_unsigned_integer (memaddr, len)
      CORE_ADDR memaddr;
      int len;
 {
-  unsigned char cbuf;
-  unsigned short sbuf;
-  unsigned int ibuf;
-  unsigned long lbuf;
+  char buf[sizeof (unsigned 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 unsigned integers of %d bytes.", len);
-  return -1;   /* for lint */
+  read_memory (memaddr, buf, len);
+  return extract_unsigned_integer (buf, len);
 }
 \f
+/* The current default bfd target.  Points to storage allocated for
+   gnutarget_string.  */
+char *gnutarget;
+
+/* Same thing, except it is "auto" not NULL for the default case.  */
+static char *gnutarget_string;
+
+static void set_gnutarget_command
+  PARAMS ((char *, int, struct cmd_list_element *));
+
+static void
+set_gnutarget_command (ignore, from_tty, c)
+     char *ignore;
+     int from_tty;
+     struct cmd_list_element *c;
+{
+  if (STREQ (gnutarget_string, "auto"))
+    gnutarget = NULL;
+  else
+    gnutarget = gnutarget_string;
+}
+
+/* Set the gnutarget.  */
+void
+set_gnutarget (newtarget)
+     char *newtarget;
+{
+  if (gnutarget_string != NULL)
+    free (gnutarget_string);
+  gnutarget_string = savestring (newtarget, strlen (newtarget));
+  set_gnutarget_command (NULL, 0, NULL);
+}
+
 void
 _initialize_core()
 {
@@ -293,4 +275,17 @@ _initialize_core()
 No arg means have no core file.  This command has been superseded by the\n\
 `target core' and `detach' commands.", &cmdlist);
   c->completer = filename_completer;
+
+  c = add_set_cmd ("gnutarget", class_files, var_string_noescape,
+                 (char *) &gnutarget_string,
+                 "Set the current BFD target.\n\
+Use `set gnutarget auto' to specify automatic detection.",
+                 &setlist);
+  c->function.sfunc = set_gnutarget_command;
+  add_show_from_set (c, &showlist);
+
+  if (getenv ("GNUTARGET"))
+    set_gnutarget (getenv ("GNUTARGET"));
+  else
+    set_gnutarget ("auto");
 }
This page took 0.023982 seconds and 4 git commands to generate.