#include "arch-utils.h"
#include "charset.h"
#include "cp-abi.h"
-#include "gdb_assert.h"
#include "infcall.h"
#include "symtab.h" /* Needed by language.h. */
#include "language.h"
v_smob->next->prev = v_smob->prev;
}
-/* The smob "mark" function for <gdb:value>. */
-
-static SCM
-vlscm_mark_value_smob (SCM self)
-{
- value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self);
-
- scm_gc_mark (v_smob->address);
- scm_gc_mark (v_smob->type);
- scm_gc_mark (v_smob->dynamic_type);
- /* Do this last. */
- return gdbscm_mark_gsmob (&v_smob->base);
-}
-
/* The smob "free" function for <gdb:value>. */
static size_t
struct value *target;
int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR;
- target = value_ind (value);
+ if (was_pointer)
+ target = value_ind (value);
+ else
+ target = coerce_ref (value);
type = value_rtti_type (target, NULL, NULL, NULL);
if (type)
the target's charset.
ERRORS is one of #f, 'error or 'substitute.
- An error setting of #f means use the default, which is
- Guile's %default-port-conversion-strategy. If the default is not one
- of 'error or 'substitute, 'substitute is used.
+ An error setting of #f means use the default, which is Guile's
+ %default-port-conversion-strategy when using Guile >= 2.0.6, or 'error if
+ using an earlier version of Guile. Earlier versions do not properly
+ support obtaining the default port conversion strategy.
+ If the default is not one of 'error or 'substitute, 'substitute is used.
An error setting of "error" causes an exception to be thrown if there's
a decoding error. An error setting of "substitute" causes invalid
characters to be replaced with "?".
gdbscm_throw (excp);
}
if (errors == SCM_BOOL_F)
- errors = scm_port_conversion_strategy (SCM_BOOL_F);
+ {
+ /* N.B. scm_port_conversion_strategy in Guile versions prior to 2.0.6
+ will throw a Scheme error when passed #f. */
+ if (gdbscm_guile_version_is_at_least (2, 0, 6))
+ errors = scm_port_conversion_strategy (SCM_BOOL_F);
+ else
+ errors = error_symbol;
+ }
/* We don't assume anything about the result of scm_port_conversion_strategy.
From this point on, if errors is not 'errors, use 'substitute. */
return vlscm_scm_from_value (res_val);
}
+
+/* (history-append! <gdb:value>) -> index
+ Append VALUE to GDB's value history. Return its index in the history. */
+
+static SCM
+gdbscm_history_append_x (SCM value)
+{
+ int res_index = -1;
+ struct value *v;
+ value_smob *v_smob;
+ volatile struct gdb_exception except;
+
+ v_smob = vlscm_get_value_smob_arg_unsafe (value, SCM_ARG1, FUNC_NAME);
+ v = v_smob->value;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ res_index = record_latest_value (v);
+ }
+ GDBSCM_HANDLE_GDB_EXCEPTION (except);
+
+ return scm_from_int (res_index);
+}
\f
/* Initialize the Scheme value code. */
"\
Return the specified value from GDB's value history." },
+ { "history-append!", 1, 0, 0, gdbscm_history_append_x,
+ "\
+Append the specified value onto GDB's value history." },
+
END_FUNCTIONS
};
{
value_smob_tag = gdbscm_make_smob_type (value_smob_name,
sizeof (value_smob));
- scm_set_smob_mark (value_smob_tag, vlscm_mark_value_smob);
scm_set_smob_free (value_smob_tag, vlscm_free_value_smob);
scm_set_smob_print (value_smob_tag, vlscm_print_value_smob);
scm_set_smob_equalp (value_smob_tag, vlscm_equal_p_value_smob);