Skip to content

Commit 5cb0f2d

Browse files
committed
Convert selected architectures to gdbarch_return_value_as_value
This converts a few selected architectures to use gdbarch_return_value_as_value rather than gdbarch_return_value. The architectures are just the ones that I am able to test. This patch should not introduce any behavior changes.
1 parent 12bb802 commit 5cb0f2d

File tree

9 files changed

+81
-20
lines changed

9 files changed

+81
-20
lines changed

gdb/aarch64-tdep.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,8 +2446,14 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
24462446
static enum return_value_convention
24472447
aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
24482448
struct type *valtype, struct regcache *regcache,
2449-
gdb_byte *readbuf, const gdb_byte *writebuf)
2449+
struct value **read_value, const gdb_byte *writebuf)
24502450
{
2451+
gdb_byte *readbuf = nullptr;
2452+
if (read_value != nullptr)
2453+
{
2454+
*read_value = allocate_value (valtype);
2455+
readbuf = value_contents_raw (*read_value).data ();
2456+
}
24512457

24522458
if (valtype->code () == TYPE_CODE_STRUCT
24532459
|| valtype->code () == TYPE_CODE_UNION
@@ -3765,7 +3771,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
37653771
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, aarch64_dwarf_reg_to_regnum);
37663772

37673773
/* Returning results. */
3768-
set_gdbarch_return_value (gdbarch, aarch64_return_value);
3774+
set_gdbarch_return_value_as_value (gdbarch, aarch64_return_value);
37693775

37703776
/* Disassembly. */
37713777
set_gdbarch_print_insn (gdbarch, aarch64_gdb_print_insn);

gdb/amd64-tdep.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ amd64_classify (struct type *type, enum amd64_reg_class theclass[2])
789789
static enum return_value_convention
790790
amd64_return_value (struct gdbarch *gdbarch, struct value *function,
791791
struct type *type, struct regcache *regcache,
792-
gdb_byte *readbuf, const gdb_byte *writebuf)
792+
struct value **read_value, const gdb_byte *writebuf)
793793
{
794794
enum amd64_reg_class theclass[2];
795795
int len = type->length ();
@@ -799,7 +799,14 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
799799
int sse_reg = 0;
800800
int i;
801801

802-
gdb_assert (!(readbuf && writebuf));
802+
gdb_assert (!(read_value && writebuf));
803+
804+
gdb_byte *readbuf = nullptr;
805+
if (read_value != nullptr)
806+
{
807+
*read_value = allocate_value (type);
808+
readbuf = value_contents_raw (*read_value).data ();
809+
}
803810

804811
/* 1. Classify the return type with the classification algorithm. */
805812
amd64_classify (type, theclass);
@@ -3236,7 +3243,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
32363243
set_gdbarch_register_to_value (gdbarch, i387_register_to_value);
32373244
set_gdbarch_value_to_register (gdbarch, i387_value_to_register);
32383245

3239-
set_gdbarch_return_value (gdbarch, amd64_return_value);
3246+
set_gdbarch_return_value_as_value (gdbarch, amd64_return_value);
32403247

32413248
set_gdbarch_skip_prologue (gdbarch, amd64_skip_prologue);
32423249

gdb/amd64-windows-tdep.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,18 @@ amd64_windows_push_dummy_call
355355
static enum return_value_convention
356356
amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
357357
struct type *type, struct regcache *regcache,
358-
gdb_byte *readbuf, const gdb_byte *writebuf)
358+
struct value **read_value, const gdb_byte *writebuf)
359359
{
360360
int len = type->length ();
361361
int regnum = -1;
362362

363+
gdb_byte *readbuf = nullptr;
364+
if (read_value != nullptr)
365+
{
366+
*read_value = allocate_value (type);
367+
readbuf = value_contents_raw (*read_value).data ();
368+
}
369+
363370
/* See if our value is returned through a register. If it is, then
364371
store the associated register number in REGNUM. */
365372
switch (type->code ())
@@ -1297,7 +1304,7 @@ amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch)
12971304

12981305
/* Function calls. */
12991306
set_gdbarch_push_dummy_call (gdbarch, amd64_windows_push_dummy_call);
1300-
set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
1307+
set_gdbarch_return_value_as_value (gdbarch, amd64_windows_return_value);
13011308
set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue);
13021309
set_gdbarch_skip_trampoline_code (gdbarch,
13031310
amd64_windows_skip_trampoline_code);

gdb/arm-tdep.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9138,8 +9138,15 @@ arm_store_return_value (struct type *type, struct regcache *regs,
91389138
static enum return_value_convention
91399139
arm_return_value (struct gdbarch *gdbarch, struct value *function,
91409140
struct type *valtype, struct regcache *regcache,
9141-
gdb_byte *readbuf, const gdb_byte *writebuf)
9141+
struct value **read_value, const gdb_byte *writebuf)
91429142
{
9143+
gdb_byte *readbuf = nullptr;
9144+
if (read_value != nullptr)
9145+
{
9146+
*read_value = allocate_value (valtype);
9147+
readbuf = value_contents_raw (*read_value).data ();
9148+
}
9149+
91439150
arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
91449151
struct type *func_type = function ? value_type (function) : NULL;
91459152
enum arm_vfp_cprc_base_type vfp_base_type;
@@ -10675,7 +10682,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1067510682
set_gdbarch_register_name (gdbarch, arm_register_name);
1067610683

1067710684
/* Returning results. */
10678-
set_gdbarch_return_value (gdbarch, arm_return_value);
10685+
set_gdbarch_return_value_as_value (gdbarch, arm_return_value);
1067910686

1068010687
/* Disassembly. */
1068110688
set_gdbarch_print_insn (gdbarch, gdb_print_insn_arm);

gdb/i386-tdep.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,10 +3030,17 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
30303030
static enum return_value_convention
30313031
i386_return_value (struct gdbarch *gdbarch, struct value *function,
30323032
struct type *type, struct regcache *regcache,
3033-
gdb_byte *readbuf, const gdb_byte *writebuf)
3033+
struct value **read_value, const gdb_byte *writebuf)
30343034
{
30353035
enum type_code code = type->code ();
30363036

3037+
gdb_byte *readbuf = nullptr;
3038+
if (read_value != nullptr)
3039+
{
3040+
*read_value = allocate_value (type);
3041+
readbuf = value_contents_raw (*read_value).data ();
3042+
}
3043+
30373044
if (((code == TYPE_CODE_STRUCT
30383045
|| code == TYPE_CODE_UNION
30393046
|| code == TYPE_CODE_ARRAY)
@@ -3081,9 +3088,13 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
30813088
here. */
30823089
if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
30833090
{
3084-
type = check_typedef (type->field (0).type ());
3085-
return i386_return_value (gdbarch, function, type, regcache,
3086-
readbuf, writebuf);
3091+
struct type *inner_type = check_typedef (type->field (0).type ());
3092+
enum return_value_convention result
3093+
= i386_return_value (gdbarch, function, inner_type, regcache,
3094+
read_value, writebuf);
3095+
if (read_value != nullptr)
3096+
deprecated_set_value_type (*read_value, type);
3097+
return result;
30873098
}
30883099

30893100
if (readbuf)
@@ -8572,7 +8583,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
85728583
set_gdbarch_register_to_value (gdbarch, i386_register_to_value);
85738584
set_gdbarch_value_to_register (gdbarch, i386_value_to_register);
85748585

8575-
set_gdbarch_return_value (gdbarch, i386_return_value);
8586+
set_gdbarch_return_value_as_value (gdbarch, i386_return_value);
85768587

85778588
set_gdbarch_skip_prologue (gdbarch, i386_skip_prologue);
85788589

gdb/ppc-linux-tdep.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,15 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
249249
static enum return_value_convention
250250
ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function,
251251
struct type *valtype, struct regcache *regcache,
252-
gdb_byte *readbuf, const gdb_byte *writebuf)
252+
struct value **read_value, const gdb_byte *writebuf)
253253
{
254+
gdb_byte *readbuf = nullptr;
255+
if (read_value != nullptr)
256+
{
257+
*read_value = allocate_value (valtype);
258+
readbuf = value_contents_raw (*read_value).data ();
259+
}
260+
254261
if ((valtype->code () == TYPE_CODE_STRUCT
255262
|| valtype->code () == TYPE_CODE_UNION)
256263
&& !((valtype->length () == 16 || valtype->length () == 8)
@@ -2102,7 +2109,8 @@ ppc_linux_init_abi (struct gdbarch_info info,
21022109
(well ignoring vectors that is). When this was corrected, it
21032110
wasn't fixed for GNU/Linux native platform. Use the
21042111
PowerOpen struct convention. */
2105-
set_gdbarch_return_value (gdbarch, ppc_linux_return_value);
2112+
set_gdbarch_return_value_as_value (gdbarch, ppc_linux_return_value);
2113+
set_gdbarch_return_value (gdbarch, nullptr);
21062114

21072115
set_gdbarch_memory_remove_breakpoint (gdbarch,
21082116
ppc_linux_memory_remove_breakpoint);

gdb/riscv-tdep.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,13 +3221,20 @@ riscv_return_value (struct gdbarch *gdbarch,
32213221
struct value *function,
32223222
struct type *type,
32233223
struct regcache *regcache,
3224-
gdb_byte *readbuf,
3224+
struct value **read_value,
32253225
const gdb_byte *writebuf)
32263226
{
32273227
struct riscv_call_info call_info (gdbarch);
32283228
struct riscv_arg_info info;
32293229
struct type *arg_type;
32303230

3231+
gdb_byte *readbuf = nullptr;
3232+
if (read_value != nullptr)
3233+
{
3234+
*read_value = allocate_value (type);
3235+
readbuf = value_contents_raw (*read_value).data ();
3236+
}
3237+
32313238
arg_type = check_typedef (type);
32323239
riscv_arg_location (gdbarch, &info, &call_info, arg_type, false);
32333240

@@ -3888,7 +3895,7 @@ riscv_gdbarch_init (struct gdbarch_info info,
38883895
set_gdbarch_type_align (gdbarch, riscv_type_align);
38893896

38903897
/* Information about the target architecture. */
3891-
set_gdbarch_return_value (gdbarch, riscv_return_value);
3898+
set_gdbarch_return_value_as_value (gdbarch, riscv_return_value);
38923899
set_gdbarch_breakpoint_kind_from_pc (gdbarch, riscv_breakpoint_kind_from_pc);
38933900
set_gdbarch_sw_breakpoint_from_kind (gdbarch, riscv_sw_breakpoint_from_kind);
38943901
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);

gdb/sparc-tdep.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,10 +1496,17 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache,
14961496
static enum return_value_convention
14971497
sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
14981498
struct type *type, struct regcache *regcache,
1499-
gdb_byte *readbuf, const gdb_byte *writebuf)
1499+
struct value **read_value, const gdb_byte *writebuf)
15001500
{
15011501
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
15021502

1503+
gdb_byte *readbuf = nullptr;
1504+
if (read_value != nullptr)
1505+
{
1506+
*read_value = allocate_value (type);
1507+
readbuf = value_contents_raw (*read_value).data ();
1508+
}
1509+
15031510
/* The psABI says that "...every stack frame reserves the word at
15041511
%fp+64. If a function returns a structure, union, or
15051512
quad-precision value, this word should hold the address of the
@@ -1853,7 +1860,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
18531860
set_gdbarch_push_dummy_code (gdbarch, sparc32_push_dummy_code);
18541861
set_gdbarch_push_dummy_call (gdbarch, sparc32_push_dummy_call);
18551862

1856-
set_gdbarch_return_value (gdbarch, sparc32_return_value);
1863+
set_gdbarch_return_value_as_value (gdbarch, sparc32_return_value);
18571864
set_gdbarch_stabs_argument_has_addr
18581865
(gdbarch, sparc32_stabs_argument_has_addr);
18591866

gdb/sparc64-tdep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,7 @@ sparc64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
18351835
set_gdbarch_push_dummy_call (gdbarch, sparc64_push_dummy_call);
18361836

18371837
set_gdbarch_return_value (gdbarch, sparc64_return_value);
1838+
set_gdbarch_return_value_as_value (gdbarch, default_gdbarch_return_value);
18381839
set_gdbarch_stabs_argument_has_addr
18391840
(gdbarch, default_stabs_argument_has_addr);
18401841

0 commit comments

Comments
 (0)