Change ptid_t::tid to ULONGEST
The ptid_t 'tid' member is normally used as an address in gdb -- both bsd-uthread and ravenscar-thread use it this way. However, because the type is 'long', this can cause problems with sign extension. This patch changes the type to ULONGEST to ensure that sign extension does not occur.
This commit is contained in:
parent
184ea2f731
commit
96bbe3ef96
@ -1233,7 +1233,8 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
|
|||||||
fprintf_styled (gdb_stdout, metadata_style.style (), _("<no name>\n"));
|
fprintf_styled (gdb_stdout, metadata_style.style (), _("<no name>\n"));
|
||||||
|
|
||||||
/* Print the TID and LWP. */
|
/* Print the TID and LWP. */
|
||||||
printf_filtered (_("Thread: %#lx\n"), task_info->ptid.tid ());
|
printf_filtered (_("Thread: 0x%s\n"), phex_nz (task_info->ptid.tid (),
|
||||||
|
sizeof (ULONGEST)));
|
||||||
printf_filtered (_("LWP: %#lx\n"), task_info->ptid.lwp ());
|
printf_filtered (_("LWP: %#lx\n"), task_info->ptid.lwp ());
|
||||||
|
|
||||||
/* If set, print the base CPU. */
|
/* If set, print the base CPU. */
|
||||||
|
@ -538,8 +538,9 @@ std::string
|
|||||||
bsd_uthread_target::pid_to_str (ptid_t ptid)
|
bsd_uthread_target::pid_to_str (ptid_t ptid)
|
||||||
{
|
{
|
||||||
if (ptid.tid () != 0)
|
if (ptid.tid () != 0)
|
||||||
return string_printf ("process %d, thread 0x%lx",
|
return string_printf ("process %d, thread 0x%s",
|
||||||
ptid.pid (), ptid.tid ());
|
ptid.pid (),
|
||||||
|
phex_nz (ptid.tid (), sizeof (ULONGEST)));
|
||||||
|
|
||||||
return normal_pid_to_str (ptid);
|
return normal_pid_to_str (ptid);
|
||||||
}
|
}
|
||||||
|
10
gdb/infrun.c
10
gdb/infrun.c
@ -4646,11 +4646,9 @@ wait_one ()
|
|||||||
static void
|
static void
|
||||||
save_waitstatus (struct thread_info *tp, const target_waitstatus *ws)
|
save_waitstatus (struct thread_info *tp, const target_waitstatus *ws)
|
||||||
{
|
{
|
||||||
infrun_debug_printf ("saving status %s for %d.%ld.%ld",
|
infrun_debug_printf ("saving status %s for %s",
|
||||||
target_waitstatus_to_string (ws).c_str (),
|
target_waitstatus_to_string (ws).c_str (),
|
||||||
tp->ptid.pid (),
|
tp->ptid.to_string ().c_str ());
|
||||||
tp->ptid.lwp (),
|
|
||||||
tp->ptid.tid ());
|
|
||||||
|
|
||||||
/* Record for later. */
|
/* Record for later. */
|
||||||
tp->set_pending_waitstatus (*ws);
|
tp->set_pending_waitstatus (*ws);
|
||||||
@ -4845,9 +4843,9 @@ handle_one (const wait_one_event &event)
|
|||||||
struct regcache *regcache;
|
struct regcache *regcache;
|
||||||
|
|
||||||
infrun_debug_printf
|
infrun_debug_printf
|
||||||
("target_wait %s, saving status for %d.%ld.%ld",
|
("target_wait %s, saving status for %s",
|
||||||
target_waitstatus_to_string (&event.ws).c_str (),
|
target_waitstatus_to_string (&event.ws).c_str (),
|
||||||
t->ptid.pid (), t->ptid.lwp (), t->ptid.tid ());
|
t->ptid.to_string ().c_str ());
|
||||||
|
|
||||||
/* Record for later. */
|
/* Record for later. */
|
||||||
save_waitstatus (t, &event.ws);
|
save_waitstatus (t, &event.ws);
|
||||||
|
@ -296,7 +296,8 @@ PyObject *
|
|||||||
gdbpy_create_ptid_object (ptid_t ptid)
|
gdbpy_create_ptid_object (ptid_t ptid)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
long tid, lwp;
|
long lwp;
|
||||||
|
ULONGEST tid;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
ret = PyTuple_New (3);
|
ret = PyTuple_New (3);
|
||||||
@ -313,7 +314,7 @@ gdbpy_create_ptid_object (ptid_t ptid)
|
|||||||
gdbpy_ref<> lwp_obj = gdb_py_object_from_longest (lwp);
|
gdbpy_ref<> lwp_obj = gdb_py_object_from_longest (lwp);
|
||||||
if (lwp_obj == nullptr)
|
if (lwp_obj == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
gdbpy_ref<> tid_obj = gdb_py_object_from_longest (tid);
|
gdbpy_ref<> tid_obj = gdb_py_object_from_ulongest (tid);
|
||||||
if (tid_obj == nullptr)
|
if (tid_obj == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ private:
|
|||||||
needed because sometimes the runtime will report an active task
|
needed because sometimes the runtime will report an active task
|
||||||
that hasn't yet been put on the list of tasks that is read by
|
that hasn't yet been put on the list of tasks that is read by
|
||||||
ada-tasks.c. */
|
ada-tasks.c. */
|
||||||
std::unordered_map<long, int> m_cpu_map;
|
std::unordered_map<ULONGEST, int> m_cpu_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return true iff PTID corresponds to a ravenscar task. */
|
/* Return true iff PTID corresponds to a ravenscar task. */
|
||||||
@ -469,7 +469,8 @@ ravenscar_thread_target::pid_to_str (ptid_t ptid)
|
|||||||
if (!is_ravenscar_task (ptid))
|
if (!is_ravenscar_task (ptid))
|
||||||
return beneath ()->pid_to_str (ptid);
|
return beneath ()->pid_to_str (ptid);
|
||||||
|
|
||||||
return string_printf ("Ravenscar Thread %#x", (int) ptid.tid ());
|
return string_printf ("Ravenscar Thread 0x%s",
|
||||||
|
phex_nz (ptid.tid (), sizeof (ULONGEST)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Temporarily set the ptid of a regcache to some other value. When
|
/* Temporarily set the ptid of a regcache to some other value. When
|
||||||
|
@ -6907,8 +6907,9 @@ remote_target::remote_stop_ns (ptid_t ptid)
|
|||||||
== resume_state::RESUMED_PENDING_VCONT)
|
== resume_state::RESUMED_PENDING_VCONT)
|
||||||
{
|
{
|
||||||
remote_debug_printf ("Enqueueing phony stop reply for thread pending "
|
remote_debug_printf ("Enqueueing phony stop reply for thread pending "
|
||||||
"vCont-resume (%d, %ld, %ld)", tp->ptid.pid(),
|
"vCont-resume (%d, %ld, %s)", tp->ptid.pid(),
|
||||||
tp->ptid.lwp (), tp->ptid.tid ());
|
tp->ptid.lwp (),
|
||||||
|
pulongest (tp->ptid.tid ()));
|
||||||
|
|
||||||
/* Check that the thread wasn't resumed with a signal.
|
/* Check that the thread wasn't resumed with a signal.
|
||||||
Generating a phony stop would result in losing the
|
Generating a phony stop would result in losing the
|
||||||
|
@ -286,8 +286,8 @@ target_pid_to_str (ptid_t ptid)
|
|||||||
else if (ptid == null_ptid)
|
else if (ptid == null_ptid)
|
||||||
xsnprintf (buf, sizeof (buf), "<null thread>");
|
xsnprintf (buf, sizeof (buf), "<null thread>");
|
||||||
else if (ptid.tid () != 0)
|
else if (ptid.tid () != 0)
|
||||||
xsnprintf (buf, sizeof (buf), "Thread %d.0x%lx",
|
xsnprintf (buf, sizeof (buf), "Thread %d.0x%s",
|
||||||
ptid.pid (), ptid.tid ());
|
ptid.pid (), phex_nz (ptid.tid (), sizeof (ULONGEST)));
|
||||||
else if (ptid.lwp () != 0)
|
else if (ptid.lwp () != 0)
|
||||||
xsnprintf (buf, sizeof (buf), "LWP %d.%ld",
|
xsnprintf (buf, sizeof (buf), "LWP %d.%ld",
|
||||||
ptid.pid (), ptid.lwp ());
|
ptid.pid (), ptid.lwp ());
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "common-defs.h"
|
#include "common-defs.h"
|
||||||
#include "ptid.h"
|
#include "ptid.h"
|
||||||
|
#include "print-utils.h"
|
||||||
|
|
||||||
/* See ptid.h for these. */
|
/* See ptid.h for these. */
|
||||||
|
|
||||||
@ -30,5 +31,5 @@ ptid_t const minus_one_ptid = ptid_t::make_minus_one ();
|
|||||||
std::string
|
std::string
|
||||||
ptid_t::to_string () const
|
ptid_t::to_string () const
|
||||||
{
|
{
|
||||||
return string_printf ("%d.%ld.%ld", m_pid, m_lwp, m_tid);
|
return string_printf ("%d.%ld.%s", m_pid, m_lwp, pulongest (m_tid));
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "gdbsupport/common-types.h"
|
||||||
|
|
||||||
class ptid_t
|
class ptid_t
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ public:
|
|||||||
A ptid with only a PID (LWP and TID equal to zero) is usually used to
|
A ptid with only a PID (LWP and TID equal to zero) is usually used to
|
||||||
represent a whole process, including all its lwps/threads. */
|
represent a whole process, including all its lwps/threads. */
|
||||||
|
|
||||||
explicit constexpr ptid_t (int pid, long lwp = 0, long tid = 0)
|
explicit constexpr ptid_t (int pid, long lwp = 0, ULONGEST tid = 0)
|
||||||
: m_pid (pid), m_lwp (lwp), m_tid (tid)
|
: m_pid (pid), m_lwp (lwp), m_tid (tid)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ public:
|
|||||||
|
|
||||||
/* Fetch the tid (thread id) component from a ptid. */
|
/* Fetch the tid (thread id) component from a ptid. */
|
||||||
|
|
||||||
constexpr long tid () const
|
constexpr ULONGEST tid () const
|
||||||
{ return m_tid; }
|
{ return m_tid; }
|
||||||
|
|
||||||
/* Return true if the ptid represents a whole process, including all its
|
/* Return true if the ptid represents a whole process, including all its
|
||||||
@ -149,7 +150,7 @@ private:
|
|||||||
long m_lwp;
|
long m_lwp;
|
||||||
|
|
||||||
/* Thread id. */
|
/* Thread id. */
|
||||||
long m_tid;
|
ULONGEST m_tid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Functor to hash a ptid. */
|
/* Functor to hash a ptid. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user