Make "bt N" print correct number of frames when using a frame filter
[deliverable/binutils-gdb.git] / gdb / python / py-framefilter.c
index e887849c3625869ba18950c325bc2dd9b95d9390..3a3fb97c6c26da963f269f8b6bc1f5c4cb28105b 100644 (file)
@@ -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.024283 seconds and 4 git commands to generate.