Display a pointer value with lldb debugger
c, c++, debugging, lldb
Solution
You need to use
(lldb) expr phrase[i]
or equivalently
(lldb) p phrase[i]
for that
frame variable supports constant indexes (i.e. plain ol’ numbers), but if you need to use a variable or anything BUT a number, you need to use the expression command
As a caveat, the behavior of frame var vs. expression might be different in some cases when doing array-like access. This won’t affect your example (but it would if you were using an std::vector, for instance).
Problem
I'm working in a personal project of open-source technologies developing an application build it in C. I'm using the lldb debugger tool. My question is simple: How can I display or show the values of an element when I'm debugging. For example: ``` #include <iostream.h> int main(){ char phrase[1024]; int i=0; for(i=0;i<1024;i++){ printf("%c",phrase[i]); } return 0; } ``` In the lldb prompt, I can see the values for specific character of the array: ``` lldb>b 6 lldb>frame variable phrase[0]; ``` When I want to execute: ``` lldb>frame variable phrase[i] ``` I got an error: "unable to find any variable expression path that matches 'phrase[i]'"