]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb set and map in mi-main.c
authorTom Tromey <tom@tromey.com>
Tue, 25 Feb 2025 14:58:59 +0000 (07:58 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 11 Mar 2025 14:40:06 +0000 (08:40 -0600)
This changes mi-main.c to use gdb::unordered_set and
gdb::unordered_map.

this may change the order of core ids that are emitted, but that seems
fine as MI generally doesn't guarantee ordering.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/mi/mi-main.c

index 1b5d9fb102196e09979ef83989fc49c0b904dae6..1ae54d0d36c01cb5f65c567c3bd6295a1da379f7 100644 (file)
@@ -57,8 +57,8 @@
 #include <chrono>
 #include "progspace-and-thread.h"
 #include "gdbsupport/rsp-low.h"
-#include <set>
-#include <map>
+#include "gdbsupport/unordered_map.h"
+#include "gdbsupport/unordered_set.h"
 
 enum
   {
@@ -583,13 +583,13 @@ mi_cmd_thread_info (const char *command, const char *const *argv, int argc)
 
 static void
 print_one_inferior (struct inferior *inferior, bool recurse,
-                   const std::set<int> &ids)
+                   const gdb::unordered_set<int> &ids)
 {
   struct ui_out *uiout = current_uiout;
 
   if (ids.empty () || (ids.find (inferior->pid) != ids.end ()))
     {
-      std::set<int> cores;
+      gdb::unordered_set<int> cores;
       ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       uiout->field_fmt ("id", "i%d", inferior->num);
@@ -648,13 +648,13 @@ output_cores (struct ui_out *uiout, const char *field_name, const char *xcores)
 }
 
 static void
-list_available_thread_groups (const std::set<int> &ids, int recurse)
+list_available_thread_groups (const gdb::unordered_set<int> &ids, int recurse)
 {
   struct ui_out *uiout = current_uiout;
 
   /* This keeps a map from integer (pid) to vector of struct osdata_item.
      The vector contains information about all threads for the given pid.  */
-  std::map<int, std::vector<osdata_item>> tree;
+  gdb::unordered_map<int, std::vector<osdata_item>> tree;
 
   /* get_osdata will throw if it cannot return data.  */
   std::unique_ptr<osdata> data = get_osdata ("processes");
@@ -731,7 +731,7 @@ mi_cmd_list_thread_groups (const char *command, const char *const *argv,
   struct ui_out *uiout = current_uiout;
   int available = 0;
   int recurse = 0;
-  std::set<int> ids;
+  gdb::unordered_set<int> ids;
 
   enum opt
   {