static char * core_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; struct inferior *inf; int pid; /* The preferred way is to have a gdbarch/OS specific implementation. */ if (core_gdbarch && gdbarch_core_pid_to_str_p (core_gdbarch)) return gdbarch_core_pid_to_str (core_gdbarch, ptid); /* Otherwise, if we don't have one, we'll just fallback to "process", with normal_pid_to_str. */ /* Try the LWPID field first. */ pid = ptid_get_lwp (ptid); if (pid != 0) return normal_pid_to_str (pid_to_ptid (pid)); /* Otherwise, this isn't a "threaded" core -- use the PID field, but only if it isn't a fake PID. */ inf = find_inferior_pid (ptid_get_pid (ptid)); if (inf != NULL && !inf->fake_pid_p) return normal_pid_to_str (ptid); /* No luck. We simply don't have a valid PID to print. */ xsnprintf (buf, sizeof buf, "<main task>"); return buf; }
std::string core_target::pid_to_str (ptid_t ptid) { struct inferior *inf; int pid; /* The preferred way is to have a gdbarch/OS specific implementation. */ if (m_core_gdbarch != nullptr && gdbarch_core_pid_to_str_p (m_core_gdbarch)) return gdbarch_core_pid_to_str (m_core_gdbarch, ptid); /* Otherwise, if we don't have one, we'll just fallback to "process", with normal_pid_to_str. */ /* Try the LWPID field first. */ pid = ptid.lwp (); if (pid != 0) return normal_pid_to_str (ptid_t (pid)); /* Otherwise, this isn't a "threaded" core -- use the PID field, but only if it isn't a fake PID. */ inf = find_inferior_ptid (ptid); if (inf != NULL && !inf->fake_pid_p) return normal_pid_to_str (ptid); /* No luck. We simply don't have a valid PID to print. */ return "<main task>"; }