diff options
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-prettyprint.c | 15 | ||||
-rw-r--r-- | gdb/python/py-value.c | 7 |
2 files changed, 19 insertions, 3 deletions
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 7760cab..fdc520d 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -517,7 +517,17 @@ print_children (PyObject *printer, const char *hint, error (_("Error while executing Python code.")); } else - common_val_print (value, stream, recurse + 1, options, language); + { + /* 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) @@ -590,6 +600,9 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, if (printer == Py_None) return EXT_LANG_RC_NOP; + if (val_print_check_max_depth (stream, recurse, options, language)) + return EXT_LANG_RC_OK; + /* If we are printing a map, we want some special formatting. */ gdb::unique_xmalloc_ptr<char> hint (gdbpy_get_display_hint (printer.get ())); diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 512e5d02..0ffd0b0 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -623,6 +623,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) "static_members", /* See set print static-members on|off. */ /* C non-bool options. */ "max_elements", /* See set print elements N. */ + "max_depth", /* See set print max-depth N. */ "repeat_threshold", /* See set print repeats. */ "format", /* The format passed to the print command. */ NULL @@ -665,7 +666,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) char *format = NULL; if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, - "|O!O!O!O!O!O!O!O!O!IIs", + "|O!O!O!O!O!O!O!O!O!IIIs", keywords, &PyBool_Type, &raw_obj, &PyBool_Type, &pretty_arrays_obj, @@ -677,6 +678,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) &PyBool_Type, &actual_objects_obj, &PyBool_Type, &static_members_obj, &opts.print_max, + &opts.max_depth, &opts.repeat_count_threshold, &format)) return NULL; @@ -702,7 +704,8 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) return NULL; /* Numeric arguments for which 0 means unlimited (which we represent as - UINT_MAX). */ + UINT_MAX). Note that the max-depth numeric argument uses -1 as + unlimited, and 0 is a valid choice. */ if (opts.print_max == 0) opts.print_max = UINT_MAX; if (opts.repeat_count_threshold == 0) |