106 "gdb:pretty-printer";
108 "gdb:pretty-printer-worker";
135 scm_write (pp_smob->
name, port);
138 scm_puts (
">", port);
140 scm_remember_upto_here_1 (self);
191 const char *func_name)
204 const char *func_name)
237 return SCM_UNSPECIFIED;
255 SCM_ASSERT_TYPE (
gdbscm_is_true (scm_list_p (printers)), printers,
260 return SCM_UNSPECIFIED;
277 scm_puts (
" ", port);
279 scm_puts (
" ", port);
281 scm_puts (
">", port);
283 scm_remember_upto_here_1 (self);
331 std::string msg = string_printf (
"%s: ~S", message);
334 scm_list_1 (
object), scm_list_1 (
object));
364 SCM orig_list = list;
366 if (scm_is_null (list))
371 (_(
"pretty-printer list is not a list"), list);
374 for ( ; scm_is_pair (list); list = scm_cdr (list))
376 SCM matcher = scm_car (list);
383 (_(
"pretty-printer list contains non-pretty-printer object"),
396 (_(
"invalid lookup object in pretty-printer matcher"),
409 (_(
"invalid result from pretty-printer lookup"), worker);
413 if (!scm_is_null (list))
416 (_(
"pretty-printer list is not a list"), orig_list);
525 SCM result = SCM_BOOL_F;
537 else if (scm_is_string (result)
548 if (*out_value != NULL)
559 (_(
"invalid result from pretty-printer to-string"), result);
562 catch (
const gdb_exception_forced_quit &except)
566 catch (
const gdb_exception &except)
598 if (scm_is_string (hint))
620 gdb::unique_xmalloc_ptr<char> msg
624 if (msg == NULL || msg.get ()[0] ==
'\0')
625 gdb_printf (stream, _(
"<error reading variable>"));
631 char *msg_text = msg.get ();
632 size_t len = strlen (msg_text);
634 if (msg_text[len - 1] ==
'\n')
635 msg_text[len - 1] =
'\0';
636 gdb_printf (stream, _(
"<error reading variable: %s>"), msg_text);
648 struct ui_file *stream,
int recurse,
653 struct value *replacement = NULL;
663 else if (scm_is_eq (str_scm, SCM_BOOL_T))
667 gdb_assert (replacement != NULL);
668 opts.addressprint =
false;
672 else if (scm_is_string (str_scm))
675 gdb::unique_xmalloc_ptr<char>
string
684 length, NULL, 0, options);
692 for (i = 0; i <
length; ++i)
694 if (
string.
get ()[i] ==
'\0')
728 struct ui_file *stream,
int recurse,
736 int is_map, is_array, done_flag, pretty;
739 SCM iter = SCM_BOOL_F;
746 (_(
"pretty-printer \"children\" object is not a procedure or #f"),
769 (_(
"result of pretty-printer \"children\" procedure is not"
770 " a <gdb:iterator> object"), children);
806 if (! scm_is_pair (item))
809 (_(
"result of pretty-printer children iterator is not a pair"
810 " or (end-of-iteration)"),
814 scm_name = scm_car (item);
815 v_scm = scm_cdr (item);
816 if (!scm_is_string (scm_name))
819 (_(
"first element of pretty-printer children iterator is not"
823 gdb::unique_xmalloc_ptr<char>
name
833 if (!printed_nothing)
836 else if (! is_map || i % 2 == 0)
837 gdb_puts (pretty ?
"," :
", ", stream);
861 if (! is_map || i % 2 == 0)
872 if (is_map && i % 2 == 0)
894 else if (scm_is_string (v_scm))
896 gdb::unique_xmalloc_ptr<char> output
919 if (is_map && i % 2 == 0
927 if (is_map && i % 2 == 0)
952 scm_remember_upto_here_1 (iter);
960 struct ui_file *stream,
int recurse,
966 SCM exception = SCM_BOOL_F;
967 SCM printer = SCM_BOOL_F;
968 SCM val_obj = SCM_BOOL_F;
1041 {
"make-pretty-printer", 2, 0, 0,
1044Create a <gdb:pretty-printer> object.\n\
1046 Arguments: name lookup\n\
1047 name: a string naming the matcher\n\
1048 lookup: a procedure:\n\
1049 (pretty-printer <gdb:value>) -> <gdb:pretty-printer-worker> | #f." },
1053Return #t if the object is a <gdb:pretty-printer> object." },
1055 {
"pretty-printer-enabled?", 1, 0, 0,
1058Return #t if the pretty-printer is enabled." },
1060 {
"set-pretty-printer-enabled!", 2, 0, 0,
1063Set the enabled flag of the pretty-printer.\n\
1064Returns \"unspecified\"." },
1066 {
"make-pretty-printer-worker", 3, 0, 0,
1069Create a <gdb:pretty-printer-worker> object.\n\
1071 Arguments: display-hint to-string children\n\
1072 display-hint: either #f or one of \"array\", \"map\", or \"string\"\n\
1073 to-string: a procedure:\n\
1074 (pretty-printer) -> string | #f | <gdb:value>\n\
1075 children: either #f or a procedure:\n\
1076 (pretty-printer) -> <gdb:iterator>" },
1078 {
"pretty-printer-worker?", 1, 0, 0,
1081Return #t if the object is a <gdb:pretty-printer-worker> object." },
1085Return the list of global pretty-printers." },
1087 {
"set-pretty-printers!", 1, 0, 0,
1090Set the list of global pretty-printers." },
constexpr string_view get()
static struct parser_state * pstate
const char * target_charset(struct gdbarch *gdbarch)
virtual void wrap_here(int indent)
std::string to_string(cooked_index_flag flags)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
#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)
SCM vlscm_scm_from_value_no_release(struct value *value)
void lsscm_val_print_lazy_string(SCM string, struct ui_file *stream, const struct value_print_options *options)
objfile_smob * ofscm_objfile_smob_from_objfile(struct objfile *objfile)
int vlscm_is_value(SCM scm)
int gdbscm_is_procedure(SCM proc)
void gdbscm_init_gsmob(gdb_smob *base)
void gdbscm_print_gdb_exception(SCM port, SCM exception)
SCM ofscm_objfile_smob_pretty_printers(objfile_smob *o_smob)
gdb::unique_xmalloc_ptr< char > gdbscm_exception_message_to_string(SCM exception)
SCM gdbscm_exception_key(SCM excp)
int lsscm_is_lazy_string(SCM scm)
SCM gdbscm_safe_call_2(SCM proc, SCM arg0, SCM arg1, excp_matcher_func *ok_excps)
SCM gdbscm_safe_call_1(SCM proc, SCM arg0, excp_matcher_func *ok_excps)
excp_matcher_func gdbscm_memory_error_p
SCM itscm_safe_call_next_x(SCM iter, excp_matcher_func *ok_excps)
#define gdbscm_is_false(scm)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
SCM gdb::unique_xmalloc_ptr< char > gdbscm_scm_to_string(SCM string, size_t *lenp, const char *charset, int strict, SCM *except_scmp)
gdb::unique_xmalloc_ptr< char > gdbscm_scm_to_c_string(SCM string)
int itscm_is_iterator(SCM scm)
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)
int itscm_is_end_of_iteration(SCM obj)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
SCM psscm_pspace_smob_pretty_printers(const pspace_smob *)
pspace_smob * psscm_pspace_smob_from_pspace(struct program_space *)
int gdb_scheme_initialized
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
SCM gdbscm_make_error(SCM key, const char *subr, const char *message, SCM args, SCM data)
struct program_space * current_program_space
static SCM ppscm_get_pretty_printer_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static void ppscm_print_pp_type_error(const char *message, SCM object)
static void ppscm_print_children(SCM printer, enum display_hint hint, struct ui_file *stream, int recurse, const struct value_print_options *options, struct gdbarch *gdbarch, const struct language_defn *language, int printed_nothing)
static SCM ppscm_map_string
static int ppscm_is_pretty_printer_worker(SCM scm)
static scm_t_bits pretty_printer_worker_smob_tag
static SCM ppscm_find_pretty_printer_from_gdb(SCM value)
static int ppscm_print_pretty_printer_smob(SCM self, SCM port, scm_print_state *pstate)
static pretty_printer_smob * ppscm_get_pretty_printer_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static enum display_hint ppscm_get_display_hint_enum(SCM printer)
static const char pretty_printer_worker_smob_name[]
static SCM ppscm_array_string
static enum guile_string_repr_result ppscm_print_string_repr(SCM printer, enum display_hint hint, struct ui_file *stream, int recurse, const struct value_print_options *options, struct gdbarch *gdbarch, const struct language_defn *language)
static SCM gdbscm_pretty_printers(void)
static SCM ppscm_search_pp_list(SCM list, SCM value)
static const char pretty_printer_smob_name[]
enum ext_lang_rc gdbscm_apply_val_pretty_printer(const struct extension_language_defn *extlang, struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
static SCM gdbscm_make_pretty_printer(SCM name, SCM lookup)
static SCM ppscm_find_pretty_printer(SCM value)
static SCM ppscm_get_display_hint_scm(SCM printer)
static SCM gdbscm_pretty_printer_enabled_p(SCM self)
static void ppscm_print_exception_unless_memory_error(SCM exception, struct ui_file *stream)
static SCM ppscm_string_string
static SCM gdbscm_pretty_printer_worker_p(SCM scm)
static SCM gdbscm_set_pretty_printer_enabled_x(SCM self, SCM enabled)
void gdbscm_initialize_pretty_printers(void)
static SCM gdbscm_make_pretty_printer_worker(SCM display_hint, SCM to_string, SCM children)
static int ppscm_is_pretty_printer(SCM scm)
static SCM ppscm_pretty_print_one_value(SCM printer, struct value **out_value, struct gdbarch *gdbarch, const struct language_defn *language)
static SCM ppscm_make_pp_type_error_exception(const char *message, SCM object)
static SCM ppscm_find_pretty_printer_from_objfiles(SCM value)
static const scheme_function pretty_printer_functions[]
static SCM ppscm_find_pretty_printer_from_progspace(SCM value)
static SCM gdbscm_pretty_printer_p(SCM scm)
static SCM pretty_printer_list
static scm_t_bits pretty_printer_smob_tag
static SCM pp_type_error_symbol
static int ppscm_print_pretty_printer_worker_smob(SCM self, SCM port, scm_print_state *pstate)
static SCM gdbscm_set_pretty_printers_x(SCM printers)
struct type * builtin_char
objfiles_range objfiles()
enum val_prettyformat prettyformat
bool prettyformat_structs
bool bytes_available(LONGEST offset, ULONGEST length) const
struct type * type() const
void quit_force(int *exit_arg, int from_tty)
void print_spaces(int n, struct ui_file *stream)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
bool val_print_check_max_depth(struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)