Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Extend GDB plugin to communicate with other plugins
oBFusCATed:
DeleteMemoryRange and HasMemoryRange seem redundant...
Also I'm not sure it is a good idea to use GDBWatch as a class and to store the command in the symbol field or the result as a string in the value.
BlueHazzard:
--- Quote ---DeleteMemoryRange and HasMemoryRange seem redundant...
--- End quote ---
i agree with that.. This popped up my mind as soon as i pushed the code
--- Quote ---Also I'm not sure it is a good idea to use GDBWatch as a class and to store the command in the symbol field or the result as a string in the value.
--- End quote ---
This could easily be made, and honestly i would prefer it. But the result has to be stored in the value member as string, because otherwise the cbWatch has to be modified, or how do you think to get the result from outside of the gdb plugin? One possibility would be to add a function
--- Code: ---bool GetMemoryRangeValue(cb:shared_ptr<cbWatch> watch, std::vector<char> &data)
--- End code ---
to cbDebuggerPlugin, but this seems not intuitive if the normal use of cbWatch is GetValue().
oBFusCATed:
--- Quote from: BlueHazzard on August 08, 2017, 10:28:48 am ---This could easily be made, and honestly i would prefer it. But the result has to be stored in the value member as string, because otherwise the cbWatch has to be modified, or how do you think to get the result from outside of the gdb plugin?
--- End quote ---
It depends what you want to do with the data. Do you know what operations you want to do?
--- Quote from: BlueHazzard on August 08, 2017, 10:28:48 am --- One possibility would be to add a function
--- Code: ---bool GetMemoryRangeValue(cb:shared_ptr<cbWatch> watch, std::vector<char> &data)
--- End code ---
to cbDebuggerPlugin, but this seems not intuitive if the normal use of cbWatch is GetValue().
--- End quote ---
Do not go this route, please.
BlueHazzard:
Hi,
i reworked the implementation: https://github.com/bluehazzard/codeblocks_sf/tree/debugger/memory_range_watch
The interface to all plugins is only one function:
--- Code: ---cb::shared_ptr<cbWatch> cbDebuggerPlugin::AddMemoryRange(uint64_t address, uint64_t size, const wxString &id ) = 0;
--- End code ---
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):
--- 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);
--- End code ---
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
--- Code: ---std::vector<cb::shared_ptr<GDBMemoryRangeWatch> > m_memoryRange;
--- End code ---
and the following functions are transparent for normal and memory range watches:
--- Code: ---void DebuggerGDB::DeleteWatch(cb::shared_ptr<cbWatch> watch)
bool DebuggerGDB::HasWatch(cb::shared_ptr<cbWatch> watch)
--- End code ---
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
--- Code: ---bool DebuggerGDB::IsMemoryRangeWatch(cb::shared_ptr<cbWatch> watch)
--- End code ---
The actual reading of the memory from gdb is implemented like the normal watches with a
--- Code: ---class GdbCmd_MemoryRangeWatch : public DebuggerCmd
--- End code ---
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?
BlueHazzard:
Ok, this is my suggestion for a pull request. I think the commits are not to large and quite obvious...
https://github.com/bluehazzard/codeblocks_sf/tree/debugger/pull_candidate/memory_range_watch/1
any thoughts on this?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version