Author Topic: Load and save watch file in 12.11  (Read 16084 times)

Offline euzkoarima

  • Single posting newcomer
  • *
  • Posts: 8
Load and save watch file in 12.11
« on: January 18, 2013, 11:43:07 pm »
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
« Last Edit: January 19, 2013, 04:20:32 am by euzkoarima »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save wath file in 12.11
« Reply #1 on: January 18, 2013, 11:55:47 pm »
No.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline euzkoarima

  • Single posting newcomer
  • *
  • Posts: 8
Re: Load and save watch file in 12.11
« Reply #2 on: January 19, 2013, 04:20:52 am »
Thanks for your answer, is there any plan to include this feature ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #3 on: January 19, 2013, 08:38:46 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline euzkoarima

  • Single posting newcomer
  • *
  • Posts: 8
Re: Load and save watch file in 12.11
« Reply #4 on: January 19, 2013, 04:33:24 pm »
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 !!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #5 on: January 19, 2013, 07:12:36 pm »
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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #6 on: January 19, 2013, 09:41:14 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... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #7 on: January 19, 2013, 09:48:12 pm »
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #8 on: January 19, 2013, 11:21:39 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Load and save watch file in 12.11
« Reply #9 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #10 on: January 20, 2013, 12:12:52 am »
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 :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #11 on: January 20, 2013, 09:17:43 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #12 on: January 20, 2013, 01:07:38 pm »
As you know I don't like non-generic solutions... The patch probably have been provided by Ollydbg.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #13 on: January 20, 2013, 01:54:22 pm »
As you know I don't like non-generic solutions...
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. ???
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #14 on: January 20, 2013, 02:00:37 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #15 on: January 20, 2013, 03:03:31 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:
Code
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);
}
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #16 on: January 20, 2013, 03:13:08 pm »
The code is basic. If you just want the keyword saved, it is pretty simple to add, but I doubt it will be enough.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Load and save watch file in 12.11
« Reply #17 on: January 20, 2013, 03:19:28 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. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Load and save watch file in 12.11
« Reply #18 on: January 20, 2013, 03:25:04 pm »
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]