<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62168>62168</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] Vector index starts at 1 instead of 0 in pretty-printing with libc++ in gdb
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hiratasa
      </td>
    </tr>
</table>

<pre>
    When debugging a program using libc++ by gdb with the pretty-printer script provided by https://github.com/llvm/llvm-project/blob/main/libcxx/utils/gdb/libcxx/printers.py, the output of the pretty-printing for the vector's index starts from 1 instead of 0.

Although the index is omitted when using GDB in CLI, it is visible in debug using GDB through some IDEs such as VSCode. 

```
  std::vector<int> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
```
<img width="275" alt="image" src="https://user-images.githubusercontent.com/36002166/232375620-ed13383f-6967-483d-91e9-cf09659af650.png">

Upon investigating the issue, it appears that the code in https://github.com/llvm/llvm-project/blob/main/libcxx/utils/gdb/libcxx/printers.py#L375-L381 is responsible for this behavior.

```python
        def __next__(self):
            self.count += 1
            if self.item == self.end:
                raise StopIteration
            entry = self.item.dereference()
            self.item += 1
            return ("[%d]" % self.count, entry)
```

I'm not sure whether this is intended behavior or a bug, but it would be helpful if this issue could be addressed. Thank you.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vc2O4zYMfhrlQsSwpfjvkMNksikG2Nu22-NAthhbrS0ZEp2ZvH1BO7ObmZ0eeqkQMLBEUR_Jj6SO0XYOcS_yg8iPGz1T78O-t0GTjnrTeHPd_9mjA4PN3HXWdaBhCr4LeoQ58vdgm1bIg5AHaK7QmQZeLPVAPcIUkOi6nYJ1hAFiG-xEfP1iDRpW74mmKNSDkCchT52lfm6S1o9Cnobh8va3nYL_C1sS8tQMvhHyNGrr-NA27eurkKeZ7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