GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | 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"

Go to the source code of this file.

Classes

struct  value_object
 

Macros

#define builtin_type_pyint    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_long
 
#define builtin_type_pyfloat    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_double
 
#define builtin_type_pylong    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_long_long
 
#define builtin_type_upylong
 
#define builtin_type_pybool    language_bool_type (current_language, gdbpy_enter::get_gdbarch ())
 
#define builtin_type_pychar    language_string_char_type (current_language, gdbpy_enter::get_gdbarch ())
 
#define STRIP_REFERENCE(TYPE)    (TYPE_IS_REFERENCE (TYPE) ? ((TYPE)->target_type ()) : (TYPE))
 

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_clear_value (value_object *self)
 
static void valpy_dealloc (PyObject *obj)
 
static void note_value (value_object *value_obj)
 
static struct valueconvert_buffer_and_type_to_value (PyObject *obj, struct type *type)
 
static int valpy_init (PyObject *self, PyObject *args, PyObject *kwds)
 
void gdbpy_preserve_values (const struct extension_language_defn *extlang, struct objfile *objfile, htab_t copied_types)
 
static PyObjectvalpy_dereference (PyObject *self, PyObject *args)
 
static PyObjectvalpy_referenced_value (PyObject *self, PyObject *args)
 
static PyObjectvalpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode)
 
static PyObjectvalpy_lvalue_reference_value (PyObject *self, PyObject *args)
 
static PyObjectvalpy_rvalue_reference_value (PyObject *self, PyObject *args)
 
static PyObjectvalpy_const_value (PyObject *self, PyObject *args)
 
static PyObjectvalpy_get_address (PyObject *self, void *closure)
 
static PyObjectvalpy_get_type (PyObject *self, void *closure)
 
static PyObjectvalpy_get_dynamic_type (PyObject *self, void *closure)
 
static PyObjectvalpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObjectvalpy_string (PyObject *self, PyObject *args, PyObject *kw)
 
static bool copy_py_bool_obj (bool *dest, PyObject *src_obj)
 
static PyObjectvalpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
 
static PyObjectvalpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
 
static PyObjectvalpy_cast (PyObject *self, PyObject *args)
 
static PyObjectvalpy_dynamic_cast (PyObject *self, PyObject *args)
 
static PyObjectvalpy_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 PyObjectvalpy_getitem (PyObject *self, PyObject *key)
 
static int valpy_setitem (PyObject *self, PyObject *key, PyObject *value)
 
static PyObjectvalpy_call (PyObject *self, PyObject *args, PyObject *keywords)
 
static PyObjectvalpy_str (PyObject *self)
 
static PyObjectvalpy_get_is_optimized_out (PyObject *self, void *closure)
 
static PyObjectvalpy_get_is_lazy (PyObject *self, void *closure)
 
static PyObjectvalpy_fetch_lazy (PyObject *self, PyObject *args)
 
static Py_hash_t valpy_hash (PyObject *self)
 
static PyObjectvalpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
 
static PyObjectvalpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
 
static PyObjectvalpy_add (PyObject *self, PyObject *other)
 
static PyObjectvalpy_subtract (PyObject *self, PyObject *other)
 
static PyObjectvalpy_multiply (PyObject *self, PyObject *other)
 
static PyObjectvalpy_divide (PyObject *self, PyObject *other)
 
static PyObjectvalpy_remainder (PyObject *self, PyObject *other)
 
static PyObjectvalpy_power (PyObject *self, PyObject *other, PyObject *unused)
 
static PyObjectvalpy_negative (PyObject *self)
 
static PyObjectvalpy_positive (PyObject *self)
 
static PyObjectvalpy_absolute (PyObject *self)
 
static int valpy_nonzero (PyObject *self)
 
static PyObjectvalpy_invert (PyObject *self)
 
static PyObjectvalpy_lsh (PyObject *self, PyObject *other)
 
static PyObjectvalpy_rsh (PyObject *self, PyObject *other)
 
static PyObjectvalpy_and (PyObject *self, PyObject *other)
 
static PyObjectvalpy_or (PyObject *self, PyObject *other)
 
static PyObjectvalpy_xor (PyObject *self, PyObject *other)
 
static int valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
 
static PyObjectvalpy_richcompare (PyObject *self, PyObject *other, int op)
 
static PyObjectvalpy_long (PyObject *self)
 
static PyObjectvalpy_float (PyObject *self)
 
PyObjectvalue_to_value_object (struct value *val)
 
PyObjectvalue_to_value_object_no_release (struct value *val)
 
struct valuevalue_object_to_value (PyObject *self)
 
struct valueconvert_value_from_python (PyObject *obj)
 
PyObjectgdbpy_history (PyObject *self, PyObject *args)
 
PyObjectgdbpy_add_history (PyObject *self, PyObject *args)
 
PyObjectgdbpy_history_count (PyObject *self, PyObject *args)
 
PyObjectgdbpy_convenience_variable (PyObject *self, PyObject *args)
 
PyObjectgdbpy_set_convenience_variable (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 (current_language, gdbpy_enter::get_gdbarch ())

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

◆ builtin_type_pychar

#define builtin_type_pychar    language_string_char_type (current_language, gdbpy_enter::get_gdbarch ())

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

◆ builtin_type_pyfloat

#define builtin_type_pyfloat    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_double

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

◆ builtin_type_pyint

#define builtin_type_pyint    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_long

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

◆ builtin_type_pylong

#define builtin_type_pylong    builtin_type (gdbpy_enter::get_gdbarch ())->builtin_long_long

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

◆ builtin_type_upylong

#define builtin_type_upylong
Value:
(gdbpy_enter::get_gdbarch ())->builtin_unsigned_long_long
static struct gdbarch * get_gdbarch()

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

◆ STRIP_REFERENCE

#define STRIP_REFERENCE (   TYPE)     (TYPE_IS_REFERENCE (TYPE) ? ((TYPE)->target_type ()) : (TYPE))

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

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 1260 of file py-value.c.

Function Documentation

◆ convert_buffer_and_type_to_value()

static struct value * convert_buffer_and_type_to_value ( PyObject obj,
struct type type 
)
static

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

References type::length(), and value_from_contents().

Referenced by valpy_init().

◆ convert_value_from_python()

struct value * convert_value_from_python ( PyObject obj)

◆ copy_py_bool_obj()

static bool copy_py_bool_obj ( bool *  dest,
PyObject src_obj 
)
static

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

Referenced by valpy_format_string().

◆ gdbpy_add_history()

PyObject * gdbpy_add_history ( PyObject self,
PyObject args 
)

◆ gdbpy_convenience_variable()

PyObject * gdbpy_convenience_variable ( PyObject self,
PyObject args 
)

◆ gdbpy_history()

PyObject * gdbpy_history ( PyObject self,
PyObject args 
)

◆ gdbpy_history_count()

PyObject * gdbpy_history_count ( PyObject self,
PyObject args 
)

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

References gdb_py_object_from_ulongest(), and value_history_count().

◆ gdbpy_initialize_values()

int gdbpy_initialize_values ( void  )

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

References gdb_module, gdb_pymodule_addobject(), and value_object_type.

◆ gdbpy_is_value_object()

int gdbpy_is_value_object ( PyObject obj)

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

◆ gdbpy_set_convenience_variable()

PyObject * gdbpy_set_convenience_variable ( PyObject self,
PyObject args 
)

◆ get_field_flag()

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

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

Referenced by valpy_getitem().

◆ get_field_type()

static struct type * get_field_type ( PyObject field)
static

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

References type_object_to_type().

Referenced by valpy_getitem().

◆ note_value()

static void note_value ( value_object value_obj)
static

◆ valpy_absolute()

static PyObject * valpy_absolute ( PyObject self)
static

◆ valpy_add()

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

Definition at line 1424 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 1590 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 831 of file py-value.c.

References valpy_do_cast().

◆ valpy_clear_value()

static void valpy_clear_value ( value_object self)
static

◆ 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

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

References GDB_PY_HANDLE_EXCEPTION, value_ind(), and value_to_value_object().

◆ valpy_divide()

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

Definition at line 1442 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 839 of file py-value.c.

References valpy_do_cast().

◆ valpy_fetch_lazy()

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

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

References GDB_PY_HANDLE_EXCEPTION, value::value(), value_fetch_lazy(), and value_lazy().

◆ valpy_float()

static PyObject * valpy_float ( PyObject self)
static

◆ valpy_format_string()

static PyObject * valpy_format_string ( PyObject self,
PyObject args,
PyObject kw 
)
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 1213 of file py-value.c.

References GDB_PY_HANDLE_EXCEPTION, value::value(), and value_lazy().

◆ valpy_get_is_optimized_out()

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

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

References GDB_PY_HANDLE_EXCEPTION, value::value(), and value_optimized_out().

◆ 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 1255 of file py-value.c.

◆ valpy_init()

static int valpy_init ( PyObject self,
PyObject args,
PyObject kwds 
)
static

◆ valpy_invert()

static PyObject * valpy_invert ( PyObject self)
static

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

References GDB_PY_HANDLE_EXCEPTION, value_complement(), and value_to_value_object().

◆ 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 853 of file py-value.c.

◆ valpy_long()

static PyObject * valpy_long ( PyObject self)
static

◆ valpy_lsh()

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

Definition at line 1576 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 323 of file py-value.c.

References valpy_reference_value().

◆ valpy_multiply()

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

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

References valpy_binop(), and VALPY_MUL.

◆ valpy_negative()

static PyObject * valpy_negative ( PyObject self)
static

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

References GDB_PY_HANDLE_EXCEPTION, value_neg(), and value_to_value_object().

Referenced by valpy_absolute().

◆ valpy_nonzero()

static int valpy_nonzero ( PyObject self)
static

◆ valpy_or()

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

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

References valpy_binop(), and VALPY_BITOR.

◆ valpy_positive()

static PyObject * valpy_positive ( PyObject self)
static

Definition at line 1492 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 1454 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 847 of file py-value.c.

References valpy_do_cast().

◆ valpy_remainder()

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

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

References valpy_binop(), and VALPY_REM.

◆ valpy_richcompare()

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

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

References GDB_PY_HANDLE_EXCEPTION, and valpy_richcompare_throw().

◆ valpy_richcompare_throw()

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

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

References convert_value_from_python(), value::value(), value_equal(), and value_less().

Referenced by valpy_richcompare().

◆ valpy_rsh()

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

Definition at line 1583 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 329 of file py-value.c.

References valpy_reference_value().

◆ valpy_setitem()

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

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

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

◆ value_to_value_object_no_release()

PyObject * value_to_value_object_no_release ( struct value val)

Variable Documentation

◆ value_object_as_mapping

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

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

◆ value_object_as_number

PyNumberMethods value_object_as_number
static

Definition at line 2128 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:405
static PyObject * valpy_get_address(PyObject *self, void *closure)
Definition py-value.c:360
static PyObject * valpy_get_type(PyObject *self, void *closure)
Definition py-value.c:388
static PyObject * valpy_get_is_lazy(PyObject *self, void *closure)
Definition py-value.c:1213
static PyObject * valpy_get_is_optimized_out(PyObject *self, void *closure)
Definition py-value.c:1191

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

◆ value_object_methods

PyMethodDef value_object_methods[]
static

Definition at line 2091 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 74 of file py-value.c.

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