Hi,
i reworked the implementation:
https://github.com/bluehazzard/codeblocks_sf/tree/debugger/memory_range_watchThe interface to all plugins is only one function:
cb::shared_ptr<cbWatch> cbDebuggerPlugin::AddMemoryRange(uint64_t address, uint64_t size, const wxString &id ) = 0;
This function returns a cbWatch object that represents a memory range. The value of the Watch (the memory raw data directly from ram) can be get with (pseudo code):
cb::shared_ptr<cbWatch> m_watch = dbg_plugin->AddMemoryRange(0x400000, 16, wxEmtyString );
// Run the debugger
wxString tmp;
m_watch->GetValue(tmp);
size_t lengthOfData = tmp.size();
char* memoryContetn = new char[ lengthOfData ];
memcpy(memoryContent, tmp.To8BitData(), 16);
// yay: ram content in memoryContent for your free use and interpretation
// i know there is a uint16_t @ 0x400002
uint16_t myNeededValue = 0;
memcpy(&myNeededValue, memoryContent+2, 2);
At plugin level there is a internal watch class: GDBMemoryRangeWatch that represents a memory range. It derives from cbWatch and stores the address and size of the range.
All the memory range watches are stored in
std::vector<cb::shared_ptr<GDBMemoryRangeWatch> > m_memoryRange;
and the following functions are transparent for normal and memory range watches:
void DebuggerGDB::DeleteWatch(cb::shared_ptr<cbWatch> watch)
bool DebuggerGDB::HasWatch(cb::shared_ptr<cbWatch> watch)
there is an additional function (at the moment only for GDBPlugin but it can be added to cbDebuggerPlugin) to check if the watch is a memory range watch
bool DebuggerGDB::IsMemoryRangeWatch(cb::shared_ptr<cbWatch> watch)
The actual reading of the memory from gdb is implemented like the normal watches with a
class GdbCmd_MemoryRangeWatch : public DebuggerCmd
This implementation works nice and transparent. It is relatively fast and i use it in the new plugin i showed with the video above. I will post the link to the source later tody...
conclusion:
To add a interface for other plugins to read random ram content from the debugger, only one new function has to be added to
cbDebuggerPlugin. The data is exchanged through wxString::To8BitData() so the cbWatch class has not to be altered.
@oBFusCATed: Is this interface somehow acceptable for you?