How to view variable values ​​in KDevelop?

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

+6
source share
1 answer

Use the 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 the KDevelop IDE . Debug your program and at the moment when you should check the value of the variable, enter print variable_name in the text field corresponding to GDB cmd . The value of the variable will be printed.

Some examples of commands:

Show array (will show the 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 array range buffer [index] @count:

 (gdb) print buffer[50]@40 print buffer[50]@40 $2 = "23456789:;<=> ?@ABCDEFGHIJKLMNOPQRSTUVWXY " 
+3
source

Source: https://habr.com/ru/post/988897/


All Articles