Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/6] Move throw_perror_with_name to common/
Date: Fri, 06 Mar 2015 19:58:00 -0000	[thread overview]
Message-ID: <1425671886-7798-2-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1425671886-7798-1-git-send-email-palves@redhat.com>

I have a use for throw_perror_with_name in nat/, but currently, only
perror_with_name is available to common gdb+gdbserver code.  This
patch makes throw_perror_with_name the function that client need to
implement (instead of perror_with_name), and adds a common
perror_with_name as a wrapper over throw_perror_with_name, just like
GDB's is currently.

gdb/ChangeLog:
2015-03-06  Pedro Alves  <palves@redhat.com>

	* utils.c (perror_with_name): Move ...
	* common/errors.c (perror_with_name): ... here.
	* common/errors.h: Include common-exceptions.h.
	(throw_perror_with_name): Declare.
	(perror_with_name): Update comment.

gdb/gdbserver/ChangeLog:
2015-03-06  Pedro Alves  <palves@redhat.com>

	* utils.c (perror_with_name): Rename to ...
	(throw_perror_with_name): ... this.  Use throw_error in gdbserver.
---
 gdb/common/errors.c   |  8 ++++++++
 gdb/common/errors.h   | 13 +++++++++++--
 gdb/gdbserver/utils.c |  6 +++++-
 gdb/utils.c           |  8 --------
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/gdb/common/errors.c b/gdb/common/errors.c
index 00b325e..5fd4a80 100644
--- a/gdb/common/errors.c
+++ b/gdb/common/errors.c
@@ -67,3 +67,11 @@ internal_warning (const char *file, int line, const char *fmt, ...)
   internal_vwarning (file, line, fmt, ap);
   va_end (ap);
 }
+
+/* See common/errors.h.  */
+
+void
+perror_with_name (const char *string)
+{
+  throw_perror_with_name (GENERIC_ERROR, string);
+}
diff --git a/gdb/common/errors.h b/gdb/common/errors.h
index 36e2c49..c7d85f1 100644
--- a/gdb/common/errors.h
+++ b/gdb/common/errors.h
@@ -20,6 +20,8 @@
 #ifndef COMMON_ERRORS_H
 #define COMMON_ERRORS_H
 
+#include "common-exceptions.h"
+
 /* A problem was detected, but the requested operation can still
    proceed.  A warning message is constructed using a printf- or
    vprintf-style argument list.  The function "vwarning" must be
@@ -76,8 +78,15 @@ extern void internal_vwarning (const char *file, int line,
 \f
 
 /* Like "error", but the error message is constructed by combining
-   STRING with the system error message for errno.  This function does
-   not return.  This function must be provided by the client.  */
+   STRING with the system error message for errno.  Uses ERRCODE for
+   the thrown exception.  This function does not return.  This
+   function must be provided by the client.  */
+
+extern void throw_perror_with_name (enum errors errcode, const char *string)
+  ATTRIBUTE_NORETURN;
+
+/* Convenience wrapper for "throw_perror_with_name" that throws
+   GENERIC_ERROR.  */
 
 extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
 
diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index e89a862..cd5734b 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -54,7 +54,7 @@ xstrdup (const char *s)
    Then return to command level.  */
 
 void
-perror_with_name (const char *string)
+throw_perror_with_name (enum errors errcode, const char *string)
 {
   const char *err;
   char *combined;
@@ -68,7 +68,11 @@ perror_with_name (const char *string)
   strcat (combined, ": ");
   strcat (combined, err);
 
+#ifdef IN_PROCESS_AGENT
   error ("%s.", combined);
+#else
+  throw_error (errcode, "%s.", combined);
+#endif
 }
 
 /* Print an error message and return to top level.  */
diff --git a/gdb/utils.c b/gdb/utils.c
index 7172bba..6b1aa89 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -990,14 +990,6 @@ throw_perror_with_name (enum errors errcode, const char *string)
   throw_error (errcode, _("%s."), combined);
 }
 
-/* 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.  */
 
-- 
1.9.3


  parent reply	other threads:[~2015-03-06 19:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 19:58 [PATCH 0/6] Fix problems if inferior disappears while being debugged Pedro Alves
2015-03-06 19:58 ` [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint Pedro Alves
2015-03-19 12:37   ` [pushed] native/Linux: internal error if resume is short-circuited (Re: [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint) Pedro Alves
2015-03-19 12:49     ` [pushed] gdbserver/Linux: unbreak thread event randomization (Re: [pushed] native/Linux: internal error if resume is short-circuited) Pedro Alves
2015-03-19 16:14       ` [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization) Pedro Alves
2015-03-19 16:54         ` [pushed] " Pedro Alves
2015-03-06 19:58 ` [PATCH 5/6] gdbserver/Linux: internal error when killing a process that is already gone Pedro Alves
2015-03-06 19:58 ` [PATCH 3/6] Fix race exposed by gdb.threads/killed.exp Pedro Alves
2015-03-19 17:39   ` Pedro Alves
2015-03-06 19:58 ` [PATCH 2/6] Introduce throw_ptrace_error Pedro Alves
2015-03-06 21:04   ` Mark Kettenis
2015-03-06 21:40     ` Pedro Alves
2015-03-08 20:30       ` Mark Kettenis
2015-03-08 21:48         ` Pedro Alves
2015-03-10 14:53           ` Mark Kettenis
2015-03-11 15:44             ` Pedro Alves
2015-03-19 17:33               ` [pushed] Fix race exposed by gdb.threads/killed.exp (Re: [PATCH 2/6] Introduce throw_ptrace_error) Pedro Alves
2015-03-06 19:58 ` Pedro Alves [this message]
2015-03-06 20:27 ` [PATCH 6/6] Add test that exercises the inferior being killed while stopped under GDB Pedro Alves
2015-07-14 10:22   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425671886-7798-2-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox