views:

141

answers:

1

Hi everyone,

I'm trying to display the information from a custom matrix class in Visual Studio 2008's debugger by enhancing/modifying the file autoexp.dat. The custom class goes as follow :

LVSN::Matrix<T> {

... functions ...



  struct base_mat
  {
     T **Val;
     size_t Row, Col, RowSiz, ColSiz;
     int Refcnt;
     T Err;

     base_mat (size_t row, size_t col, T** v)
     {
        Row = row; RowSiz = row;
        Col = col; ColSiz = col;
        Refcnt = 1;
        Err = 0;

        Val = new T* [row];
        size_t rowlen = col * sizeof(T);

        for (size_t i=0; i < row; i++)
        {
           Val[i] = new T [col];
           if (v) memcpy( Val[i], v[i], rowlen);
        }
     }

     ~base_mat ()
     {
        for (size_t i=0; i < RowSiz; i++)
           delete [] Val[i];
        delete [] Val;
     }
  };

  base_mat *_m;

} // end of matrix class

So I am basically accessing the base_mat _m in autoexp.dat.. What I have so far is this :

;------------------------------------------------------------------------------
;  LVSN::Matrix
;------------------------------------------------------------------------------
LVSN::Matrix<double>{

preview
(
   #( "[", [(int)$c._m->Row], ",", [(int)$c._m->Col], "]")
)

children
(
  #(
     #array 
     (
  expr : $c._m->Val[$i],
  size : ((unsigned int*)(&($c._m->Row)))[$r],
  rank : 2
     )
  )   
)

}

This is able to display the preview properly, but I am unable to access the inner values of my matrix since it is an array of pointers to arrays of doubles. Rank will generate indexes as if it was one contiguous space in memory [col + row*rowsize]... and What I need is a double access [row][col]. If I understood correctly, autoexp does not allow for #if statements inside of #array, so I cannot rely on them.. I tried but I got an error message.

Has anyone toyed with autoexp.dat ? Do you see any way to do what I'm looking to do (apart from modifying the base class, hehe!) ?

thanks ! JC

A: 

OOK, after going to sleep and back I found a solution to my own problem. You see, while using rank, the $i variable contains one array of contiguous indexes 0..15, which I wasn't totally sure about... From this point it's easy to just adapt those indices to become [0..3][0..3] using rows and columns.

Here goes the solution :

;------------------------------------------------------------------------------
;  LVSN::Matrix3D
;------------------------------------------------------------------------------
LVSN::Matrix3D<double>|LVSN::Matrix<double>{
   preview
  (
   #( "[", [(int)$c._m->Row], ",", [(int)$c._m->Col], "] (",
   #array 
   (
    expr : (float)$c._m->Val[(int)($i / (unsigned int)$c._m->Col)][$i % (unsigned int)$c._m->Col],
    size : (int)$c._m->Row * (int)$c._m->Col
   ),
   ")")
   )

   children
   (
   #(
   #array 
   (
   expr : $c._m->Val[(int)($i / (unsigned int)$c._m->Col)][$i % (unsigned int)$c._m->Col],
   size : ((unsigned int*)(&($c._m->Row)))[$r],
   rank : 2
   )
   )   
   )
}

The biggest hack here is that I assume that my Row and Col variables are contiguous in memory space, which is true in my case, but not in every case. The rank: assignment needs a vector containing the size of every dimension of the multidimensional array. I tricked it into believing it has such an array.. gonna have to watch my back.. malpractice raptors prolly looking for me now.

JC