Observing the content of a custom matrix class in the Visual Studio 2008 debugger

I am trying to display information from a custom matrix class in the Visual Studio 2008 debugger by incrementing / modifying the autoexp.dat file. The custom class looks like this:

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 base_mat _m in autoexp.dat. What I have so far:

;------------------------------------------------------------------------------
;  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 allows the preview to be displayed correctly, but I cannot access the internal values ​​of my matrix as it is an array of pointers to arrays of twins. The rank will generate indexes as if it were one contiguous memory space [col + row * rowsize] ... and I need double access [row] [col]. If I understand correctly, autoexp does not allow for # if statements inside #array, so I cannot rely on them. I tried, but I got an error message.

Has anyone played with autoexp.dat? Do you see any way to do what I'm looking for (other than changing the base class, hehe!)?

thank! JC

+2


source to share


1 answer


OOK, after sleeping and back, I found a solution to my problem. You see, when using rank, the variable $ i contains one array of contiguous indices 0..15, which I was not completely sure about ... From now on, it's easy to just tune these indices to become [0..3] [0..3 ] using rows and columns.

Here's 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 the Row and Col variables are contiguous in memory space, which is true in my case, but not in all cases. Rank: The assignment requires a vector containing the size of each dimension of the multidimensional array. I tricked him into believing that he has such an array. I will need to look at my back ... the cunning predators who are now looking for me.

0


source







All Articles