I'm using the VSIP Debugging SDK for building a custom Debugger.
I want to show the data of memory in the MemoryWindow.
Question 1: The method of using the interface of IDebugMemoryContext2 and
IDebugMemoryByte2 cannot understand well.
Could anyone show me the sample?
Question 2: My target processor bus size is 16bits(2bytes). I want to show
the 16bits(2bytes) data of memory per address in the MemoryWindow. Is it
possible?
Thanks,
Ichiyan
Although the following is the sample which I made, it does not operate exactly.
A MemoryContext class inherits IDebugMemoryContext2 interface.
A MemoryBytesclass inherits IDebugMemoryBytes2 interface.
Thanks,
Ichiyan
********************************************************
// MemoryContext
HRESULT MemoryContext::GetName(BSTR* pbstrName) {return E_NOTIMPL;}
HRESULT MemoryContext::GetInfo(CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO*
pInfo) {
pInfo->dwFields = dwFields;
if (dwFields & CIF_ADDRESS) {
pInfo->bstrAddress = exprCode.AllocSysString();
}
if (dwFields & CIF_ADDRESSOFFSET) {
pInfo->bstrAddressOffset = CComBSTR(_T("0")).Detach();
}
return S_OK;
}
HRESULT MemoryContext::Add(UINT64 dwCount, IDebugMemoryContext2** ppMemCxt) {
if (dwCount == 0) {
*ppMemCxt = this;
(*ppMemCxt)->AddRef();
return S_OK;
}
return S_FALSE;
}
HRESULT MemoryContext::Subtract(UINT64 dwCount, IDebugMemoryContext2**
ppMemCxt) {
ULONG newAddress = address - (ULONG)dwCount;
MemoryContext** memArray = new MemoryContext*[dwCount];
CString newStrAddress;
int i;
for (i = 0; i < (int)dwCount - 1; i++) {
CComObject<MemoryContext>* p_memoryContext;
CComObject<MemoryContext>::CreateInstance(&p_memoryContext);
p_memoryContext->AddRef();
newStrAddress.Format(_T("0x%x"), newAddress);
p_memoryContext->Init(p_memory, p_table, newStrAddress);
memArray[i] = p_memoryContext;
(memArray[i])->AddRef();
p_memoryContext->Release();
newAddress++;
}
memArray[i] = this;
(memArray[i])->AddRef();
*ppMemCxt = memArray[0];
return S_OK;
}
HRESULT MemoryContext::Compare(
CONTEXT_COMPARE compare,
IDebugMemoryContext2** rgpMemoryContextSet,
DWORD dwMemoryContextSetLen,
DWORD* pdwMemoryContext) {return E_NOTIMPL;}
void MemoryContext::Init(Memory* p_memory, IDbgTable* p_table, LPCTSTR
p_exprCode) {
this->p_memory = p_memory;
this->p_table = p_table;
this->exprCode = p_exprCode;
_stscanf(p_exprCode, _T("%x"), &address);
}
// MemoryBytes
HRESULT MemoryBytes::ReadAt(
IDebugMemoryContext2* pStartContext,
DWORD dwCount,
BYTE* rgbMemory,
DWORD* pdwRead,
DWORD* pdwUnreadable)
{
CONTEXT_INFO contextInfo;
pStartContext->GetInfo(CIF_ADDRESS, &contextInfo);
CString straddress = contextInfo.bstrAddress;
ULONG address;
_stscanf((LPCTSTR)straddress, _T("%x"), &address);
for (DWORD i = 0; i < dwCount; i++) {
rgbMemory[i] = (BYTE)i;
}
*pdwRead = dwCount;
*pdwUnreadable = 0;
return S_OK;
}
HRESULT MemoryBytes::WriteAt(
IDebugMemoryContext2* pStartContext,
DWORD dwCount,
BYTE* rgbMemory) {return E_NOTIMPL;}
HRESULT MemoryBytes::GetSize(UINT64* pqwSize) {return E_NOTIMPL;}
void MemoryBytes::Init(Memory* p_memory) {
this->p_memory = p_memory;
}
> I'm using the VSIP Debugging SDK for building a custom Debugger.
> I want to show the data of memory in the MemoryWindow.
[quoted text clipped - 9 lines]
> Thanks,
> Ichiyan
1. From my experience, we should implement IDebugProperty2 for the
memory address user entered in the UI, then the debug package will call
IDebugProperty2::GetMemoryContext. After that, the
IDebugProgram2::GetMemoryBytes will be called.
2. You don't need to write code for it. Just right click in the Mem
WIndow, you can select to display the data in BYTE, WORD or DWORD...
Ichiyan - 30 Nov 2004 03:05 GMT
> > I'm using the VSIP Debugging SDK for building a custom Debugger.
> > I want to show the data of memory in the MemoryWindow.
[quoted text clipped - 11 lines]
> IDebugProperty2::GetMemoryContext. After that, the
> IDebugProgram2::GetMemoryBytes will be called.
Michael,
Thank you for your reply.
I already know the above. But my sample causes an exception.
I think that a cause is in IDebugMemoryContext2::Subtract
or IDebugMemoryContext2::Add of a sample of me.
> 2. You don't need to write code for it. Just right click in the Mem
> WIndow, you can select to display the data in BYTE, WORD or DWORD...
I want to display the memory data as follows.
00001000 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
00001008 1011 1213 ....
^
But IDE displays as follows.
00001000 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
00001010 1011 1213 ....
^
I want to display the half of the value of an address on left-hand side.
I think that this is probably impossible.
So, I'll make my own memory window using VSPackage.
Thanks,
Ichiyan
Ichiyan - 30 Nov 2004 03:25 GMT
> > I'm using the VSIP Debugging SDK for building a custom Debugger.
> > I want to show the data of memory in the MemoryWindow.
[quoted text clipped - 14 lines]
> IDebugProperty2::GetMemoryContext. After that, the
> IDebugProgram2::GetMemoryBytes will be called.
Michael,
Thank you for your reply.
I already know the above. But my sample causes an exception.
I think that a cause is in IDebugMemoryContext2::Subtract
or IDebugMemoryContext2::Add of my sample.
> 2. You don't need to write code for it. Just right click in the Mem
> WIndow, you can select to display the data in BYTE, WORD or DWORD...
I want to display the memory data as follows.
00001000 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
00001008 1011 1213 ....
^^
But IDE displays it as follows.
00001000 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
00001010 1011 1213 ....
^^
I want to display the half of the value of an address on left-hand side.
It seems to be probably impossible.
So, I'll make my own memory window using VSPackage.
Thanks,
Ichiyan