2009-12-15 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / auxv.c
index 236196f6630d541704bfa8de8383aabc148d866f..7b4ecbe2bc8fdef4061fc8c18c52b8ffba1baaf9 100644 (file)
 #include <fcntl.h>
 
 
-/* This function is called like a to_xfer_partial hook,
-   but must be called with TARGET_OBJECT_AUXV.
-   It handles access via /proc/PID/auxv, which is the common method.
-   This function is appropriate for doing:
-          #define NATIVE_XFER_AUXV     procfs_xfer_auxv
-   for a native target that uses inftarg.c's child_xfer_partial hook.  */
+/* This function is called like a to_xfer_partial hook, but must be
+   called with TARGET_OBJECT_AUXV.  It handles access via
+   /proc/PID/auxv, which is a common method for native targets.  */
 
 LONGEST
 procfs_xfer_auxv (struct target_ops *ops,
-                 int /* enum target_object */ object,
+                 enum target_object object,
                  const char *annex,
                  gdb_byte *readbuf,
                  const gdb_byte *writebuf,
@@ -85,6 +82,7 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 {
   const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
                                / TARGET_CHAR_BIT;
+  const enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -93,9 +91,9 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
   if (endptr - ptr < sizeof_auxv_field * 2)
     return -1;
 
-  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
   ptr += sizeof_auxv_field;
-  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
   ptr += sizeof_auxv_field;
 
   *readptr = ptr;
@@ -240,15 +238,16 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
          fprintf_filtered (file, "%s\n", plongest (val));
          break;
        case hex:
-         fprintf_filtered (file, "0x%s\n", paddr_nz (val));
+         fprintf_filtered (file, "%s\n", paddress (target_gdbarch, val));
          break;
        case str:
          {
            struct value_print_options opts;
            get_user_print_options (&opts);
            if (opts.addressprint)
-             fprintf_filtered (file, "0x%s", paddr_nz (val));
-           val_print_string (val, -1, 1, file, &opts);
+             fprintf_filtered (file, "%s", paddress (target_gdbarch, val));
+           val_print_string (builtin_type (target_gdbarch)->builtin_char,
+                             val, -1, file, &opts);
            fprintf_filtered (file, "\n");
          }
          break;
This page took 0.025555 seconds and 4 git commands to generate.