GDB (xrefs)
Classes | Macros | Typedefs | Enumerations | Functions | Variables
py-value.c File Reference
#include "defs.h"
#include "charset.h"
#include "value.h"
#include "language.h"
#include "target-float.h"
#include "valprint.h"
#include "infcall.h"
#include "expression.h"
#include "cp-abi.h"
#include "python.h"
#include "python-internal.h"
#include "py-ref.h"

Go to the source code of this file.

Classes

struct  value_object
 

Macros

#define builtin_type_pyint   builtin_type (python_gdbarch)->builtin_long
 
#define builtin_type_pyfloat   builtin_type (python_gdbarch)->builtin_double
 
#define builtin_type_pylong   builtin_type (python_gdbarch)->builtin_long_long
 
#define builtin_type_upylong
 
#define builtin_type_pybool   language_bool_type (python_language, python_gdbarch)
 
#define builtin_type_pychar   language_string_char_type (python_language, python_gdbarch)
 
#define STRIP_REFERENCE(TYPE)   (TYPE_IS_REFERENCE (TYPE) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))
 

Typedefs

typedef struct value_object value_object
 

Enumerations

enum  valpy_opcode {
  VALPY_ADD, VALPY_SUB, VALPY_MUL, VALPY_DIV,
  VALPY_REM, VALPY_POW, VALPY_LSH, VALPY_RSH,
  VALPY_BITAND, VALPY_BITOR, VALPY_BITXOR
}
 

Functions

static void valpy_dealloc (PyObject *obj)
 
static void note_value (value_object *value_obj)
 
static PyObject * valpy_new (PyTypeObject *subtype, PyObject *args, PyObject *keywords)
 
void gdbpy_preserve_values (const struct extension_language_defn *extlang, struct objfile *objfile, htab_t copied_types)
 
static PyObject * valpy_dereference (PyObject *self, PyObject *args)
 
static PyObject * valpy_referenced_value (PyObject *self, PyObject *args)
 
static PyObject * valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode)
 
static PyObject * valpy_lvalue_reference_value (PyObject *self, PyObject *args)
 
static PyObject * valpy_rvalue_reference_value (PyObject *self, PyObject *args)
 
static PyObject * valpy_const_value (PyObject *self, PyObject *args)
 
static PyObject * valpy_get_address (PyObject *self, void *closure)
 
static PyObject * valpy_get_type (PyObject *self, void *closure)
 
static PyObject * valpy_get_dynamic_type (PyObject *self, void *closure)
 
static PyObject * valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * valpy_string (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObject * valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
 
static PyObject * valpy_cast (PyObject *self, PyObject *args)
 
static PyObject * valpy_dynamic_cast (PyObject *self, PyObject *args)
 
static PyObject * valpy_reinterpret_cast (PyObject *self, PyObject *args)
 
static Py_ssize_t valpy_length (PyObject *self)
 
static int value_has_field (struct value *v, PyObject *field)
 
static int get_field_flag (PyObject *field, const char *flag_name)
 
static struct typeget_field_type (PyObject *field)
 
static PyObject * valpy_getitem (PyObject *self, PyObject *key)
 
static int valpy_setitem (PyObject *self, PyObject *key, PyObject *value)
 
static PyObject * valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
 
static PyObject * valpy_str (PyObject *self)
 
static PyObject * valpy_get_is_optimized_out (PyObject *self, void *closure)
 
static PyObject * valpy_get_is_lazy (PyObject *self, void *closure)
 
static PyObject * valpy_fetch_lazy (PyObject *self, PyObject *args)
 
static Py_hash_t valpy_hash (PyObject *self)
 
static PyObject * valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
 
static PyObject * valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
 
static PyObject * valpy_add (PyObject *self, PyObject *other)
 
static PyObject * valpy_subtract (PyObject *self, PyObject *other)
 
static PyObject * valpy_multiply (PyObject *self, PyObject *other)
 
static PyObject * valpy_divide (PyObject *self, PyObject *other)
 
static PyObject * valpy_remainder (PyObject *self, PyObject *other)
 
static PyObject * valpy_power (PyObject *self, PyObject *other, PyObject *unused)
 
static PyObject * valpy_negative (PyObject *self)
 
static PyObject * valpy_positive (PyObject *self)
 
static PyObject * valpy_absolute (PyObject *self)
 
static int valpy_nonzero (PyObject *self)
 
static PyObject * valpy_invert (PyObject *self)
 
static PyObject * valpy_lsh (PyObject *self, PyObject *other)
 
static PyObject * valpy_rsh (PyObject *self, PyObject *other)
 
static PyObject * valpy_and (PyObject *self, PyObject *other)
 
static PyObject * valpy_or (PyObject *self, PyObject *other)
 
static PyObject * valpy_xor (PyObject *self, PyObject *other)
 
static int valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
 
static PyObject * valpy_richcompare (PyObject *self, PyObject *other, int op)
 
static PyObject * valpy_int (PyObject *self)
 
static PyObject * valpy_long (PyObject *self)
 
static PyObject * valpy_float (PyObject *self)
 
PyObject * value_to_value_object (struct value *val)
 
struct valuevalue_object_to_value (PyObject *self)
 
struct valueconvert_value_from_python (PyObject *obj)
 
PyObject * gdbpy_history (PyObject *self, PyObject *args)
 
int gdbpy_is_value_object (PyObject *obj)
 
int gdbpy_initialize_values (void)
 

Variables

static value_objectvalues_in_python = NULL
 
static gdb_PyGetSetDef value_object_getset []
 
static PyMethodDef value_object_methods []
 
static PyNumberMethods value_object_as_number
 
static PyMappingMethods value_object_as_mapping
 
PyTypeObject value_object_type
 

Macro Definition Documentation

◆ builtin_type_pybool

#define builtin_type_pybool   language_bool_type (python_language, python_gdbarch)

Definition at line 51 of file py-value.c.

Referenced by convert_value_from_python().

◆ builtin_type_pychar

#define builtin_type_pychar   language_string_char_type (python_language, python_gdbarch)

Definition at line 54 of file py-value.c.

Referenced by convert_value_from_python().

◆ builtin_type_pyfloat

#define builtin_type_pyfloat   builtin_type (python_gdbarch)->builtin_double

Definition at line 42 of file py-value.c.

Referenced by convert_value_from_python().

◆ builtin_type_pyint

#define builtin_type_pyint   builtin_type (python_gdbarch)->builtin_long

Definition at line 39 of file py-value.c.

Referenced by convert_value_from_python(), and valpy_binop_throw().

◆ builtin_type_pylong

#define builtin_type_pylong   builtin_type (python_gdbarch)->builtin_long_long

Definition at line 45 of file py-value.c.

Referenced by convert_value_from_python().

◆ builtin_type_upylong

#define builtin_type_upylong
Value:
(python_gdbarch)->builtin_unsigned_long_long
struct gdbarch * python_gdbarch
Definition: python.c:203

Definition at line 48 of file py-value.c.

Referenced by convert_value_from_python().

◆ STRIP_REFERENCE

#define STRIP_REFERENCE (   TYPE)    (TYPE_IS_REFERENCE (TYPE) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))

Definition at line 1056 of file py-value.c.

Referenced by valpy_binop_throw().

Typedef Documentation

◆ value_object

typedef struct value_object value_object

Enumeration Type Documentation

◆ valpy_opcode

Enumerator
VALPY_ADD 
VALPY_SUB 
VALPY_MUL 
VALPY_DIV 
VALPY_REM 
VALPY_POW 
VALPY_LSH 
VALPY_RSH 
VALPY_BITAND 
VALPY_BITOR 
VALPY_BITXOR 

Definition at line 1040 of file py-value.c.

Function Documentation

◆ convert_value_from_python()

struct value* convert_value_from_python ( PyObject *  obj)

◆ gdbpy_history()

PyObject* gdbpy_history ( PyObject *  self,
PyObject *  args 
)

◆ gdbpy_initialize_values()

int gdbpy_initialize_values ( void  )

Definition at line 1760 of file py-value.c.

References gdb_module, gdb_pymodule_addobject(), and value_object_type.

Referenced by do_start_initialization().

◆ gdbpy_is_value_object()

int gdbpy_is_value_object ( PyObject *  obj)

Definition at line 1754 of file py-value.c.

References value_object_type.

Referenced by get_addr_from_python(), and infpy_thread_from_thread_handle().

◆ gdbpy_preserve_values()

void gdbpy_preserve_values ( const struct extension_language_defn extlang,
struct objfile objfile,
htab_t  copied_types 
)

◆ get_field_flag()

static int get_field_flag ( PyObject *  field,
const char *  flag_name 
)
static

Definition at line 684 of file py-value.c.

References gdb::ref_ptr< T, Policy >::get(), and PyObject_GetAttrString.

Referenced by valpy_getitem().

◆ get_field_type()

static struct type* get_field_type ( PyObject *  field)
static

Definition at line 698 of file py-value.c.

References _, gdb::ref_ptr< T, Policy >::get(), PyObject_GetAttrString, and type_object_to_type().

Referenced by valpy_getitem().

◆ note_value()

static void note_value ( value_object value_obj)
static

Definition at line 111 of file py-value.c.

References value_object::next, value_object::prev, and values_in_python.

Referenced by valpy_new(), and value_to_value_object().

◆ valpy_absolute()

static PyObject* valpy_absolute ( PyObject *  self)
static

◆ valpy_add()

static PyObject* valpy_add ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1205 of file py-value.c.

References VALPY_ADD, and valpy_binop().

◆ valpy_and()

static PyObject* valpy_and ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1375 of file py-value.c.

References valpy_binop(), and VALPY_BITAND.

◆ valpy_binop()

static PyObject* valpy_binop ( enum valpy_opcode  opcode,
PyObject *  self,
PyObject *  other 
)
static

◆ valpy_binop_throw()

static PyObject* valpy_binop_throw ( enum valpy_opcode  opcode,
PyObject *  self,
PyObject *  other 
)
static

◆ valpy_call()

static PyObject* valpy_call ( PyObject *  self,
PyObject *  args,
PyObject *  keywords 
)
static

◆ valpy_cast()

static PyObject* valpy_cast ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 603 of file py-value.c.

References valpy_do_cast().

◆ valpy_const_value()

static PyObject* valpy_const_value ( PyObject *  self,
PyObject *  args 
)
static

◆ valpy_dealloc()

static void valpy_dealloc ( PyObject *  obj)
static

◆ valpy_dereference()

static PyObject* valpy_dereference ( PyObject *  self,
PyObject *  args 
)
static

◆ valpy_divide()

static PyObject* valpy_divide ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1223 of file py-value.c.

References valpy_binop(), and VALPY_DIV.

◆ valpy_do_cast()

static PyObject* valpy_do_cast ( PyObject *  self,
PyObject *  args,
enum exp_opcode  op 
)
static

◆ valpy_dynamic_cast()

static PyObject* valpy_dynamic_cast ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 611 of file py-value.c.

References valpy_do_cast().

◆ valpy_fetch_lazy()

static PyObject* valpy_fetch_lazy ( PyObject *  self,
PyObject *  args 
)
static

◆ valpy_float()

static PyObject* valpy_float ( PyObject *  self)
static

◆ valpy_get_address()

static PyObject* valpy_get_address ( PyObject *  self,
void *  closure 
)
static

◆ valpy_get_dynamic_type()

static PyObject* valpy_get_dynamic_type ( PyObject *  self,
void *  closure 
)
static

◆ valpy_get_is_lazy()

static PyObject* valpy_get_is_lazy ( PyObject *  self,
void *  closure 
)
static

Definition at line 991 of file py-value.c.

References CATCH, END_CATCH, GDB_PY_HANDLE_EXCEPTION, RETURN_MASK_ALL, TRY, and value_lazy().

◆ valpy_get_is_optimized_out()

static PyObject* valpy_get_is_optimized_out ( PyObject *  self,
void *  closure 
)
static

◆ valpy_get_type()

static PyObject* valpy_get_type ( PyObject *  self,
void *  closure 
)
static

◆ valpy_getitem()

static PyObject* valpy_getitem ( PyObject *  self,
PyObject *  key 
)
static

◆ valpy_hash()

static Py_hash_t valpy_hash ( PyObject *  self)
static

Definition at line 1035 of file py-value.c.

◆ valpy_int()

static PyObject* valpy_int ( PyObject *  self)
static

◆ valpy_invert()

static PyObject* valpy_invert ( PyObject *  self)
static

◆ valpy_lazy_string()

static PyObject* valpy_lazy_string ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ valpy_length()

static Py_ssize_t valpy_length ( PyObject *  self)
static

Definition at line 625 of file py-value.c.

References _.

◆ valpy_long()

static PyObject* valpy_long ( PyObject *  self)
static

◆ valpy_lsh()

static PyObject* valpy_lsh ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1361 of file py-value.c.

References valpy_binop(), and VALPY_LSH.

◆ valpy_lvalue_reference_value()

static PyObject* valpy_lvalue_reference_value ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 264 of file py-value.c.

References TYPE_CODE_REF, and valpy_reference_value().

◆ valpy_multiply()

static PyObject* valpy_multiply ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1217 of file py-value.c.

References valpy_binop(), and VALPY_MUL.

◆ valpy_negative()

static PyObject* valpy_negative ( PyObject *  self)
static

◆ valpy_new()

static PyObject* valpy_new ( PyTypeObject *  subtype,
PyObject *  args,
PyObject *  keywords 
)
static

◆ valpy_nonzero()

static int valpy_nonzero ( PyObject *  self)
static

◆ valpy_or()

static PyObject* valpy_or ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1382 of file py-value.c.

References valpy_binop(), and VALPY_BITOR.

◆ valpy_positive()

static PyObject* valpy_positive ( PyObject *  self)
static

Definition at line 1274 of file py-value.c.

References value_to_value_object().

Referenced by valpy_absolute().

◆ valpy_power()

static PyObject* valpy_power ( PyObject *  self,
PyObject *  other,
PyObject *  unused 
)
static

Definition at line 1235 of file py-value.c.

References valpy_binop(), and VALPY_POW.

◆ valpy_reference_value()

static PyObject* valpy_reference_value ( PyObject *  self,
PyObject *  args,
enum type_code  refcode 
)
static

◆ valpy_referenced_value()

static PyObject* valpy_referenced_value ( PyObject *  self,
PyObject *  args 
)
static

◆ valpy_reinterpret_cast()

static PyObject* valpy_reinterpret_cast ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 619 of file py-value.c.

References valpy_do_cast().

◆ valpy_remainder()

static PyObject* valpy_remainder ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1229 of file py-value.c.

References valpy_binop(), and VALPY_REM.

◆ valpy_richcompare()

static PyObject* valpy_richcompare ( PyObject *  self,
PyObject *  other,
int  op 
)
static

◆ valpy_richcompare_throw()

static int valpy_richcompare_throw ( PyObject *  self,
PyObject *  other,
int  op 
)
static

Definition at line 1400 of file py-value.c.

References _, convert_value_from_python(), value_equal(), and value_less().

Referenced by valpy_richcompare().

◆ valpy_rsh()

static PyObject* valpy_rsh ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1368 of file py-value.c.

References valpy_binop(), and VALPY_RSH.

◆ valpy_rvalue_reference_value()

static PyObject* valpy_rvalue_reference_value ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 270 of file py-value.c.

References TYPE_CODE_RVALUE_REF, and valpy_reference_value().

◆ valpy_setitem()

static int valpy_setitem ( PyObject *  self,
PyObject *  key,
PyObject *  value 
)
static

Definition at line 861 of file py-value.c.

References _.

◆ valpy_str()

static PyObject* valpy_str ( PyObject *  self)
static

◆ valpy_string()

static PyObject* valpy_string ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)
static

◆ valpy_subtract()

static PyObject* valpy_subtract ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1211 of file py-value.c.

References valpy_binop(), and VALPY_SUB.

◆ valpy_xor()

static PyObject* valpy_xor ( PyObject *  self,
PyObject *  other 
)
static

Definition at line 1389 of file py-value.c.

References valpy_binop(), and VALPY_BITXOR.

◆ value_has_field()

static int value_has_field ( struct value v,
PyObject *  field 
)
static

◆ value_object_to_value()

struct value* value_object_to_value ( PyObject *  self)

◆ value_to_value_object()

PyObject* value_to_value_object ( struct value val)

Variable Documentation

◆ value_object_as_mapping

PyMappingMethods value_object_as_mapping
static
Initial value:
= {
}
static PyObject * valpy_getitem(PyObject *self, PyObject *key)
Definition: py-value.c:719
static int valpy_setitem(PyObject *self, PyObject *key, PyObject *value)
Definition: py-value.c:861
static Py_ssize_t valpy_length(PyObject *self)
Definition: py-value.c:625

Definition at line 1876 of file py-value.c.

◆ value_object_as_number

PyNumberMethods value_object_as_number
static

Definition at line 1820 of file py-value.c.

◆ value_object_getset

gdb_PyGetSetDef value_object_getset[]
static
Initial value:
= {
{ "address", valpy_get_address, NULL, "The address of the value.",
NULL },
{ "is_optimized_out", valpy_get_is_optimized_out, NULL,
"Boolean telling whether the value is optimized "
"out (i.e., not available).",
NULL },
{ "type", valpy_get_type, NULL, "Type of the value.", NULL },
{ "dynamic_type", valpy_get_dynamic_type, NULL,
"Dynamic type of the value.", NULL },
{ "is_lazy", valpy_get_is_lazy, NULL,
"Boolean telling whether the value is lazy (not fetched yet\n\
from the inferior). A lazy value is fetched when needed, or when\n\
the \"fetch_lazy()\" method is called.", NULL },
{NULL}
}
static PyObject * valpy_get_dynamic_type(PyObject *self, void *closure)
Definition: py-value.c:348
static PyObject * valpy_get_type(PyObject *self, void *closure)
Definition: py-value.c:331
static PyObject * valpy_get_is_optimized_out(PyObject *self, void *closure)
Definition: py-value.c:968
static PyObject * valpy_get_address(PyObject *self, void *closure)
Definition: py-value.c:302
static PyObject * valpy_get_is_lazy(PyObject *self, void *closure)
Definition: py-value.c:991

Definition at line 1771 of file py-value.c.

◆ value_object_methods

PyMethodDef value_object_methods[]
static

Definition at line 1788 of file py-value.c.

◆ value_object_type

PyTypeObject value_object_type

◆ values_in_python

value_object* values_in_python = NULL
static

Definition at line 72 of file py-value.c.

Referenced by gdbpy_preserve_values(), note_value(), and valpy_dealloc().