Return std::string from ada_exception_catchpoint_cond_string
[deliverable/binutils-gdb.git] / gdb / corelow.c
index 250f46aa051920ebbd8c04dbd55099241a9473a0..97a957c8fcf6defa0afa0339f259816184958813 100644 (file)
 #define O_LARGEFILE 0
 #endif
 
+/* The core file target.  */
+
+static const target_info core_target_info = {
+  "core",
+  N_("Local core dump file"),
+  N_("Use a core file as a target.  Specify the filename of the core file.")
+};
+
+class core_target final : public target_ops
+{
+public:
+  core_target ()
+  { to_stratum = process_stratum; }
+
+  const target_info &info () const override
+  { return core_target_info; }
+
+  void close () override;
+  void detach (inferior *, int) override;
+  void fetch_registers (struct regcache *, int) override;
+
+  enum target_xfer_status xfer_partial (enum target_object object,
+                                       const char *annex,
+                                       gdb_byte *readbuf,
+                                       const gdb_byte *writebuf,
+                                       ULONGEST offset, ULONGEST len,
+                                       ULONGEST *xfered_len) override;
+  void files_info () override;
+
+  bool thread_alive (ptid_t ptid) override;
+  const struct target_desc *read_description () override;
+
+  const char *pid_to_str (ptid_t) override;
+
+  const char *thread_name (struct thread_info *) override;
+
+  bool has_memory () override;
+  bool has_stack () override;
+  bool has_registers () override;
+  bool info_proc (const char *, enum info_proc_what) override;
+};
+
+/* See gdbcore.h.  */
+struct target_ops *the_core_target;
+
 /* List of all available core_fns.  On gdb startup, each core file
    register reader calls deprecated_add_core_fns() to register
    information on each core format it is prepared to read.  */
@@ -74,21 +119,15 @@ static struct gdbarch *core_gdbarch = NULL;
    unix child targets.  */
 static struct target_section_table *core_data;
 
-static void core_files_info (struct target_ops *);
-
 static struct core_fns *sniff_core_bfd (bfd *);
 
 static int gdb_check_format (bfd *);
 
-static void core_close (struct target_ops *self);
-
 static void core_close_cleanup (void *ignore);
 
 static void add_to_thread_list (bfd *, asection *, void *);
 
-static void init_core_ops (void);
-
-static struct target_ops core_ops;
+static core_target core_ops;
 
 /* An arbitrary identifier for the core inferior.  */
 #define CORELOW_PID 1
@@ -185,7 +224,7 @@ gdb_check_format (bfd *abfd)
    stack spaces as empty.  */
 
 static void
-core_close (struct target_ops *self)
+core_close ()
 {
   if (core_bfd)
     {
@@ -216,7 +255,13 @@ core_close (struct target_ops *self)
 static void
 core_close_cleanup (void *ignore)
 {
-  core_close (NULL);
+  core_close ();
+}
+
+void
+core_target::close ()
+{
+  core_close ();
 }
 
 /* Look for sections whose names start with `.reg/' so that we can
@@ -264,10 +309,10 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
     inferior_ptid = ptid;                      /* Yes, make it current.  */
 }
 
-/* This routine opens and sets up the core file bfd.  */
+/* See gdbcore.h.  */
 
-static void
-core_open (const char *arg, int from_tty)
+void
+core_target_open (const char *arg, int from_tty)
 {
   const char *p;
   int siggy;
@@ -463,10 +508,10 @@ core_open (const char *arg, int from_tty)
     }
 }
 
-static void
-core_detach (struct target_ops *ops, int from_tty)
+void
+core_target::detach (inferior *inf, int from_tty)
 {
-  unpush_target (ops);
+  unpush_target (this);
   reinit_frame_cache ();
   if (from_tty)
     printf_filtered (_("No core file now.\n"));
@@ -585,9 +630,8 @@ get_core_registers_cb (const char *sect_name, int size,
 
 /* We just get all the registers, so we don't use regno.  */
 
-static void
-get_core_registers (struct target_ops *ops,
-                   struct regcache *regcache, int regno)
+void
+core_target::fetch_registers (struct regcache *regcache, int regno)
 {
   int i;
   struct gdbarch *gdbarch;
@@ -619,8 +663,8 @@ get_core_registers (struct target_ops *ops,
       regcache_raw_supply (regcache, i, NULL);
 }
 
-static void
-core_files_info (struct target_ops *t)
+void
+core_target::files_info ()
 {
   print_section_info (core_data, core_bfd);
 }
@@ -655,11 +699,10 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p)
   list->pos += 4;
 }
 
-static enum target_xfer_status
-core_xfer_partial (struct target_ops *ops, enum target_object object,
-                  const char *annex, gdb_byte *readbuf,
-                  const gdb_byte *writebuf, ULONGEST offset,
-                  ULONGEST len, ULONGEST *xfered_len)
+enum target_xfer_status
+core_target::xfer_partial (enum target_object object, const char *annex,
+                          gdb_byte *readbuf, const gdb_byte *writebuf,
+                          ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
 {
   switch (object)
     {
@@ -861,35 +904,13 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
       return TARGET_XFER_E_IO;
 
     default:
-      return ops->beneath->to_xfer_partial (ops->beneath, object,
-                                           annex, readbuf,
-                                           writebuf, offset, len,
-                                           xfered_len);
+      return this->beneath->xfer_partial (object, annex, readbuf,
+                                         writebuf, offset, len,
+                                         xfered_len);
     }
 }
 
 \f
-/* If mourn is being called in all the right places, this could be say
-   `gdb internal error' (since generic_mourn calls
-   breakpoint_init_inferior).  */
-
-static int
-ignore (struct target_ops *ops, struct gdbarch *gdbarch,
-       struct bp_target_info *bp_tgt)
-{
-  return 0;
-}
-
-/* Implement the to_remove_breakpoint method.  */
-
-static int
-core_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
-                       struct bp_target_info *bp_tgt,
-                       enum remove_bp_reason reason)
-{
-  return 0;
-}
-
 
 /* Okay, let's be honest: threads gleaned from a core file aren't
    exactly lively, are they?  On the other hand, if we don't claim
@@ -897,10 +918,10 @@ core_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
    to appear in an "info thread" command, which is quite a useful
    behaviour.
  */
-static int
-core_thread_alive (struct target_ops *ops, ptid_t ptid)
+bool
+core_target::thread_alive (ptid_t ptid)
 {
-  return 1;
+  return true;
 }
 
 /* Ask the current architecture what it knows about this core file.
@@ -908,24 +929,23 @@ core_thread_alive (struct target_ops *ops, ptid_t ptid)
    wrapper could be avoided if targets got a chance to specialize
    core_ops.  */
 
-static const struct target_desc *
-core_read_description (struct target_ops *target)
+const struct target_desc *
+core_target::read_description ()
 {
   if (core_gdbarch && gdbarch_core_read_description_p (core_gdbarch))
     {
       const struct target_desc *result;
 
-      result = gdbarch_core_read_description (core_gdbarch, 
-                                             target, core_bfd);
+      result = gdbarch_core_read_description (core_gdbarch, this, core_bfd);
       if (result != NULL)
        return result;
     }
 
-  return target->beneath->to_read_description (target->beneath);
+  return this->beneath->read_description ();
 }
 
-static const char *
-core_pid_to_str (struct target_ops *ops, ptid_t ptid)
+const char *
+core_target::pid_to_str (ptid_t ptid)
 {
   static char buf[64];
   struct inferior *inf;
@@ -956,8 +976,8 @@ core_pid_to_str (struct target_ops *ops, ptid_t ptid)
   return buf;
 }
 
-static const char *
-core_thread_name (struct target_ops *self, struct thread_info *thr)
+const char *
+core_target::thread_name (struct thread_info *thr)
 {
   if (core_gdbarch
       && gdbarch_core_thread_name_p (core_gdbarch))
@@ -965,29 +985,28 @@ core_thread_name (struct target_ops *self, struct thread_info *thr)
   return NULL;
 }
 
-static int
-core_has_memory (struct target_ops *ops)
+bool
+core_target::has_memory ()
 {
   return (core_bfd != NULL);
 }
 
-static int
-core_has_stack (struct target_ops *ops)
+bool
+core_target::has_stack ()
 {
   return (core_bfd != NULL);
 }
 
-static int
-core_has_registers (struct target_ops *ops)
+bool
+core_target::has_registers ()
 {
   return (core_bfd != NULL);
 }
 
 /* Implement the to_info_proc method.  */
 
-static void
-core_info_proc (struct target_ops *ops, const char *args,
-               enum info_proc_what request)
+bool
+core_target::info_proc (const char *args, enum info_proc_what request)
 {
   struct gdbarch *gdbarch = get_current_arch ();
 
@@ -995,47 +1014,18 @@ core_info_proc (struct target_ops *ops, const char *args,
      method on gdbarch, not 'info_proc'.  */
   if (gdbarch_core_info_proc_p (gdbarch))
     gdbarch_core_info_proc (gdbarch, args, request);
-}
 
-/* Fill in core_ops with its defined operations and properties.  */
-
-static void
-init_core_ops (void)
-{
-  core_ops.to_shortname = "core";
-  core_ops.to_longname = "Local core dump file";
-  core_ops.to_doc =
-    "Use a core file as a target.  Specify the filename of the core file.";
-  core_ops.to_open = core_open;
-  core_ops.to_close = core_close;
-  core_ops.to_detach = core_detach;
-  core_ops.to_fetch_registers = get_core_registers;
-  core_ops.to_xfer_partial = core_xfer_partial;
-  core_ops.to_files_info = core_files_info;
-  core_ops.to_insert_breakpoint = ignore;
-  core_ops.to_remove_breakpoint = core_remove_breakpoint;
-  core_ops.to_thread_alive = core_thread_alive;
-  core_ops.to_read_description = core_read_description;
-  core_ops.to_pid_to_str = core_pid_to_str;
-  core_ops.to_thread_name = core_thread_name;
-  core_ops.to_stratum = process_stratum;
-  core_ops.to_has_memory = core_has_memory;
-  core_ops.to_has_stack = core_has_stack;
-  core_ops.to_has_registers = core_has_registers;
-  core_ops.to_info_proc = core_info_proc;
-  core_ops.to_magic = OPS_MAGIC;
-
-  if (core_target)
-    internal_error (__FILE__, __LINE__, 
-                   _("init_core_ops: core target already exists (\"%s\")."),
-                   core_target->to_longname);
-  core_target = &core_ops;
+  return true;
 }
 
 void
 _initialize_corelow (void)
 {
-  init_core_ops ();
+  if (the_core_target != NULL)
+    internal_error (__FILE__, __LINE__,
+                   _("core target already exists (\"%s\")."),
+                   the_core_target->longname ());
+  the_core_target = &core_ops;
 
-  add_target_with_completer (&core_ops, filename_completer);
+  add_target (core_target_info, core_target_open, filename_completer);
 }
This page took 0.0273 seconds and 4 git commands to generate.