* [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
@ 2007-11-05 12:23 Markus Deuling
2007-11-05 13:44 ` Mark Kettenis
0 siblings, 1 reply; 4+ messages in thread
From: Markus Deuling @ 2007-11-05 12:23 UTC (permalink / raw)
To: GDB Patches; +Cc: Ulrich Weigand
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
Hi,
this patch replaces SIZEOF_FRAME_SAVED_REGS macro by its expression.
Tested by gdb_mbuild with alpha target. Is this ok to commit?
ChangeLog:
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Replace
SIZEOF_FRAME_SAVED_REGS by its expression. Use get_frame_arch to get at
the current architecture by frame_info.
* alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
* frame.h (SIZEOF_FRAME_SAVED_REGS): Remove.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-frame --]
[-- Type: text/plain, Size: 2873 bytes --]
diff -urpN src/gdb/alpha-mdebug-tdep.c dev2/gdb/alpha-mdebug-tdep.c
--- src/gdb/alpha-mdebug-tdep.c 2007-10-17 15:36:43.000000000 +0200
+++ dev2/gdb/alpha-mdebug-tdep.c 2007-11-05 09:00:20.000000000 +0100
@@ -180,6 +180,7 @@ static struct alpha_mdebug_unwind_cache
alpha_mdebug_frame_unwind_cache (struct frame_info *next_frame,
void **this_prologue_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
struct alpha_mdebug_unwind_cache *info;
struct mdebug_extra_func_info *proc_desc;
ULONGEST vfp;
@@ -201,7 +202,9 @@ alpha_mdebug_frame_unwind_cache (struct
info->proc_desc = proc_desc;
gdb_assert (proc_desc != NULL);
- info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
+ info->saved_regs = frame_obstack_zalloc (sizeof (CORE_ADDR) *
+ (gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch)));
/* The VFP of the frame is at FRAME_REG+FRAME_OFFSET. */
vfp = frame_unwind_register_unsigned (next_frame, PROC_FRAME_REG (proc_desc));
diff -urpN src/gdb/alpha-tdep.c dev2/gdb/alpha-tdep.c
--- src/gdb/alpha-tdep.c 2007-11-05 05:32:21.000000000 +0100
+++ dev2/gdb/alpha-tdep.c 2007-11-05 09:01:50.000000000 +0100
@@ -999,6 +999,7 @@ alpha_heuristic_frame_unwind_cache (stru
void **this_prologue_cache,
CORE_ADDR start_pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
struct alpha_heuristic_unwind_cache *info;
ULONGEST val;
CORE_ADDR limit_pc, cur_pc;
@@ -1009,7 +1010,9 @@ alpha_heuristic_frame_unwind_cache (stru
info = FRAME_OBSTACK_ZALLOC (struct alpha_heuristic_unwind_cache);
*this_prologue_cache = info;
- info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
+ info->saved_regs = frame_obstack_zalloc (sizeof (CORE_ADDR) *
+ (gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch)));
limit_pc = frame_pc_unwind (next_frame);
if (start_pc == 0)
diff -urpN src/gdb/frame.h dev2/gdb/frame.h
--- src/gdb/frame.h 2007-11-05 05:32:21.000000000 +0100
+++ dev2/gdb/frame.h 2007-11-05 09:02:29.000000000 +0100
@@ -569,18 +569,6 @@ enum print_what
LOC_AND_ADDRESS
};
-/* Allocate additional space for appendices to a struct frame_info.
- NOTE: Much of GDB's code works on the assumption that the allocated
- saved_regs[] array is the size specified below. If you try to make
- that array smaller, GDB will happily walk off its end. */
-
-#ifdef SIZEOF_FRAME_SAVED_REGS
-#error "SIZEOF_FRAME_SAVED_REGS can not be re-defined"
-#endif
-#define SIZEOF_FRAME_SAVED_REGS \
- (sizeof (CORE_ADDR) * (gdbarch_num_regs (current_gdbarch)\
- + gdbarch_num_pseudo_regs (current_gdbarch)))
-
/* Allocate zero initialized memory from the frame cache obstack.
Appendices to the frame info (such as the unwind cache) should
allocate memory using this method. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
2007-11-05 12:23 [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro) Markus Deuling
@ 2007-11-05 13:44 ` Mark Kettenis
2007-11-05 14:00 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2007-11-05 13:44 UTC (permalink / raw)
To: deuling; +Cc: gdb-patches, uweigand
> Date: Mon, 05 Nov 2007 13:21:29 +0100
> From: Markus Deuling <deuling@de.ibm.com>
>
> Hi,
>
> this patch replaces SIZEOF_FRAME_SAVED_REGS macro by its expression.
>
> Tested by gdb_mbuild with alpha target. Is this ok to commit?
I'm not thrilled, since this replaces a #define that has a sensible
name with some sort of complicated expression, and therefore makes the
code much more difficult to read.
> ChangeLog:
>
>
> * alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Replace
> SIZEOF_FRAME_SAVED_REGS by its expression. Use get_frame_arch to get at
> the current architecture by frame_info.
> * alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
> * frame.h (SIZEOF_FRAME_SAVED_REGS): Remove.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
2007-11-05 13:44 ` Mark Kettenis
@ 2007-11-05 14:00 ` Daniel Jacobowitz
2007-11-05 15:14 ` Ulrich Weigand
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-11-05 14:00 UTC (permalink / raw)
To: gdb-patches
On Mon, Nov 05, 2007 at 02:43:29PM +0100, Mark Kettenis wrote:
> > Date: Mon, 05 Nov 2007 13:21:29 +0100
> > From: Markus Deuling <deuling@de.ibm.com>
> >
> > Hi,
> >
> > this patch replaces SIZEOF_FRAME_SAVED_REGS macro by its expression.
> >
> > Tested by gdb_mbuild with alpha target. Is this ok to commit?
>
> I'm not thrilled, since this replaces a #define that has a sensible
> name with some sort of complicated expression, and therefore makes the
> code much more difficult to read.
Ditto. frame_zalloc_saved_regs (frame)?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
2007-11-05 14:00 ` Daniel Jacobowitz
@ 2007-11-05 15:14 ` Ulrich Weigand
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Weigand @ 2007-11-05 15:14 UTC (permalink / raw)
To: Daniel Jacobowitz, mark.kettenis, deuling; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Mon, Nov 05, 2007 at 02:43:29PM +0100, Mark Kettenis wrote:
> > > Date: Mon, 05 Nov 2007 13:21:29 +0100
> > > From: Markus Deuling <deuling@de.ibm.com>
> > >
> > > Hi,
> > >
> > > this patch replaces SIZEOF_FRAME_SAVED_REGS macro by its expression.
> > >
> > > Tested by gdb_mbuild with alpha target. Is this ok to commit?
> >
> > I'm not thrilled, since this replaces a #define that has a sensible
> > name with some sort of complicated expression, and therefore makes the
> > code much more difficult to read.
>
> Ditto. frame_zalloc_saved_regs (frame)?
As far as I can see SIZEOF_FRAME_SAVED_REGS is really just a remainder
of the old frame logic that happens to be still in local use on alpha
for some reason -- I do not think it makes sense to "generalize" it
like that, it should be removed from common code.
Note that the expression
#define SIZEOF_FRAME_SAVED_REGS \
(sizeof (CORE_ADDR) * (gdbarch_num_regs (current_gdbarch)\
+ gdbarch_num_pseudo_regs (current_gdbarch)))
would likely be incorrect on most other platforms anyway nowadays.
However, on the alpha, this is actually constant: num_regs is alway
ALPHA_NUM_REGS, pseudo registers are not used, and sizeof (CORE_ADDR)
should always be 8 in a gdb build targetting the alpha.
In fact, there exists already an alpha-specific macro that should
have just the correct value:
#define ALPHA_REGISTER_BYTES (ALPHA_NUM_REGS * 8)
Why not just replace SIZEOF_FRAME_SAVED_REGS with ALPHA_REGISTER_BYTES
in the alpha files and remove it from common code?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-05 15:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-05 12:23 [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro) Markus Deuling
2007-11-05 13:44 ` Mark Kettenis
2007-11-05 14:00 ` Daniel Jacobowitz
2007-11-05 15:14 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox