gdb: introduce target_waitkind_str, use it in target_waitstatus::to_string
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 22 Nov 2021 16:27:30 +0000 (11:27 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 22 Nov 2021 18:57:49 +0000 (13:57 -0500)
commit06de25b7af21eb1173d7b86c5c0f37aae5ec2674
tree257ca777e7e7c96de2844956bb61256f1ed5e111
parent7dca2ea7ff4c2c786119e13e81a5e6b0c1bf1d2d
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
gdb/target/waitstatus.c
gdb/target/waitstatus.h
gdb/unittests/common-utils-selftests.c
gdbsupport/common-utils.cc
gdbsupport/common-utils.h