Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [commit] mn10300: Register a dwarf2_reg_to_regnum function
Date: Sat, 03 Sep 2005 02:02:00 -0000	[thread overview]
Message-ID: <20050902190222.5ab1edac@ironwood.lan> (raw)
In-Reply-To: <200509030126.j831Q26V032052@elgar.sibelius.xs4all.nl>

On Sat, 3 Sep 2005 03:26:02 +0200 (CEST)
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:

> > +  if (dwarf2 < 0
> > +      || dwarf2 >= (sizeof (dwarf2_to_gdb) / sizeof (dwarf2_to_gdb[0]))
> > +      || dwarf2_to_gdb[dwarf2] == -1)
> > +    internal_error (__FILE__, __LINE__,
> > +                    "bogus register number in debug info: %d", dwarf2);
> > +
> > +  return dwarf2_to_gdb[dwarf2];
> > +}
> 
> Could you use ARRAY_SIZE here?

Sure.  (I should've spotted that myself...)

> And that string should be i18n'd.  or
> perhaps it's better to use gdb_assert(); saves the translators some
> work ;-).
> 
> Hmm, isn't an internal error actually inappropriate here?  The
> condition could be triggered by bogus debug info, couldn't it?  That
> should be handled more graceful.

I agree.  It seems to me that a warning is more appropriate.  But what
should we do about the return value?  There is no good choice since the
value is bogus.  I ended up just returning 0.  (It should be safe...)

For the time being, I've committed the patch below.  I'm willing to
change it again if we end up deciding that an internal error or assert
is really more appropriate.

	* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Use ARRAY_SIZE.
	Change internal error to warning.  Add i18n markup to warning
	string.

Index: mn10300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v
retrieving revision 1.129
retrieving revision 1.131
diff -u -p -r1.129 -r1.131
--- mn10300-tdep.c	3 Sep 2005 01:12:21 -0000	1.129
+++ mn10300-tdep.c	3 Sep 2005 01:55:26 -0000	1.131
@@ -961,10 +961,12 @@ mn10300_dwarf2_reg_to_regnum (int dwarf2
   };
 
   if (dwarf2 < 0
-      || dwarf2 >= (sizeof (dwarf2_to_gdb) / sizeof (dwarf2_to_gdb[0]))
+      || dwarf2 >= ARRAY_SIZE (dwarf2_to_gdb)
       || dwarf2_to_gdb[dwarf2] == -1)
-    internal_error (__FILE__, __LINE__,
-                    "bogus register number in debug info: %d", dwarf2);
+    {
+      warning (_("Bogus register number in debug info: %d"), dwarf2);
+      return 0;
+    }
 
   return dwarf2_to_gdb[dwarf2];
 }


      reply	other threads:[~2005-09-03  2:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-03  1:10 Kevin Buettner
2005-09-03  1:26 ` Mark Kettenis
2005-09-03  2:02   ` 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=20050902190222.5ab1edac@ironwood.lan \
    --to=kevinb@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