Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Update use of deque in _frame_iterator
Date: Tue,  2 Jun 2026 18:26:39 -0600	[thread overview]
Message-ID: <20260603002639.3920962-1-tom@tromey.com> (raw)

_frame_iterator has an old comment about some hand-written code that
was needed when supporting Python 2.6.  This patch simplifies the code
by using a couple of features of collections.deque.
---
 gdb/python/lib/gdb/frames.py | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py
index de954e4fb38..6539416b1c2 100644
--- a/gdb/python/lib/gdb/frames.py
+++ b/gdb/python/lib/gdb/frames.py
@@ -186,18 +186,7 @@ def _frame_iterator(frame, frame_low, frame_high, dap_semantics):
 
     # Is this a slice from the end of the backtrace, ie bt -2?
     if frame_low < 0:
-        count = 0
-        slice_length = abs(frame_low)
-        # We cannot use MAXLEN argument for deque as it is 2.6 onwards
-        # and some GDB versions might be < 2.6.
-        sliced = collections.deque()
-
-        for frame_item in frame_iterator:
-            if count >= slice_length:
-                sliced.popleft()
-            count = count + 1
-            sliced.append(frame_item)
-
+        sliced = collections.deque(iterable=frame_iterator, maxlen=abs(frame_low))
         return iter(sliced)
 
     # -1 for frame_high means until the end of the backtrace.  Set to
-- 
2.49.0


             reply	other threads:[~2026-06-03  0:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  0:26 Tom Tromey [this message]
2026-06-22 22:16 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260603002639.3920962-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox