aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/hostio.cc62
-rw-r--r--gdbserver/linux-low.cc10
-rw-r--r--gdbserver/linux-low.h2
-rw-r--r--gdbserver/server.cc443
-rw-r--r--gdbserver/target.cc9
-rw-r--r--gdbserver/target.h7
-rw-r--r--gdbserver/tracepoint.cc6
-rw-r--r--gdbserver/utils.cc2
8 files changed, 352 insertions, 189 deletions
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index 17b6179..69729a8 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -89,12 +89,18 @@ require_filename (char **pp, char *filename)
return 0;
}
+template <typename T>
static int
-require_int (char **pp, int *value)
+require_int (char **pp, T *value)
{
+ constexpr bool is_signed = std::is_signed<T>::value;
+
char *p;
int count, firstdigit;
+ /* Max count of hexadecimal digits in T (1 hex digit is 4 bits). */
+ int max_count = sizeof (T) * CHAR_BIT / 4;
+
p = *pp;
*value = 0;
count = 0;
@@ -111,7 +117,8 @@ require_int (char **pp, int *value)
firstdigit = nib;
/* Don't allow overflow. */
- if (count >= 8 || (count == 7 && firstdigit >= 0x8))
+ if (count >= max_count
+ || (is_signed && count == (max_count - 1) && firstdigit >= 0x8))
return -1;
*value = *value * 16 + nib;
@@ -343,7 +350,8 @@ handle_open (char *own_buf)
static void
handle_pread (char *own_buf, int *new_packet_len)
{
- int fd, ret, len, offset, bytes_sent;
+ int fd, ret, len, bytes_sent;
+ off_t offset;
char *p, *data;
static int max_reply_size = -1;
@@ -410,7 +418,8 @@ handle_pread (char *own_buf, int *new_packet_len)
static void
handle_pwrite (char *own_buf, int packet_len)
{
- int fd, ret, len, offset;
+ int fd, ret, len;
+ off_t offset;
char *p, *data;
p = own_buf + strlen ("vFile:pwrite:");
@@ -504,7 +513,48 @@ handle_stat (char *own_buf, int *new_packet_len)
return;
}
- if (lstat (filename, &st) == -1)
+ if (stat (filename, &st) == -1)
+ {
+ hostio_error (own_buf);
+ return;
+ }
+
+ host_to_fileio_stat (&st, &fst);
+
+ bytes_sent = hostio_reply_with_data (own_buf,
+ (char *) &fst, sizeof (fst),
+ new_packet_len);
+
+ /* If the response does not fit into a single packet, do not attempt
+ to return a partial response, but simply fail. */
+ if (bytes_sent < sizeof (fst))
+ write_enn (own_buf);
+}
+
+static void
+handle_lstat (char *own_buf, int *new_packet_len)
+{
+ int ret, bytes_sent;
+ char *p;
+ struct stat st;
+ struct fio_stat fst;
+ char filename[HOSTIO_PATH_MAX];
+
+ p = own_buf + strlen ("vFile:lstat:");
+
+ if (require_filename (&p, filename)
+ || require_end (p))
+ {
+ hostio_packet_error (own_buf);
+ return;
+ }
+
+ if (hostio_fs_pid != 0)
+ ret = the_target->multifs_lstat (hostio_fs_pid, filename, &st);
+ else
+ ret = lstat (filename, &st);
+
+ if (ret == -1)
{
hostio_error (own_buf);
return;
@@ -641,6 +691,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
handle_fstat (own_buf, new_packet_len);
else if (startswith (own_buf, "vFile:stat:"))
handle_stat (own_buf, new_packet_len);
+ else if (startswith (own_buf, "vFile:lstat:"))
+ handle_lstat (own_buf, new_packet_len);
else if (startswith (own_buf, "vFile:close:"))
handle_close (own_buf);
else if (startswith (own_buf, "vFile:unlink:"))
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1d223c1..3964270 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -751,7 +751,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
/* Set the event status. */
event_lwp->waitstatus.set_execd
(make_unique_xstrdup
- (linux_proc_pid_to_exec_file (event_thr->id.lwp ())));
+ (pid_to_exec_file (event_thr->id.lwp ())));
/* Mark the exec status as pending. */
event_lwp->stopped = 1;
@@ -6033,7 +6033,7 @@ linux_process_target::supports_pid_to_exec_file ()
const char *
linux_process_target::pid_to_exec_file (int pid)
{
- return linux_proc_pid_to_exec_file (pid);
+ return linux_proc_pid_to_exec_file (pid, linux_ns_same (pid, LINUX_NS_MNT));
}
bool
@@ -6050,6 +6050,12 @@ linux_process_target::multifs_open (int pid, const char *filename,
}
int
+linux_process_target::multifs_lstat (int pid, const char *filename, struct stat *sb)
+{
+ return linux_mntns_lstat (pid, filename, sb);
+}
+
+int
linux_process_target::multifs_unlink (int pid, const char *filename)
{
return linux_mntns_unlink (pid, filename);
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 7d3e35f..e1c88ee 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -304,6 +304,8 @@ public:
int multifs_open (int pid, const char *filename, int flags,
mode_t mode) override;
+ int multifs_lstat (int pid, const char *filename, struct stat *st) override;
+
int multifs_unlink (int pid, const char *filename) override;
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 0ce40ee..4037b1c 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -51,6 +51,9 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/search.h"
#include "gdbsupport/gdb_argv_vec.h"
+#include "gdbsupport/remote-args.h"
+
+#include <getopt.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
@@ -1017,20 +1020,15 @@ handle_general_set (char *own_buf)
});
}
- for (const auto &iter : set_options)
- {
- thread_info *thread = iter.first;
- gdb_thread_options options = iter.second;
-
- if (thread->thread_options != options)
- {
- threads_debug_printf ("[options for %s are now %s]\n",
- target_pid_to_str (thread->id).c_str (),
- to_string (options).c_str ());
+ for (const auto &[thread, options] : set_options)
+ if (thread->thread_options != options)
+ {
+ threads_debug_printf ("[options for %s are now %s]\n",
+ target_pid_to_str (thread->id).c_str (),
+ to_string (options).c_str ());
- thread->thread_options = options;
- }
- }
+ thread->thread_options = options;
+ }
write_ok (own_buf);
return;
@@ -2863,7 +2861,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+");
@@ -3465,7 +3463,7 @@ handle_v_run (char *own_buf)
else
program_path.set (new_program_name.get ());
- program_args = construct_inferior_arguments (new_argv.get (), true);
+ program_args = gdb::remote_args::join (new_argv.get ());
try
{
@@ -4107,14 +4105,9 @@ static void test_registers_raw_compare_zero_length ()
[[noreturn]] static void
captured_main (int argc, char *argv[])
{
- int bad_attach;
int pid;
- char *arg_end;
- const char *port = NULL;
- char **next_arg = &argv[1];
- volatile int multi_mode = 0;
- volatile int attach = 0;
- int was_running;
+ volatile bool multi_mode = false;
+ volatile bool attach = false;
bool selftest = false;
#if GDB_SELF_TEST
std::vector<const char *> selftest_filters;
@@ -4134,184 +4127,278 @@ captured_main (int argc, char *argv[])
safe_strerror (errno));
}
- while (*next_arg != NULL && **next_arg == '-')
- {
- if (strcmp (*next_arg, "--version") == 0)
+ enum opts { OPT_VERSION = 1, OPT_HELP, OPT_ATTACH, OPT_MULTI, OPT_WRAPPER,
+ OPT_DEBUG, OPT_DEBUG_FILE, OPT_DEBUG_FORMAT, OPT_DISABLE_PACKET,
+ OPT_DISABLE_RANDOMIZATION, OPT_NO_DISABLE_RANDOMIZATION,
+ OPT_STARTUP_WITH_SHELL, OPT_NO_STARTUP_WITH_SHELL, OPT_ONCE,
+ OPT_SELFTEST,
+ };
+
+ static struct option longopts[] =
+ {
+ {"version", no_argument, nullptr, OPT_VERSION},
+ {"help", no_argument, nullptr, OPT_HELP},
+ {"attach", no_argument, nullptr, OPT_ATTACH},
+ {"multi", no_argument, nullptr, OPT_MULTI},
+ {"wrapper", no_argument, nullptr, OPT_WRAPPER},
+ {"debug", optional_argument, nullptr, OPT_DEBUG},
+ {"debug-file", required_argument, nullptr, OPT_DEBUG_FILE},
+ {"debug-format", required_argument, nullptr, OPT_DEBUG_FORMAT},
+ /* --disable-packet is optional_argument only so that we can print a
+ better help list when the argument is missing. */
+ {"disable-packet", optional_argument, nullptr, OPT_DISABLE_PACKET},
+ {"disable-randomization", no_argument, nullptr,
+ OPT_DISABLE_RANDOMIZATION},
+ {"no-disable-randomization", no_argument, nullptr,
+ OPT_NO_DISABLE_RANDOMIZATION},
+ {"startup-with-shell", no_argument, nullptr, OPT_STARTUP_WITH_SHELL},
+ {"no-startup-with-shell", no_argument, nullptr,
+ OPT_NO_STARTUP_WITH_SHELL},
+ {"once", no_argument, nullptr, OPT_ONCE},
+ {"selftest", optional_argument, nullptr, OPT_SELFTEST},
+ {nullptr, no_argument, nullptr, 0}
+ };
+
+ /* Ask getopt_long not to print error messages, we'll do that ourselves.
+ Look for handling of '?' from getopt_long. */
+ opterr = 0;
+
+ int optc, longindex;
+
+ /* The '+' passed to getopt_long here stops ARGV being reordered. In a
+ command line like: 'gdbserver PORT program --arg1 --arg2', the
+ '--arg1' and '--arg2' are arguments to 'program', not to gdbserver.
+ If getopt_long is free to reorder ARGV then it will try to steal those
+ arguments for itself. */
+ while ((longindex = -1,
+ optc = getopt_long (argc, argv, "+", longopts, &longindex)) != -1)
+ {
+ /* We only support '--option=value' form, not '--option value'. To
+ achieve this, if global OPTARG points to the start of the previous
+ ARGV entry, then we must have used the second (unsupported) form,
+ so set OPTARG to NULL and decrement OPTIND to make it appear that
+ there was no value passed. If the option requires an argument,
+ then this means we should convert OPTC to '?' to indicate an
+ error. */
+ if (longindex != -1
+ && longopts[longindex].has_arg != no_argument)
{
- gdbserver_version ();
- exit (0);
+ if (optarg == argv[optind - 1])
+ {
+ optarg = nullptr;
+ --optind;
+ }
+
+ if (longopts[longindex].has_arg == required_argument
+ && optarg == nullptr)
+ optc = '?';
}
- else if (strcmp (*next_arg, "--help") == 0)
+
+ switch (optc)
{
+ case OPT_VERSION:
+ gdbserver_version ();
+ exit (0);
+
+ case OPT_HELP:
gdbserver_usage (stdout);
exit (0);
- }
- else if (strcmp (*next_arg, "--attach") == 0)
- attach = 1;
- else if (strcmp (*next_arg, "--multi") == 0)
- multi_mode = 1;
- else if (strcmp (*next_arg, "--wrapper") == 0)
- {
- char **tmp;
- next_arg++;
+ case OPT_ATTACH:
+ attach = true;
+ break;
- tmp = next_arg;
- while (*next_arg != NULL && strcmp (*next_arg, "--") != 0)
- {
- wrapper_argv += *next_arg;
- wrapper_argv += ' ';
- next_arg++;
- }
+ case OPT_MULTI:
+ multi_mode = true;
+ break;
- if (!wrapper_argv.empty ())
- {
- /* Erase the last whitespace. */
- wrapper_argv.erase (wrapper_argv.end () - 1);
- }
+ case OPT_WRAPPER:
+ {
+ int original_optind = optind;
- if (next_arg == tmp || *next_arg == NULL)
- {
- gdbserver_usage (stderr);
- exit (1);
- }
+ while (argv[optind] != nullptr
+ && strcmp (argv[optind], "--") != 0)
+ {
+ wrapper_argv += argv[optind];
+ wrapper_argv += ' ';
+ ++optind;
+ }
- /* Consume the "--". */
- *next_arg = NULL;
- }
- else if (startswith (*next_arg, "--debug="))
- {
- try
- {
- parse_debug_options ((*next_arg) + sizeof ("--debug=") - 1);
- }
- catch (const gdb_exception_error &exception)
- {
- fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.what ());
- exit (1);
- }
- }
- else if (strcmp (*next_arg, "--debug") == 0)
- {
- try
- {
- parse_debug_options ("");
- }
- catch (const gdb_exception_error &exception)
- {
- fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.what ());
- exit (1);
- }
- }
- else if (startswith (*next_arg, "--debug-format="))
- {
- std::string error_msg
- = parse_debug_format_options ((*next_arg)
- + sizeof ("--debug-format=") - 1, 0);
+ if (!wrapper_argv.empty ())
+ {
+ /* Erase the last whitespace. */
+ wrapper_argv.erase (wrapper_argv.end () - 1);
+ }
- if (!error_msg.empty ())
- {
- fprintf (stderr, "%s", error_msg.c_str ());
- exit (1);
- }
- }
- else if (startswith (*next_arg, "--debug-file="))
- debug_set_output ((*next_arg) + sizeof ("--debug-file=") -1);
- else if (strcmp (*next_arg, "--disable-packet") == 0)
- {
- gdbserver_show_disableable (stdout);
- exit (0);
- }
- else if (startswith (*next_arg, "--disable-packet="))
- {
- char *packets = *next_arg += sizeof ("--disable-packet=") - 1;
- char *saveptr;
- for (char *tok = strtok_r (packets, ",", &saveptr);
- tok != NULL;
- tok = strtok_r (NULL, ",", &saveptr))
- {
- if (strcmp ("vCont", tok) == 0)
- disable_packet_vCont = true;
- else if (strcmp ("Tthread", tok) == 0)
- disable_packet_Tthread = true;
- else if (strcmp ("qC", tok) == 0)
- disable_packet_qC = true;
- else if (strcmp ("qfThreadInfo", tok) == 0)
- disable_packet_qfThreadInfo = true;
- else if (strcmp ("T", tok) == 0)
- disable_packet_T = true;
- else if (strcmp ("threads", tok) == 0)
- {
+ if (original_optind == optind || argv[optind] == nullptr)
+ {
+ gdbserver_usage (stderr);
+ exit (1);
+ }
+
+ /* Consume the "--". */
+ ++optind;
+ }
+ break;
+
+ case OPT_DEBUG:
+ {
+ const char *debug_opt = (optarg == nullptr) ? "" : optarg;
+ try
+ {
+ parse_debug_options (debug_opt);
+ }
+ catch (const gdb_exception_error &exception)
+ {
+ fflush (stdout);
+ fprintf (stderr, "gdbserver: %s\n", exception.what ());
+ exit (1);
+ }
+ }
+ break;
+
+ case OPT_DEBUG_FILE:
+ {
+ gdb_assert (optarg != nullptr);
+ debug_set_output (optarg);
+ }
+ break;
+
+ case OPT_DEBUG_FORMAT:
+ {
+ gdb_assert (optarg != nullptr);
+ std::string error_msg
+ = parse_debug_format_options (optarg, 0);
+
+ if (!error_msg.empty ())
+ {
+ fprintf (stderr, "%s", error_msg.c_str ());
+ exit (1);
+ }
+ }
+ break;
+
+ case OPT_DISABLE_PACKET:
+ {
+ char *packets = optarg;
+ if (packets == nullptr)
+ {
+ gdbserver_show_disableable (stdout);
+ exit (1);
+ }
+ char *saveptr;
+ for (char *tok = strtok_r (packets, ",", &saveptr);
+ tok != nullptr;
+ tok = strtok_r (nullptr, ",", &saveptr))
+ {
+ if (strcmp ("vCont", tok) == 0)
disable_packet_vCont = true;
+ else if (strcmp ("Tthread", tok) == 0)
disable_packet_Tthread = true;
+ else if (strcmp ("qC", tok) == 0)
disable_packet_qC = true;
+ else if (strcmp ("qfThreadInfo", tok) == 0)
disable_packet_qfThreadInfo = true;
- }
- else
- {
- fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
- tok);
- gdbserver_show_disableable (stderr);
- exit (1);
- }
- }
- }
- else if (strcmp (*next_arg, "-") == 0)
- {
- /* "-" specifies a stdio connection and is a form of port
- specification. */
- port = STDIO_CONNECTION_NAME;
+ else if (strcmp ("T", tok) == 0)
+ disable_packet_T = true;
+ else if (strcmp ("threads", tok) == 0)
+ {
+ disable_packet_vCont = true;
+ disable_packet_Tthread = true;
+ disable_packet_qC = true;
+ disable_packet_qfThreadInfo = true;
+ }
+ else
+ {
+ fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
+ tok);
+ gdbserver_show_disableable (stderr);
+ exit (1);
+ }
+ }
+ }
+ break;
- /* Implying --once here prevents a hang after stdin has been closed. */
- run_once = true;
+ case OPT_DISABLE_RANDOMIZATION:
+ cs.disable_randomization = 1;
+ break;
- next_arg++;
+ case OPT_NO_DISABLE_RANDOMIZATION:
+ cs.disable_randomization = 0;
+ break;
+
+ case OPT_STARTUP_WITH_SHELL:
+ startup_with_shell = true;
break;
- }
- else if (strcmp (*next_arg, "--disable-randomization") == 0)
- cs.disable_randomization = 1;
- else if (strcmp (*next_arg, "--no-disable-randomization") == 0)
- cs.disable_randomization = 0;
- else if (strcmp (*next_arg, "--startup-with-shell") == 0)
- startup_with_shell = true;
- else if (strcmp (*next_arg, "--no-startup-with-shell") == 0)
- startup_with_shell = false;
- else if (strcmp (*next_arg, "--once") == 0)
- run_once = true;
- else if (strcmp (*next_arg, "--selftest") == 0)
- selftest = true;
- else if (startswith (*next_arg, "--selftest="))
- {
- selftest = true;
+ case OPT_NO_STARTUP_WITH_SHELL:
+ startup_with_shell = false;
+ break;
+
+ case OPT_ONCE:
+ run_once = true;
+ break;
+
+ case OPT_SELFTEST:
+ {
+ selftest = true;
+ if (optarg != nullptr)
+ {
#if GDB_SELF_TEST
- const char *filter = *next_arg + strlen ("--selftest=");
- if (*filter == '\0')
- {
- fprintf (stderr, _("Error: selftest filter is empty.\n"));
- exit (1);
- }
+ if (*optarg == '\0')
+ {
+ fprintf (stderr, _("Error: selftest filter is empty.\n"));
+ exit (1);
+ }
- selftest_filters.push_back (filter);
+ selftest_filters.push_back (optarg);
#endif
- }
- else
- {
- fprintf (stderr, "Unknown argument: %s\n", *next_arg);
+ }
+ }
+ break;
+
+ case '?':
+ /* Figuring out which element of ARGV contained the invalid
+ argument is not simple. There are a couple of cases we need
+ to consider.
+
+ (1) Something like '-x'. gdbserver doesn't support single
+ character options, so a '-' followed by a character is
+ always invalid. In this case global OPTOPT will be set to
+ 'x', and global OPTIND will point to the next ARGV entry.
+
+ (2) Something like '-xyz'. gdbserver doesn't support single
+ dash arguments for its command line options. The
+ getopt_long call treats this like '-x -y -z', in which
+ case global OPTOPT is set to 'x' and global OPTIND will
+ point to this ARGV entry.
+
+ (3) Something like '--unknown'. This is just an unknown
+ double dash argument. Global OPTOPT is set to '\0', and
+ global OPTIND points to the next ARGV entry. */
+ std::string bad_arg;
+ if (optopt == '\0' || argv[optind] == nullptr
+ || argv[optind][0] != '-' || argv[optind][1] != optopt)
+ bad_arg = argv[optind - 1];
+ else
+ bad_arg = argv[optind];
+
+ fprintf (stderr, "Unknown argument: %s\n", bad_arg.c_str ());
exit (1);
}
-
- next_arg++;
- continue;
}
- if (port == NULL)
+ const char *port = argv[optind];
+ ++optind;
+ if (port != nullptr && strcmp (port, "-") == 0)
{
- port = *next_arg;
- next_arg++;
+ port = STDIO_CONNECTION_NAME;
+
+ /* Implying --once here prevents a hang after stdin has been closed. */
+ run_once = true;
}
+
+ char **next_arg = &argv[optind];
if ((port == NULL || (!attach && !multi_mode && *next_arg == NULL))
&& !selftest)
{
@@ -4332,24 +4419,25 @@ captured_main (int argc, char *argv[])
if (port != NULL)
remote_prepare (port);
- bad_attach = 0;
+ bool bad_attach = false;
pid = 0;
/* --attach used to come after PORT, so allow it there for
compatibility. */
if (*next_arg != NULL && strcmp (*next_arg, "--attach") == 0)
{
- attach = 1;
+ attach = true;
next_arg++;
}
+ char *arg_end;
if (attach
&& (*next_arg == NULL
|| (*next_arg)[0] == '\0'
|| (pid = strtoul (*next_arg, &arg_end, 0)) == 0
|| *arg_end != '\0'
|| next_arg[1] != NULL))
- bad_attach = 1;
+ bad_attach = true;
if (bad_attach)
{
@@ -4414,11 +4502,12 @@ captured_main (int argc, char *argv[])
if (current_thread != nullptr)
current_process ()->dlls_changed = false;
+ bool was_running;
if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
|| cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
- was_running = 0;
+ was_running = false;
else
- was_running = 1;
+ was_running = true;
if (!was_running && !multi_mode)
error ("No program to debug");
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4838b39..c400174c 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -258,7 +258,7 @@ target_pid_to_str (ptid_t ptid)
else if (ptid.tid () != 0)
return string_printf("Thread %d.0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
else if (ptid.lwp () != 0)
return string_printf("LWP %d.%ld",
ptid.pid (), ptid.lwp ());
@@ -773,6 +773,13 @@ process_stratum_target::multifs_open (int pid, const char *filename,
}
int
+process_stratum_target::multifs_lstat (int pid, const char *filename,
+ struct stat *sb)
+{
+ return lstat (filename, sb);
+}
+
+int
process_stratum_target::multifs_unlink (int pid, const char *filename)
{
return unlink (filename);
diff --git a/gdbserver/target.h b/gdbserver/target.h
index af788e2..66ca72f 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -31,6 +31,7 @@
#include "gdbsupport/btrace-common.h"
#include <vector>
#include "gdbsupport/byte-vector.h"
+#include <sys/stat.h>
struct emit_ops;
struct process_info;
@@ -441,6 +442,12 @@ public:
virtual int multifs_open (int pid, const char *filename,
int flags, mode_t mode);
+ /* Multiple-filesystem-aware lstat. Like lstat(2), but operating in
+ the filesystem as it appears to process PID. Systems where all
+ processes share a common filesystem should not override this.
+ The default behavior is to use lstat(2). */
+ virtual int multifs_lstat (int pid, const char *filename, struct stat *sb);
+
/* Multiple-filesystem-aware unlink. Like unlink(2), but operates
in the filesystem as it appears to process PID. Systems where
all processes share a common filesystem should not override this.
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 715cc63..b308c82 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -3461,8 +3461,8 @@ cmd_qtstatus (char *packet)
free_space (), phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
circular_trace_buffer,
disconnected_tracing,
- phex_nz (tracing_start_time, sizeof (tracing_start_time)),
- phex_nz (tracing_stop_time, sizeof (tracing_stop_time)),
+ phex_nz (tracing_start_time),
+ phex_nz (tracing_stop_time),
buf1, buf2);
}
@@ -4990,7 +4990,7 @@ build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data)
dataptr += sizeof (mlen);
string_xml_appendf (*buffer,
"<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ paddress (maddr), phex_nz (mlen));
break;
}
case 'V':
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index 092fe47..a86405e 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -102,5 +102,5 @@ internal_vwarning (const char *file, int line, const char *fmt, va_list args)
const char *
paddress (CORE_ADDR addr)
{
- return phex_nz (addr, sizeof (CORE_ADDR));
+ return phex_nz (addr);
}