gdb: introduce target_waitkind_str, use it in target_waitstatus::to_string

I would like to print target_waitkind values in debug messages, so I
think that a target_waitkind-to-string function would be useful.  While
at it, use it in target_waitstatus::to_string.  This changes the output
of target_waitstatus::to_string a bit, but I think it is for the better.
The debug messages will show a string matching exactly the
target_waitkind enumerator (minus the TARGET_WAITKIND prefix).

As a convenience, make string_appendf return the same reference to
string it got as a parameter.  This allows doing this:

  return string_appendf (str, "foo");

... keeping the code concise.

Change-Id: I383dffc9c78614e7d0668b1516073905e798eef7
This commit is contained in:
Simon Marchi
2021-11-22 11:27:30 -05:00
committed by Simon Marchi
parent 7dca2ea7ff
commit 06de25b7af
5 changed files with 85 additions and 51 deletions

View File

@ -80,7 +80,8 @@ string_vprintf_tests ()
/* Type of both 'string_appendf' and the 'string_vappendf_wrapper'
function below. Used to run the same tests against both
string_appendf and string_vappendf. */
typedef void (string_appendf_func) (std::string &str, const char *fmt, ...)
typedef std::string &(string_appendf_func) (std::string &str, const char *fmt,
...)
ATTRIBUTE_PRINTF (2, 3);
static void
@ -101,7 +102,7 @@ test_appendf_func (string_appendf_func *func)
SELF_CHECK (str == "test23foo 45 bar");
}
static void ATTRIBUTE_PRINTF (2, 3)
static std::string & ATTRIBUTE_PRINTF (2, 3)
string_vappendf_wrapper (std::string &str, const char *fmt, ...)
{
va_list vp;
@ -109,6 +110,8 @@ string_vappendf_wrapper (std::string &str, const char *fmt, ...)
va_start (vp, fmt);
string_vappendf (str, fmt, vp);
va_end (vp);
return str;
}
static void