GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
py-value.c File Reference
#include "defs.h"
#include "top.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 "ada-lang.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 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_to_array (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 PyObjectvalpy_assign (PyObject *self_obj, 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)
 
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)
 
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_values (void)
 
 GDBPY_INITIALIZE_FILE (gdbpy_initialize_values)
 

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

Referenced by convert_value_from_python().

◆ builtin_type_pyfloat

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

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

Referenced by convert_value_from_python().

◆ builtin_type_pyint

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

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

Referenced by valpy_binop_throw().

◆ builtin_type_pylong

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

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

Referenced by convert_value_from_python(), and valpy_long().

◆ builtin_type_upylong

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

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

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

Referenced by valpy_binop_throw().

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 1334 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 141 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 649 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 2031 of file py-value.c.

References gdb_py_object_from_ulongest(), and value_history_count().

◆ GDBPY_INITIALIZE_FILE()

GDBPY_INITIALIZE_FILE ( gdbpy_initialize_values )

◆ gdbpy_initialize_values()

static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_values ( void )
static

Definition at line 2128 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 2122 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 983 of file py-value.c.

Referenced by valpy_getitem().

◆ get_field_type()

static struct type * get_field_type ( PyObject * field)
static

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

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

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

Referenced by valpy_init(), 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 1498 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 1666 of file py-value.c.

References valpy_binop(), and VALPY_BITAND.

◆ valpy_assign()

static PyObject * valpy_assign ( PyObject * self_obj,
PyObject * args )
static

◆ 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 870 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 235 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 1516 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 878 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_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 1287 of file py-value.c.

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

◆ valpy_get_is_optimized_out()

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

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

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

◆ 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 1329 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 1632 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 925 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 1652 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 322 of file py-value.c.

References valpy_reference_value().

◆ valpy_multiply()

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

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

References valpy_binop(), and VALPY_MUL.

◆ valpy_negative()

static PyObject * valpy_negative ( PyObject * self)
static

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

References valpy_binop(), and VALPY_BITOR.

◆ valpy_positive()

static PyObject * valpy_positive ( PyObject * self)
static

Definition at line 1566 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 1528 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 886 of file py-value.c.

References valpy_do_cast().

◆ valpy_remainder()

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

Definition at line 1522 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 1742 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 1691 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 1659 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 328 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 1161 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 1504 of file py-value.c.

References valpy_binop(), and VALPY_SUB.

◆ valpy_to_array()

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

◆ valpy_xor()

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

Definition at line 1680 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 Py_ssize_t valpy_length(PyObject *self)
Definition py-value.c:925
static int valpy_setitem(PyObject *self, PyObject *key, PyObject *value)
Definition py-value.c:1161
static PyObject * valpy_getitem(PyObject *self, PyObject *key)
Definition py-value.c:1018

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

◆ value_object_as_number

PyNumberMethods value_object_as_number
static

Definition at line 2201 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:442
static PyObject * valpy_get_address(PyObject *self, void *closure)
Definition py-value.c:393
static PyObject * valpy_get_type(PyObject *self, void *closure)
Definition py-value.c:425
static PyObject * valpy_get_is_lazy(PyObject *self, void *closure)
Definition py-value.c:1287
static PyObject * valpy_get_is_optimized_out(PyObject *self, void *closure)
Definition py-value.c:1265

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

◆ value_object_methods

PyMethodDef value_object_methods[]
static

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

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