Author Topic: Watches modification  (Read 11448 times)

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Watches modification
« on: January 26, 2006, 05:01:45 pm »
Hello,

It will be great if we can modify watches value during a debug session.
Testing the sdk to add this feature, i try to recompile debuggergdb plugins
But i have a link error
Quote
undefined reference :wxdialog::MSWProcessMessage(...)

What's wrong in my conf ?

Have a nice day
Ouille

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Watches modification
« Reply #1 on: January 26, 2006, 06:24:59 pm »
Have you looked at the watches script thread below?  Maybe an expansion of that concept would be what you want.

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #2 on: January 26, 2006, 10:19:40 pm »
Hello,

I've look at scripts but it's too complex for me sorry. It seem complex to just modify the value of a watch  :(

After managing to get debuggergdb compiling :D, i try to modify On edit watch that way to allow modification of a watch
Code: [Select]
void DebuggerTree::OnEditWatch(wxCommandEvent& event)
{
    wxString cmd;

wxString item = m_pTree->GetItemText(m_pTree->GetSelection());
wxString w = wxGetTextFromUser(_("Edit watch"), _("Enter New Value:"), item);
    cmd << _T("set var ") << item << _T("=") << w;
    SendCommand(cmd);
    return;
if (!w.IsEmpty())
{
DeleteWatch(item);
AddWatch(w);
}
}


BUT my c++ courses are far away now, the sendcommand belong to debuggergdb class, is there a simple way to call it from an other class.
I think it's possible, but don't remember how.
Looking forward at the code it seem's that comunication between debuggergdb an other class are uniderectionnal. To modifiy watch i'll to make them working from debuggergdb to debugger tree and backward, is it right ?

Have a nice day
Ouille

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Watches modification
« Reply #3 on: January 26, 2006, 10:47:40 pm »
Never, ever, use SendCommand(). This is just to pipe a command to the debugger process. It is only to be used by debugger drivers.

Assuming you 're talking gdb here, you have to create a new debugger command inheriting DebuggerCmd and put it inside gdb_commands.h. Look there for examples of how commands are created and what they do. It should be pretty straightforward.
Be patient!
This bug will be fixed soon...

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #4 on: January 26, 2006, 10:58:11 pm »
Hello,

I just want to pipe a command to the debugger, gdb in fact
sending for example
Code: [Select]
set var i=17My problem is that i need to send that command from debuggertree class wich manage watch tree class.

I look at debuggercmd.

Bye
Ouille

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #5 on: January 26, 2006, 11:05:00 pm »
where are gdb_commands.h ?????
Havn't found in source tree !

Bye
Ouille

sethjackson

  • Guest
Re: Watches modification
« Reply #6 on: January 26, 2006, 11:24:37 pm »
where are gdb_commands.h ?????
Havn't found in source tree !

Bye
Ouille

Open C::B project.

Headers -> plugins -> debuggergdb -> gdb_commands.h

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #7 on: January 27, 2006, 12:15:30 am »
Here is it.
haven't found here Headers -> plugins -> debuggergdb -> gdb_commands.h :(

:) :) Here is the function: :) :)
Code: [Select]
void DebuggerTree::OnEditWatch(wxCommandEvent& event)
{
    wxString cmd,varname;

wxString item = m_pTree->GetItemText(m_pTree->GetSelection());
varname = item.BeforeFirst('=');
item = item.AfterFirst('=');
wxString w = wxGetTextFromUser(_("Edit watch value"), _("Enter New Value:"), item);
if ((item.Contains("\"")) && (!w.Contains("\"")))
            w = _T("\"") + w + _T("\"");

    cmd << _T("set var ") << varname << _T("=") << w;
    m_pDebugger->SendCommand(cmd);
    wxPostEvent(m_pDebugger, event);

    return;
}

This allow watches modification using edit submenus
To add edit submenu on each watches:
Code: [Select]
void DebuggerTree::ShowMenu(wxTreeItemId id, const wxPoint& pt)
{
wxString caption;
    wxMenu menu(wxEmptyString);

// add watch always visible
menu.Append(idEditWatch, _("&Edit watch"));

// we have to have a valid id for the following to be enabled
    if (id.IsOk()  && m_pTree->GetItemParent(id) == m_pTree->GetRootItem())
    {
        menu.Append(idAddWatch, _("&Add watch"));
        menu.Append(idDeleteWatch, _("&Delete watch"));
}

PopupMenu(&menu, pt);
}
Seem more usefull than add on each element and edit only on root nodes
The rest is not really clean, but i've done what i can

the class definition need's to be modified to have a pointer on the debuggerGDB classe
Code: [Select]
        DebuggerGDB* m_pDebugger; Copying this from backtrace class

At last
SendCommand need's to be public in debuggerGDB class.
and class debuggerGDB in debuggertree.h

When done you can edit watches values either numerical and strings during debug session.

If someone interested ...
Any feedback welcome !

Have a nice day
Ouille

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Watches modification
« Reply #8 on: January 27, 2006, 02:54:08 am »
You should of done this the way Mandrav suggested, methods are private for a reason you know.  It was not hard to find gdb_commands.h, you just have to realize that the codeblocks src is not ogranized into and header and include trees.  This is to me is a little messy, but you it means that the header and source files are in the same directory.  So in this case gdb_commands.h is in src/plugins/debuggergdb/gdb_commands.h, I found that in about 3 minutes using viewCVS.  I think a think search in windows or a good old "find . -name gdb_commands.h" in unix would of done the trick.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Watches modification
« Reply #9 on: January 27, 2006, 08:51:46 am »
Here is it.

<snip...>

If someone interested ...
Any feedback welcome !

May I ask what happens if I am debugging a MSVC executable using CDB? Is "set var" going to work?
Using SendCommand() directly will only give you trouble.
I told you what is the correct way to do it...
Be patient!
This bug will be fixed soon...

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #10 on: January 27, 2006, 03:30:21 pm »
Here we go
First of all
Game_ender
Here is my directory
Quote
ocks-1.0rc2\src\plugins\debuggergdb

26/01/2006  09:13    <REP>          .
26/01/2006  09:13    <REP>          ..
25/10/2005  08:59             4 381 backtracedlg.cpp
11/05/2005  11:02               608 backtracedlg.h
25/10/2005  08:59            51 482 debuggergdb.cpp
26/01/2006  23:16             4 340 debuggergdb.h
25/10/2005  08:59             3 108 debuggeroptionsdlg.cpp
18/03/2005  23:23               564 debuggeroptionsdlg.h
27/01/2006  00:01             9 667 debuggertree.cpp
26/01/2006  23:13             1 395 debuggertree.h
25/10/2005  08:59             4 997 disassemblydlg.cpp
28/09/2005  14:56               869 disassemblydlg.h
04/10/2005  20:59               674 Makefile.am
26/01/2006  09:13    <REP>          resources
              11 fichier(s)           82 085 octets
               3 Rép(s)     121 221 120 octets libres
Bah no gdb_commands.h,
This directory is from source code of code block, perhaps i miss something, but codeblock compile.
Sorry if i bother you, but i'll try to find this file, using a search in windows, and dir gdb*.* /s didn't find anything.

So there is a problem  in my source tree, sorry, you can understand that looking at debugger:gdb i saw:
Code: [Select]
                        cmd << _T("break ") << filename << _T(":") << bp->line + 1;
                        SendCommand(cmd);
break is a true gdb command ...
So i am perhaps a bit stupid, but source are not sync with your response.
Last but not least, it is not really pleasent when i try to add my to cents to a project to be treated like this.

Mandrav:
i work on debuggergdb so the command needs to be gdb compiant only ?

I've try to expand debuggergdb plungins to add these fonctionnality

I'll try to find gdb_commands.h

Thank's
Have a nice day

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Watches modification
« Reply #11 on: January 27, 2006, 03:50:32 pm »
Quote
break is a true gdb command ...
So i am perhaps a bit stupid, but source are not sync with your response.
Last but not least, it is not really pleasent when i try to add my to cents to a project to be treated like this.

No one treated you like stupid. But the responses you got are valid for the development version. You are probably talking about RC2 which would explain a lot :). All you had to do was say which version you 're using in your first post ;).
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Watches modification
« Reply #12 on: January 27, 2006, 04:48:36 pm »
to get up to date :
1) download/install a nightly
2) get the sources from svn
3) build CB and happy coding

Good luck, it's a nice feature you are trying to implement. Looking forward to it.

Cheers,
Lieven

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: Watches modification
« Reply #13 on: January 27, 2006, 05:03:34 pm »
2) get the sources from svn
If you're on windows, just install TortoiseSVN.
And checkout from svn://svn.berlios.de/codeblocks/trunk

Or if you're in linux, install SVN.
And checkout doing a svn checkout svn://svn.berlios.de/codeblocks/trunk

:wink:

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #14 on: January 27, 2006, 08:56:00 pm »
 :( Sorry, i was working on the rc2, i though that there where only minors modifs.

I get last svn update, and found gdb_commands  :D

I have some problem to compile it, libwxmsv26u why u ???
wxstring beforefirst missing, and working in the rc2 ???

I'll try and give you my code if i manage to make it working.

Have a nice day.

sethjackson

  • Guest
Re: Watches modification
« Reply #15 on: January 27, 2006, 08:58:34 pm »
:( Sorry, i was working on the rc2, i though that there where only minors modifs.

I get last svn update, and found gdb_commands  :D

I have some problem to compile it, libwxmsv26u why u ???
wxstring beforefirst missing, and working in the rc2 ???

I'll try and give you my code if i manage to make it working.

Have a nice day.

u is for UNICODE. :) If you didn't compile wx with UNICODE=1 then leave off the u. :)

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: Watches modification
« Reply #16 on: January 27, 2006, 09:00:18 pm »
That u means unicode.
If you don't want to recompile wxWidgets in Unicode mode, change the variable WX_PREFIX from "u" to "".

EDIT: sethjackson won me :P but the forum didn't tell me that anyone posted before :D

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Watches modification
« Reply #17 on: January 27, 2006, 09:06:02 pm »
I have some problem to compile it, libwxmsv26u why u ???

u for UNICODE :D.

Michael

[EDIT] The forum did not tell me too that someone has already posted. And before posting, I have done a page update...
« Last Edit: January 27, 2006, 09:18:02 pm by Michael »

sethjackson

  • Guest
Re: Watches modification
« Reply #18 on: January 27, 2006, 09:08:44 pm »
That u means unicode.
If you don't want to recompile wxWidgets in Unicode mode, change the variable WX_PREFIX from "u" to "".

EDIT: sethjackson won me :P but the forum didn't tell me that anyone posted before :D

:lol: it is WX_SUFFIX not WX_PREFIX. :lol:

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: Watches modification
« Reply #19 on: January 27, 2006, 09:11:25 pm »
That u means unicode.
If you don't want to recompile wxWidgets in Unicode mode, change the variable WX_PREFIX from "u" to "".

EDIT: sethjackson won me :P but the forum didn't tell me that anyone posted before :D

:lol: it is WX_SUFFIX not WX_PREFIX. :lol:

lol :lol: guess I've got to sleep...

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #20 on: January 27, 2006, 09:21:50 pm »
too late i began a new compile of wxwidget with unicode ...

And know i'm waiting,  waiting waiting ...

Offline ouille

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Watches modification
« Reply #21 on: January 27, 2006, 09:40:10 pm »