Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: Andrew Cagney <ac131313@ges.redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] utils.c: Revise a couple of internal_error() messages
Date: Wed, 31 Jul 2002 10:25:00 -0000	[thread overview]
Message-ID: <1020731170313.ZM21454@localhost.localdomain> (raw)
In-Reply-To: Andrew Cagney <ac131313@ges.redhat.com> "Re: [PATCH] utils.c: Revise a couple of internal_error() messages" (Jul 29, 11:51am)

On Jul 29, 11:51am, Andrew Cagney wrote:

> >  {
> >    if (sizeof (ptr) != TYPE_LENGTH (builtin_type_void_data_ptr))
> >      internal_error (__FILE__, __LINE__,
> > -		    "core_addr_to_void_ptr: bad cast");
> > +		    "host_pointer_to_address: bad cast");
> >    return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr);
> >  }
> 
> BTW, another (easier/better?) way of resolving this is to convert the 
> above into gdb_assert().  That way you pick up the function name for 
> free (and in a maintainable way).

I agree.  I've just committed the patch below.

	* utils.c (host_pointer_to_address, address_to_host_pointer):
	Use gdb_assert() instead of explicit call to internal_error().

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.74
diff -u -p -r1.74 utils.c
--- utils.c	27 Jul 2002 02:03:45 -0000	1.74
+++ utils.c	31 Jul 2002 16:58:15 -0000
@@ -2462,9 +2462,7 @@ phex_nz (ULONGEST l, int sizeof_l)
 CORE_ADDR
 host_pointer_to_address (void *ptr)
 {
-  if (sizeof (ptr) != TYPE_LENGTH (builtin_type_void_data_ptr))
-    internal_error (__FILE__, __LINE__,
-		    "host_pointer_to_address: bad cast");
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
   return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr);
 }
 
@@ -2472,9 +2470,8 @@ void *
 address_to_host_pointer (CORE_ADDR addr)
 {
   void *ptr;
-  if (sizeof (ptr) != TYPE_LENGTH (builtin_type_void_data_ptr))
-    internal_error (__FILE__, __LINE__,
-		    "address_to_host_pointer: bad cast");
+
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
   ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
   return ptr;
 }


      reply	other threads:[~2002-07-31 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-27 23:26 Kevin Buettner
2002-07-29  8:56 ` Andrew Cagney
2002-07-31 10:25   ` Kevin Buettner [this message]

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=1020731170313.ZM21454@localhost.localdomain \
    --to=kevinb@redhat.com \
    --cc=ac131313@ges.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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