gdb: remove BLOCK_NAMESPACE macro
[binutils-gdb.git] / gdb / probe.c
index 7bc75d8e879bd8cd0932827716cec46c1d13f6d1..f0a40f5face1317b41ad06c0ed8b9336e32c08fa 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"
@@ -36,7 +36,7 @@
 #include "location.h"
 #include <ctype.h>
 #include <algorithm>
-#include "common/gdb_optional.h"
+#include "gdbsupport/gdb_optional.h"
 
 /* Class that implements the static probe methods for "any" probe.  */
 
@@ -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->location = new_probe_location (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));
@@ -695,7 +692,7 @@ probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
   if (!probe.prob)
     return NULL;
 
-  n_args = probe.prob->get_argument_count (frame);
+  n_args = probe.prob->get_argument_count (get_frame_arch (frame));
   if (n >= n_args)
     return NULL;
 
@@ -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;
 }
@@ -818,7 +814,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
   if (pc_probe.prob == NULL)
     error (_("No probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = pc_probe.prob->get_argument_count (frame);
+  n_args = pc_probe.prob->get_argument_count (arch);
   if (sel == -1)
     return value_from_longest (builtin_type (arch)->builtin_int, n_args);
 
@@ -840,7 +836,6 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   int sel = (int) (uintptr_t) data;
   struct bound_probe pc_probe;
   int n_args;
-  struct frame_info *frame = get_selected_frame (NULL);
 
   /* SEL == -1 means "_probe_argc".  */
   gdb_assert (sel >= -1);
@@ -849,7 +844,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   if (pc_probe.prob == NULL)
     error (_("No probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = pc_probe.prob->get_argument_count (frame);
+  n_args = pc_probe.prob->get_argument_count (expr->gdbarch);
 
   if (sel == -1)
     {
@@ -871,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);