objdump: avoid shadowing a libiberty symbol
[deliverable/binutils-gdb.git] / gdb / dtrace-probe.c
index 0114c401af1f662b60e9aae5b2a6168ebdcf541e..2a2eae1f709ba53f2448d6bb53074024cbbc75d0 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-
-/* Local non-gdb includes.  */
-#include "ax-gdb.h"
-#include "ax.h"
+#include "probe.h"
 #include "common/vec.h"
-#include "complaints.h"
 #include "elf-bfd.h"
 #include "gdbtypes.h"
-#include "inferior.h"
-#include "language.h"
-#include "objfiles.h"
 #include "obstack.h"
-#include "parser-defs.h"
-#include "probe.h"
+#include "objfiles.h"
+#include "complaints.h"
 #include "value.h"
+#include "ax.h"
+#include "ax-gdb.h"
+#include "language.h"
+#include "parser-defs.h"
+#include "inferior.h"
 
 /* The type of the ELF sections where we will find the DOF programs
    with information about probes.  */
@@ -83,7 +81,7 @@ public:
   bool is_linespec (const char **linespecp) const override;
 
   /* See probe.h.  */
-  void get_probes (std::vector<probe *> *probesp,
+  void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
                   struct objfile *objfile) const override;
 
   /* See probe.h.  */
@@ -382,7 +380,7 @@ struct dtrace_dof_probe
 static void
 dtrace_process_dof_probe (struct objfile *objfile,
                          struct gdbarch *gdbarch,
-                         std::vector<probe *> *probesp,
+                         std::vector<std::unique_ptr<probe>> *probesp,
                          struct dtrace_dof_hdr *dof,
                          struct dtrace_dof_probe *probe,
                          struct dtrace_dof_provider *provider,
@@ -486,15 +484,14 @@ dtrace_process_dof_probe (struct objfile *objfile,
             int'.  */
           struct type *type = builtin_type (gdbarch)->builtin_long;
 
-         TRY
+         try
            {
              expr = parse_expression_with_language (type_str.c_str (),
                                                     language_c);
            }
-         CATCH (ex, RETURN_MASK_ERROR)
+         catch (const gdb_exception_error &ex)
            {
            }
-         END_CATCH
 
          if (expr != NULL && expr.get ()->elts[0].opcode == OP_TYPE)
            type = expr.get ()->elts[1].type;
@@ -510,7 +507,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
                                            std::move (enablers_copy));
 
       /* Successfully created probe.  */
-      probesp->push_back (ret);
+      probesp->emplace_back (ret);
     }
 }
 
@@ -521,7 +518,8 @@ dtrace_process_dof_probe (struct objfile *objfile,
 
 static void
 dtrace_process_dof (asection *sect, struct objfile *objfile,
-                   std::vector<probe *> *probesp, struct dtrace_dof_hdr *dof)
+                   std::vector<std::unique_ptr<probe>> *probesp,
+                   struct dtrace_dof_hdr *dof)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct dtrace_dof_sect *section;
@@ -836,8 +834,9 @@ dtrace_static_probe_ops::is_linespec (const char **linespecp) const
 /* Implementation of the get_probes method.  */
 
 void
-dtrace_static_probe_ops::get_probes (std::vector<probe *> *probesp,
-                                    struct objfile *objfile) const
+dtrace_static_probe_ops::get_probes
+  (std::vector<std::unique_ptr<probe>> *probesp,
+   struct objfile *objfile) const
 {
   bfd *abfd = objfile->obfd;
   asection *sect = NULL;
@@ -857,13 +856,14 @@ dtrace_static_probe_ops::get_probes (std::vector<probe *> *probesp,
 
          /* Read the contents of the DOF section and then process it to
             extract the information of any probe defined into it.  */
-         if (!bfd_malloc_and_get_section (abfd, sect, &dof))
+         if (bfd_malloc_and_get_section (abfd, sect, &dof) && dof != NULL)
+           dtrace_process_dof (sect, objfile, probesp,
+                               (struct dtrace_dof_hdr *) dof);
+         else
            complaint (_("could not obtain the contents of"
                         "section '%s' in objfile `%s'."),
                       sect->name, abfd->filename);
-      
-         dtrace_process_dof (sect, objfile, probesp,
-                             (struct dtrace_dof_hdr *) dof);
+
          xfree (dof);
        }
     }
This page took 0.026429 seconds and 4 git commands to generate.