GNOME Bugzilla – Bug 465137
Add ability to specify a starting offset
Last modified: 2007-12-21 14:51:03 UTC
I'm in need of a basic hex-editor widget for use in the nemiver debugger. the GtkHex widget looks like a good candidate, but it currently is constructed with a HexDocument* argument, which assumes that the data is being read from a file. For my use, I would be sending the 'read memory' command to gdb with a particular address and a number of bytes to read. This will essentially give me back the starting address I passed in and an array of data bytes. I'd like to be able to pass this data to the hex editor widget to be displayed and edited. But in my situation, there's no concept of a 'document' involved, so I'm not sure whether it makes sense to modify the HexDocument class to allow it to behave in a non-document mode, or if it would be better to separate the document functionality completely out. Perhaps create a base class like HexDataModel, which just deals with data buffers and then have HexDocument inherit from this new base class and extend it with some file loading/saving file-specific functionality. The other thing I would need that doesn't seem to be supported yet by this widget is to be able to set an arbitrary start address instead of always starting from 0. I'm willing to do the work required, but would appreciate some feedback on the best approach to take.
Abstracting the data model seems like the best approach. It will probably be needed to be able to implement loading from VFS sources properly as well, as we will just be getting data through the VFS stream. And being able to specify the starting address value sounds sane to me. Having the class abstracted would probably make it easier to deal with loading large files as well. Thanks for volunteering to do the work.
I'm coming to the realization that I'm really not going to ever get the motivation to actually do this in gobject, so if anybody else feels the motivation, feel free to step up.
OK, so I'm an idiot. This is already possible using hex_document_set_data(). So I think the only thing I really need is a way to specify an arbitrary starting address/offset. Updating bug summary
Created attachment 99951 [details] [review] [PATCH] Add ability to specify arbitrary starting address for offsets in GtkHex widget * src/gtkhex.c: * src/gtkhex.h: add API to set a starting offset address. In some ways it seems that this information is a property of the document rather than the view, but the GtkHex widget does all of the offset-related stuff, so I put it here. This is useful for using this widget as a debugger memory editor since we'll only read a small amount of memory from gdb and we want to be able to label the rows with the correct address. Fix for bug #465137 --- ChangeLog | 10 ++++++++++ src/gtkhex.c | 10 +++++++++- src/gtkhex.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletions(-)
just fyi, I'm waiting for these changes to get into ghex svn so I can start committing the experimental memory editing stuff for nemiver.
Looks good. Please commit. Thanks!
Thanks, committed as r1178