Repository: pwndbg/pwndbg

Issue:
telescope should not fold single values, should probably be configurable
In this screenshot, we should simply display the 0x28 and 0x90 and 0x108 offset in the stack trace.  The ellipsis isn't particularly useful here, and actually adds to cognitive load due to having to check how many values are skipped.

This should probably be behind a config, e.g. `telescope-fold-minimum` which is expressed in pointer widths.  This will allow people to control the setting to their choosing (or disable folding it with a value of 0 or -1 or something).

![](https://user-images.githubusercontent.com/10009354/85929449-471e9780-b8b5-11ea-86c6-d4191845f781.png)



Discussion:
I found a way that can solve this temporarily,  in command/ directory open telescope.py and we can find words like "Collapse repeating values", just change line 111 "if not skip" into “if skip”, we will get the problem fixed.

Resolving patch:
diff --git a/pwndbg/commands/telescope.py b/pwndbg/commands/telescope.py
--- a/pwndbg/commands/telescope.py
+++ b/pwndbg/commands/telescope.py
@@ -23,6 +23,8 @@
 telescope_lines = pwndbg.config.Parameter('telescope-lines', 8, 'number of lines to printed by the telescope command')
 skip_repeating_values = pwndbg.config.Parameter('telescope-skip-repeating-val', True,
                                                 'whether to skip repeating values of the telescope command')
+skip_repeating_values_minimum = pwndbg.config.Parameter('telescope-skip-repeating-val-minimum', 3,
+                                                        'minimum amount of repeated values before skipping lines')
 
 offset_separator = theme.Parameter('telescope-offset-separator', '│', 'offset separator of the telescope command')
 offset_delimiter = theme.Parameter('telescope-offset-delimiter', ':', 'offset delimiter of the telescope command')
@@ -88,34 +90,47 @@ def telescope(address=None, count=telescope_lines, to_string=False):
 
     # Find the longest set of register information
     if regs:
-        longest_regs = max(map(len, regs.values())) + 1
+        longest_regs = max(map(len, regs.values()))
     else:
         longest_regs = 0
 
     # Print everything out
     result = []
-    last   = None
-    skip   = False
-    for i,addr in enumerate(range(start, stop, step)):
+    last = None
+    collapse_buffer = []
+    skipped_padding = 2 + len(offset_delimiter) + 4 + len(offset_separator) + 1 + longest_regs + 1 - len(repeating_marker)
+
+    # Collapse repeating values exceeding minimum delta.
+    def collapse_repeating_values():
+        # The first line was already printed, hence increment by 1
+        if collapse_buffer and len(collapse_buffer) + 1 >= skip_repeating_values_minimum:
+            result.append(T.repeating_marker('%s%s%i skipped' % (repeating_marker, ' ' * skipped_padding, len(collapse_buffer))))
+        else:
+            result.extend(collapse_buffer)
+        collapse_buffer.clear()
+
+    for i, addr in enumerate(range(start, stop, step)):
         if not pwndbg.memory.peek(addr):
+            collapse_repeating_values()
             result.append("<Could not read memory at %#x>" % addr)
             break
 
-        # Collapse repeating values.
-        value = pwndbg.memory.pvoid(addr)
-        if skip_repeating_values and last == value:
-            if not skip:
-                result.append(T.repeating_marker('%s' % repeating_marker))
-                skip = True
-            continue
-        last = value
-        skip = False
-
         line = ' '.join((T.offset("%02x%s%04x%s" % (i + telescope.offset, delimiter,
                                                     addr - start + (telescope.offset * ptrsize), separator)),
                          T.register(regs[addr].ljust(longest_regs)),
                          pwndbg.chain.format(addr)))
+
+        # Buffer repeating values.
+        if skip_repeating_values:
+            value = pwndbg.memory.pvoid(addr)
+            if last == value:
+                collapse_buffer.append(line)
+                continue
+            collapse_repeating_values()
+            last = value
+
         result.append(line)
+
     telescope.offset += i
     telescope.last_address = addr
 


Test patch: