本文整理汇总了C++中ptid_build函数的典型用法代码示例。如果您正苦于以下问题:C++ ptid_build函数的具体用法?C++ ptid_build怎么用?C++ ptid_build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ptid_build函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nto_find_new_threads
static void
nto_find_new_threads (struct nto_inferior *nto_inferior)
{
pthread_t tid;
TRACE ("%s pid:%d\n", __func__, nto_inferior->pid);
if (nto_inferior->ctl_fd == -1)
return;
for (tid = 1;; ++tid)
{
procfs_status status;
ptid_t ptid;
int err;
status.tid = tid;
err = devctl (nto_inferior->ctl_fd, DCMD_PROC_TIDSTATUS, &status,
sizeof (status), 0);
if (err != EOK || status.tid == 0)
break;
/* All threads in between are gone. */
while (tid != status.tid || status.state == STATE_DEAD)
{
struct thread_info *ti;
ptid = ptid_build (nto_inferior->pid, tid, 0);
ti = find_thread_ptid (ptid);
if (ti != NULL)
{
TRACE ("Removing thread %d\n", tid);
remove_thread (ti);
}
if (tid == status.tid)
break;
++tid;
}
if (status.state != STATE_DEAD)
{
TRACE ("Adding thread %d\n", tid);
ptid = ptid_build (nto_inferior->pid, tid, 0);
if (!find_thread_ptid (ptid))
add_thread (ptid, NULL);
}
}
}
示例2: nbsd_update_thread_list
static void
nbsd_update_thread_list (struct target_ops *ops)
{
int retval;
ptid_t ptid;
if (nbsd_thread_active == 0)
return;
if (ptid_equal (inferior_ptid, minus_one_ptid))
{
printf_filtered ("No process.\n");
return;
}
if (target_has_execution)
{
struct ptrace_lwpinfo pl;
pl.pl_lwpid = 0;
retval = ptrace (PT_LWPINFO, ptid_get_pid(inferior_ptid), (void *)&pl, sizeof(pl));
while ((retval != -1) && pl.pl_lwpid != 0)
{
ptid = ptid_build (ptid_get_pid (main_ptid), pl.pl_lwpid, 0);
if (!in_thread_list (ptid))
add_thread (ptid);
retval = ptrace (PT_LWPINFO, ptid_get_pid(inferior_ptid), (void *)&pl, sizeof(pl));
}
}
}
示例3: add_to_thread_list
static void
add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
{
ptid_t ptid;
int core_tid;
int pid, lwpid;
asection *reg_sect = (asection *) reg_sect_arg;
if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
return;
core_tid = atoi (bfd_section_name (abfd, asect) + 5);
pid = bfd_core_file_pid (core_bfd);
if (pid == 0)
{
core_has_fake_pid = 1;
pid = CORELOW_PID;
}
lwpid = core_tid;
if (current_inferior ()->pid == 0)
inferior_appeared (current_inferior (), pid);
ptid = ptid_build (pid, lwpid, 0);
add_thread (ptid);
/* Warning, Will Robinson, looking at BFD private data! */
if (reg_sect != NULL
&& asect->filepos == reg_sect->filepos) /* Did we find .reg? */
inferior_ptid = ptid; /* Yes, make it current. */
}
示例4: find_active_thread
static ptid_t
find_active_thread (void)
{
int val;
td_thread_t *thread;
td_thread_info_t ti;
struct ptrace_lwpinfo pl;
if (!ptid_equal (cached_thread, minus_one_ptid))
return cached_thread;
if (target_has_execution)
{
pl.pl_lwpid = 0;
val = ptrace (PT_LWPINFO, ptid_get_pid(inferior_ptid), (void *)&pl, sizeof(pl));
while ((val != -1) && (pl.pl_lwpid != 0) &&
(pl.pl_event != PL_EVENT_SIGNAL)) {
val = ptrace (PT_LWPINFO, ptid_get_pid(inferior_ptid), (void *)&pl, sizeof(pl));
}
if (pl.pl_lwpid == 0)
/* found no "active" thread, stay with current */
pl.pl_lwpid = inferior_ptid.lwp;
}
else
{
return inferior_ptid;
}
cached_thread = ptid_build (ptid_get_pid (main_ptid), pl.pl_lwpid, 0);
return cached_thread;
}
示例5: attach_thread
static int
attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
{
struct process_info *proc = current_process ();
int pid = pid_of (proc);
ptid_t ptid = ptid_build (pid, ti_p->ti_lid, 0);
struct lwp_info *lwp;
int err;
if (debug_threads)
debug_printf ("Attaching to thread %ld (LWP %d)\n",
(unsigned long) ti_p->ti_tid, ti_p->ti_lid);
err = linux_attach_lwp (ptid);
if (err != 0)
{
warning ("Could not attach to thread %ld (LWP %d): %s\n",
(unsigned long) ti_p->ti_tid, ti_p->ti_lid,
linux_ptrace_attach_fail_reason_string (ptid, err));
return 0;
}
lwp = find_lwp_pid (ptid);
gdb_assert (lwp != NULL);
lwp->thread_known = 1;
lwp->th = *th_p;
return 1;
}
示例6: obsd_update_thread_list
static void
obsd_update_thread_list (struct target_ops *ops)
{
pid_t pid = ptid_get_pid (inferior_ptid);
struct ptrace_thread_state pts;
prune_threads ();
if (ptrace (PT_GET_THREAD_FIRST, pid, (caddr_t)&pts, sizeof pts) == -1)
perror_with_name (("ptrace"));
while (pts.pts_tid != -1)
{
ptid_t ptid = ptid_build (pid, pts.pts_tid, 0);
if (!in_thread_list (ptid))
{
if (ptid_get_lwp (inferior_ptid) == 0)
thread_change_ptid (inferior_ptid, ptid);
else
add_thread (ptid);
}
if (ptrace (PT_GET_THREAD_NEXT, pid, (caddr_t)&pts, sizeof pts) == -1)
perror_with_name (("ptrace"));
}
}
示例7: nbsd_thread_proc_setregs
static int
nbsd_thread_proc_setregs (void *arg, int regset, int lwp, void *buf)
{
struct nbsd_thread_proc_arg *a = (struct nbsd_thread_proc_arg *) arg;
struct regcache *cache = a->cache;
struct target_ops *ops = a->ops;
struct cleanup *old_chain;
struct target_ops *beneath = find_target_beneath (ops);
int ret;
ret = 0;
old_chain = save_inferior_ptid ();
switch (regset)
{
case 0:
supply_gregset(cache, (gregset_t *)buf);
break;
case 1:
#ifdef HAVE_FPREGS
supply_fpregset(cache, (fpregset_t *)buf);
#endif
break;
default: /* XXX need to handle other reg sets: SSE, AltiVec, etc. */
ret = TD_ERR_INVAL;
}
/* Storing registers requires that inferior_ptid is a LWP value
rather than a thread value. */
inferior_ptid = ptid_build (ptid_get_pid (main_ptid), lwp, 0);
beneath->to_store_registers (beneath, cache, -1);
do_cleanups (old_chain);
return ret;
}
示例8: nto_request_interrupt
static void
nto_request_interrupt (void)
{
TRACE ("%s\n", __func__);
nto_set_thread (ptid_build (nto_inferior.pid, 1, 0));
if (EOK != devctl (nto_inferior.ctl_fd, DCMD_PROC_STOP, NULL, 0, 0))
TRACE ("Error stopping inferior.\n");
}
示例9: do_attach
static pid_t
do_attach (pid_t pid)
{
procfs_status status;
struct sigevent event;
if (nto_inferior.ctl_fd != -1)
{
close (nto_inferior.ctl_fd);
init_nto_inferior (&nto_inferior);
}
xsnprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
nto_inferior.ctl_fd = open (nto_inferior.nto_procfs_path, O_RDWR);
if (nto_inferior.ctl_fd == -1)
{
TRACE ("Failed to open %s\n", nto_inferior.nto_procfs_path);
init_nto_inferior (&nto_inferior);
return -1;
}
if (devctl (nto_inferior.ctl_fd, DCMD_PROC_STOP, &status, sizeof (status), 0)
!= EOK)
{
do_detach ();
return -1;
}
nto_inferior.pid = pid;
/* Define a sigevent for process stopped notification. */
event.sigev_notify = SIGEV_SIGNAL_THREAD;
event.sigev_signo = SIGUSR1;
event.sigev_code = 0;
event.sigev_value.sival_ptr = NULL;
event.sigev_priority = -1;
devctl (nto_inferior.ctl_fd, DCMD_PROC_EVENT, &event, sizeof (event), 0);
if (devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status),
0) == EOK
&& (status.flags & _DEBUG_FLAG_STOPPED))
{
ptid_t ptid;
struct process_info *proc;
kill (pid, SIGCONT);
ptid = ptid_build (status.pid, status.tid, 0);
the_low_target.arch_setup ();
proc = add_process (status.pid, 1);
proc->tdesc = nto_tdesc;
TRACE ("Adding thread: pid=%d tid=%ld\n", status.pid,
ptid_get_lwp (ptid));
nto_find_new_threads (&nto_inferior);
}
else
{
do_detach ();
return -1;
}
return pid;
}
示例10: lynx_ptid_build
static ptid_t
lynx_ptid_build (int pid, long tid)
{
/* brobecker/2010-06-21: It looks like the LWP field in ptids
should be distinct for each thread (see write_ptid where it
writes the thread ID from the LWP). So instead of storing
the LynxOS tid in the tid field of the ptid, we store it in
the lwp field. */
return ptid_build (pid, tid, 0);
}
示例11: nbsd_thread_activate
static void
nbsd_thread_activate (void)
{
nbsd_thread_active = 1;
main_ptid = inferior_ptid;
cached_thread = minus_one_ptid;
thread_change_ptid(inferior_ptid,
ptid_build (ptid_get_pid (inferior_ptid), 1, 0));
nbsd_update_thread_list (NULL);
inferior_ptid = find_active_thread ();
}
示例12: get_sim_inferior_data
static struct sim_inferior_data *
get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
{
SIM_DESC sim_desc = NULL;
struct sim_inferior_data *sim_data
= (struct sim_inferior_data *) inferior_data (inf, sim_inferior_data_key);
/* Try to allocate a new sim instance, if needed. We do this ahead of
a potential allocation of a sim_inferior_data struct in order to
avoid needlessly allocating that struct in the event that the sim
instance allocation fails. */
if (sim_instance_needed == SIM_INSTANCE_NEEDED
&& (sim_data == NULL || sim_data->gdbsim_desc == NULL))
{
struct inferior *idup;
sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
if (sim_desc == NULL)
error (_("Unable to create simulator instance for inferior %d."),
inf->num);
idup = iterate_over_inferiors (check_for_duplicate_sim_descriptor,
sim_desc);
if (idup != NULL)
{
/* We don't close the descriptor due to the fact that it's
shared with some other inferior. If we were to close it,
that might needlessly muck up the other inferior. Of
course, it's possible that the damage has already been
done... Note that it *will* ultimately be closed during
cleanup of the other inferior. */
sim_desc = NULL;
error (
_("Inferior %d and inferior %d would have identical simulator state.\n"
"(This simulator does not support the running of more than one inferior.)"),
inf->num, idup->num);
}
}
if (sim_data == NULL)
{
sim_data = XCNEW(struct sim_inferior_data);
set_inferior_data (inf, sim_inferior_data_key, sim_data);
/* Allocate a ptid for this inferior. */
sim_data->remote_sim_ptid = ptid_build (next_pid, 0, next_pid);
next_pid++;
/* Initialize the other instance variables. */
sim_data->program_loaded = 0;
sim_data->gdbsim_desc = sim_desc;
sim_data->resume_siggnal = GDB_SIGNAL_0;
sim_data->resume_step = 0;
}
示例13: ps_lsetregs
ps_err_e
ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
{
ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
return PS_OK;
}
示例14: ps_lgetregs
ps_err_e
ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
{
ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
return PS_OK;
}
示例15: _initialize_remote_sim
void
_initialize_remote_sim (void)
{
init_gdbsim_ops ();
add_target (&gdbsim_ops);
add_com ("sim", class_obscure, simulator_command,
_("Send a command to the simulator."));
/* Yes, 42000 is arbitrary. The only sense out of it, is that it
isn't 0. */
remote_sim_ptid = ptid_build (42000, 0, 42000);
}