aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-11-30 11:37:11 +0100
committerTom de Vries <tdevries@suse.de>2022-11-30 11:37:11 +0100
commitaaa79cd62b873be672e3163eb267513c97ec4399 (patch)
tree9c7408044b19cc0d5d112de8361f84eb42df4324 /gdb/arch-utils.c
parent6bd454ca033dcb2e178721eb004d0c5f24415c4c (diff)
downloadgdb-aaa79cd62b873be672e3163eb267513c97ec4399.zip
gdb-aaa79cd62b873be672e3163eb267513c97ec4399.tar.gz
gdb-aaa79cd62b873be672e3163eb267513c97ec4399.tar.bz2
[gdb] Improve printing of float formats
Currently, on x86_64, a little endian target, I get: ... $ gdb -q -batch -ex "maint print architecture" | grep " = floatformat" gdbarch_dump: bfloat16_format = floatformat_bfloat16_big gdbarch_dump: double_format = floatformat_ieee_double_big gdbarch_dump: float_format = floatformat_ieee_single_big gdbarch_dump: half_format = floatformat_ieee_half_big gdbarch_dump: long_double_format = floatformat_i387_ext ... which suggests big endian. This is due to this bit of code in pformat: ... /* Just print out one of them - this is only for diagnostics. */ return format[0]->name; ... Fix this by using gdbarch_byte_order to pick the appropriate index, such that we have the more accurate: ... gdbarch_dump: bfloat16_format = floatformat_bfloat16_little gdbarch_dump: half_format = floatformat_ieee_half_little gdbarch_dump: float_format = floatformat_ieee_single_little gdbarch_dump: double_format = floatformat_ieee_double_little gdbarch_dump: long_double_format = floatformat_i387_ext ... Tested on x86_64-linux.
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 7b84daf..60ffdc5 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -1104,13 +1104,13 @@ show_gdbarch_debug (struct ui_file *file, int from_tty,
}
static const char *
-pformat (const struct floatformat **format)
+pformat (struct gdbarch *gdbarch, const struct floatformat **format)
{
if (format == NULL)
return "(null)";
- else
- /* Just print out one of them - this is only for diagnostics. */
- return format[0]->name;
+
+ int format_index = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE ? 1 : 0;
+ return format[format_index]->name;
}
static const char *