/* GDB/Scheme pretty-printing.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2020 Free Software Foundation, Inc.
This file is part of GDB.
static SCM
ppscm_find_pretty_printer_from_objfiles (SCM value)
{
- struct objfile *objfile;
-
- ALL_OBJFILES (objfile)
- {
- objfile_smob *o_smob = ofscm_objfile_smob_from_objfile (objfile);
- SCM pp = ppscm_search_pp_list (ofscm_objfile_smob_pretty_printers (o_smob),
- value);
-
- /* Note: This will return if pp is a <gdb:exception> object,
- which is what we want. */
- if (gdbscm_is_true (pp))
- return pp;
- }
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ objfile_smob *o_smob = ofscm_objfile_smob_from_objfile (objfile);
+ SCM pp
+ = ppscm_search_pp_list (ofscm_objfile_smob_pretty_printers (o_smob),
+ value);
+
+ /* Note: This will return if pp is a <gdb:exception> object,
+ which is what we want. */
+ if (gdbscm_is_true (pp))
+ return pp;
+ }
return SCM_BOOL_F;
}
SCM result = SCM_BOOL_F;
*out_value = NULL;
- TRY
+ try
{
pretty_printer_worker_smob *w_smob
= (pretty_printer_worker_smob *) SCM_SMOB_DATA (printer);
(_("invalid result from pretty-printer to-string"), result);
}
}
- CATCH (except, RETURN_MASK_ALL)
+ catch (const gdb_exception &except)
{
}
- END_CATCH
return result;
}
ppscm_print_exception_unless_memory_error (except_scm, stream);
break;
}
- common_val_print (value, stream, recurse + 1, options, language);
+ else
+ {
+ /* When printing the key of a map we allow one additional
+ level of depth. This means the key will print before the
+ value does. */
+ struct value_print_options opt = *options;
+ if (is_map && i % 2 == 0
+ && opt.max_depth != -1
+ && opt.max_depth < INT_MAX)
+ ++opt.max_depth;
+ common_val_print (value, stream, recurse + 1, &opt, language);
+ }
}
if (is_map && i % 2 == 0)
}
gdb_assert (ppscm_is_pretty_printer_worker (printer));
+ if (val_print_check_max_depth (stream, recurse, options, language))
+ {
+ result = EXT_LANG_RC_OK;
+ goto done;
+ }
+
/* If we are printing a map, we want some special formatting. */
hint = ppscm_get_display_hint_enum (printer);
if (hint == HINT_ERROR)