Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display pointer as array in Qt Creator with CDB for debugger

Edit 2: If it's not possible, I will award the bounty to an answer that proves it (I mean provides some credible sources that back the claim that it's not possible).


Let's say I have a pointer to an array, for example:

int arr[3];
int *p = new int[3];

I can see all the elements of arr, but only the first element of p. How can I see all 3 elements of p?

I tried the various suggestions from the answers from View Array contents in QtCreator and View Array contents in Qt Creator debugger, however they didn't work for me:

enter image description here

I assume this is because I'm on CDB, while the other 2 questions are for GDB. Is it possible to achieve the same for CDB?

Edit: I forgot to mention, but p,3 also doesn't work.

like image 488
sashoalm Avatar asked Mar 17 '15 09:03

sashoalm


1 Answers

Add into Expression Evaluator (menu Window->Views->Locals and Expressions)

(int(*)[3])p

That works fine in Qt Creator 3.2.1 Based on Qt 5.3.2 (GCC 4.9.2, 64 bit) Built on May 10 2016 at 17:53:15.

like image 185
Alexander Khomyak Avatar answered Nov 02 '22 15:11

Alexander Khomyak