Minor C++-ification in ravenscar-thread.c
[deliverable/binutils-gdb.git] / gdb / corelow.c
index ecf966525ed7b35503b8b21d9c6be876ade824ee..52d6d95b3c07e2dbbfa39e880dddd1d948f301f0 100644 (file)
@@ -1,6 +1,6 @@
 /* Core dump and executable file functions below target vector, for GDB.
 
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,9 +21,6 @@
 #include "arch-utils.h"
 #include <signal.h>
 #include <fcntl.h>
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>          /* needed for F_OK and friends */
-#endif
 #include "frame.h"             /* required by inferior.h */
 #include "inferior.h"
 #include "infrun.h"
@@ -31,6 +28,7 @@
 #include "command.h"
 #include "bfd.h"
 #include "target.h"
+#include "process-stratum-target.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
 #include "regcache.h"
@@ -44,7 +42,7 @@
 #include "objfiles.h"
 #include "gdb_bfd.h"
 #include "completer.h"
-#include "filestuff.h"
+#include "common/filestuff.h"
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
@@ -61,7 +59,7 @@ static const target_info core_target_info = {
   N_("Use a core file as a target.  Specify the filename of the core file.")
 };
 
-class core_target final : public target_ops
+class core_target final : public process_stratum_target
 {
 public:
   core_target ();
@@ -89,9 +87,12 @@ public:
 
   const char *thread_name (struct thread_info *) override;
 
+  bool has_all_memory () override { return false; }
   bool has_memory () override;
   bool has_stack () override;
   bool has_registers () override;
+  bool has_execution (ptid_t) override { return false; }
+
   bool info_proc (const char *, enum info_proc_what) override;
 
   /* A few helpers.  */
@@ -106,7 +107,7 @@ public:
   void get_core_register_section (struct regcache *regcache,
                                  const struct regset *regset,
                                  const char *name,
-                                 int min_size,
+                                 int section_min_size,
                                  int which,
                                  const char *human_name,
                                  bool required);
@@ -132,8 +133,6 @@ private: /* per-core data */
 
 core_target::core_target ()
 {
-  to_stratum = process_stratum;
-
   m_core_gdbarch = gdbarch_from_bfd (core_bfd);
 
   /* Find a suitable core file handler to munch on core_bfd */
@@ -358,7 +357,6 @@ core_target_open (const char *arg, int from_tty)
 {
   const char *p;
   int siggy;
-  struct cleanup *old_chain;
   int scratch_chan;
   int flags;
 
@@ -422,12 +420,6 @@ core_target_open (const char *arg, int from_tty)
   push_target (target);
   target_holder.release ();
 
-  /* Do this before acknowledging the inferior, so if
-     post_create_inferior throws (can happen easilly if you're loading
-     a core file with the wrong exec), we aren't left with threads
-     from the previous inferior.  */
-  init_thread_list ();
-
   inferior_ptid = null_ptid;
 
   /* Need to flush the register cache (and the frame cache) from a
@@ -570,7 +562,7 @@ void
 core_target::get_core_register_section (struct regcache *regcache,
                                        const struct regset *regset,
                                        const char *name,
-                                       int min_size,
+                                       int section_min_size,
                                        int which,
                                        const char *human_name,
                                        bool required)
@@ -593,13 +585,13 @@ core_target::get_core_register_section (struct regcache *regcache,
     }
 
   size = bfd_section_size (core_bfd, section);
-  if (size < min_size)
+  if (size < section_min_size)
     {
       warning (_("Section `%s' in core file too small."),
               section_name.c_str ());
       return;
     }
-  if (size != min_size && !variable_size_section)
+  if (size != section_min_size && !variable_size_section)
     {
       warning (_("Unexpected size of section `%s' in core file."),
               section_name.c_str ());
@@ -637,12 +629,17 @@ struct get_core_registers_cb_data
    register note section. */
 
 static void
-get_core_registers_cb (const char *sect_name, int size,
+get_core_registers_cb (const char *sect_name, int supply_size, int collect_size,
                       const struct regset *regset,
                       const char *human_name, void *cb_data)
 {
   auto *data = (get_core_registers_cb_data *) cb_data;
   bool required = false;
+  bool variable_size_section = (regset != NULL
+                               && regset->flags & REGSET_VARIABLE_SIZE);
+
+  if (!variable_size_section)
+    gdb_assert (supply_size == collect_size);
 
   if (strcmp (sect_name, ".reg") == 0)
     {
@@ -659,7 +656,8 @@ get_core_registers_cb (const char *sect_name, int size,
   /* The 'which' parameter is only used when no regset is provided.
      Thus we just set it to -1. */
   data->target->get_core_register_section (data->regcache, regset, sect_name,
-                                          size, -1, human_name, required);
+                                          supply_size, -1, human_name,
+                                          required);
 }
 
 /* Get the registers out of a core file.  This is the machine-
This page took 0.027172 seconds and 4 git commands to generate.