Remove EXT_LANG_BT_COMPLETED
[deliverable/binutils-gdb.git] / gdb / python / py-framefilter.c
index 75b055c98c9803eaab26689c9b902812518f87f0..1dc15ae14e4f7f709065718514e0a9f3efb6a7bb 100644 (file)
@@ -1,6 +1,6 @@
 /* Python frame filters
 
-   Copyright (C) 2013-2017 Free Software Foundation, Inc.
+   Copyright (C) 2013-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -916,11 +916,11 @@ py_print_args (PyObject *filter,
     containing all the frames level that have already been printed.
     If a frame level has been printed, do not print it again (in the
     case of elided frames).  Returns EXT_LANG_BT_ERROR on error, with any
-    GDB exceptions converted to a Python exception, or EXT_LANG_BT_COMPLETED
+    GDB exceptions converted to a Python exception, or EXT_LANG_BT_OK
     on success.  It can also throw an exception RETURN_QUIT.  */
 
 static enum ext_lang_bt_status
-py_print_frame (PyObject *filter, int flags,
+py_print_frame (PyObject *filter, frame_filter_flags flags,
                enum ext_lang_frame_args args_type,
                struct ui_out *out, int indent, htab_t levels_printed)
 {
@@ -969,7 +969,7 @@ py_print_frame (PyObject *filter, int flags,
       if (py_mi_print_variables (filter, out, &opts,
                                 args_type, frame) == EXT_LANG_BT_ERROR)
        return EXT_LANG_BT_ERROR;
-      return EXT_LANG_BT_COMPLETED;
+      return EXT_LANG_BT_OK;
     }
 
   gdb::optional<ui_out_emit_tuple> tuple;
@@ -1238,39 +1238,39 @@ py_print_frame (PyObject *filter, int flags,
        return EXT_LANG_BT_ERROR;
     }
 
-  {
-    /* Finally recursively print elided frames, if any.  */
-    gdbpy_ref<> elided (get_py_iter_from_func (filter, "elided"));
-    if (elided == NULL)
-      return EXT_LANG_BT_ERROR;
+  if ((flags & PRINT_HIDE) == 0)
+    {
+      /* Finally recursively print elided frames, if any.  */
+      gdbpy_ref<> elided (get_py_iter_from_func (filter, "elided"));
+      if (elided == NULL)
+       return EXT_LANG_BT_ERROR;
 
-    if (elided != Py_None)
-      {
-       PyObject *item;
+      if (elided != Py_None)
+       {
+         PyObject *item;
 
-       ui_out_emit_list inner_list_emiter (out, "children");
+         ui_out_emit_list inner_list_emiter (out, "children");
 
-       if (! out->is_mi_like_p ())
-         indent++;
+         if (! out->is_mi_like_p ())
+           indent++;
 
-       while ((item = PyIter_Next (elided.get ())))
-         {
-           gdbpy_ref<> item_ref (item);
+         while ((item = PyIter_Next (elided.get ())))
+           {
+             gdbpy_ref<> item_ref (item);
 
-           enum ext_lang_bt_status success = py_print_frame (item, flags,
-                                                             args_type, out,
-                                                             indent,
-                                                             levels_printed);
+             enum ext_lang_bt_status success
+               = py_print_frame (item, flags, args_type, out, indent,
+                                 levels_printed);
 
-           if (success == EXT_LANG_BT_ERROR)
-             return EXT_LANG_BT_ERROR;
-         }
-       if (item == NULL && PyErr_Occurred ())
-         return EXT_LANG_BT_ERROR;
-      }
-  }
+             if (success == EXT_LANG_BT_ERROR)
+               return EXT_LANG_BT_ERROR;
+           }
+         if (item == NULL && PyErr_Occurred ())
+           return EXT_LANG_BT_ERROR;
+       }
+    }
 
-  return EXT_LANG_BT_COMPLETED;
+  return EXT_LANG_BT_OK;
 }
 
 /* Helper function to initiate frame filter invocation at starting
@@ -1328,11 +1328,11 @@ bootstrap_python_frame_filters (struct frame_info *frame,
     format, OUT is the output stream to print.  FRAME_LOW is the
     beginning of the slice of frames to print, and FRAME_HIGH is the
     upper limit of the frames to count.  Returns EXT_LANG_BT_ERROR on error,
-    or EXT_LANG_BT_COMPLETED on success.  */
+    or EXT_LANG_BT_OK on success.  */
 
 enum ext_lang_bt_status
 gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
-                         struct frame_info *frame, int flags,
+                         struct frame_info *frame, frame_filter_flags flags,
                          enum ext_lang_frame_args args_type,
                          struct ui_out *out, int frame_low, int frame_high)
 {
@@ -1355,6 +1355,18 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
 
   gdbpy_enter enter_py (gdbarch, current_language);
 
+  /* When we're limiting the number of frames, be careful to request
+     one extra frame, so that we can print a message if there are more
+     frames.  */
+  int frame_countdown = -1;
+  if ((flags & PRINT_MORE_FRAMES) != 0 && frame_low >= 0 && frame_high >= 0)
+    {
+      ++frame_high;
+      /* This has an extra +1 because it is checked before a frame is
+        printed.  */
+      frame_countdown = frame_high - frame_low + 1;
+    }
+
   gdbpy_ref<> iterable (bootstrap_python_frame_filters (frame, frame_low,
                                                        frame_high));
 
@@ -1402,6 +1414,19 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
          break;
        }
 
+      if (frame_countdown != -1)
+       {
+         gdb_assert ((flags & PRINT_MORE_FRAMES) != 0);
+         --frame_countdown;
+         if (frame_countdown == 0)
+           {
+             /* We've printed all the frames we were asked to
+                print, but more frames existed.  */
+             printf_filtered (_("(More stack frames follow...)\n"));
+             break;
+           }
+       }
+
       success = py_print_frame (item.get (), flags, args_type, out, 0,
                                levels_printed.get ());
 
This page took 0.027513 seconds and 4 git commands to generate.