Fix an illegal memory access triggered when trying to examine an input file containin...
[deliverable/binutils-gdb.git] / gdb / guile / scm-pretty-print.c
index 656c4bbc52e5960697bf531636c12a0ce95d9e79..3ab1bd1c7a778063025512413c4a64a540034d3e 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB/Scheme pretty-printing.
 
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
+   Copyright (C) 2008-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -897,7 +897,18 @@ ppscm_print_children (SCM printer, enum display_hint hint,
              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)
@@ -984,6 +995,12 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
     }
   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)
This page took 0.02456 seconds and 4 git commands to generate.