105 "gdb:pretty-printer";
107 "gdb:pretty-printer-worker";
134 scm_write (pp_smob->
name, port);
137 scm_puts (
">", port);
139 scm_remember_upto_here_1 (
self);
155 SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1,
FUNC_NAME,
190 const char *func_name)
203 const char *func_name)
236 return SCM_UNSPECIFIED;
254 SCM_ASSERT_TYPE (
gdbscm_is_true (scm_list_p (printers)), printers,
259 return SCM_UNSPECIFIED;
276 scm_puts (
" ", port);
278 scm_puts (
" ", port);
280 scm_puts (
">", port);
282 scm_remember_upto_here_1 (
self);
335 scm_list_1 (
object), scm_list_1 (
object));
369 SCM orig_list = list;
371 if (scm_is_null (list))
376 (
_(
"pretty-printer list is not a list"), list);
379 for ( ; scm_is_pair (list); list = scm_cdr (list))
381 SCM matcher = scm_car (list);
389 (
_(
"pretty-printer list contains non-pretty-printer object"),
402 (
_(
"invalid lookup object in pretty-printer matcher"),
415 (
_(
"invalid result from pretty-printer lookup"), worker);
419 if (!scm_is_null (list))
422 (
_(
"pretty-printer list is not a list"), orig_list);
532 SCM result = SCM_BOOL_F;
545 else if (scm_is_string (result)
556 if (*out_value != NULL)
567 (
_(
"invalid result from pretty-printer to-string"), result);
603 if (scm_is_string (hint))
629 if (msg == NULL || *msg ==
'\0')
636 size_t len = strlen (msg);
638 if (msg[len - 1] ==
'\n')
654 struct ui_file *stream,
int recurse,
659 struct value *replacement = NULL;
669 else if (scm_is_eq (str_scm, SCM_BOOL_T))
678 else if (scm_is_string (str_scm))
692 length, NULL, 0, options);
700 for (i = 0; i <
length; ++i)
702 if (
string[i] ==
'\0')
737 struct ui_file *stream,
int recurse,
745 int is_map, is_array, done_flag, pretty;
748 SCM iter = SCM_BOOL_F;
756 (
_(
"pretty-printer \"children\" object is not a procedure or #f"),
781 (
_(
"result of pretty-printer \"children\" procedure is not"
782 " a <gdb:iterator> object"), children);
821 if (! scm_is_pair (item))
824 (
_(
"result of pretty-printer children iterator is not a pair"
825 " or (end-of-iteration)"),
829 scm_name = scm_car (item);
830 v_scm = scm_cdr (item);
831 if (!scm_is_string (scm_name))
834 (
_(
"first element of pretty-printer children iterator is not"
853 else if (! is_map || i % 2 == 0)
868 if (! is_map || i % 2 == 0)
879 if (is_map && i % 2 == 0)
901 else if (scm_is_string (v_scm))
924 if (is_map && i % 2 == 0)
953 scm_remember_upto_here_1 (iter);
962 struct ui_file *stream,
int recurse,
963 const struct value *val,
968 SCM exception = SCM_BOOL_F;
969 SCM printer = SCM_BOOL_F;
970 SCM val_obj = SCM_BOOL_F;
988 valaddr += embedded_offset;
990 address + embedded_offset);
1003 exception = val_obj;
1012 exception = printer;
1037 options, gdbarch, language);
1060 Create a <gdb:pretty-printer> object.\n\
1062 Arguments: name lookup\n\
1063 name: a string naming the matcher\n\
1064 lookup: a procedure:\n\
1065 (pretty-printer <gdb:value>) -> <gdb:pretty-printer-worker> | #f." },
1069 Return #t if the object is a <gdb:pretty-printer> object." },
1073 Return #t if the pretty-printer is enabled." },
1075 {
"set-pretty-printer-enabled!", 2, 0, 0,
1078 Set the enabled flag of the pretty-printer.\n\
1079 Returns \"unspecified\"." },
1083 Create a <gdb:pretty-printer-worker> object.\n\
1085 Arguments: display-hint to-string children\n\
1086 display-hint: either #f or one of \"array\", \"map\", or \"string\"\n\
1087 to-string: a procedure:\n\
1088 (pretty-printer) -> string | #f | <gdb:value>\n\
1089 children: either #f or a procedure:\n\
1090 (pretty-printer) -> <gdb:iterator>" },
1094 Return #t if the object is a <gdb:pretty-printer-worker> object." },
1098 Return the list of global pretty-printers." },
1100 {
"set-pretty-printers!", 1, 0, 0,
1103 Set the list of global pretty-printers." },
static enum display_hint ppscm_get_display_hint_enum(SCM printer)
static SCM ppscm_array_string
const char * target_charset(struct gdbarch *gdbarch)
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
static SCM gdbscm_set_pretty_printer_enabled_x(SCM self, SCM enabled)
static SCM ppscm_find_pretty_printer_from_objfiles(SCM value)
static SCM gdbscm_make_pretty_printer(SCM name, SCM lookup)
void gdbscm_define_functions(const scheme_function *, int is_public)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address)
static pretty_printer_smob * ppscm_get_pretty_printer_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static SCM ppscm_search_pp_list(SCM list, SCM value)
int fputc_filtered(int c, struct ui_file *stream)
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)
static SCM ppscm_get_pretty_printer_arg_unsafe(SCM self, int arg_pos, const char *func_name)
static SCM ppscm_map_string
char * gdbscm_scm_to_c_string(SCM string)
static SCM ppscm_find_pretty_printer(SCM value)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void common_val_print(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
int vlscm_is_value(SCM scm)
static int ppscm_print_pretty_printer_worker_smob(SCM self, SCM port, scm_print_state *pstate)
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
static SCM gdbscm_pretty_printer_p(SCM scm)
static SCM gdbscm_pretty_printer_enabled_p(SCM self)
enum val_prettyformat prettyformat
SCM vlscm_scm_from_value(struct value *value)
int gdbscm_is_exception(SCM scm)
#define gdbscm_is_true(scm)
void set_value_address(struct value *value, CORE_ADDR addr)
void null_cleanup(void *arg)
#define ALL_OBJFILES(obj)
void gdbscm_init_gsmob(gdb_smob *base)
void gdbscm_initialize_pretty_printers(void)
#define CATCH(EXCEPTION, MASK)
char * gdbscm_exception_message_to_string(SCM exception)
objfile_smob * ofscm_objfile_smob_from_objfile(struct objfile *objfile)
static scm_t_bits pretty_printer_smob_tag
static struct parser_state * pstate
static scm_t_bits pretty_printer_worker_smob_tag
static SCM gdbscm_pretty_printer_worker_p(SCM scm)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
SCM gdbscm_exception_key(SCM excp)
excp_matcher_func gdbscm_memory_error_p
#define gdbscm_is_false(scm)
static int ppscm_is_pretty_printer(SCM scm)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
static SCM ppscm_find_pretty_printer_from_gdb(SCM value)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
SCM gdbscm_safe_call_2(SCM proc, SCM arg0, SCM arg1, excp_matcher_func *ok_excps)
struct gdbarch * get_type_arch(const struct type *type)
SCM ofscm_objfile_smob_pretty_printers(objfile_smob *o_smob)
static void ppscm_print_pp_type_error(const char *message, SCM object)
static SCM gdbscm_make_pretty_printer_worker(SCM display_hint, SCM to_string, SCM children)
static int ppscm_print_pretty_printer_smob(SCM self, SCM port, scm_print_state *pstate)
static SCM gdbscm_set_pretty_printers_x(SCM printers)
void lsscm_val_print_lazy_string(SCM string, struct ui_file *stream, const struct value_print_options *options)
int lsscm_is_lazy_string(SCM scm)
char * xstrprintf(const char *format,...)
void wrap_here(char *indent)
enum ext_lang_rc gdbscm_apply_val_pretty_printer(const struct extension_language_defn *extlang, struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, const struct language_defn *language)
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
static SCM ppscm_get_display_hint_scm(SCM printer)
static SCM ppscm_pretty_print_one_value(SCM printer, struct value **out_value, struct gdbarch *gdbarch, const struct language_defn *language)
int itscm_is_end_of_iteration(SCM obj)
SCM gdbscm_safe_call_1(SCM proc, SCM arg0, excp_matcher_func *ok_excps)
static int ppscm_is_pretty_printer_worker(SCM scm)
void print_spaces_filtered(int n, struct ui_file *stream)
struct type * builtin_char
void gdbscm_print_gdb_exception(SCM port, SCM exception)
static SCM ppscm_string_string
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)
SCM psscm_pspace_smob_pretty_printers(const pspace_smob *)
static const char pretty_printer_smob_name[]
int value_bytes_available(const struct value *value, int offset, int length)
static SCM pretty_printer_list
static SCM ppscm_make_pp_type_error_exception(const char *message, SCM object)
struct program_space * current_program_space
SCM gdbscm_make_error(SCM key, const char *subr, const char *message, SCM args, SCM data)
SCM itscm_safe_call_next_x(SCM iter, excp_matcher_func *ok_excps)
static SCM gdbscm_pretty_printers(void)
static enum 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)
int gdb_scheme_initialized
static void ppscm_print_exception_unless_memory_error(SCM exception, struct ui_file *stream)
#define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options)
static SCM pp_type_error_symbol
int itscm_is_iterator(SCM scm)
#define TYPE_LENGTH(thistype)
static SCM ppscm_find_pretty_printer_from_progspace(SCM value)
pspace_smob * psscm_pspace_smob_from_pspace(struct program_space *)
int gdbscm_is_procedure(SCM proc)
static const char pretty_printer_worker_smob_name[]
SCM char * gdbscm_scm_to_string(SCM string, size_t *lenp, const char *charset, int strict, SCM *except_scmp)
void do_cleanups(struct cleanup *old_chain)
void set_value_component_location(struct value *component, const struct value *whole)
const ULONGEST const LONGEST len