Reputation: 2035
How do I print in lldb the entries in a std::vector between say 1000 - 1073.
For example in the following code:
1
2 #include <numeric>
3 #include <vector>
4
5 using namespace std;
6
7 int main() {
8 vector<int> v(100000);
9 std::iota(v.begin(), v.end(), 3);
-> 10 return 0;
11 }
(lldb)
I want to see what is in v[1000] - v[1073]
Upvotes: 2
Views: 720
Reputation: 27148
There isn't a subrange operator in the lldb variable printing. But you can do this sort of thing pretty simply with the Python API's. For instance:
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> for i in range(2,6):
... print(lldb.frame.GetValueForVariablePath("int_vec[%d]"%(i)))
...
(int) [2] = 3
(int) [3] = 4
(int) [4] = 5
(int) [5] = 6
You could make up a little command to do this easily as well. See:
https://lldb.llvm.org/use/python-reference.html#create-a-new-lldb-command-using-a-python-function
for details on doing that, and:
https://lldb.llvm.org/python_reference/index.html
for a general reference to the Python API's.
Upvotes: 3