From: Simon Marchi Date: Thu, 28 Oct 2021 20:25:42 +0000 (-0400) Subject: Add ptid_t::to_string (gdb-11-branch only) X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=3b2fb5bda8d95d2e1ea7e0219068edab890ee8f4;hp=edf56335c4626a443d3cdf420dd40521f658fa8e;p=deliverable%2Fbinutils-gdb.git Add ptid_t::to_string (gdb-11-branch only) Change-Id: I0c3e9d4faf1bd79c18f2f60c1c32132b8e6e6052 --- diff --git a/gdbsupport/ptid.cc b/gdbsupport/ptid.cc index 73e2918cbc..e518066261 100644 --- a/gdbsupport/ptid.cc +++ b/gdbsupport/ptid.cc @@ -19,8 +19,17 @@ #include "common-defs.h" #include "ptid.h" +#include "print-utils.h" /* See ptid.h for these. */ ptid_t const null_ptid = ptid_t::make_null (); ptid_t const minus_one_ptid = ptid_t::make_minus_one (); + +/* See ptid.h. */ + +std::string +ptid_t::to_string () const +{ + return string_printf ("%d.%ld.%s", m_pid, m_lwp, pulongest (m_tid)); +} diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h index a0a91758b3..a2553b29c1 100644 --- a/gdbsupport/ptid.h +++ b/gdbsupport/ptid.h @@ -33,6 +33,7 @@ */ #include +#include class ptid_t { @@ -124,6 +125,12 @@ public: || *this == filter); } + /* Return a string representation of the ptid. + + This is only meant to be used in debug messages. */ + + std::string to_string () const; + /* Make a null ptid. */ static constexpr ptid_t make_null ()