aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-06 16:00:47 +0100
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-11-06 16:00:47 +0100
commit14ad9311720fc17bd646b2ff08483fe60a489959 (patch)
tree1092793393df19bbcfa96f188eaf3eb2fbfdceee /gdb/python
parent50eff16b85073287b1b184a257a8fd80e960fe02 (diff)
downloadbinutils-14ad9311720fc17bd646b2ff08483fe60a489959.zip
binutils-14ad9311720fc17bd646b2ff08483fe60a489959.tar.gz
binutils-14ad9311720fc17bd646b2ff08483fe60a489959.tar.bz2
Target FP: Handle interfaces to scripting languages
The last remaing use for DOUBLEST is in the code that interfaces to the scripting languages (Python and Guile). The problem here is that we expose interfaces to convert a GDB value to and from native values of floating-point type in those languages, and those by definition use the host floating-point format. While we cannot completely eliminate conversions to/from the host floating-point format here, we still need to get rid of the uses of value_as_double / value_from_double, since those will go away. This patch implements two new target-float.c routine: - target_float_to_host_double - target_float_from_host_double which convert to/from a host "double". Those should only ever be used where a host "double" is mandated by an external interface. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (floatformat_to_host_double): New function. (floatformat_from_host_double): Likewise. (target_float_to_host_double): Likewise. (target_float_from_host_double): Likewise. * target-float.h (target_float_to_host_double): Add prototype. (target_float_from_host_double): Likewise. * guile/scm-value.c: Include "target-float.h". (gdbscm_value_to_real): Use target_float_to_host_double. Handle integer source values via value_as_long. * guile/scm-math.c: Include "target-float.h". Do not include "doublest.h", "dfp.h", and "expression.h". (vlscm_convert_typed_number): Use target_float_from_host_double. (vlscm_convert_number): Likewise. * python/py-value.c (valpy_float): Use target_float_to_host_double. (convert_value_from_python): Use target_float_from_host_double.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-value.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 16c7650..11f1fc9 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1560,10 +1560,10 @@ valpy_float (PyObject *self)
{
type = check_typedef (type);
- if (TYPE_CODE (type) != TYPE_CODE_FLT)
+ if (TYPE_CODE (type) != TYPE_CODE_FLT || !is_floating_value (value))
error (_("Cannot convert value to float."));
- d = value_as_double (value);
+ d = target_float_to_host_double (value_contents (value), type);
}
CATCH (except, RETURN_MASK_ALL)
{
@@ -1681,7 +1681,11 @@ convert_value_from_python (PyObject *obj)
double d = PyFloat_AsDouble (obj);
if (! PyErr_Occurred ())
- value = value_from_double (builtin_type_pyfloat, d);
+ {
+ value = allocate_value (builtin_type_pyfloat);
+ target_float_from_host_double (value_contents_raw (value),
+ value_type (value), d);
+ }
}
else if (gdbpy_is_string (obj))
{