152 opts.deref_ref =
false;
158 opts.raw = !!
pstate->writingp;
166 scm_puts (stb.
c_str (), port);
168 catch (
const gdb_exception &except)
175 scm_puts (
">", port);
177 scm_remember_upto_here_1 (self);
197 catch (
const gdb_exception &except)
203 return scm_from_bool (result);
216 v_smob->
value = NULL;
221 v_smob->
address = SCM_UNDEFINED;
222 v_smob->
type = SCM_UNDEFINED;
316 v_smob = (
value_smob *) SCM_SMOB_DATA (v_scm);
317 return v_smob->
value;
329 int type_arg_pos = -1;
330 SCM type_scm = SCM_UNDEFINED;
332 &type_arg_pos, &type_scm);
335 if (type_arg_pos > 0)
350 type_arg_pos, type_scm,
type,
372 address_scm, &address);
410 if (SCM_UNBNDP (v_smob->
address))
412 scoped_value_mark free_values;
414 SCM address = SCM_BOOL_F;
418 address = vlscm_scm_from_value (value_addr (value));
420 catch (
const gdb_exception_forced_quit &except)
424 catch (
const gdb_exception &except)
476 struct value *res_val;
481 res_val = value_ind (value);
484 case TYPE_CODE_RVALUE_REF:
485 res_val = coerce_ref (value);
488 error (_(
"Trying to get the referenced value from a value which is"
489 " neither a pointer nor a reference"));
555 if (SCM_UNBNDP (v_smob->
type))
582 if (((
type->
code () == TYPE_CODE_PTR)
583 || (
type->
code () == TYPE_CODE_REF))
586 struct value *target;
587 int was_pointer =
type->
code () == TYPE_CODE_PTR;
603 else if (
type->
code () == TYPE_CODE_STRUCT)
611 catch (
const gdb_exception &except)
629 const char *func_name)
642 struct value *res_val;
643 if (op == UNOP_DYNAMIC_CAST)
645 else if (op == UNOP_REINTERPRET_CAST)
649 gdb_assert (op == UNOP_CAST);
691 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2,
FUNC_NAME,
703 "struct/class/union");
741 if (tmp_type->
code () != TYPE_CODE_ARRAY
742 && tmp_type->
code () != TYPE_CODE_PTR)
743 error (_(
"Cannot subscript requested type"));
759 struct type *ftype = NULL;
761 struct value **vargs = NULL;
768 catch (
const gdb_exception &except)
774 SCM_ASSERT_TYPE (ftype->
code () == TYPE_CODE_FUNC, self,
776 _(
"function (value of TYPE_CODE_FUNC)"));
781 args_count = scm_ilength (args);
789 vargs = XALLOCAVEC (
struct value *, args_count);
790 for (i = 0; i < args_count; i++)
792 SCM arg = scm_car (args);
798 if (vargs[i] == NULL)
801 args = scm_cdr (args);
810 auto av = gdb::make_array_view (vargs, args_count);
826 const gdb_byte *contents = NULL;
838 catch (
const gdb_exception &except)
844 bv = scm_c_make_bytevector (
length);
845 memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents,
length);
855 return (
type->
code () == TYPE_CODE_INT
859 || (ptr_ok &&
type->
code () == TYPE_CODE_PTR));
881 catch (
const gdb_exception &except)
888 _(
"integer-like gdb value"));
897 catch (
const gdb_exception &except)
903 return scm_from_bool (l != 0);
925 catch (
const gdb_exception &except)
932 _(
"integer-like gdb value"));
941 catch (
const gdb_exception &except)
973 catch (
const gdb_exception &except)
1001 catch (
const gdb_exception &except)
1010 _(
"number can't be converted to a double"));
1012 return scm_from_double (d);
1044 const SCM keywords[] = {
1047 int encoding_arg_pos = -1, errors_arg_pos = -1, length_arg_pos = -1;
1048 char *encoding = NULL;
1049 SCM errors = SCM_BOOL_F;
1051 gdb_byte *buffer_contents =
nullptr;
1053 const char *la_encoding = NULL;
1054 struct type *char_type = NULL;
1061 &encoding_arg_pos, &encoding,
1062 &errors_arg_pos, &errors,
1063 &length_arg_pos, &
length);
1065 if (errors_arg_pos > 0
1066 && errors != SCM_BOOL_F
1072 _(
"invalid error kind"));
1077 if (errors == SCM_BOOL_F)
1082 errors = scm_port_conversion_strategy (SCM_BOOL_F);
1092 gdb::unique_xmalloc_ptr<gdb_byte> buffer;
1094 buffer_contents = buffer.release ();
1096 catch (
const gdb_exception &except)
1106 scm_dynwind_begin ((scm_t_dynwind_flags) 0);
1111 result = scm_from_stringn ((
const char *) buffer_contents,
1113 (encoding != NULL && *encoding !=
'\0'
1117 ? SCM_FAILED_CONVERSION_ERROR
1118 : SCM_FAILED_CONVERSION_QUESTION_MARK);
1143 int encoding_arg_pos = -1, length_arg_pos = -1;
1144 char *encoding = NULL;
1146 SCM result = SCM_BOOL_F;
1153 &encoding_arg_pos, &encoding,
1154 &length_arg_pos, &length);
1159 scm_from_int (length),
1160 _(
"invalid length"));
1173 switch (realtype->
code ())
1175 case TYPE_CODE_ARRAY:
1177 LONGEST array_length = -1;
1178 LONGEST low_bound, high_bound;
1184 array_length = high_bound - low_bound + 1;
1187 else if (array_length == -1)
1192 else if (
length != array_length)
1196 if (
length > array_length)
1197 error (_(
"length is larger than array size"));
1218 catch (
const gdb_exception &ex)
1257 return SCM_UNSPECIFIED;
1272 opts.deref_ref =
false;
1281 catch (
const gdb_exception &except)
1293 SCM_FAILED_CONVERSION_QUESTION_MARK);
1304 expr_scm, &expr_str);
1348Return #t if the object is a <gdb:value> object." },
1352Create a <gdb:value> representing object.\n\
1353Typically this is used to convert numbers and strings to\n\
1354<gdb:value> objects.\n\
1356 Arguments: object [#:type <gdb:type>]" },
1358 {
"value-optimized-out?", 1, 0, 0,
1361Return #t if the value has been optimized out." },
1365Return the address of the value." },
1369Return the type of the value." },
1373Return the dynamic type of the value." },
1377Cast the value to the supplied type.\n\
1379 Arguments: <gdb:value> <gdb:type>" },
1383Cast the value to the supplied type, as if by the C++\n\
1384dynamic_cast operator.\n\
1386 Arguments: <gdb:value> <gdb:type>" },
1388 {
"value-reinterpret-cast", 2, 0, 0,
1391Cast the value to the supplied type, as if by the C++\n\
1392reinterpret_cast operator.\n\
1394 Arguments: <gdb:value> <gdb:type>" },
1398Return the result of applying the C unary * operator to the value." },
1400 {
"value-referenced-value", 1, 0, 0,
1403Given a value of a reference type, return the value referenced.\n\
1404The difference between this function and value-dereference is that\n\
1405the latter applies * unary operator to a value, which need not always\n\
1406result in the value referenced.\n\
1407For example, for a value which is a reference to an 'int' pointer ('int *'),\n\
1408value-dereference will result in a value of type 'int' while\n\
1409value-referenced-value will result in a value of type 'int *'." },
1411 {
"value-reference-value", 1, 0, 0,
1414Return a <gdb:value> object which is a reference to the given value." },
1416 {
"value-rvalue-reference-value", 1, 0, 0,
1419Return a <gdb:value> object which is an rvalue reference to the given value." },
1421 {
"value-const-value", 1, 0, 0,
1424Return a <gdb:value> object which is a 'const' version of the given value." },
1428Return the specified field of the value.\n\
1430 Arguments: <gdb:value> string" },
1434Return the value of the array at the specified index.\n\
1436 Arguments: <gdb:value> integer" },
1440Perform an inferior function call taking the value as a pointer to the\n\
1442Each element of the argument list must be a <gdb:value> object or an object\n\
1443that can be converted to one.\n\
1444The result is the value returned by the function.\n\
1446 Arguments: <gdb:value> arg-list" },
1450Return the Scheme boolean representing the GDB value.\n\
1451The value must be \"integer like\". Pointers are ok." },
1455Return the Scheme integer representing the GDB value.\n\
1456The value must be \"integer like\". Pointers are ok." },
1460Return the Scheme real number representing the GDB value.\n\
1461The value must be a number." },
1465Return a Scheme bytevector with the raw contents of the GDB value.\n\
1466No transformation, endian or otherwise, is performed." },
1470Return the Unicode string of the value's contents.\n\
1471If ENCODING is not given, the string is assumed to be encoded in\n\
1472the target's charset.\n\
1473An error setting \"error\" causes an exception to be thrown if there's\n\
1474a decoding error. An error setting of \"substitute\" causes invalid\n\
1475characters to be replaced with \"?\". The default is \"error\".\n\
1476If LENGTH is provided, only fetch string to the length provided.\n\
1478 Arguments: <gdb:value>\n\
1479 [#:encoding encoding] [#:errors \"error\"|\"substitute\"]\n\
1480 [#:length length]" },
1482 {
"value->lazy-string", 1, 0, 1,
1485Return a Scheme object representing a lazily fetched Unicode string\n\
1486of the value's contents.\n\
1487If ENCODING is not given, the string is assumed to be encoded in\n\
1488the target's charset.\n\
1489If LENGTH is provided, only fetch string to the length provided.\n\
1491 Arguments: <gdb:value> [#:encoding encoding] [#:length length]" },
1495Return #t if the value is lazy (not fetched yet from the inferior).\n\
1496A lazy value is fetched when needed, or when the value-fetch-lazy! function\n\
1501Create a <gdb:value> that will be lazily fetched from the target.\n\
1503 Arguments: <gdb:type> address" },
1507Fetch the value from the inferior, if it was lazy.\n\
1508The result is \"unspecified\"." },
1512Return the string representation (print form) of the value." },
1516Evaluates string in gdb and returns the result as a <gdb:value> object." },
1520Return the specified value from GDB's value history." },
1524Append the specified value onto GDB's value history." },
static struct parser_state * pstate
struct gdbarch * get_current_arch(void)
void c_get_string(struct value *value, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *length, struct type **char_type, const char **charset)
const char * host_charset(void)
const char * c_str() const
struct type * value_rtti_type(struct value *v, int *full, LONGEST *top, int *using_enc)
struct value * parse_and_eval(const char *exp, parser_flags flags)
struct type * lookup_pointer_type(struct type *type)
struct type * lookup_lvalue_reference_type(struct type *type)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
bool get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
struct type * check_typedef(struct type *type)
SCM gdbscm_make_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error)
#define gdbscm_is_true(scm)
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)
SCM gdbscm_wrap(Function &&func, Args &&... args)
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)
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
gdbscm_gdb_exception unpack(const gdb_exception &exc)
SCM lsscm_make_lazy_string(CORE_ADDR address, int length, const char *encoding, struct type *type)
void gdbscm_init_gsmob(gdb_smob *base)
void gdbscm_dynwind_xfree(void *ptr)
SCM gdbscm_scm_from_longest(LONGEST l)
SCM tyscm_scm_from_type(struct type *type)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
type_smob * tyscm_get_type_smob_arg_unsafe(SCM type_scm, int arg_pos, const char *func_name)
SCM gdbscm_scm_from_ulongest(ULONGEST l)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
int gdbscm_guile_version_is_at_least(int major, int minor, int micro)
gdb::unique_xmalloc_ptr< char > gdbscm_scm_to_c_string(SCM string)
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
int gdbscm_is_exception(SCM scm)
void gdbscm_define_functions(const scheme_function *, int is_public)
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
struct value * call_function_by_hand(struct value *function, type *default_return_type, gdb::array_view< value * > args)
const struct language_defn * current_language
static struct type * new_type(char *)
struct value * vlscm_scm_to_value(SCM v_scm)
static SCM gdbscm_value_cast(SCM self, SCM new_type)
static SCM gdbscm_value_p(SCM scm)
static SCM gdbscm_value_reinterpret_cast(SCM self, SCM new_type)
static SCM vlscm_do_cast(SCM self, SCM type_scm, enum exp_opcode op, const char *func_name)
static scm_t_bits value_smob_tag
SCM vlscm_scm_from_value_no_release(struct value *value)
static SCM gdbscm_reference_value(SCM self, enum type_code refcode)
static SCM gdbscm_value_reference_value(SCM self)
static SCM vlscm_make_value_smob(void)
static SCM gdbscm_history_append_x(SCM value)
int vlscm_is_value(SCM 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_referenced_value(SCM self)
static SCM gdbscm_value_type(SCM self)
static const char value_smob_name[]
SCM vlscm_scm_from_value(struct value *value)
static SCM gdbscm_value_rvalue_reference_value(SCM self)
static SCM gdbscm_make_value(SCM x, SCM rest)
static SCM gdbscm_value_to_lazy_string(SCM self, SCM rest)
static SCM gdbscm_value_to_string(SCM self, SCM rest)
static void vlscm_remember_scheme_value(value_smob *v_smob)
static SCM gdbscm_value_call(SCM self, SCM args)
static SCM gdbscm_value_optimized_out_p(SCM self)
void gdbscm_initialize_values(void)
static SCM substitute_symbol
static SCM gdbscm_make_lazy_value(SCM type_scm, SCM address_scm)
static SCM gdbscm_value_subscript(SCM self, SCM index_scm)
static SCM gdbscm_value_to_bytevector(SCM self)
static SCM gdbscm_value_to_integer(SCM self)
static SCM gdbscm_value_lazy_p(SCM self)
static SCM gdbscm_value_address(SCM self)
static SCM gdbscm_history_ref(SCM index)
static SCM gdbscm_value_dereference(SCM self)
static SCM encoding_keyword
static SCM gdbscm_value_dynamic_type(SCM self)
static int vlscm_print_value_smob(SCM self, SCM port, scm_print_state *pstate)
static SCM gdbscm_value_const_value(SCM self)
static size_t vlscm_free_value_smob(SCM self)
static SCM vlscm_get_value_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static const scheme_function value_functions[]
static SCM length_keyword
static SCM gdbscm_value_field(SCM self, SCM field_scm)
static int is_intlike(struct type *type, int ptr_ok)
static value_smob * values_in_scheme
static value_smob * vlscm_get_value_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static SCM gdbscm_value_to_bool(SCM self)
static SCM errors_keyword
static SCM vlscm_equal_p_value_smob(SCM v1, SCM v2)
static SCM gdbscm_value_fetch_lazy_x(SCM self)
static SCM gdbscm_value_dynamic_cast(SCM self, SCM new_type)
static SCM gdbscm_value_to_real(SCM self)
static SCM gdbscm_parse_and_eval(SCM expr_scm)
static SCM gdbscm_value_print(SCM self)
struct type * target_type() const
void preserve(struct objfile *objfile, htab_t copied_types)
gdb::array_view< const gdb_byte > contents()
struct type * type() const
double target_float_to_host_double(const gdb_byte *addr, const struct type *type)
void quit_force(int *exit_arg, int from_tty)
struct value * value_subscript(struct value *array, LONGEST index)
int value_equal(struct value *arg1, struct value *arg2)
struct value * value_struct_elt(struct value **argp, gdb::optional< gdb::array_view< value * > > args, const char *name, int *static_memfuncp, const char *err)
struct value * value_cast(struct type *type, struct value *arg2)
struct value * value_ind(struct value *arg1)
struct value * value_ref(struct value *arg1, enum type_code refcode)
struct value * value_dynamic_cast(struct type *type, struct value *arg)
struct value * value_reinterpret_cast(struct type *type, struct value *arg)
void get_user_print_options(struct value_print_options *opts)
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
bool is_floating_value(struct value *val)
CORE_ADDR value_as_address(struct value *val)
struct value * value_from_ulongest(struct type *type, ULONGEST num)
struct value * value_from_longest(struct type *type, LONGEST num)
struct value * coerce_ref(struct value *arg)
LONGEST value_as_long(struct value *val)
struct value * make_cv_value(int cnst, int voltl, struct value *v)
struct value * value_from_host_double(struct type *type, double d)
struct value * access_value_history(int num)
value_ref_ptr release_value(struct value *val)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address, frame_info_ptr frame)
static void check(BOOL ok, const char *file, int line)