Target FP: Add string routines to target-float.{c,h}

This adds target_float_to_string and target_float_from_string,
which dispatch to the corresponding floatformat_ or decimal_ routines.

Existing users of those routines are changed to use the new
target-float routines instead (most of those places already handle
both binary and decimal FP).

In addition, two other places are changes to use target_float_from_string:

- define_symbol in stabsread.c, when parsing a floating-point literal
  from stabs debug info

- gdbarch-selftest.c when initializing a target format values (to
  eliminate use of DOUBLEST there).

gdb/ChangeLog:
2017-11-06  Ulrich Weigand  <uweigand@de.ibm.com>

	* target-float.c (target_float_to_string): New function.
	(target_float_from_string): New function.
	* target-float.h (target_float_to_string): Add prototype.
	(target_float_from_string): Add prototype.

	* valprint.c: Include "target-float.h".  Do not include
	"doublest.h" and "dfp.h".
	(print_floating): Use target_float_to_string.
	* printcmd.c: Include "target-float.h".  Do not include "dfp.h".
	(printf_floating): Use target_float_to_string.
	* i387-tdep.c: Include "target-float.h".  Do not include "doublest.h".
	(print_i387_value): Use target_float_to_string.
	* mips-tdep.c: Include "target-float.h".
	(mips_print_fp_register): Use target_float_to_string.
	* sh64-tdep.c: Include "target-float.h".
	(sh64_do_fp_register): Use target_float_to_string.

	* parse.c: Include "target-float.h".  Do not include
	"doublest.h" and "dfp.h".
	(parse_float): Use target_float_from_string.
	* stabsread.c: Include "target-float.h".  Do not include "doublest.h".
	(define_symbol): Use target_float_from_string.
	* gdbarch-selftests.c: Include "target-float.h".
	(register_to_value_test): Use target_float_from_string.
This commit is contained in:
Ulrich Weigand 2017-11-06 15:56:35 +01:00
parent 701000146a
commit f69fdf9bca
11 changed files with 96 additions and 57 deletions

View file

@ -44,8 +44,7 @@
#include "gdbcmd.h"
#include "symfile.h" /* for overlay functions */
#include "inferior.h"
#include "doublest.h"
#include "dfp.h"
#include "target-float.h"
#include "block.h"
#include "source.h"
#include "objfiles.h"
@ -1338,13 +1337,7 @@ bool
parse_float (const char *p, int len,
const struct type *type, gdb_byte *data)
{
if (TYPE_CODE (type) == TYPE_CODE_FLT)
return floatformat_from_string (floatformat_from_type (type),
data, std::string (p, len));
else
return decimal_from_string (data, TYPE_LENGTH (type),
gdbarch_byte_order (get_type_arch (type)),
std::string (p, len));
return target_float_from_string (data, type, std::string (p, len));
}
/* Stuff for maintaining a stack of types. Currently just used by C, but