solib-darwin.c: handle PIE when attaching processes.
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index 83001829af03e6cf3c6b23ab5e87b952ceab9da7..4e38725ce29ca4ea616a711b2079deebe0e48ffc 100644 (file)
@@ -469,7 +469,7 @@ post_create_inferior (struct target_ops *target, int from_tty)
 
          /* If the solist is global across processes, there's no need to
             refetch it here.  */
-         if (!gdbarch_has_global_solist (target_gdbarch))
+         if (!gdbarch_has_global_solist (target_gdbarch ()))
            {
 #ifdef SOLIB_ADD
              SOLIB_ADD (NULL, 0, target, auto_solib_add);
@@ -708,6 +708,24 @@ ensure_not_tfind_mode (void)
     error (_("Cannot execute this command while looking at trace frames."));
 }
 
+/* Throw an error indicating the current thread is running.  */
+
+static void
+error_is_running (void)
+{
+  error (_("Cannot execute this command while "
+          "the selected thread is running."));
+}
+
+/* Calls error_is_running if the current thread is running.  */
+
+static void
+ensure_not_running (void)
+{
+  if (is_running (inferior_ptid))
+    error_is_running ();
+}
+
 void
 continue_1 (int all_threads)
 {
@@ -1777,6 +1795,11 @@ finish_command (char *arg, int from_tty)
       return;
     }
 
+  /* Ignore TAILCALL_FRAME type frames, they were executed already before
+     entering THISFRAME.  */
+  while (get_frame_type (frame) == TAILCALL_FRAME)
+    frame = get_prev_frame (frame);
+
   /* Find the function we will return from.  */
 
   function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
@@ -1834,7 +1857,7 @@ program_info (char *args, int from_tty)
 
   target_files_info ();
   printf_filtered (_("Program stopped at %s.\n"),
-                  paddress (target_gdbarch, stop_pc));
+                  paddress (target_gdbarch (), stop_pc));
   if (tp->control.stop_step)
     printf_filtered (_("It stopped after being stepped.\n"));
   else if (stat != 0)
@@ -2015,6 +2038,84 @@ path_command (char *dirname, int from_tty)
 }
 \f
 
+/* Print out the register NAME with value VAL, to FILE, in the default
+   fashion.  */
+
+static void
+default_print_one_register_info (struct ui_file *file,
+                                const char *name,
+                                struct value *val)
+{
+  struct type *regtype = value_type (val);
+
+  fputs_filtered (name, file);
+  print_spaces_filtered (15 - strlen (name), file);
+
+  if (!value_entirely_available (val))
+    {
+      fprintf_filtered (file, "*value not available*\n");
+      return;
+    }
+
+  /* If virtual format is floating, print it that way, and in raw
+     hex.  */
+  if (TYPE_CODE (regtype) == TYPE_CODE_FLT
+      || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT)
+    {
+      int j;
+      struct value_print_options opts;
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (regtype));
+
+      get_user_print_options (&opts);
+      opts.deref_ref = 1;
+
+      val_print (regtype,
+                value_contents_for_printing (val),
+                value_embedded_offset (val), 0,
+                file, 0, val, &opts, current_language);
+
+      fprintf_filtered (file, "\t(raw 0x");
+      for (j = 0; j < TYPE_LENGTH (regtype); j++)
+       {
+         int idx;
+
+         if (byte_order == BFD_ENDIAN_BIG)
+           idx = j;
+         else
+           idx = TYPE_LENGTH (regtype) - 1 - j;
+         fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]);
+       }
+      fprintf_filtered (file, ")");
+    }
+  else
+    {
+      struct value_print_options opts;
+
+      /* Print the register in hex.  */
+      get_formatted_print_options (&opts, 'x');
+      opts.deref_ref = 1;
+      val_print (regtype,
+                value_contents_for_printing (val),
+                value_embedded_offset (val), 0,
+                file, 0, val, &opts, current_language);
+      /* If not a vector register, print it also according to its
+        natural format.  */
+      if (TYPE_VECTOR (regtype) == 0)
+       {
+         get_user_print_options (&opts);
+         opts.deref_ref = 1;
+         fprintf_filtered (file, "\t");
+         val_print (regtype,
+                    value_contents_for_printing (val),
+                    value_embedded_offset (val), 0,
+                    file, 0, val, &opts, current_language);
+       }
+    }
+
+  fprintf_filtered (file, "\n");
+}
+
 /* Print out the machine register regnum.  If regnum is -1, print all
    registers (print_all == 1) or all non-float and non-vector
    registers (print_all == 0).
@@ -2068,76 +2169,16 @@ default_print_registers_info (struct gdbarch *gdbarch,
          || *(gdbarch_register_name (gdbarch, i)) == '\0')
        continue;
 
-      fputs_filtered (gdbarch_register_name (gdbarch, i), file);
-      print_spaces_filtered (15 - strlen (gdbarch_register_name
-                                         (gdbarch, i)), file);
-
       regtype = register_type (gdbarch, i);
       val = allocate_value (regtype);
 
       /* Get the data in raw format.  */
-      if (! frame_register_read (frame, i, value_contents_raw (val)))
-       {
-         fprintf_filtered (file, "*value not available*\n");
-         continue;
-       }
-
-      /* If virtual format is floating, print it that way, and in raw
-         hex.  */
-      if (TYPE_CODE (regtype) == TYPE_CODE_FLT
-         || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT)
-       {
-         int j;
-         struct value_print_options opts;
-         const gdb_byte *valaddr = value_contents_for_printing (val);
-
-         get_user_print_options (&opts);
-         opts.deref_ref = 1;
-
-         val_print (regtype,
-                    value_contents_for_printing (val),
-                    value_embedded_offset (val), 0,
-                    file, 0, val, &opts, current_language);
-
-         fprintf_filtered (file, "\t(raw 0x");
-         for (j = 0; j < register_size (gdbarch, i); j++)
-           {
-             int idx;
-
-             if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
-               idx = j;
-             else
-               idx = register_size (gdbarch, i) - 1 - j;
-             fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]);
-           }
-         fprintf_filtered (file, ")");
-       }
-      else
-       {
-         struct value_print_options opts;
-
-         /* Print the register in hex.  */
-         get_formatted_print_options (&opts, 'x');
-         opts.deref_ref = 1;
-         val_print (regtype,
-                    value_contents_for_printing (val),
-                    value_embedded_offset (val), 0,
-                    file, 0, val, &opts, current_language);
-          /* If not a vector register, print it also according to its
-             natural format.  */
-         if (TYPE_VECTOR (regtype) == 0)
-           {
-             get_user_print_options (&opts);
-             opts.deref_ref = 1;
-             fprintf_filtered (file, "\t");
-             val_print (regtype,
-                        value_contents_for_printing (val),
-                        value_embedded_offset (val), 0,
-                        file, 0, val, &opts, current_language);
-           }
-       }
+      if (! deprecated_frame_register_read (frame, i, value_contents_raw (val)))
+       mark_value_bytes_unavailable (val, 0, TYPE_LENGTH (value_type (val)));
 
-      fprintf_filtered (file, "\n");
+      default_print_one_register_info (file,
+                                      gdbarch_register_name (gdbarch, i),
+                                      val);
     }
 }
 
@@ -2198,17 +2239,16 @@ registers_info (char *addr_exp, int fpregs)
            if (regnum >= gdbarch_num_regs (gdbarch)
                          + gdbarch_num_pseudo_regs (gdbarch))
              {
-               struct value_print_options opts;
-               struct value *val = value_of_user_reg (regnum, frame);
-
-               printf_filtered ("%.*s: ", (int) (end - start), start);
-               get_formatted_print_options (&opts, 'x');
-               val_print_scalar_formatted (check_typedef (value_type (val)),
-                                           value_contents_for_printing (val),
-                                           value_embedded_offset (val),
-                                           val,
-                                           &opts, 0, gdb_stdout);
-               printf_filtered ("\n");
+               struct value *regval = value_of_user_reg (regnum, frame);
+               const char *regname = user_reg_map_regnum_to_name (gdbarch,
+                                                                  regnum);
+
+               /* Print in the same fashion
+                  gdbarch_print_registers_info's default
+                  implementation prints.  */
+               default_print_one_register_info (gdb_stdout,
+                                                regname,
+                                                regval);
              }
            else
              gdbarch_print_registers_info (gdbarch, gdb_stdout,
@@ -2520,7 +2560,7 @@ attach_command (char *args, int from_tty)
 
   dont_repeat ();              /* Not for the faint of heart */
 
-  if (gdbarch_has_global_solist (target_gdbarch))
+  if (gdbarch_has_global_solist (target_gdbarch ()))
     /* Don't complain if all processes share the same symbol
        space.  */
     ;
@@ -2710,7 +2750,7 @@ detach_command (char *args, int from_tty)
 
   /* If the solist is global across inferiors, don't clear it when we
      detach from a single inferior.  */
-  if (!gdbarch_has_global_solist (target_gdbarch))
+  if (!gdbarch_has_global_solist (target_gdbarch ()))
     no_shared_libraries (NULL, from_tty);
 
   /* If we still have inferiors to debug, then don't mess with their
@@ -2843,10 +2883,13 @@ info_proc_cmd_1 (char *args, enum info_proc_what what, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
 
-  if (gdbarch_info_proc_p (gdbarch))
-    gdbarch_info_proc (gdbarch, args, what);
-  else
-    target_info_proc (args, what);
+  if (!target_info_proc (args, what))
+    {
+      if (gdbarch_info_proc_p (gdbarch))
+       gdbarch_info_proc (gdbarch, args, what);
+      else
+       error (_("Not supported on this target."));
+    }
 }
 
 /* Implement `info proc' when given without any futher parameters.  */
@@ -3019,7 +3062,7 @@ all targets."));
   c = add_com ("signal", class_run, signal_command, _("\
 Continue program with the specified signal.\n\
 Usage: signal SIGNAL\n\
-The SIGNAL arugment is processed the same as the handle command.\n\
+The SIGNAL argument is processed the same as the handle command.\n\
 \n\
 An argument of \"0\" means continue the program without sending it a signal.\n\
 This is useful in cases where the program stopped because of a signal,\n\
@@ -3082,6 +3125,7 @@ Usage: jump <location>\n\
 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
 for an address to start at."));
   set_cmd_completer (c, location_completer);
+  add_com_alias ("j", "jump", class_run, 1);
 
   if (xdb_commands)
     {
This page took 0.027028 seconds and 4 git commands to generate.