* win32-nat.c (psapi_module_handle): Remove static.
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index 1690b5cde11a159caedc089e865ec74b7fca9319..e8ac46a8ac44bc22938b42728de4c98dd1cddc69 100644 (file)
@@ -47,6 +47,7 @@
 #include "gdb_assert.h"
 #include "observer.h"
 #include "target-descriptions.h"
+#include "user-regs.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -66,7 +67,7 @@ void interrupt_target_command (char *args, int from_tty);
 
 static void nofp_registers_info (char *, int);
 
-static void print_return_value (int struct_return, struct type *value_type);
+static void print_return_value (struct type *value_type);
 
 static void finish_command_continuation (struct continuation_arg *);
 
@@ -433,10 +434,6 @@ post_create_inferior (struct target_ops *target, int from_tty)
 #else
       solib_create_inferior_hook ();
 #endif
-
-      /* Enable any breakpoints which were disabled when the
-        underlying shared library was deleted.  */
-      re_enable_breakpoints_in_shlibs ();
     }
 
   observer_notify_inferior_created (target, from_tty);
@@ -485,7 +482,7 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
   /* Purge old solib objfiles. */
   objfile_purge_solibs ();
 
-  do_run_cleanups (NULL);
+  clear_solib ();
 
   /* The comment here used to read, "The exec file is re-read every
      time we do a generic_mourn_inferior, so we just have to worry
@@ -1164,7 +1161,7 @@ advance_command (char *arg, int from_tty)
 /* Print the result of a function at the end of a 'finish' command.  */
 
 static void
-print_return_value (int struct_return, struct type *value_type)
+print_return_value (struct type *value_type)
 {
   struct gdbarch *gdbarch = current_gdbarch;
   struct cleanup *old_chain;
@@ -1187,7 +1184,7 @@ print_return_value (int struct_return, struct type *value_type)
     case RETURN_VALUE_ABI_RETURNS_ADDRESS:
     case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
       value = allocate_value (value_type);
-      gdbarch_return_value (current_gdbarch, value_type, stop_registers,
+      gdbarch_return_value (gdbarch, value_type, stop_registers,
                            value_contents_raw (value), NULL);
       break;
     case RETURN_VALUE_STRUCT_CONVENTION:
@@ -1197,11 +1194,11 @@ print_return_value (int struct_return, struct type *value_type)
       internal_error (__FILE__, __LINE__, _("bad switch"));
     }
 
-  stb = ui_out_stream_new (uiout);
-  old_chain = make_cleanup_ui_out_stream_delete (stb);
   if (value)
     {
       /* Print it.  */
+      stb = ui_out_stream_new (uiout);
+      old_chain = make_cleanup_ui_out_stream_delete (stb);
       ui_out_text (uiout, "Value returned is ");
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
                        record_latest_value (value));
@@ -1209,16 +1206,15 @@ print_return_value (int struct_return, struct type *value_type)
       value_print (value, stb->stream, 0, Val_no_prettyprint);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
+      do_cleanups (old_chain);
     }
   else
     {
-      /* Just print the type.  */
       ui_out_text (uiout, "Value returned has type: ");
-      type_print (value_type, NULL, stb->stream, 0);
-      ui_out_field_stream (uiout, "return-type", stb);
-      ui_out_text (uiout, ". Cannot determine contents.\n");
+      ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
+      ui_out_text (uiout, ".");
+      ui_out_text (uiout, " Cannot determine contents\n");
     }
-  do_cleanups (old_chain);
 }
 
 /* Stuff that needs to be done by the finish command after the target
@@ -1245,25 +1241,14 @@ finish_command_continuation (struct continuation_arg *arg)
       && function != NULL)
     {
       struct type *value_type;
-      int struct_return;
-      int gcc_compiled;
 
       value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
       if (!value_type)
        internal_error (__FILE__, __LINE__,
                        _("finish_command: function has no target type"));
 
-      if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
-       {
-         do_exec_cleanups (cleanups);
-         return;
-       }
-
-      CHECK_TYPEDEF (value_type);
-      gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
-      struct_return = using_struct_return (value_type, gcc_compiled);
-
-      print_return_value (struct_return, value_type); 
+      if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
+       print_return_value (value_type); 
     }
 
   do_exec_cleanups (cleanups);
@@ -1368,23 +1353,14 @@ finish_command (char *arg, int from_tty)
          && function != NULL)
        {
          struct type *value_type;
-         int struct_return;
-         int gcc_compiled;
 
          value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
          if (!value_type)
            internal_error (__FILE__, __LINE__,
                            _("finish_command: function has no target type"));
 
-         /* FIXME: Shouldn't we do the cleanups before returning?  */
-         if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
-           return;
-
-         CHECK_TYPEDEF (value_type);
-         gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
-         struct_return = using_struct_return (value_type, gcc_compiled);
-
-         print_return_value (struct_return, value_type); 
+         if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
+           print_return_value (value_type); 
        }
 
       do_cleanups (old_chain);
@@ -1602,8 +1578,8 @@ default_print_registers_info (struct gdbarch *gdbarch,
                              int regnum, int print_all)
 {
   int i;
-  const int numregs = gdbarch_num_regs (current_gdbarch)
-                     + gdbarch_num_pseudo_regs (current_gdbarch);
+  const int numregs = gdbarch_num_regs (gdbarch)
+                     + gdbarch_num_pseudo_regs (gdbarch);
   gdb_byte buffer[MAX_REGISTER_SIZE];
 
   for (i = 0; i < numregs; i++)
@@ -1631,13 +1607,13 @@ default_print_registers_info (struct gdbarch *gdbarch,
 
       /* If the register name is empty, it is undefined for this
          processor, so don't display anything.  */
-      if (gdbarch_register_name (current_gdbarch, i) == NULL
-         || *(gdbarch_register_name (current_gdbarch, i)) == '\0')
+      if (gdbarch_register_name (gdbarch, i) == NULL
+         || *(gdbarch_register_name (gdbarch, i)) == '\0')
        continue;
 
-      fputs_filtered (gdbarch_register_name (current_gdbarch, i), file);
+      fputs_filtered (gdbarch_register_name (gdbarch, i), file);
       print_spaces_filtered (15 - strlen (gdbarch_register_name
-                                         (current_gdbarch, i)), file);
+                                         (gdbarch, i)), file);
 
       /* Get the data in raw format.  */
       if (! frame_register_read (frame, i, buffer))
@@ -1648,21 +1624,21 @@ default_print_registers_info (struct gdbarch *gdbarch,
 
       /* If virtual format is floating, print it that way, and in raw
          hex.  */
-      if (TYPE_CODE (register_type (current_gdbarch, i)) == TYPE_CODE_FLT)
+      if (TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_FLT)
        {
          int j;
 
-         val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+         val_print (register_type (gdbarch, i), buffer, 0, 0,
                     file, 0, 1, 0, Val_pretty_default);
 
          fprintf_filtered (file, "\t(raw 0x");
-         for (j = 0; j < register_size (current_gdbarch, i); j++)
+         for (j = 0; j < register_size (gdbarch, i); j++)
            {
              int idx;
-             if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+             if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
                idx = j;
              else
-               idx = register_size (current_gdbarch, i) - 1 - j;
+               idx = register_size (gdbarch, i) - 1 - j;
              fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
            }
          fprintf_filtered (file, ")");
@@ -1670,14 +1646,14 @@ default_print_registers_info (struct gdbarch *gdbarch,
       else
        {
          /* Print the register in hex.  */
-         val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+         val_print (register_type (gdbarch, i), buffer, 0, 0,
                     file, 'x', 1, 0, Val_pretty_default);
           /* If not a vector register, print it also according to its
              natural format.  */
-         if (TYPE_VECTOR (register_type (current_gdbarch, i)) == 0)
+         if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
            {
              fprintf_filtered (file, "\t");
-             val_print (register_type (current_gdbarch, i), buffer, 0, 0,
+             val_print (register_type (gdbarch, i), buffer, 0, 0,
                         file, 0, 1, 0, Val_pretty_default);
            }
        }
@@ -1690,16 +1666,18 @@ void
 registers_info (char *addr_exp, int fpregs)
 {
   struct frame_info *frame;
+  struct gdbarch *gdbarch;
   int regnum, numregs;
   char *end;
 
   if (!target_has_registers)
     error (_("The program has no registers now."));
   frame = get_selected_frame (NULL);
+  gdbarch = get_frame_arch (frame);
 
   if (!addr_exp)
     {
-      gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+      gdbarch_print_registers_info (gdbarch, gdb_stdout,
                                    frame, -1, fpregs);
       return;
     }
@@ -1728,31 +1706,45 @@ registers_info (char *addr_exp, int fpregs)
       while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
        addr_exp++;
       end = addr_exp;
-      
+
       /* Figure out what we've found and display it.  */
 
       /* A register name?  */
       {
-       int regnum = frame_map_name_to_regnum (frame,
-                                              start, end - start);
+       int regnum = frame_map_name_to_regnum (frame, start, end - start);
        if (regnum >= 0)
          {
-           gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
-                                         frame, regnum, fpregs);
+           /* User registers lie completely outside of the range of
+              normal registers.  Catch them early so that the target
+              never sees them.  */
+           if (regnum >= gdbarch_num_regs (gdbarch)
+                         + gdbarch_num_pseudo_regs (gdbarch))
+             {
+               struct value *val = value_of_user_reg (regnum, frame);
+
+               printf_filtered ("%s: ", start);
+               print_scalar_formatted (value_contents (val),
+                                       check_typedef (value_type (val)),
+                                       'x', 0, gdb_stdout);
+               printf_filtered ("\n");
+             }
+           else
+             gdbarch_print_registers_info (gdbarch, gdb_stdout,
+                                           frame, regnum, fpregs);
            continue;
          }
       }
-       
+
       /* A register number?  (how portable is this one?).  */
       {
        char *endptr;
        int regnum = strtol (start, &endptr, 0);
        if (endptr == end
            && regnum >= 0
-           && regnum < gdbarch_num_regs (current_gdbarch)
-                       + gdbarch_num_pseudo_regs (current_gdbarch))
+           && regnum < gdbarch_num_regs (gdbarch)
+                       + gdbarch_num_pseudo_regs (gdbarch))
          {
-           gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+           gdbarch_print_registers_info (gdbarch, gdb_stdout,
                                          frame, regnum, fpregs);
            continue;
          }
@@ -1761,9 +1753,9 @@ registers_info (char *addr_exp, int fpregs)
       /* A register group?  */
       {
        struct reggroup *group;
-       for (group = reggroup_next (current_gdbarch, NULL);
+       for (group = reggroup_next (gdbarch, NULL);
             group != NULL;
-            group = reggroup_next (current_gdbarch, group))
+            group = reggroup_next (gdbarch, group))
          {
            /* Don't bother with a length check.  Should the user
               enter a short register group name, go with the first
@@ -1775,13 +1767,12 @@ registers_info (char *addr_exp, int fpregs)
          {
            int regnum;
            for (regnum = 0;
-                regnum < gdbarch_num_regs (current_gdbarch)
-                         + gdbarch_num_pseudo_regs (current_gdbarch);
+                regnum < gdbarch_num_regs (gdbarch)
+                         + gdbarch_num_pseudo_regs (gdbarch);
                 regnum++)
              {
-               if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
-                                                group))
-                 gdbarch_print_registers_info (current_gdbarch,
+               if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
+                 gdbarch_print_registers_info (gdbarch,
                                                gdb_stdout, frame,
                                                regnum, fpregs);
              }
@@ -1818,8 +1809,8 @@ print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
       int printed_something = 0;
 
       for (regnum = 0;
-          regnum < gdbarch_num_regs (current_gdbarch)
-                   + gdbarch_num_pseudo_regs (current_gdbarch);
+          regnum < gdbarch_num_regs (gdbarch)
+                   + gdbarch_num_pseudo_regs (gdbarch);
           regnum++)
        {
          if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
@@ -1896,11 +1887,7 @@ attach_command (char *args, int from_tty)
      (gdb) attach 4712
      Cannot access memory at address 0xdeadbeef
   */
-#ifdef CLEAR_SOLIB
-      CLEAR_SOLIB ();
-#else
-      clear_solib ();
-#endif
+  clear_solib ();
 
   target_attach (args, from_tty);
 
@@ -2038,8 +2025,8 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
       int printed_something = 0;
 
       for (regnum = 0;
-          regnum < gdbarch_num_regs (current_gdbarch)
-                   + gdbarch_num_pseudo_regs (current_gdbarch);
+          regnum < gdbarch_num_regs (gdbarch)
+                   + gdbarch_num_pseudo_regs (gdbarch);
           regnum++)
        {
          if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
This page took 0.029405 seconds and 4 git commands to generate.