Use strerror_r in safe_strerror if available
Also stores the result in a thread-local static variable and changes the return value to a const char*. This is already important because Guile creates threads and Python can create threads, but with the patch series here: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176 GDB itself will create threads, too. gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Check for strerror_r. * gdbsupport/common-utils.h (safe_strerror): Change return value to const char * and document that this function is now threadsafe. * gdbsupport/posix-strerror.c (safe_strerror): Make buf thread_local and call strerror_r, if available. * utils.c (perror_string): Update. (print_sys_errmsg): Update. Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb
This commit is contained in:
parent
a2726d4ff8
commit
b231e86ac9
6 changed files with 32 additions and 16 deletions
11
gdb/utils.c
11
gdb/utils.c
|
@ -582,9 +582,7 @@ add_internal_problem_command (struct internal_problem *problem)
|
|||
static std::string
|
||||
perror_string (const char *prefix)
|
||||
{
|
||||
char *err;
|
||||
|
||||
err = safe_strerror (errno);
|
||||
const char *err = safe_strerror (errno);
|
||||
return std::string (prefix) + ": " + err;
|
||||
}
|
||||
|
||||
|
@ -630,11 +628,8 @@ perror_warning_with_name (const char *string)
|
|||
void
|
||||
print_sys_errmsg (const char *string, int errcode)
|
||||
{
|
||||
char *err;
|
||||
char *combined;
|
||||
|
||||
err = safe_strerror (errcode);
|
||||
combined = (char *) alloca (strlen (err) + strlen (string) + 3);
|
||||
const char *err = safe_strerror (errcode);
|
||||
char *combined = (char *) alloca (strlen (err) + strlen (string) + 3);
|
||||
strcpy (combined, string);
|
||||
strcat (combined, ": ");
|
||||
strcat (combined, err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue