From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: brobecker@adacore.com, gdb-patches@sourceware.org
Subject: [rfa/Ada] Remove current_gdbarch from ensure_lval
Date: Fri, 26 Jun 2009 15:54:00 -0000 [thread overview]
Message-ID: <200906261554.n5QFsDgD030625@d12av02.megacenter.de.ibm.com> (raw)
Hello Joel,
this patch doesn't do anything with builtin types, but it removes references
to current_gdbarch in ensure_lval. This routine allocates temporary space
on the inferior's stack during inferior call argument setup.
The patch simply passes the appropriate architecture to use though from
infcall.c code, alongside the SP value that is already passed through.
Tested on amd64-linux. OK for mainline?
Bye,
Ulrich
ChangeLog:
* ada-lang.h (ada_convert_actual): Add GDBARCH argument.
* ada-lang.c (convert_actual): Remove stale prototype.
(ensure_lval, make_array_descriptor, ada_convert_actual):
Add GDBARCH argument and pass through to subroutine calls.
(ensure_lval): Use GDBARCH instead of current_gdbarch.
* infcall.c (value_arg_coerce): Update ada_convert_actual call.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -101,13 +101,11 @@ static int ada_type_match (struct type *
static int ada_args_match (struct symbol *, struct value **, int);
-static struct value *ensure_lval (struct value *, CORE_ADDR *);
-
-static struct value *convert_actual (struct value *, struct type *,
- CORE_ADDR *);
+static struct value *ensure_lval (struct value *,
+ struct gdbarch *, CORE_ADDR *);
static struct value *make_array_descriptor (struct type *, struct value *,
- CORE_ADDR *);
+ struct gdbarch *, CORE_ADDR *);
static void ada_add_block_symbols (struct obstack *,
struct block *, const char *,
@@ -3726,7 +3724,7 @@ parse_old_style_renaming (struct type *t
returning an lvalue whose value_address points to the copy. */
static struct value *
-ensure_lval (struct value *val, CORE_ADDR *sp)
+ensure_lval (struct value *val, struct gdbarch *gdbarch, CORE_ADDR *sp)
{
if (! VALUE_LVAL (val))
{
@@ -3735,25 +3733,25 @@ ensure_lval (struct value *val, CORE_ADD
/* The following is taken from the structure-return code in
call_function_by_hand. FIXME: Therefore, some refactoring seems
indicated. */
- if (gdbarch_inner_than (current_gdbarch, 1, 2))
+ if (gdbarch_inner_than (gdbarch, 1, 2))
{
/* Stack grows downward. Align SP and value_address (val) after
reserving sufficient space. */
*sp -= len;
- if (gdbarch_frame_align_p (current_gdbarch))
- *sp = gdbarch_frame_align (current_gdbarch, *sp);
+ if (gdbarch_frame_align_p (gdbarch))
+ *sp = gdbarch_frame_align (gdbarch, *sp);
set_value_address (val, *sp);
}
else
{
/* Stack grows upward. Align the frame, allocate space, and
then again, re-align the frame. */
- if (gdbarch_frame_align_p (current_gdbarch))
- *sp = gdbarch_frame_align (current_gdbarch, *sp);
+ if (gdbarch_frame_align_p (gdbarch))
+ *sp = gdbarch_frame_align (gdbarch, *sp);
set_value_address (val, *sp);
*sp += len;
- if (gdbarch_frame_align_p (current_gdbarch))
- *sp = gdbarch_frame_align (current_gdbarch, *sp);
+ if (gdbarch_frame_align_p (gdbarch))
+ *sp = gdbarch_frame_align (gdbarch, *sp);
}
VALUE_LVAL (val) = lval_memory;
@@ -3770,7 +3768,7 @@ ensure_lval (struct value *val, CORE_ADD
struct value *
ada_convert_actual (struct value *actual, struct type *formal_type0,
- CORE_ADDR *sp)
+ struct gdbarch *gdbarch, CORE_ADDR *sp)
{
struct type *actual_type = ada_check_typedef (value_type (actual));
struct type *formal_type = ada_check_typedef (formal_type0);
@@ -3783,7 +3781,7 @@ ada_convert_actual (struct value *actual
if (ada_is_array_descriptor_type (formal_target)
&& TYPE_CODE (actual_target) == TYPE_CODE_ARRAY)
- return make_array_descriptor (formal_type, actual, sp);
+ return make_array_descriptor (formal_type, actual, gdbarch, sp);
else if (TYPE_CODE (formal_type) == TYPE_CODE_PTR
|| TYPE_CODE (formal_type) == TYPE_CODE_REF)
{
@@ -3801,7 +3799,7 @@ ada_convert_actual (struct value *actual
memcpy ((char *) value_contents_raw (val),
(char *) value_contents (actual),
TYPE_LENGTH (actual_type));
- actual = ensure_lval (val, sp);
+ actual = ensure_lval (val, gdbarch, sp);
}
result = value_addr (actual);
}
@@ -3823,7 +3821,8 @@ ada_convert_actual (struct value *actual
representing a pointer to this descriptor. */
static struct value *
-make_array_descriptor (struct type *type, struct value *arr, CORE_ADDR *sp)
+make_array_descriptor (struct type *type, struct value *arr,
+ struct gdbarch *gdbarch, CORE_ADDR *sp)
{
struct type *bounds_type = desc_bounds_type (type);
struct type *desc_type = desc_base_type (type);
@@ -3843,10 +3842,10 @@ make_array_descriptor (struct type *type
desc_bound_bitsize (bounds_type, i, 1));
}
- bounds = ensure_lval (bounds, sp);
+ bounds = ensure_lval (bounds, gdbarch, sp);
modify_general_field (value_contents_writeable (descriptor),
- value_address (ensure_lval (arr, sp)),
+ value_address (ensure_lval (arr, gdbarch, sp)),
fat_pntr_data_bitpos (desc_type),
fat_pntr_data_bitsize (desc_type));
@@ -3855,7 +3854,7 @@ make_array_descriptor (struct type *type
fat_pntr_bounds_bitpos (desc_type),
fat_pntr_bounds_bitsize (desc_type));
- descriptor = ensure_lval (descriptor, sp);
+ descriptor = ensure_lval (descriptor, gdbarch, sp);
if (TYPE_CODE (type) == TYPE_CODE_PTR)
return value_addr (descriptor);
Index: gdb-head/gdb/ada-lang.h
===================================================================
--- gdb-head.orig/gdb/ada-lang.h
+++ gdb-head/gdb/ada-lang.h
@@ -265,6 +265,7 @@ extern void ada_printstr (struct ui_file
struct value *ada_convert_actual (struct value *actual,
struct type *formal_type0,
+ struct gdbarch *gdbarch,
CORE_ADDR *sp);
extern struct value *ada_value_subscript (struct value *, int,
Index: gdb-head/gdb/infcall.c
===================================================================
--- gdb-head.orig/gdb/infcall.c
+++ gdb-head/gdb/infcall.c
@@ -142,7 +142,7 @@ value_arg_coerce (struct gdbarch *gdbarc
/* Perform any Ada-specific coercion first. */
if (current_language->la_language == language_ada)
- arg = ada_convert_actual (arg, type, sp);
+ arg = ada_convert_actual (arg, type, gdbarch, sp);
/* Force the value to the target if we will need its address. At
this point, we could allocate arguments on the stack instead of
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next reply other threads:[~2009-06-26 15:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-26 15:54 Ulrich Weigand [this message]
2009-06-29 15:40 ` Joel Brobecker
2009-06-29 17:34 ` Ulrich Weigand
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=200906261554.n5QFsDgD030625@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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