PR29482 - strip: heap-buffer-overflow
[binutils-gdb.git] / gdb / probe.c
index 8b108d6b02dce8e8dc87a7a01244199b740e93e6..ad7af77f72228238592faae72d3de732016854f6 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic static probe support for GDB.
 
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
+   Copyright (C) 2012-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -27,7 +27,7 @@
 #include "progspace.h"
 #include "filenames.h"
 #include "linespec.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "frame.h"
 #include "arch-utils.h"
 #include "value.h"
@@ -114,7 +114,7 @@ parse_probes_in_pspace (const static_probe_ops *spops,
 /* See definition in probe.h.  */
 
 std::vector<symtab_and_line>
-parse_probes (const struct event_location *location,
+parse_probes (const location_spec *locspec,
              struct program_space *search_pspace,
              struct linespec_result *canonical)
 {
@@ -122,8 +122,8 @@ parse_probes (const struct event_location *location,
   char *objfile_namestr = NULL, *provider = NULL, *name, *p;
   const char *arg_start, *cs;
 
-  gdb_assert (event_location_type (location) == PROBE_LOCATION);
-  arg_start = get_probe_location (location);
+  gdb_assert (locspec->type () == PROBE_LOCATION_SPEC);
+  arg_start = locspec->to_string ();
 
   cs = arg_start;
   const static_probe_ops *spops = probe_linespec_to_static_ops (&cs);
@@ -185,9 +185,7 @@ parse_probes (const struct event_location *location,
     }
   else
     {
-      struct program_space *pspace;
-
-      ALL_PSPACES (pspace)
+      for (struct program_space *pspace : program_spaces)
        parse_probes_in_pspace (spops, pspace, objfile_namestr,
                                provider, name, &result);
     }
@@ -206,7 +204,7 @@ parse_probes (const struct event_location *location,
       std::string canon (arg_start, arg_end - arg_start);
       canonical->special_display = 1;
       canonical->pre_expanded = 1;
-      canonical->location = new_probe_location (canon.c_str ());
+      canonical->locspec = new_probe_location_spec (std::move (canon));
     }
 
   return result;
@@ -573,9 +571,8 @@ info_probes_for_spops (const char *arg, int from_tty,
        ui_out_emit_tuple tuple_emitter (current_uiout, "probe");
 
        current_uiout->field_string ("type", probe_type);
-       current_uiout->field_string ("provider",
-                                    probe.prob->get_provider ().c_str ());
-       current_uiout->field_string ("name", probe.prob->get_name ().c_str ());
+       current_uiout->field_string ("provider", probe.prob->get_provider ());
+       current_uiout->field_string ("name", probe.prob->get_name ());
        current_uiout->field_core_addr ("addr", probe.prob->get_gdbarch (),
                                        probe.prob->get_relocated_address
                                        (probe.objfile));
@@ -790,8 +787,7 @@ If you specify TYPE, there may be additional arguments needed by the\n\
 subcommand.\n\
 If you do not specify any argument, or specify `all', then the command\n\
 will show information about all types of probes."),
-                   &info_probes_cmdlist, "info probes ",
-                   0/*allow-unknown*/, &infolist);
+                   &info_probes_cmdlist, 0/*allow-unknown*/, &infolist);
 
   return &info_probes_cmdlist;
 }
@@ -870,14 +866,14 @@ static const struct internalvar_funcs probe_funcs =
 {
   compute_probe_arg,
   compile_probe_arg,
-  NULL
 };
 
 
 std::vector<const static_probe_ops *> all_static_probe_ops;
 
+void _initialize_probe ();
 void
-_initialize_probe (void)
+_initialize_probe ()
 {
   all_static_probe_ops.push_back (&any_static_probe_ops);