forked from Imagelibrary/binutils-gdb
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:
committed by
Simon Marchi
parent
7dca2ea7ff
commit
06de25b7af
@@ -119,7 +119,7 @@ string_vprintf (const char* fmt, va_list args)
|
||||
|
||||
/* See documentation in common-utils.h. */
|
||||
|
||||
void
|
||||
std::string &
|
||||
string_appendf (std::string &str, const char *fmt, ...)
|
||||
{
|
||||
va_list vp;
|
||||
@@ -127,12 +127,14 @@ string_appendf (std::string &str, const char *fmt, ...)
|
||||
va_start (vp, fmt);
|
||||
string_vappendf (str, fmt, vp);
|
||||
va_end (vp);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/* See documentation in common-utils.h. */
|
||||
|
||||
void
|
||||
std::string &
|
||||
string_vappendf (std::string &str, const char *fmt, va_list args)
|
||||
{
|
||||
va_list vp;
|
||||
@@ -148,6 +150,8 @@ string_vappendf (std::string &str, const char *fmt, va_list args)
|
||||
/* C++11 and later guarantee std::string uses contiguous memory and
|
||||
always includes the terminating '\0'. */
|
||||
vsprintf (&str[curr_size], fmt, args); /* ARI: vsprintf */
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
Reference in New Issue
Block a user