How to view values of variables in KDevelop?

2.8k views Asked by At

I am using KDevelop as IDE for my C++ program. I have an array char buffer[1024] in my program. After reading data to buffer, I would like to check it manually. But in the left panel, I need to read the array character by character. Is there some way by which I can get the content of the array at a stretch?

2

There are 2 answers

4
doqtor On BEST ANSWER

Use GDB tool view available in KDevelop. In KDevelop 4.6, Window->Add ToolView->GDB will open the GDB tool view at the bottom/left/right of KDevelop IDE. Debug your program and at the point at which you have to check value of the variable, enter print variable_name in the textbox corresponding to GDB cmd. The value of variable will be printed.

Some example commands:

Show an array (will show first 200 elements by default):

(gdb) print buffer
print buffer
$1 = "\000\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307"...

Show an array range buffer[index]@count:

(gdb) print buffer[50]@40
print buffer[50]@40
$2 = "23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY"
0
FireFragment On

There's the Variables tool view.
Show it by right clicking left, right or bottom border of KDevelop's window and click Variables