aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gdbserver/server.cc')
-rw-r--r--gdbserver/server.cc50
1 files changed, 42 insertions, 8 deletions
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index fb1a3f8..ab69400 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1,5 +1,5 @@
/* Main code for remote server for GDB.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -35,7 +35,7 @@
#include "dll.h"
#include "hostio.h"
#include <vector>
-#include <unordered_map>
+#include "gdbsupport/unordered_map.h"
#include "gdbsupport/common-inferior.h"
#include "gdbsupport/job-control.h"
#include "gdbsupport/environ.h"
@@ -51,6 +51,7 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/search.h"
#include "gdbsupport/gdb_argv_vec.h"
+#include "gdbsupport/remote-args.h"
/* PBUFSIZ must also be at least as big as IPA_CMD_BUF_SIZE, because
the client state data is passed directly to some agent
@@ -952,7 +953,7 @@ handle_general_set (char *own_buf)
It's nicer if we only print the final options for each TID,
and if we only print about it if the options changed compared
to the options that were previously set on the thread. */
- std::unordered_map<thread_info *, gdb_thread_options> set_options;
+ gdb::unordered_map<thread_info *, gdb_thread_options> set_options;
while (*p != '\0')
{
@@ -1981,6 +1982,7 @@ handle_qxfer_threads_worker (thread_info *thread, std::string *buffer)
int core = target_core_of_thread (ptid);
char core_s[21];
const char *name = target_thread_name (ptid);
+ std::string id_str = target_thread_id_str (thread);
int handle_len;
gdb_byte *handle;
bool handle_status = target_thread_handle (ptid, &handle, &handle_len);
@@ -2005,6 +2007,9 @@ handle_qxfer_threads_worker (thread_info *thread, std::string *buffer)
if (name != NULL)
string_xml_appendf (*buffer, " name=\"%s\"", name);
+ if (!id_str.empty ())
+ string_xml_appendf (*buffer, " id_str=\"%s\"", id_str.c_str ());
+
if (handle_status)
{
char *handle_s = (char *) alloca (handle_len * 2 + 1);
@@ -2859,7 +2864,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
{
char *end_buf = own_buf + strlen (own_buf);
sprintf (end_buf, ";QThreadOptions=%s",
- phex_nz (supported_options, sizeof (supported_options)));
+ phex_nz (supported_options));
}
strcat (own_buf, ";QThreadEvents+");
@@ -3461,7 +3466,7 @@ handle_v_run (char *own_buf)
else
program_path.set (new_program_name.get ());
- program_args = construct_inferior_arguments (new_argv.get ());
+ program_args = gdb::remote_args::join (new_argv.get ());
try
{
@@ -4067,7 +4072,34 @@ test_memory_tagging_functions (void)
&& tags.size () == 5);
}
-} // namespace selftests
+/* Exercise the behavior of doing a 0-length comparison for a register in a
+ register buffer, which should return true. */
+
+static void test_registers_raw_compare_zero_length ()
+{
+ /* Start off with a dummy target description. */
+ target_desc dummy_tdesc;
+
+ /* Make it 8 bytes long. */
+ dummy_tdesc.registers_size = 8;
+
+ /* Add a couple dummy 32-bit registers. */
+ dummy_tdesc.reg_defs.emplace_back ("r0", 0, 32);
+ dummy_tdesc.reg_defs.emplace_back ("r1", 32, 32);
+
+ /* Create our dummy register cache so we can invoke the raw_compare method
+ we want to validate. */
+ regcache dummy_regcache (&dummy_tdesc);
+
+ /* Create a dummy byte buffer we can pass to the raw_compare method. */
+ gdb_byte dummy_buffer[8];
+
+ /* Validate the 0-length comparison (due to the comparison offset being
+ equal to the length of the register) returns true. */
+ SELF_CHECK (dummy_regcache.raw_compare (0, dummy_buffer, 4));
+}
+
+} /* namespace selftests */
#endif /* GDB_SELF_TEST */
/* Main function. This is called by the real "main" function,
@@ -4090,6 +4122,8 @@ captured_main (int argc, char *argv[])
selftests::register_test ("remote_memory_tagging",
selftests::test_memory_tagging_functions);
+ selftests::register_test ("test_registers_raw_compare_zero_length",
+ selftests::test_registers_raw_compare_zero_length);
#endif
current_directory = getcwd (NULL, 0);
@@ -4351,7 +4385,7 @@ captured_main (int argc, char *argv[])
int n = argc - (next_arg - argv);
program_args
- = construct_inferior_arguments ({&next_arg[1], &next_arg[n]});
+ = construct_inferior_arguments ({&next_arg[1], &next_arg[n]}, true);
/* Wait till we are at first instruction in program. */
target_create_inferior (program_path.get (), program_args);
@@ -5117,5 +5151,5 @@ void
reset ()
{}
-} // namespace selftests
+} /* namespace selftests */
#endif /* GDB_SELF_TEST */