Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view values of variables in KDevelop?

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?

like image 295
Jackzz Avatar asked Jun 11 '15 07:06

Jackzz


1 Answers

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"
like image 170
doqtor Avatar answered Oct 06 '22 13:10

doqtor