logo       

Re: [PATCH] utils.c: Revise a couple of internal_error() messages: msg#00615

Subject: Re: [PATCH] utils.c: Revise a couple of internal_error() messages
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;
 }




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe