* [commit] mn10300: Register a dwarf2_reg_to_regnum function
@ 2005-09-03 1:10 Kevin Buettner
2005-09-03 1:26 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2005-09-03 1:10 UTC (permalink / raw)
To: gdb-patches; +Cc: Michael Snyder
I've just committed the change below.
This code used to be in the old version of mn10300-tdep.c. It's absence
from the current version of mn10300-tdep.c is an oversight. When I asked
Michael Snyder about it a while back, he asked me to reinstate it. So
here it is...
* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): New function.
(mn10300_gdbarch_init): Register mn10300_dwarf2_reg_to_regnum().
Index: mn10300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v
retrieving revision 1.128
diff -u -p -r1.128 mn10300-tdep.c
--- mn10300-tdep.c 3 Sep 2005 00:49:06 -0000 1.128
+++ mn10300-tdep.c 3 Sep 2005 01:02:48 -0000
@@ -937,6 +937,37 @@ mn10300_push_dummy_call (struct gdbarch
return sp;
}
+/* If DWARF2 is a register number appearing in Dwarf2 debug info, then
+ mn10300_dwarf2_reg_to_regnum (DWARF2) is the corresponding GDB
+ register number. Why don't Dwarf2 and GDB use the same numbering?
+ Who knows? But since people have object files lying around with
+ the existing Dwarf2 numbering, and other people have written stubs
+ to work with the existing GDB, neither of them can change. So we
+ just have to cope. */
+static int
+mn10300_dwarf2_reg_to_regnum (int dwarf2)
+{
+ /* This table is supposed to be shaped like the REGISTER_NAMES
+ initializer in gcc/config/mn10300/mn10300.h. Registers which
+ appear in GCC's numbering, but have no counterpart in GDB's
+ world, are marked with a -1. */
+ static int dwarf2_to_gdb[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, -1, 8,
+ 15, 16, 17, 18, 19, 20, 21, 22,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63
+ };
+
+ 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];
+}
static struct gdbarch *
mn10300_gdbarch_init (struct gdbarch_info info,
@@ -977,6 +1008,7 @@ mn10300_gdbarch_init (struct gdbarch_inf
set_gdbarch_write_pc (gdbarch, mn10300_write_pc);
set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
+ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum);
/* Stack unwinding. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [commit] mn10300: Register a dwarf2_reg_to_regnum function
2005-09-03 1:10 [commit] mn10300: Register a dwarf2_reg_to_regnum function Kevin Buettner
@ 2005-09-03 1:26 ` Mark Kettenis
2005-09-03 2:02 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2005-09-03 1:26 UTC (permalink / raw)
To: kevinb; +Cc: gdb-patches, msnyder
> Date: Fri, 2 Sep 2005 18:09:15 -0700
> From: Kevin Buettner <kevinb@redhat.com>
>
> This code used to be in the old version of mn10300-tdep.c. It's absence
> from the current version of mn10300-tdep.c is an oversight. When I asked
> Michael Snyder about it a while back, he asked me to reinstate it. So
> here it is...
>
> * mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): New function.
> (mn10300_gdbarch_init): Register mn10300_dwarf2_reg_to_regnum().
>
> Index: mn10300-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v
> retrieving revision 1.128
> diff -u -p -r1.128 mn10300-tdep.c
> --- mn10300-tdep.c 3 Sep 2005 00:49:06 -0000 1.128
> +++ mn10300-tdep.c 3 Sep 2005 01:02:48 -0000
> @@ -937,6 +937,37 @@ mn10300_push_dummy_call (struct gdbarch
> return sp;
> }
>
> +/* If DWARF2 is a register number appearing in Dwarf2 debug info, then
> + mn10300_dwarf2_reg_to_regnum (DWARF2) is the corresponding GDB
> + register number. Why don't Dwarf2 and GDB use the same numbering?
> + Who knows? But since people have object files lying around with
> + the existing Dwarf2 numbering, and other people have written stubs
> + to work with the existing GDB, neither of them can change. So we
> + just have to cope. */
> +static int
> +mn10300_dwarf2_reg_to_regnum (int dwarf2)
> +{
> + /* This table is supposed to be shaped like the REGISTER_NAMES
> + initializer in gcc/config/mn10300/mn10300.h. Registers which
> + appear in GCC's numbering, but have no counterpart in GDB's
> + world, are marked with a -1. */
> + static int dwarf2_to_gdb[] = {
> + 0, 1, 2, 3, 4, 5, 6, 7, -1, 8,
> + 15, 16, 17, 18, 19, 20, 21, 22,
> + 32, 33, 34, 35, 36, 37, 38, 39,
> + 40, 41, 42, 43, 44, 45, 46, 47,
> + 48, 49, 50, 51, 52, 53, 54, 55,
> + 56, 57, 58, 59, 60, 61, 62, 63
> + };
> +
> + 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? 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.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [commit] mn10300: Register a dwarf2_reg_to_regnum function
2005-09-03 1:26 ` Mark Kettenis
@ 2005-09-03 2:02 ` Kevin Buettner
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2005-09-03 2:02 UTC (permalink / raw)
To: gdb-patches
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];
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-09-03 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-03 1:10 [commit] mn10300: Register a dwarf2_reg_to_regnum function Kevin Buettner
2005-09-03 1:26 ` Mark Kettenis
2005-09-03 2:02 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox