This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Mon, 05 Nov 2007 13:21:29 +0100
- Subject: [rfc] [04/09] Get rid of current_gdbarch (SIZEOF_FRAME_SAVED_REGS macro)
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
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. */