diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-04-06 23:29:53 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2017-04-06 23:29:53 -0400 |
commit | 436252de3e9de546001c4312d0863ce7e10aa200 (patch) | |
tree | aaf19dc5ede1cabea18b78abb4239ab22bc02b10 /bfd/cf-i386lynx.c | |
parent | 1379e3aaea5e9454d7e75f293c3fe24c0d11c688 (diff) | |
download | gdb-436252de3e9de546001c4312d0863ce7e10aa200.zip gdb-436252de3e9de546001c4312d0863ce7e10aa200.tar.gz gdb-436252de3e9de546001c4312d0863ce7e10aa200.tar.bz2 |
Class-ify ptid_t
I grew a bit tired of using ptid_get_{lwp,pid,tid} and friends, so I decided to
make it a bit easier to use by making it a proper class. The fields are now
private, so it's not possible to change a ptid_t field by mistake.
The new methods of ptid_t map to existing functions/practice like this:
ptid_t (pid, lwp, tid) -> ptid_build (pid, lwp, tid)
ptid_t (pid) -> pid_to_ptid (pid)
ptid.is_pid () -> ptid_is_pid (ptid)
ptid == other -> ptid_equal (ptid, other)
ptid != other -> !ptid_equal (ptid, other)
ptid.pid () -> ptid_get_pid (ptid)
ptid.lwp_p () -> ptid_lwp_p (ptid)
ptid.lwp () -> ptid_get_lwp (ptid)
ptid.tid_p () -> ptid_tid_p (ptid)
ptid.tid () -> ptid_get_tid (ptid)
ptid.matches (filter) -> ptid_match (ptid, filter)
I've replaced the implementation of the existing functions with calls to
the new methods. People are encouraged to gradually switch to using the
ptid_t methods instead of the functions (or we can change them all in
one pass eventually).
Also, I'm not sure if it's worth it (because of ptid_t's relatively
small size), but I have made the functions and methods take ptid_t
arguments by const reference instead of by value.
gdb/ChangeLog:
* common/ptid.h (struct ptid): Change to...
(class ptid_t): ... this.
<ptid_t>: New constructors.
<pid, lwp_p, lwp, tid_p, tid, is_pid, operator==, operator!=,
matches>: New methods.
<make_null, make_minus_one>: New static methods.
<pid>: Rename to...
<m_pid>: ...this.
<lwp>: Rename to...
<m_lwp>: ...this.
<tid>: Rename to...
<m_tid>: ...this.
(ptid_build, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal,
ptid_is_pid, ptid_lwp_p, ptid_tid_p, ptid_match): Take ptid arguments
as references, move comment to class ptid_t.
* common/ptid.c (null_ptid, minus_one_ptid): Initialize with
ptid_t static methods.
(ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_tid,
ptid_equal, ptid_is_pid, ptid_lwp_p, ptid_tid_p, ptid_match):
Take ptid arguments as references, implement using ptid_t methods.
* unittests/ptid-selftests.c: New file.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/ptid-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add unittests/ptid-selftests.o.
gdb/gdbserver/ChangeLog:
* server.c (handle_v_cont): Initialize thread_resume::thread
with null_ptid.
Diffstat (limited to 'bfd/cf-i386lynx.c')
0 files changed, 0 insertions, 0 deletions