92 for (iter = values_in_scheme; iter; iter = iter->
next)
105 values_in_scheme = v_smob;
119 values_in_scheme = v_smob->
next;
147 if (pstate->writingp)
157 opts.
raw = !!pstate->writingp;
181 if (pstate->writingp)
182 scm_puts (
">", port);
184 scm_remember_upto_here_1 (
self);
209 return scm_from_bool (result);
222 v_smob->
value = NULL;
227 v_smob->
address = SCM_UNDEFINED;
228 v_smob->
type = SCM_UNDEFINED;
265 v_smob->
value = value;
305 v_smob = (
value_smob *) SCM_SMOB_DATA (v_scm);
306 return v_smob->
value;
319 int type_arg_pos = -1;
320 SCM type_scm = SCM_UNDEFINED;
321 SCM except_scm, result;
328 &type_arg_pos, &type_scm);
330 if (type_arg_pos > 0)
340 type_arg_pos, type_scm, type,
374 address_scm, &address);
419 return scm_from_bool (opt);
432 if (SCM_UNBNDP (v_smob->
address))
434 struct value *res_val = NULL;
445 address = SCM_BOOL_F;
473 struct value *res_val = NULL;
514 struct value *res_val = NULL;
530 error (
_(
"Trying to get the referenced value from a value which is"
531 " neither a pointer nor a reference"));
559 if (SCM_UNBNDP (v_smob->
type))
590 struct value *target;
635 const char *func_name)
644 struct value *res_val = NULL;
651 if (op == UNOP_DYNAMIC_CAST)
653 else if (op == UNOP_REINTERPRET_CAST)
713 struct value *res_val = NULL;
717 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2,
FUNC_NAME,
727 struct value *tmp = value;
757 struct value *index = NULL;
758 struct value *res_val = NULL;
761 SCM result, except_scm;
767 SCM_ASSERT (type != NULL,
self, SCM_ARG2,
FUNC_NAME);
783 struct value *tmp = value;
793 error (
_(
"Cannot subscript requested type"));
824 struct type *ftype = NULL;
826 struct value **vargs = NULL;
827 SCM result = SCM_BOOL_F;
841 _(
"function (value of TYPE_CODE_FUNC)"));
846 args_count = scm_ilength (args);
854 vargs = alloca (
sizeof (
struct value *) * args_count);
855 for (i = 0; i < args_count; i++)
857 SCM arg = scm_car (args);
863 if (vargs[i] == NULL)
866 args = scm_cdr (args);
874 struct value *return_value;
919 bv = scm_c_make_bytevector (length);
920 memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents, length);
962 _(
"integer-like gdb value"));
977 return scm_from_bool (l != 0);
1005 _(
"integer-like gdb value"));
1064 if (d != (
double) d)
1066 _(
"number can't be converted to a double"));
1068 return scm_from_double (d);
1100 const SCM keywords[] = {
1103 int encoding_arg_pos = -1, errors_arg_pos = -1, length_arg_pos = -1;
1108 const char *la_encoding = NULL;
1109 struct type *char_type = NULL;
1117 &encoding_arg_pos, &encoding,
1118 &errors_arg_pos, &errors,
1119 &length_arg_pos, &length);
1123 if (errors_arg_pos > 0
1124 && errors != SCM_BOOL_F
1130 _(
"invalid error kind"));
1135 if (errors == SCM_BOOL_F)
1140 errors = scm_port_conversion_strategy (SCM_BOOL_F);
1149 LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding);
1161 scm_dynwind_begin (0);
1166 result = scm_from_stringn ((
const char *) buffer,
1168 (encoding != NULL && *encoding !=
'\0'
1172 ? SCM_FAILED_CONVERSION_ERROR
1173 : SCM_FAILED_CONVERSION_QUESTION_MARK);
1196 int encoding_arg_pos = -1, length_arg_pos = -1;
1199 SCM result = SCM_BOOL_F;
1207 &encoding_arg_pos, &encoding,
1208 &length_arg_pos, &length);
1272 return SCM_UNSPECIFIED;
1311 result = scm_from_stringn (s, strlen (s),
host_charset (),
1312 SCM_FAILED_CONVERSION_QUESTION_MARK);
1325 struct value *res_val = NULL;
1333 expr_scm, &expr_str);
1366 struct value *res_val = NULL;
1406 return scm_from_int (res_index);
1415 Return #t if the object is a <gdb:value> object." },
1419 Create a <gdb:value> representing object.\n\
1420 Typically this is used to convert numbers and strings to\n\
1421 <gdb:value> objects.\n\
1423 Arguments: object [#:type <gdb:type>]" },
1427 Return #t if the value has been optimizd out." },
1431 Return the address of the value." },
1435 Return the type of the value." },
1439 Return the dynamic type of the value." },
1443 Cast the value to the supplied type.\n\
1445 Arguments: <gdb:value> <gdb:type>" },
1449 Cast the value to the supplied type, as if by the C++\n\
1450 dynamic_cast operator.\n\
1452 Arguments: <gdb:value> <gdb:type>" },
1456 Cast the value to the supplied type, as if by the C++\n\
1457 reinterpret_cast operator.\n\
1459 Arguments: <gdb:value> <gdb:type>" },
1463 Return the result of applying the C unary * operator to the value." },
1467 Given a value of a reference type, return the value referenced.\n\
1468 The difference between this function and value-dereference is that\n\
1469 the latter applies * unary operator to a value, which need not always\n\
1470 result in the value referenced.\n\
1471 For example, for a value which is a reference to an 'int' pointer ('int *'),\n\
1472 value-dereference will result in a value of type 'int' while\n\
1473 value-referenced-value will result in a value of type 'int *'." },
1477 Return the specified field of the value.\n\
1479 Arguments: <gdb:value> string" },
1483 Return the value of the array at the specified index.\n\
1485 Arguments: <gdb:value> integer" },
1489 Perform an inferior function call taking the value as a pointer to the\n\
1490 function to call.\n\
1491 Each element of the argument list must be a <gdb:value> object or an object\n\
1492 that can be converted to one.\n\
1493 The result is the value returned by the function.\n\
1495 Arguments: <gdb:value> arg-list" },
1499 Return the Scheme boolean representing the GDB value.\n\
1500 The value must be \"integer like\". Pointers are ok." },
1504 Return the Scheme integer representing the GDB value.\n\
1505 The value must be \"integer like\". Pointers are ok." },
1509 Return the Scheme real number representing the GDB value.\n\
1510 The value must be a number." },
1514 Return a Scheme bytevector with the raw contents of the GDB value.\n\
1515 No transformation, endian or otherwise, is performed." },
1519 Return the Unicode string of the value's contents.\n\
1520 If ENCODING is not given, the string is assumed to be encoded in\n\
1521 the target's charset.\n\
1522 An error setting \"error\" causes an exception to be thrown if there's\n\
1523 a decoding error. An error setting of \"substitute\" causes invalid\n\
1524 characters to be replaced with \"?\". The default is \"error\".\n\
1525 If LENGTH is provided, only fetch string to the length provided.\n\
1527 Arguments: <gdb:value>\n\
1528 [#:encoding encoding] [#:errors \"error\"|\"substitute\"]\n\
1529 [#:length length]" },
1533 Return a Scheme object representing a lazily fetched Unicode string\n\
1534 of the value's contents.\n\
1535 If ENCODING is not given, the string is assumed to be encoded in\n\
1536 the target's charset.\n\
1537 If LENGTH is provided, only fetch string to the length provided.\n\
1539 Arguments: <gdb:value> [#:encoding encoding] [#:length length]" },
1543 Return #t if the value is lazy (not fetched yet from the inferior).\n\
1544 A lazy value is fetched when needed, or when the value-fetch-lazy! function\n\
1549 Create a <gdb:value> that will be lazily fetched from the target.\n\
1551 Arguments: <gdb:type> address" },
1555 Fetch the value from the inferior, if it was lazy.\n\
1556 The result is \"unspecified\"." },
1560 Return the string representation (print form) of the value." },
1564 Evaluates string in gdb and returns the result as a <gdb:value> object." },
1568 Return the specified value from GDB's value history." },
1572 Append the specified value onto GDB's value history." },
struct value * value_mark(void)
static void vlscm_remember_scheme_value(value_smob *v_smob)
struct value * call_function_by_hand(struct value *function, int nargs, struct value **args)
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 * ui_file_xstrdup(struct ui_file *file, long *length)
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
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
static SCM length_keyword
int gdbscm_is_exception(SCM scm)
#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
int value_lazy(struct value *value)
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)
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)
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)
struct ui_file * mem_fileopen(void)
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)
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)
struct cleanup * make_cleanup_ui_file_delete(struct ui_file *arg)
static SCM gdbscm_value_fetch_lazy_x(SCM self)
#define TYPE_CODE(thistype)
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)
struct type * value_rtti_type(struct value *v, int *full, int *top, int *using_enc)
#define GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS(exception, cleanups)
#define CHECK_TYPEDEF(TYPE)
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
#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 type * lookup_reference_type(struct type *type)
struct value * access_value_history(int num)
CORE_ADDR value_as_address(struct value *val)
const char * host_charset(void)
#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)
void gdbscm_initialize_values(void)
void error(const char *fmt,...)
DOUBLEST value_as_double(struct value *val)
struct type * lookup_pointer_type(struct type *type)
static SCM gdbscm_make_value(SCM x, SCM rest)
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)