Search code examples
c++cdebugginggdbtrace

How Can I display A 2d array in gdb?


I am trying to debug a program in c++ language with gdb debugger.

I have an array[100][100] and want just to see 5 elements of rows and columns and not more.

I can handle a 1d array with the following command :

display *arr@5

but how can I display a 2d array ?

I tried these but failed :

display *arr@5*5
display *arr@5 5

Solution

  • Using "double for" for a function to print it then calling it on GDB pretty much gets it done. Here I add a link to same kind of question. Good luck!

    Here an example