/* Machine independent support for QNX Neutrino /proc (process file system)
for GDB. Written by Colin Burgess at QNX Software Systems Limited.
- Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003-2019 Free Software Foundation, Inc.
Contributed by QNX Software Systems Ltd.
#include "regcache.h"
#include "solib.h"
#include "inf-child.h"
-#include "common/filestuff.h"
-#include "common/scoped_fd.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/scoped_fd.h"
#define NULL_PID 0
#define _DEBUG_FLAG_TRACE (_DEBUG_FLAG_TRACE_EXEC|_DEBUG_FLAG_TRACE_RD|\
void mourn_inferior () override;
- void pass_signals (int, unsigned char *) override;
+ void pass_signals (gdb::array_view<const unsigned char>) override;
bool thread_alive (ptid_t ptid) override;
void update_thread_list () override;
- const char *pid_to_str (ptid_t) override;
+ std::string pid_to_str (ptid_t) override;
void interrupt () override;
- bool have_continuable_watchpoint ()
- { return true; }
-
const char *extra_thread_info (struct thread_info *) override;
char *pid_to_exec_file (int pid) override;
static const target_info nto_procfs_target_info = {
"procfs",
N_("QNX Neutrino local or remote process"),
- N_("QNX Neutrino process. target procfs <node>")
+ N_("QNX Neutrino process. target procfs NODE")
};
struct nto_procfs_target_procfs final : public nto_procfs_target
nto_procfs_node = ND_LOCAL_NODE;
nodestr = (arg != NULL) ? xstrdup (arg) : NULL;
- init_thread_list ();
-
if (nodestr)
{
nto_procfs_node = netmgr_strtond (nodestr, &endstr);
{
pid_t tid;
- tid = ptid_get_tid (ptid);
+ tid = ptid.tid ();
devctl (ctl_fd, DCMD_PROC_CURTHREAD, &tid, sizeof (tid), 0);
}
procfs_status status;
int err;
- tid = ptid_get_tid (ptid);
- pid = ptid_get_pid (ptid);
+ tid = ptid.tid ();
+ pid = ptid.pid ();
if (kill (pid, 0) == -1)
return false;
prune_threads ();
- pid = ptid_get_pid (inferior_ptid);
+ pid = inferior_ptid.pid ();
status.tid = 1;
returned different tid, meaning the requested tid no longer exists
(e.g. thread exited). */
continue;
- ptid = ptid_build (pid, 0, tid);
+ ptid = ptid_t (pid, 0, tid);
new_thread = find_thread_ptid (ptid);
if (!new_thread)
new_thread = add_thread (ptid);
if (strcmp (map.info.path, printme.name))
continue;
- /* Lower debug_vaddr is always text, if nessessary, swap. */
+ /* Lower debug_vaddr is always text, if necessary, swap. */
if ((int) map.info.vaddr < (int) printme.text.debug_vaddr)
{
memcpy (&(printme.data), &(printme.text),
printf_unfiltered ("\tUsing the running image of %s %s via %s.\n",
inf->attach_flag ? "attached" : "child",
- target_pid_to_str (inferior_ptid),
+ target_pid_to_str (inferior_ptid).c_str (),
(nodestr != NULL) ? nodestr : "local node");
}
if (exec_file)
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
- target_pid_to_str (pid_to_ptid (pid)));
+ target_pid_to_str (ptid_t (pid)).c_str ());
else
printf_unfiltered ("Attaching to %s\n",
- target_pid_to_str (pid_to_ptid (pid)));
-
- gdb_flush (gdb_stdout);
+ target_pid_to_str (ptid_t (pid)).c_str ());
}
- inferior_ptid = do_attach (pid_to_ptid (pid));
+ inferior_ptid = do_attach (ptid_t (pid));
inf = current_inferior ();
inferior_appeared (inf, pid);
inf->attach_flag = 1;
char path[PATH_MAX];
snprintf (path, PATH_MAX - 1, "%s%s/%d/as",
- (nodestr != NULL) ? nodestr : "", "/proc", ptid_get_pid (ptid));
+ (nodestr != NULL) ? nodestr : "", "/proc", ptid.pid ());
ctl_fd = open (path, O_RDWR);
if (ctl_fd == -1)
error (_("Couldn't open proc file %s, error %d (%s)"), path, errno,
if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
&& status.flags & _DEBUG_FLAG_STOPPED)
- SignalKill (nto_node (), ptid_get_pid (ptid), 0, SIGCONT, 0, 0);
+ SignalKill (nto_node (), ptid.pid (), 0, SIGCONT, 0, 0);
nto_init_solib_absolute_prefix ();
- return ptid_build (ptid_get_pid (ptid), 0, status.tid);
+ return ptid_t (ptid.pid (), 0, status.tid);
}
/* Ask the user what to do when an interrupt is received. */
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
- if (ptid_equal (inferior_ptid, null_ptid))
+ if (inferior_ptid == null_ptid)
{
ourstatus->kind = TARGET_WAITKIND_STOPPED;
ourstatus->value.sig = GDB_SIGNAL_0;
{
int waitval = 0;
- waitpid (ptid_get_pid (inferior_ptid), &waitval, WNOHANG);
+ waitpid (inferior_ptid.pid (), &waitval, WNOHANG);
if (exit_signo)
{
/* Abnormal death. */
}
}
- return ptid_build (status.pid, 0, status.tid);
+ return ptid_t (status.pid, 0, status.tid);
}
/* Read the current values of the inferior's registers, both the
}
/* Fallthru */
default:
- return this->beneath->xfer_partial (object, annex,
- readbuf, writebuf, offset, len,
- xfered_len);
+ return this->beneath ()->xfer_partial (object, annex,
+ readbuf, writebuf, offset, len,
+ xfered_len);
}
}
target_announce_detach ();
if (siggnal)
- SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, 0, 0, 0);
+ SignalKill (nto_node (), inferior_ptid.pid (), 0, 0, 0, 0);
close (ctl_fd);
ctl_fd = -1;
- pid = ptid_get_pid (inferior_ptid);
+ pid = inferior_ptid.pid ();
inferior_ptid = null_ptid;
detach_inferior (pid);
init_thread_list ();
procfs_status status;
sigset_t *run_fault = (sigset_t *) (void *) &run.fault;
- if (ptid_equal (inferior_ptid, null_ptid))
+ if (inferior_ptid == null_ptid)
return;
- procfs_set_thread (ptid_equal (ptid, minus_one_ptid) ? inferior_ptid :
+ procfs_set_thread (ptid == minus_one_ptid ? inferior_ptid :
ptid);
run.flags = _DEBUG_RUN_FAULT | _DEBUG_RUN_TRACE;
{
if (signal_to_pass != status.info.si_signo)
{
- SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0,
+ SignalKill (nto_node (), inferior_ptid.pid (), 0,
signal_to_pass, 0, 0);
run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
}
void
nto_procfs_target::mourn_inferior ()
{
- if (!ptid_equal (inferior_ptid, null_ptid))
+ if (inferior_ptid != null_ptid)
{
- SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, SIGKILL, 0, 0);
+ SignalKill (nto_node (), inferior_ptid.pid (), 0, SIGKILL, 0, 0);
close (ctl_fd);
}
inferior_ptid = null_ptid;
if (fds[2] != STDERR_FILENO)
close (fds[2]);
- inferior_ptid = do_attach (pid_to_ptid (pid));
+ inferior_ptid = do_attach (ptid_t (pid));
procfs_update_thread_list (ops);
inf = current_inferior ();
{
/* FIXME: expected warning? */
/* warning( "Failed to set Kill-on-Last-Close flag: errno = %d(%s)\n",
- errn, strerror(errn) ); */
+ errn, safe_strerror(errn) ); */
}
if (!target_is_pushed (ops))
push_target (ops);
char *data;
ptid_t ptid = regcache->ptid ();
- if (ptid_equal (ptid, null_ptid))
+ if (ptid == null_ptid)
return;
procfs_set_thread (ptid);
/* Set list of signals to be handled in the target. */
void
-nto_procfs_target::pass_signals (int numsigs, unsigned char *pass_signals)
+nto_procfs_target::pass_signals
+ (gdb::array_view<const unsigned char> pass_signals)
{
int signo;
for (signo = 1; signo < NSIG; signo++)
{
int target_signo = gdb_signal_from_host (signo);
- if (target_signo < numsigs && pass_signals[target_signo])
+ if (target_signo < pass_signals.size () && pass_signals[target_signo])
sigdelset (&run.trace, signo);
}
}
-char *
+std::string
nto_procfs_target::pid_to_str (ptid_t ptid)
{
- static char buf[1024];
- int pid, tid, n;
+ int pid, tid;
struct tidinfo *tip;
- pid = ptid_get_pid (ptid);
- tid = ptid_get_tid (ptid);
-
- n = snprintf (buf, 1023, "process %d", pid);
+ pid = ptid.pid ();
+ tid = ptid.tid ();
#if 0 /* NYI */
tip = procfs_thread_info (pid, tid);
snprintf (&buf[n], 1023, " (state = 0x%02x)", tip->state);
#endif
- return buf;
+ return string_printf ("process %d", pid);
}
/* to_can_run implementation for "target procfs". Note this really