GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
target-float.c File Reference
#include "defs.h"
#include "gdbtypes.h"
#include "floatformat.h"
#include "target-float.h"
#include "gdbarch.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_opsget_target_float_ops (enum target_float_ops_kind kind)
 
static const target_float_opsget_target_float_ops (const struct type *type)
 
static const target_float_opsget_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

◆ FLOATFORMAT_LARGEST_BYTES

#define FLOATFORMAT_LARGEST_BYTES   16

◆ MAX_DECIMAL_STRING

#define MAX_DECIMAL_STRING   43

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

Referenced by decimal_float_ops::to_string().

◆ MPFR_USE_INTMAX_T

#define MPFR_USE_INTMAX_T

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

◆ OPPOSITE_BYTE_ORDER

#define OPPOSITE_BYTE_ORDER   BFD_ENDIAN_BIG

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

Enumerator
host_float 
host_double 
host_long_double 
binary 
decimal 

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

Function Documentation

◆ decimal_check_errors()

static void decimal_check_errors ( decContext * ctx)
static

◆ decimal_from_number()

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

◆ decimal_is_zero()

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

Definition at line 1862 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

◆ floatformat_classify()

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

◆ floatformat_is_negative()

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

◆ floatformat_mantissa()

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

◆ floatformat_normalize_byteorder()

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

◆ floatformat_precision()

static int floatformat_precision ( const struct floatformat * fmt)
static

◆ 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().

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

◆ 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

◆ get_target_float_ops() [1/3]

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

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

References get_target_float_ops(), and get_target_float_ops_kind().

◆ get_target_float_ops() [2/3]

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

◆ get_target_float_ops() [3/3]

static const target_float_ops * get_target_float_ops ( enum target_float_ops_kind kind)
static

◆ get_target_float_ops_kind()

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

◆ match_endianness()

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

◆ 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.

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

◆ set_decnumber_context()

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

◆ 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 )

◆ 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 )

◆ target_float_convert()

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

◆ target_float_format_length()

static int target_float_format_length ( const struct type * type)
static

◆ target_float_from_host_double()

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

◆ target_float_from_longest()

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

◆ target_float_from_string()

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

◆ target_float_from_ulongest()

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

◆ target_float_is_valid()

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

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

References type::code(), and floatformat_from_type().

Referenced by is_floating_value().

◆ target_float_is_zero()

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

◆ target_float_same_category_p()

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

◆ target_float_same_format_p()

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

◆ target_float_to_host_double()

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

◆ target_float_to_longest()

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

Definition at line 2382 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 )

Variable Documentation

◆ host_double_format

const struct floatformat* host_double_format = GDB_HOST_DOUBLE_FORMAT
static

◆ host_float_format

const struct floatformat* host_float_format = GDB_HOST_FLOAT_FORMAT
static

◆ host_long_double_format

const struct floatformat* host_long_double_format = GDB_HOST_LONG_DOUBLE_FORMAT
static