aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorAaron Merey <amerey@redhat.com>2023-02-09 20:28:20 -0500
committerAaron Merey <amerey@redhat.com>2023-02-10 21:04:45 -0500
commit40dfb28b56fe55a370a35495e0f1eb6c95110f35 (patch)
treee5a51168f2bf2aef021346f20844ac505dcdd924 /gdb/utils.c
parentbad727e2d2d1d7f86e1bcdb8eb9ce778182b5926 (diff)
downloadgdb-40dfb28b56fe55a370a35495e0f1eb6c95110f35.zip
gdb-40dfb28b56fe55a370a35495e0f1eb6c95110f35.tar.gz
gdb-40dfb28b56fe55a370a35495e0f1eb6c95110f35.tar.bz2
Move implementation of perror_with_name to gdbsupport
gdbsupport/errors.h declares perror_with_name and leaves the implementation to the clients. However gdb and gdbserver's implementations are essentially the same, resulting in unnecessary code duplication. Fix this by implementing perror_with_name in gdbsupport. Add an optional parameter for specifying the errno used to generate the error message. Also move the implementation of perror_string to gdbsupport since perror_with_name requires it. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 95adbe5..d763e91 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -614,42 +614,6 @@ add_internal_problem_command (struct internal_problem *problem)
}
}
-/* Return a newly allocated string, containing the PREFIX followed
- by the system error message for errno (separated by a colon). */
-
-static std::string
-perror_string (const char *prefix)
-{
- const char *err = safe_strerror (errno);
- return std::string (prefix) + ": " + err;
-}
-
-/* Print the system error message for errno, and also mention STRING
- as the file name for which the error was encountered. Use ERRCODE
- for the thrown exception. Then return to command level. */
-
-static void ATTRIBUTE_NORETURN
-throw_perror_with_name (enum errors errcode, const char *string)
-{
- std::string combined = perror_string (string);
-
- /* I understand setting these is a matter of taste. Still, some people
- may clear errno but not know about bfd_error. Doing this here is not
- unreasonable. */
- bfd_set_error (bfd_error_no_error);
- errno = 0;
-
- throw_error (errcode, _("%s."), combined.c_str ());
-}
-
-/* See throw_perror_with_name, ERRCODE defaults here to GENERIC_ERROR. */
-
-void
-perror_with_name (const char *string)
-{
- throw_perror_with_name (GENERIC_ERROR, string);
-}
-
/* Same as perror_with_name except that it prints a warning instead
of throwing an error. */