My problem is this:
Code: Select all
class Table
{
protected:
ui32_v m_size;
ui32_v m_count;
ui32_v m_total;
page_v* m_table;
inline
Table (ui32_v address,ui32_v total,ui32_v size)
:m_size (size)
,m_count (0)
,m_total (total)
,m_table (0)
{
m_size = size;
m_total = total;
m_count = m_total / size;
if (m_count * size < total)
{
m_count++;
}
Vga vga;
vga.setPos(0,10);
// vga << "t-ctor total=" << total << " size=" << size << " count=" << m_count;
vga << "t-ctor total=" << m_total << " size=" << m_size << " count=" << m_count;
m_table = new((void*)address) page_v[(std::size_t)m_count];
}
public:
inline
ui32_v count()
{
return m_count;
}
inline
ui32_v size()
{
return m_size;
}
};
class SpanTable : public Table
{
public:
inline
SpanTable (ui32_v address,ui32_v total,ui32_v size)
:Table (address,total,size)
{
Vga vga;
vga.setPos(0,11);
vga << "st-ctor total=" << total << " size=" << size << " count=" << (total / size);
}
};
Code: Select all
spanTable01 = new((void*)0x60000000) SpanTable(0x70000000,0xF0000000,4096);
Code: Select all
spanTable01->size()
I am not expecting someone to debug this for me, but I am looking for any scenarios where this is possible so I can trace the problem. At this point I am out of ideas because nothing goes boom, and yet every thing in the Table class is zero.
I have chosen to build in C++, a rod for my own back but I felt there was little point in simply copying other solutions, perhaps not the best choice but I am persistent.
The only though I had was that the void* operator new(size_t,void*) method which I wrote was not calling the ctor but then the appropriate messages are displayed on the screen.
So in summary, the SpanTable and Table ctors are called, the stack arguments and local variables are correct but all of the member variables are zero. Note if I set the values of the member variables in the ctor, e.g. m_count = 12, this will display in the ctor correctly but if I attempt to display this value once the ctor has returned the value is once again zero.
So I am thinking this has something to do with the layout of the inherited class (Table) in memory, I thought the SpanTable address would begin with the Table vtab and members (although there are no virtuals in this code).
So suggestions anyone?