GDB (xrefs)

Classes | Macros | Enumerations | Functions | Variables
/tmp/gdb-8.1/gdb/target-float.c File Reference
`#include "defs.h"`
`#include "gdbtypes.h"`
`#include "floatformat.h"`
`#include "target-float.h"`
`#include <cmath>`
`#include <limits>`
`#include <mpfr.h>`
`#include "dpd/decimal128.h"`
`#include "dpd/decimal64.h"`
`#include "dpd/decimal32.h"`

Go to the source code of this file.

## Classes
class | target_float_ops
class | host_float_ops< T >
struct | printf_length_modifier< T >
struct | printf_length_modifier< long double >
struct | scanf_length_modifier< T >
struct | scanf_length_modifier< double >
struct | scanf_length_modifier< long double >
class | mpfr_float_ops
class | mpfr_float_ops::gdb_mpfr
class | decimal_float_ops

## Macros
#define | FLOATFORMAT_CHAR_BIT 8
#define | FLOATFORMAT_LARGEST_BYTES 16
#define | MPFR_USE_INTMAX_T
#define | MAX_DECIMAL_STRING 43
#define | OPPOSITE_BYTE_ORDER BFD_ENDIAN_BIG

## Enumerations
enum | float_kind { float_nan, float_infinite, float_zero, float_normal, float_subnormal }
enum | target_float_ops_kind { host_float = 0, host_double, host_long_double, binary, decimal }

## Functions
static size_t | floatformat_totalsize_bytes (const struct floatformat *fmt)
static int | floatformat_precision (const struct floatformat *fmt)
static enum floatformat_byteorders | floatformat_normalize_byteorder (const struct floatformat *fmt, const void *from, void *to)
static unsigned long | get_field (const bfd_byte *data, enum floatformat_byteorders order, unsigned int total_len, unsigned int start, unsigned int len)
static void | put_field (unsigned char *data, enum floatformat_byteorders order, unsigned int total_len, unsigned int start, unsigned int len, unsigned long stuff_to_put)
static int | floatformat_is_negative (const struct floatformat *fmt, const bfd_byte *uval)
static enum float_kind | floatformat_classify (const struct floatformat *fmt, const bfd_byte *uval)
static const char * | floatformat_mantissa (const struct floatformat *fmt, const bfd_byte *val)
static std::string | floatformat_printf_format (const struct floatformat *fmt, const char *format, char length)
static void | match_endianness (const gdb_byte *from, const struct type *type, gdb_byte *to)
static void | set_decnumber_context (decContext *ctx, const struct type *type)
static void | decimal_check_errors (decContext *ctx)
static void | decimal_from_number (const decNumber *from, gdb_byte *to, const struct type *type)
static void | decimal_to_number (const gdb_byte *addr, const struct type *type, decNumber *to)
static bool | decimal_is_zero (const gdb_byte *addr, const struct type *type)
static bool | target_float_same_category_p (const struct type *type1, const struct type *type2)
static bool | target_float_same_format_p (const struct type *type1, const struct type *type2)
static int | target_float_format_length (const struct type *type)
static enum target_float_ops_kind | get_target_float_ops_kind (const struct type *type)
static const target_float_ops * | get_target_float_ops (enum target_float_ops_kind kind)
static const target_float_ops * | get_target_float_ops (const struct type *type)
static const target_float_ops * | get_target_float_ops (const struct type *type1, const struct type *type2)
bool | target_float_is_valid (const gdb_byte *addr, const struct type *type)
bool | target_float_is_zero (const gdb_byte *addr, const struct type *type)
std::string | target_float_to_string (const gdb_byte *addr, const struct type *type, const char *format)
bool | target_float_from_string (gdb_byte *addr, const struct type *type, const std::string &string)
LONGEST | target_float_to_longest (const gdb_byte *addr, const struct type *type)
void | target_float_from_longest (gdb_byte *addr, const struct type *type, LONGEST val)
void | target_float_from_ulongest (gdb_byte *addr, const struct type *type, ULONGEST val)
double | target_float_to_host_double (const gdb_byte *addr, const struct type *type)
void | target_float_from_host_double (gdb_byte *addr, const struct type *type, double val)
void | target_float_convert (const gdb_byte *from, const struct type *from_type, gdb_byte *to, const struct type *to_type)
void | target_float_binop (enum exp_opcode opcode, const gdb_byte *x, const struct type *type_x, const gdb_byte *y, const struct type *type_y, gdb_byte *res, const struct type *type_res)
int | target_float_compare (const gdb_byte *x, const struct type *type_x, const gdb_byte *y, const struct type *type_y)

## Variables
static const struct floatformat * | host_float_format = GDB_HOST_FLOAT_FORMAT
static const struct floatformat * | host_double_format = GDB_HOST_DOUBLE_FORMAT
static const struct floatformat * | host_long_double_format = GDB_HOST_LONG_DOUBLE_FORMAT

## Macro Definition Documentation

## ◆ FLOATFORMAT_CHAR_BIT

#define FLOATFORMAT_CHAR_BIT 8

Definition at line 83 of file target-float.c.

Referenced by floatformat_classify(), floatformat_is_negative(), floatformat_mantissa(), floatformat_normalize_byteorder(), floatformat_totalsize_bytes(), host_float_ops< T >::from_target(), mpfr_float_ops::from_target(), get_field(), put_field(), host_float_ops< T >::to_target(), and mpfr_float_ops::to_target().

## ◆ FLOATFORMAT_LARGEST_BYTES

#define FLOATFORMAT_LARGEST_BYTES 16

Definition at line 87 of file target-float.c.

Referenced by floatformat_classify(), floatformat_is_negative(), floatformat_mantissa(), host_float_ops< T >::from_target(), mpfr_float_ops::from_target(), host_float_ops< T >::to_target(), and mpfr_float_ops::to_target().

## ◆ MAX_DECIMAL_STRING

#define MAX_DECIMAL_STRING 43

Definition at line 1726 of file target-float.c.

Referenced by decimal_float_ops::to_string().

## ◆ MPFR_USE_INTMAX_T

#define MPFR_USE_INTMAX_T

Definition at line 1150 of file target-float.c.

## ◆ OPPOSITE_BYTE_ORDER

#define OPPOSITE_BYTE_ORDER BFD_ENDIAN_BIG

Referenced by match_endianness().

## Enumeration Type Documentation

## ◆ float_kind

enum float_kind

Enumerator
float_nan |
float_infinite |
float_zero |
float_normal |
float_subnormal |

Definition at line 72 of file target-float.c.

## ◆ target_float_ops_kind

enum target_float_ops_kind

Enumerator
host_float |
host_double |
host_long_double |
binary |
decimal |

Definition at line 2180 of file target-float.c.

## Function Documentation

## ◆ decimal_check_errors()

static void decimal_check_errors | ( | decContext * | ctx | ) |
| static

Definition at line 1780 of file target-float.c.

References _, and error().

Referenced by decimal_float_ops::binop(), decimal_float_ops::compare(), and decimal_float_ops::from_string().

## ◆ decimal_from_number()

static void decimal_from_number | ( | const decNumber * | from,
|  | gdb_byte * | to,
|  | const struct type * | type
| ) |  |
| static

Definition at line 1799 of file target-float.c.

References _, error(), match_endianness(), set_decnumber_context(), and TYPE_LENGTH.

Referenced by decimal_float_ops::binop(), decimal_float_ops::convert(), decimal_float_ops::from_longest(), and decimal_float_ops::from_ulongest().

## ◆ decimal_is_zero()

static bool decimal_is_zero | ( | const gdb_byte * | addr,
|  | const struct type * | type
| ) |  |
| static

Definition at line 1855 of file target-float.c.

References decimal_to_number().

Referenced by target_float_is_zero().

## ◆ decimal_to_number()

static void decimal_to_number | ( | const gdb_byte * | addr,
|  | const struct type * | type,
|  | decNumber * | to
| ) |  |
| static

Definition at line 1830 of file target-float.c.

References _, error(), match_endianness(), and TYPE_LENGTH.

Referenced by decimal_float_ops::binop(), decimal_float_ops::compare(), decimal_float_ops::convert(), and decimal_is_zero().

## ◆ floatformat_classify()

static enum float_kind floatformat_classify | ( | const struct floatformat * | fmt,
|  | const bfd_byte * | uval
| ) |  |
| static

Definition at line 325 of file target-float.c.

References float_infinite, float_nan, float_normal, float_subnormal, float_zero, FLOATFORMAT_CHAR_BIT, FLOATFORMAT_LARGEST_BYTES, floatformat_normalize_byteorder(), gdb_assert, and get_field().

Referenced by host_float_ops< T >::from_target(), mpfr_float_ops::from_target(), target_float_is_zero(), target_float_to_string(), and mpfr_float_ops::to_string().

## ◆ floatformat_is_negative()

static int floatformat_is_negative | ( | const struct floatformat * | fmt,
|  | const bfd_byte * | uval
| ) |  |
| static

Definition at line 300 of file target-float.c.

References FLOATFORMAT_CHAR_BIT, FLOATFORMAT_LARGEST_BYTES, floatformat_normalize_byteorder(), gdb_assert, and get_field().

Referenced by mpfr_float_ops::from_target(), target_float_to_string(), and mpfr_float_ops::to_string().

## ◆ floatformat_mantissa()

static const char* floatformat_mantissa | ( | const struct floatformat * | fmt,
|  | const bfd_byte * | val
| ) |  |
| static

Definition at line 413 of file target-float.c.

References FLOATFORMAT_CHAR_BIT, FLOATFORMAT_LARGEST_BYTES, floatformat_normalize_byteorder(), gdb_assert, get_field(), and xsnprintf().

Referenced by target_float_to_string(), and mpfr_float_ops::to_string().

## ◆ floatformat_normalize_byteorder()

static enum floatformat_byteorders floatformat_normalize_byteorder | ( | const struct floatformat * | fmt,
|  | const void * | from,
|  | void * | to
| ) |  |
| static

Definition at line 119 of file target-float.c.

References FLOATFORMAT_CHAR_BIT, and gdb_assert.

Referenced by floatformat_classify(), floatformat_is_negative(), floatformat_mantissa(), host_float_ops< T >::from_target(), mpfr_float_ops::from_target(), host_float_ops< T >::to_target(), and mpfr_float_ops::to_target().

## ◆ floatformat_precision()

static int floatformat_precision | ( | const struct floatformat * | fmt | ) |
| static

Definition at line 99 of file target-float.c.

Referenced by floatformat_printf_format(), and mpfr_float_ops::gdb_mpfr::gdb_mpfr().

## ◆ floatformat_printf_format()

static std::string floatformat_printf_format | ( | const struct floatformat * | fmt,
|  | const char * | format,
|  | char | length
| ) |  |
| static

Definition at line 483 of file target-float.c.

References floatformat_precision(), gdb_assert, string, and string_printf().

Referenced by host_float_ops< T >::to_string(), and mpfr_float_ops::to_string().

## ◆ floatformat_totalsize_bytes()

static size_t floatformat_totalsize_bytes | ( | const struct floatformat * | fmt | ) |
| static

Definition at line 91 of file target-float.c.

References FLOATFORMAT_CHAR_BIT.

Referenced by host_float_ops< T >::from_target(), target_float_format_length(), host_float_ops< T >::to_target(), and mpfr_float_ops::to_target().

## ◆ get_field()

static unsigned long get_field | ( | const bfd_byte * | data,
|  | enum floatformat_byteorders | order,
|  | unsigned int | total_len,
|  | unsigned int | start,
|  | unsigned int | len
| ) |  |
| static

Definition at line 169 of file target-float.c.

References FLOATFORMAT_CHAR_BIT, gdb_assert, and gdb.printer.bound_registers::long.

Referenced by floatformat_classify(), floatformat_is_negative(), floatformat_mantissa(), host_float_ops< T >::from_target(), and mpfr_float_ops::from_target().

## ◆ get_target_float_ops() [1/3]

static const target_float_ops* get_target_float_ops | ( | enum target_float_ops_kind | kind | ) |
| static

Definition at line 2228 of file target-float.c.

References binary, decimal, gdb_assert_not_reached, host_double, host_float, and host_long_double.

Referenced by get_target_float_ops(), target_float_binop(), target_float_compare(), target_float_convert(), target_float_from_host_double(), target_float_from_longest(), target_float_from_string(), target_float_from_ulongest(), target_float_to_host_double(), target_float_to_longest(), and target_float_to_string().

## ◆ get_target_float_ops() [2/3]

static const target_float_ops* get_target_float_ops | ( | const struct type * | type | ) |
| static

Definition at line 2282 of file target-float.c.

References get_target_float_ops(), and get_target_float_ops_kind().

## ◆ get_target_float_ops() [3/3]

static const target_float_ops* get_target_float_ops | ( | const struct type * | type1,
|  | const struct type * | type2
| ) |  |
| static

Definition at line 2290 of file target-float.c.

References gdb_assert, get_target_float_ops(), get_target_float_ops_kind(), and TYPE_CODE.

## ◆ get_target_float_ops_kind()

static enum target_float_ops_kind get_target_float_ops_kind | ( | const struct type * | type | ) |
| static

Definition at line 2195 of file target-float.c.

References binary, decimal, floatformat_from_type(), gdb_assert_not_reached, host_double, host_double_format, host_float, host_float_format, host_long_double, host_long_double_format, TYPE_CODE, TYPE_CODE_DECFLOAT, and TYPE_CODE_FLT.

Referenced by get_target_float_ops().

## ◆ match_endianness()

static void match_endianness | ( | const gdb_byte * | from,
|  | const struct type * | type,
|  | gdb_byte * | to
| ) |  |
| static

Definition at line 1732 of file target-float.c.

References gdb_assert, gdbarch_byte_order(), get_type_arch(), OPPOSITE_BYTE_ORDER, TYPE_CODE, TYPE_CODE_DECFLOAT, and TYPE_LENGTH.

Referenced by decimal_from_number(), decimal_to_number(), decimal_float_ops::from_string(), and decimal_float_ops::to_string().

## ◆ put_field()

static void put_field | ( | unsigned char * | data,
|  | enum floatformat_byteorders | order,
|  | unsigned int | total_len,
|  | unsigned int | start,
|  | unsigned int | len,
|  | unsigned long | stuff_to_put
| ) |  |
| static

Definition at line 236 of file target-float.c.

References FLOATFORMAT_CHAR_BIT, and gdb_assert.

Referenced by host_float_ops< T >::to_target(), and mpfr_float_ops::to_target().

## ◆ set_decnumber_context()

static void set_decnumber_context | ( | decContext * | ctx,
|  | const struct type * | type
| ) |  |
| static

Definition at line 1758 of file target-float.c.

References gdb_assert, TYPE_CODE, TYPE_CODE_DECFLOAT, and TYPE_LENGTH.

Referenced by decimal_float_ops::binop(), decimal_float_ops::compare(), decimal_from_number(), and decimal_float_ops::from_string().

## ◆ target_float_binop()

void target_float_binop | ( | enum exp_opcode | opcode,
|  | const gdb_byte * | x,
|  | const struct type * | type_x,
|  | const gdb_byte * | y,
|  | const struct type * | type_y,
|  | gdb_byte * | res,
|  | const struct type * | type_res
| ) |  |

Definition at line 2464 of file target-float.c.

References target_float_ops::binop(), gdb_assert, get_target_float_ops(), and target_float_same_category_p().

Referenced by scalar_binop().

## ◆ target_float_compare()

int target_float_compare | ( | const gdb_byte * | x,
|  | const struct type * | type_x,
|  | const gdb_byte * | y,
|  | const struct type * | type_y
| ) |  |

Definition at line 2484 of file target-float.c.

References target_float_ops::compare(), gdb_assert, get_target_float_ops(), and target_float_same_category_p().

Referenced by value_equal(), and value_less().

## ◆ target_float_convert()

void target_float_convert | ( | const gdb_byte * | from,
|  | const struct type * | from_type,
|  | gdb_byte * | to,
|  | const struct type * | to_type
| ) |  |

Definition at line 2429 of file target-float.c.

References target_float_ops::convert(), get_target_float_ops(), memset(), string, target_float_format_length(), target_float_from_string(), target_float_same_category_p(), target_float_same_format_p(), target_float_to_string(), and TYPE_LENGTH.

Referenced by arm_extract_return_value(), arm_store_return_value(), do_ppc_sysv_return_value(), i386_extract_return_value(), i386_store_return_value(), i387_register_to_value(), i387_value_to_register(), ia64_extract_return_value(), ia64_push_dummy_call(), ia64_register_to_value(), ia64_store_return_value(), ia64_value_to_register(), m68k_register_to_value(), m68k_svr4_extract_return_value(), m68k_svr4_store_return_value(), m68k_value_to_register(), ppc64_sysv_abi_push_freg(), ppc64_sysv_abi_return_value_base(), ppc_sysv_abi_push_dummy_call(), rs6000_lynx178_push_dummy_call(), rs6000_lynx178_return_value(), rs6000_push_dummy_call(), rs6000_register_to_value(), rs6000_return_value(), rs6000_value_to_register(), sh64_extract_return_value(), sh64_register_convert_to_raw(), sh64_register_convert_to_virtual(), sh_register_convert_to_raw(), sh_register_convert_to_virtual(), and value_cast().

## ◆ target_float_format_length()

static int target_float_format_length | ( | const struct type * | type | ) |
| static

Definition at line 2163 of file target-float.c.

References floatformat_from_type(), floatformat_totalsize_bytes(), gdb_assert_not_reached, TYPE_CODE, TYPE_CODE_DECFLOAT, TYPE_CODE_FLT, and TYPE_LENGTH.

Referenced by target_float_convert().

## ◆ target_float_from_host_double()

void target_float_from_host_double | ( | gdb_byte * | addr,
|  | const struct type * | type,
|  | double | val
| ) |  |

Definition at line 2418 of file target-float.c.

References target_float_ops::from_host_double(), and get_target_float_ops().

Referenced by convert_value_from_python(), gdbscm_value_to_real(), vlscm_convert_number(), and vlscm_convert_typed_number().

## ◆ target_float_from_longest()

void target_float_from_longest | ( | gdb_byte * | addr,
|  | const struct type * | type,
|  | LONGEST | val
| ) |  |

Definition at line 2388 of file target-float.c.

References target_float_ops::from_longest(), and get_target_float_ops().

Referenced by pack_long(), and value_args_as_target_float().

## ◆ target_float_from_string()

bool target_float_from_string | ( | gdb_byte * | addr,
|  | const struct type * | type,
|  | const std::string & | string
| ) |  |

Definition at line 2369 of file target-float.c.

References target_float_ops::from_string(), and get_target_float_ops().

Referenced by define_symbol(), parse_float(), and target_float_convert().

## ◆ target_float_from_ulongest()

void target_float_from_ulongest | ( | gdb_byte * | addr,
|  | const struct type * | type,
|  | ULONGEST | val
| ) |  |

Definition at line 2398 of file target-float.c.

References target_float_ops::from_ulongest(), and get_target_float_ops().

Referenced by pack_unsigned_long(), and value_args_as_target_float().

## ◆ target_float_is_valid()

bool target_float_is_valid | ( | const gdb_byte * | addr,
|  | const struct type * | type
| ) |  |

Definition at line 2305 of file target-float.c.

References floatformat_from_type(), gdb_assert_not_reached, TYPE_CODE, TYPE_CODE_DECFLOAT, and TYPE_CODE_FLT.

Referenced by is_floating_value().

## ◆ target_float_is_zero()

bool target_float_is_zero | ( | const gdb_byte * | addr,
|  | const struct type * | type
| ) |  |

Definition at line 2319 of file target-float.c.

References decimal_is_zero(), float_zero, floatformat_classify(), floatformat_from_type(), gdb_assert_not_reached, TYPE_CODE, TYPE_CODE_DECFLOAT, and TYPE_CODE_FLT.

Referenced by valpy_nonzero(), and value_logical_not().

## ◆ target_float_same_category_p()

static bool target_float_same_category_p | ( | const struct type * | type1,
|  | const struct type * | type2
| ) |  |
| static

Definition at line 2131 of file target-float.c.

References TYPE_CODE.

Referenced by target_float_binop(), target_float_compare(), target_float_convert(), and target_float_same_format_p().

## ◆ target_float_same_format_p()

static bool target_float_same_format_p | ( | const struct type * | type1,
|  | const struct type * | type2
| ) |  |
| static

Definition at line 2139 of file target-float.c.

References floatformat_from_type(), gdb_assert_not_reached, gdbarch_byte_order(), get_type_arch(), target_float_same_category_p(), TYPE_CODE, TYPE_CODE_DECFLOAT, TYPE_CODE_FLT, and TYPE_LENGTH.

Referenced by target_float_convert().

## ◆ target_float_to_host_double()

double target_float_to_host_double | ( | const gdb_byte * | addr,
|  | const struct type * | type
| ) |  |

Definition at line 2408 of file target-float.c.

References get_target_float_ops(), and target_float_ops::to_host_double().

Referenced by gdbscm_value_to_real(), and valpy_float().

## ◆ target_float_to_longest()

LONGEST target_float_to_longest | ( | const gdb_byte * | addr,
|  | const struct type * | type
| ) |  |

Definition at line 2379 of file target-float.c.

References get_target_float_ops(), and target_float_ops::to_longest().

Referenced by unpack_long().

## ◆ target_float_to_string()

std::string target_float_to_string | ( | const gdb_byte * | addr,
|  | const struct type * | type,
|  | const char * | format
| ) |  |

Definition at line 2334 of file target-float.c.

References float_infinite, float_nan, floatformat_classify(), floatformat_from_type(), floatformat_is_negative(), floatformat_mantissa(), get_target_float_ops(), string_printf(), target_float_ops::to_string(), TYPE_CODE, and TYPE_CODE_FLT.

Referenced by ada_val_print_num(), mips_print_fp_register(), print_fixed_point_type(), print_floating(), print_i387_value(), printf_floating(), sh64_do_fp_register(), and target_float_convert().

## Variable Documentation

## ◆ host_double_format

const struct floatformat* host_double_format = GDB_HOST_DOUBLE_FORMAT
| static

Definition at line 592 of file target-float.c.

Referenced by host_float_ops< T >::from_target(), get_target_float_ops_kind(), and host_float_ops< T >::to_target().

## ◆ host_float_format

const struct floatformat* host_float_format = GDB_HOST_FLOAT_FORMAT
| static

Definition at line 591 of file target-float.c.

Referenced by host_float_ops< T >::from_target(), get_target_float_ops_kind(), and host_float_ops< T >::to_target().

## ◆ host_long_double_format

const struct floatformat* host_long_double_format = GDB_HOST_LONG_DOUBLE_FORMAT
| static

Definition at line 594 of file target-float.c.

Referenced by host_float_ops< T >::from_target(), get_target_float_ops_kind(), and host_float_ops< T >::to_target().