164 scm_puts (stb.
c_str (), port);
173 scm_puts (
">", port);
175 scm_remember_upto_here_1 (
self);
200 return scm_from_bool (result);
213 v_smob->
value = NULL;
218 v_smob->
address = SCM_UNDEFINED;
219 v_smob->
type = SCM_UNDEFINED;
296 v_smob = (
value_smob *) SCM_SMOB_DATA (v_scm);
297 return v_smob->
value;
310 int type_arg_pos = -1;
311 SCM type_scm = SCM_UNDEFINED;
312 SCM except_scm, result;
319 &type_arg_pos, &type_scm);
321 if (type_arg_pos > 0)
331 type_arg_pos, type_scm,
type,
365 address_scm, &address);
410 return scm_from_bool (opt);
423 if (SCM_UNBNDP (v_smob->
address))
427 SCM address = SCM_BOOL_F;
459 struct value *res_val = NULL;
500 struct value *res_val = NULL;
516 error (
_(
"Trying to get the referenced value from a value which is" 517 " neither a pointer nor a reference"));
545 if (SCM_UNBNDP (v_smob->
type))
576 struct value *target;
621 const char *func_name)
630 struct value *res_val = NULL;
637 if (op == UNOP_DYNAMIC_CAST)
639 else if (op == UNOP_REINTERPRET_CAST)
699 struct value *res_val = NULL;
703 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2,
FUNC_NAME,
716 "struct/class/union");
744 struct value *index = NULL;
745 struct value *res_val = NULL;
748 SCM result, except_scm;
780 error (
_(
"Cannot subscript requested type"));
811 struct type *ftype = NULL;
813 struct value **vargs = NULL;
814 SCM result = SCM_BOOL_F;
828 _(
"function (value of TYPE_CODE_FUNC)"));
833 args_count = scm_ilength (args);
841 vargs = XALLOCAVEC (
struct value *, args_count);
842 for (i = 0; i < args_count; i++)
844 SCM arg = scm_car (args);
850 if (vargs[i] == NULL)
853 args = scm_cdr (args);
861 struct value *return_value;
906 bv = scm_c_make_bytevector (
length);
907 memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents,
length);
949 _(
"integer-like gdb value"));
964 return scm_from_bool (l != 0);
992 _(
"integer-like gdb value"));
1069 _(
"number can't be converted to a double"));
1071 return scm_from_double (d);
1103 const SCM keywords[] = {
1106 int encoding_arg_pos = -1, errors_arg_pos = -1, length_arg_pos = -1;
1107 char *encoding = NULL;
1111 const char *la_encoding = NULL;
1112 struct type *char_type = NULL;
1120 &encoding_arg_pos, &encoding,
1121 &errors_arg_pos, &
errors,
1122 &length_arg_pos, &length);
1126 if (errors_arg_pos > 0
1133 _(
"invalid error kind"));
1138 if (
errors == SCM_BOOL_F)
1143 errors = scm_port_conversion_strategy (SCM_BOOL_F);
1164 scm_dynwind_begin ((scm_t_dynwind_flags) 0);
1169 result = scm_from_stringn ((
const char *)
buffer,
1171 (encoding != NULL && *encoding !=
'\0' 1175 ? SCM_FAILED_CONVERSION_ERROR
1176 : SCM_FAILED_CONVERSION_QUESTION_MARK);
1201 int encoding_arg_pos = -1, length_arg_pos = -1;
1202 char *encoding = NULL;
1204 SCM result = SCM_BOOL_F;
1212 &encoding_arg_pos, &encoding,
1213 &length_arg_pos, &length);
1218 scm_from_int (length),
1219 _(
"invalid length"));
1239 LONGEST low_bound, high_bound;
1245 array_length = high_bound - low_bound + 1;
1248 else if (array_length == -1)
1253 else if (
length != array_length)
1257 if (
length > array_length)
1258 error (
_(
"length is larger than array size"));
1328 return SCM_UNSPECIFIED;
1362 SCM_FAILED_CONVERSION_QUESTION_MARK);
1372 struct value *res_val = NULL;
1380 expr_scm, &expr_str);
1413 struct value *res_val = NULL;
1453 return scm_from_int (res_index);
1462 Return #t if the object is a <gdb:value> object." },
1466 Create a <gdb:value> representing object.\n\ 1467 Typically this is used to convert numbers and strings to\n\ 1468 <gdb:value> objects.\n\ 1470 Arguments: object [#:type <gdb:type>]" },
1472 {
"value-optimized-out?", 1, 0, 0,
1475 Return #t if the value has been optimizd out." },
1479 Return the address of the value." },
1483 Return the type of the value." },
1487 Return the dynamic type of the value." },
1491 Cast the value to the supplied type.\n\ 1493 Arguments: <gdb:value> <gdb:type>" },
1497 Cast the value to the supplied type, as if by the C++\n\ 1498 dynamic_cast operator.\n\ 1500 Arguments: <gdb:value> <gdb:type>" },
1502 {
"value-reinterpret-cast", 2, 0, 0,
1505 Cast the value to the supplied type, as if by the C++\n\ 1506 reinterpret_cast operator.\n\ 1508 Arguments: <gdb:value> <gdb:type>" },
1512 Return the result of applying the C unary * operator to the value." },
1514 {
"value-referenced-value", 1, 0, 0,
1517 Given a value of a reference type, return the value referenced.\n\ 1518 The difference between this function and value-dereference is that\n\ 1519 the latter applies * unary operator to a value, which need not always\n\ 1520 result in the value referenced.\n\ 1521 For example, for a value which is a reference to an 'int' pointer ('int *'),\n\ 1522 value-dereference will result in a value of type 'int' while\n\ 1523 value-referenced-value will result in a value of type 'int *'." },
1527 Return the specified field of the value.\n\ 1529 Arguments: <gdb:value> string" },
1533 Return the value of the array at the specified index.\n\ 1535 Arguments: <gdb:value> integer" },
1539 Perform an inferior function call taking the value as a pointer to the\n\ 1540 function to call.\n\ 1541 Each element of the argument list must be a <gdb:value> object or an object\n\ 1542 that can be converted to one.\n\ 1543 The result is the value returned by the function.\n\ 1545 Arguments: <gdb:value> arg-list" },
1549 Return the Scheme boolean representing the GDB value.\n\ 1550 The value must be \"integer like\". Pointers are ok." },
1554 Return the Scheme integer representing the GDB value.\n\ 1555 The value must be \"integer like\". Pointers are ok." },
1559 Return the Scheme real number representing the GDB value.\n\ 1560 The value must be a number." },
1564 Return a Scheme bytevector with the raw contents of the GDB value.\n\ 1565 No transformation, endian or otherwise, is performed." },
1569 Return the Unicode string of the value's contents.\n\ 1570 If ENCODING is not given, the string is assumed to be encoded in\n\ 1571 the target's charset.\n\ 1572 An error setting \"error\" causes an exception to be thrown if there's\n\ 1573 a decoding error. An error setting of \"substitute\" causes invalid\n\ 1574 characters to be replaced with \"?\". The default is \"error\".\n\ 1575 If LENGTH is provided, only fetch string to the length provided.\n\ 1577 Arguments: <gdb:value>\n\ 1578 [#:encoding encoding] [#:errors \"error\"|\"substitute\"]\n\ 1579 [#:length length]" },
1581 {
"value->lazy-string", 1, 0, 1,
1584 Return a Scheme object representing a lazily fetched Unicode string\n\ 1585 of the value's contents.\n\ 1586 If ENCODING is not given, the string is assumed to be encoded in\n\ 1587 the target's charset.\n\ 1588 If LENGTH is provided, only fetch string to the length provided.\n\ 1590 Arguments: <gdb:value> [#:encoding encoding] [#:length length]" },
1594 Return #t if the value is lazy (not fetched yet from the inferior).\n\ 1595 A lazy value is fetched when needed, or when the value-fetch-lazy! function\n\ 1600 Create a <gdb:value> that will be lazily fetched from the target.\n\ 1602 Arguments: <gdb:type> address" },
1606 Fetch the value from the inferior, if it was lazy.\n\ 1607 The result is \"unspecified\"." },
1611 Return the string representation (print form) of the value." },
1615 Evaluates string in gdb and returns the result as a <gdb:value> object." },
1619 Return the specified value from GDB's value history." },
1623 Append the specified value onto GDB's value history." },
struct type * value_rtti_type(struct value *v, int *full, LONGEST *top, int *using_enc)
struct value * value_mark(void)
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
static void vlscm_remember_scheme_value(value_smob *v_smob)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
struct value * value_addr(struct value *arg1)
static value_smob * values_in_scheme
static SCM gdbscm_value_cast(SCM self, SCM new_type)
struct value * value_subscript(struct value *array, LONGEST index)
void gdbscm_define_functions(const scheme_function *, int is_public)
static SCM vlscm_make_value_smob(void)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address)
static SCM errors_keyword
SCM gdbscm_scm_from_ulongest(ULONGEST l)
struct _value_smob value_smob
struct value * value_reinterpret_cast(struct type *type, struct value *arg)
static SCM gdbscm_value_type(SCM self)
LONGEST value_as_long(struct value *val)
SCM tyscm_scm_from_type(struct type *type)
struct value * vlscm_convert_value_from_scheme(const char *func_name, int obj_arg_pos, SCM obj, SCM *except_scmp, struct gdbarch *gdbarch, const struct language_defn *language)
struct type * tyscm_type_smob_type(type_smob *t_smob)
static SCM vlscm_get_value_arg_unsafe(SCM self, int arg_pos, const char *func_name)
char * gdbscm_scm_to_c_string(SCM string)
static scm_t_bits value_smob_tag
static SCM gdbscm_value_call(SCM self, SCM args)
void common_val_print(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
static SCM substitute_symbol
const struct gdb_exception exception_none
int value_lazy(const struct value *value)
struct value * coerce_ref(struct value *arg)
void value_free(struct value *val)
SCM gdbscm_scm_from_longest(LONGEST l)
struct value * value_ind(struct value *arg1)
SCM gdbscm_make_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
struct _value_smob * next
double target_float_to_host_double(const gdb_byte *addr, const struct type *type)
static SCM length_keyword
int gdbscm_is_exception(SCM scm)
struct value * allocate_value(struct type *type)
#define gdbscm_is_true(scm)
static struct type * new_type(char *)
static SCM gdbscm_value_to_lazy_string(SCM self, SCM rest)
struct _value_smob * prev
SCM lsscm_make_lazy_string(CORE_ADDR address, int length, const char *encoding, struct type *type)
static int is_intlike(struct type *type, int ptr_ok)
int gdbscm_guile_version_is_at_least(int major, int minor, int micro)
void gdbscm_dynwind_xfree(void *ptr)
static SCM gdbscm_value_subscript(SCM self, SCM index_scm)
static SCM gdbscm_value_to_bool(SCM self)
struct value * value_struct_elt(struct value **argp, struct value **args, const char *name, int *static_memfuncp, const char *err)
int vlscm_is_value(SCM scm)
void preserve_one_value(struct value *value, struct objfile *objfile, htab_t copied_types)
struct type * check_typedef(struct type *type)
void gdbscm_init_gsmob(gdb_smob *base)
const gdb_byte * value_contents(struct value *value)
#define CATCH(EXCEPTION, MASK)
static SCM gdbscm_value_address(SCM self)
static SCM gdbscm_make_lazy_value(SCM type_scm, SCM address_scm)
static struct parser_state * pstate
static SCM gdbscm_value_to_string(SCM self, SCM rest)
SCM vlscm_scm_from_value(struct value *value)
static SCM gdbscm_parse_and_eval(SCM expr_scm)
struct cleanup * make_cleanup_value_free_to_mark(struct value *mark)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static SCM gdbscm_value_to_bytevector(SCM self)
static SCM vlscm_equal_p_value_smob(SCM v1, SCM v2)
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
struct gdbarch * get_type_arch(const struct type *type)
struct gdbarch * get_current_arch(void)
static SCM gdbscm_value_print(SCM self)
struct value * value_from_longest(struct type *type, LONGEST num)
static SCM gdbscm_value_dereference(SCM self)
struct value * value_cast(struct type *type, struct value *arg2)
static SCM gdbscm_value_lazy_p(SCM self)
static const scheme_function value_functions[]
struct value * value_dynamic_cast(struct type *type, struct value *arg)
static value_smob * vlscm_get_value_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
int value_equal(struct value *arg1, struct value *arg2)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
static SCM encoding_keyword
static SCM gdbscm_value_p(SCM scm)
static SCM gdbscm_value_reinterpret_cast(SCM self, SCM new_type)
static SCM gdbscm_history_append_x(SCM value)
static SCM gdbscm_value_to_real(SCM self)
struct value * vlscm_scm_to_value(SCM v_scm)
static SCM gdbscm_value_referenced_value(SCM self)
static SCM gdbscm_value_to_integer(SCM self)
void release_value_or_incref(struct value *val)
void discard_cleanups(struct cleanup *old_chain)
void target_float_from_host_double(gdb_byte *addr, const struct type *type, double val)
const struct language_defn * current_language
int value_optimized_out(struct value *value)
#define TYPE_TARGET_TYPE(thistype)
static SCM gdbscm_value_dynamic_type(SCM self)
void value_fetch_lazy(struct value *val)
static SCM gdbscm_value_fetch_lazy_x(SCM self)
static void check(BOOL ok, const char *file, int line)
#define TYPE_CODE(thistype)
const char * c_str() const
static SCM gdbscm_value_optimized_out_p(SCM self)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
void get_user_print_options(struct value_print_options *opts)
type_smob * tyscm_get_type_smob_arg_unsafe(SCM type_scm, int arg_pos, const char *func_name)
#define GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS(exception, cleanups)
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
static SCM gdbscm_history_ref(SCM index)
static SCM vlscm_do_cast(SCM self, SCM type_scm, enum exp_opcode op, const char *func_name)
int record_latest_value(struct value *val)
struct value * parse_and_eval(const char *exp)
unsigned long long ULONGEST
struct value * call_function_by_hand(struct value *function, type *default_return_type, int nargs, struct value **args)
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
struct type * value_type(const struct value *value)
static size_t vlscm_free_value_smob(SCM self)
static int vlscm_print_value_smob(SCM self, SCM port, scm_print_state *pstate)
struct value * access_value_history(int num)
struct value * value_from_ulongest(struct type *type, ULONGEST num)
CORE_ADDR value_as_address(struct value *val)
const char * host_charset(void)
gdb_byte * value_contents_raw(struct value *value)
#define TYPE_LENGTH(thistype)
static SCM gdbscm_value_field(SCM self, SCM field_scm)
void gdbscm_preserve_values(const struct extension_language_defn *extlang, struct objfile *objfile, htab_t copied_types)
static void vlscm_forget_value_smob(value_smob *v_smob)
static SCM gdbscm_value_dynamic_cast(SCM self, SCM new_type)
static const char value_smob_name[]
CORE_ADDR value_address(const struct value *value)
int get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
void gdbscm_initialize_values(void)
struct type * lookup_lvalue_reference_type(struct type *type)
void error(const char *fmt,...)
struct type * lookup_pointer_type(struct type *type)
static SCM gdbscm_make_value(SCM x, SCM rest)
bool is_floating_value(struct value *val)
void do_cleanups(struct cleanup *old_chain)
#define LA_GET_STRING(value, buffer, length, chartype, encoding)
struct value * vlscm_convert_typed_value_from_scheme(const char *func_name, int obj_arg_pos, SCM obj, int type_arg_pos, SCM type_scm, struct type *type, SCM *except_scmp, struct gdbarch *gdbarch, const struct language_defn *language)