This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb - Printing multiple arrays or arrays of arrays


On Fri, Jun 30, 2006 at 03:42:10PM -0300, Dedeco wrote:
> int **vec = malloc( 9 * sizeof(int*));
> for (i=0; i<10; i++)
>     vec[i] = malloc(10 *sizeof(int*));
> 
>    How to print the 90 values I have?

GDB doesn't have a handy syntax for this.  However you can write a user
defined command:
  define pa
    set $i = 0
    while $i < 9
      p $1[$i]@10
    end
    $i++
  end

  pa vec

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]