Hi, the save/load watch file is implemented on 12.11 version ?
I'm trying using it but right click on watches panel do nothing
No.
Thanks for your answer, is there any plan to include this feature ?
Quote from: euzkoarima on January 19, 2013, 04:20:52 AM
Thanks for your answer, is there any plan to include this feature ?
I think this would be useful, so yes.
There was a patch in the bug tracker some time ago that did this...
Quote from: MortenMacFly on January 19, 2013, 08:38:46 AM
I think this would be useful, so yes.
There was a patch in the bug tracker some time ago that did this...
Great, that's good news !!
Quote from: MortenMacFly on January 19, 2013, 08:38:46 AM
There was a patch in the bug tracker some time ago that did this...
I doubt it will do the job, because there is no serialization API for the watches.
What are the requirements for such a feature?
Quote from: oBFusCATed on January 19, 2013, 07:12:36 PM
What are the requirements for such a feature?
Save what needs to be saved for a BP, replay "adding" BPs' when loading the file. What else?
It was implemented really simple before... saving a few information to a text file... and it was one of my first contributions to C::B, IIRC... ;-)
Yes, but now there is no single Watch class, but every plugin implements its own version and can add any property it feels necessary.
Do we want to restore the properties? Do we want to load all watches to the current active plugin or do we want to load them as they were.
It is not simple as you can see.
Quote from: oBFusCATed on January 19, 2013, 09:48:12 PM
It is not simple as you can see.
Well... there is
one simple interface to GDB how you add watches. Thats all I want to save, nothing more, nothing less. It should be a simple as it was before.
If every plugin implements it's own version, the plugins should be able to have an own function to save the watches.
Quote from: MortenMacFly on January 19, 2013, 11:21:39 PM
Well... there is one simple interface to GDB how you add watches. Thats all I want to save, nothing more, nothing less. It should be a simple as it was before.
You forget that we now have a generic debugger interface. What about the python dbg plugins or gdb/mi?
Quote from: jens on January 19, 2013, 11:30:09 PM
If every plugin implements it's own version, the plugins should be able to have an own function to save the watches.
Yes, this is the direction I'll probably take, but not now. Probably you should ping me about this is a month or two :)
Quote from: oBFusCATed on January 20, 2013, 12:12:52 AM
Yes, this is the direction I'll probably take, but not now. Probably you should ping me about this is a month or two :)
Yes, thats true and thats also what I meant. Of course I am only talking about the
one gdb plugin we have in SVN, nothing else. It had this functionality before and it seems it was useful. Especially with locals gone.
Maybe I wasn't clear enough in the first place - I am not looking for something generic nor an extension to the core, just to the debugger plugin we provide atm. Let me have a look if I find the patch again - maybe its very simple then...
As you know I don't like non-generic solutions... The patch probably have been provided by Ollydbg.
Quote from: oBFusCATed on January 20, 2013, 01:07:38 PM
As you know I don't like non-generic solutions...
Quote from: oBFusCATed on January 20, 2013, 12:12:52 AM
Quote from: jens on January 19, 2013, 11:30:09 PM
If every plugin implements it's own version, the plugins should be able to have an own function to save the watches.
Yes, this is the direction I'll probably take, but not now.
Hmmm.. I don't get it:
Whats the difference between what I propose and you? The patch does exactly that: Save watches for this very debugger plugin we distribute. ???
Quote from: MortenMacFly on January 20, 2013, 01:54:22 PM
Whats the difference between what I propose and you? The patch does exactly that: Save watches for this very debugger plugin we distribute. ???
What patch? Link?
Quote from: oBFusCATed on January 20, 2013, 02:00:37 PM
What patch? Link?
Well I didn't find it - the one of ollydbg was to save BP's imho.
However, from SVN I extracted the old two methods that did the job. See here:
void DebuggerTree::OnLoadWatchFile(wxCommandEvent& event)
{
WatchesArray fromFile = m_Watches; // copy current watches
// ToDo:
// - Currently each watch is imported as WatchType "Unspecified". This should
// be changed that the file contains another (optional) column with the type.
// - Change "Watch files" format to XML?
// - With the current implementation sometimes the debugger tree gets weird.
// - (Maybe) verify that watches are not already present?
wxString fname;
wxFileDialog dlg (Manager::Get()->GetAppWindow(),
_T("Load debugger watch file"),
_T(""),
_T(""),
_T("Watch files (*.watch)|*.watch|Any file (*)|*"),
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR | compatibility::wxHideReadonly);
PlaceWindow(&dlg);
if (dlg.ShowModal() != wxID_OK)
return;
wxTextFile tf(dlg.GetPath());
if (tf.Open())
{
// iterate over each line of file and send to debugger
wxString cmd = tf.GetFirstLine();
while(true)
{
if (!cmd.IsEmpty()) // Skip empty lines
{
// Manager::Get()->GetLogManager()->DebugLog(_T("Adding watch \"%s\" to debugger:"), keyword);
AddWatch(cmd, Undefined, false); // do not notify about new watch (we 'll do it when done)
}
if (tf.Eof()) break;
cmd = tf.GetNextLine();
}
tf.Close(); // release file handle
// notify about changed watches
NotifyForChangedWatches();
}
else
Manager::Get()->GetLogManager()->DebugLog(_T("Error opening debugger watch file: ") + fname);
}
void DebuggerTree::OnSaveWatchFile(wxCommandEvent& event)
{
// Verify that there ARE watches to save
size_t wc = m_Watches.GetCount();
if (wc<1)
{
cbMessageBox(_("There are no watches in the list to save."),
_("Save Watches"), wxICON_ERROR);
return;
}
wxString fname;
wxFileDialog dlg (Manager::Get()->GetAppWindow(),
_T("Save debugger watch file"),
_T(""),
_T(""),
_T("Watch files (*.watch)|*.watch|Any file (*)|*"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
PlaceWindow(&dlg);
if (dlg.ShowModal() != wxID_OK)
return;
wxTextFile tf(dlg.GetPath());
bool bSuccess = false;
// Create() will fail if the file exist -> must use Open() if file exist
if (tf.Exists())
{
bSuccess = tf.Open();
if (bSuccess) tf.Clear(); // remove old content (if any)
}
else
bSuccess = tf.Create();
if (bSuccess)
{
// iterate over each watch and write them to the file buffer
for (size_t i = 0; i < wc; ++i)
{
Watch& w = m_Watches[i];
tf.AddLine(w.keyword);
}
tf.Write(); // Write buffer to file
tf.Close(); // release file handle
}
else
Manager::Get()->GetLogManager()->DebugLog(_T("Error opening debugger watch file: ") + fname);
}
The code is basic. If you just want the keyword saved, it is pretty simple to add, but I doubt it will be enough.
Quote from: oBFusCATed on January 20, 2013, 03:13:08 PM
but I doubt it will be enough.
Why not? Its more convenient than having nothing like that. From a quick check of
watchesdlg.h it should be even possible in a general way applicable to all debugger plugin unless they define a more sophisticated way... Its similar to hat happens if you change a symbol in that dialog. But you should know better. :-)
Yes, it will be pretty easy. But if I do it I want to implement the full version, which saves everything. I don't want to support the old limited format.