Thanks for your answer, is there any plan to include this feature ?I think this would be useful, so yes.
I think this would be useful, so yes.
There was a patch in the bug tracker some time ago that did this...
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?Save what needs to be saved for a BP, replay "adding" BPs' when loading the file. What else?
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.
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?
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 :)
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.
As you know I don't like non-generic solutions...
Hmmm.. I don't get it: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.
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?
What patch? Link?Well I didn't find it - the one of ollydbg was to save BP's imho.
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);
}
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. :-)