Author Topic: show debugger tip under curser when ctrl key is pressed  (Read 27720 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
show debugger tip under curser when ctrl key is pressed
« on: December 17, 2010, 07:53:40 am »
Due to some unavoidable feature of gdb, such as:

1, under windows, When I use gdb with python supported, when showing a local uninitialized variable, such as a vector<string>, the gdb will crash.

2, when debugging, when I select some piece of code, the debugger plugin try to evaluate the "whole piece of the code", this will always cause gdb to crash.

So, can some devs to add an option that when the user hold the "ctrl" key, and the caret hover event send, then the debugger plugin just send the expression to gdb.

any ideas?

Both Loaden and I have just modify the code to:

Code
void DebuggerGDB::OnValueTooltip(CodeBlocksEvent& event)
{
    event.Skip();
    if (!m_pProcess || !IsStopped())
        return;
    if (!Manager::Get()->GetConfigManager(_T("debugger"))->ReadBool(_T("eval_tooltip"), false))
        return;

    if (!wxGetKeyState(WXK_CONTROL))  // does not work!!!!!
        return;

But the code does not work.

wxGetKeyState(WXK_CONTROL) this function always get false.

any comments about this?
why I can't query the ctrl key information???

thanks.

Edit:
In this post: one more years ago.
http://forums.codeblocks.org/index.php/topic,10616.msg72724.html

Quote
By the way, I want to use "CTRL" key while mouse hovering some text to get the ValueTooltip shown.

So, I try to add the code:
Code:

+//    if (!wxGetKeyState(WXK_CONTROL))
+//        return;


But it didn't works as I expect. Can you give me some suggestions?

Thanks
« Last Edit: December 17, 2010, 08:02:28 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: show debugger tip under curser when ctrl key is pressed
« Reply #1 on: December 17, 2010, 08:22:19 am »
I've just tested it and it works as expected... (tested on linux).
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #2 on: December 17, 2010, 08:28:44 am »
I've just tested it and it works as expected... (tested on linux).
thanks for the test. but it definitely does not work under windows,  :( can some windows guys test for me. thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: show debugger tip under curser when ctrl key is pressed
« Reply #3 on: December 17, 2010, 09:58:49 am »
Hi,

I think I tried it once (to show debugger event only when CTRL is down) however, the problem was that under Windows I did not receive the 'dwell' events from scintilla if CONTROL is down - so I dropped it.

Do you get the dwell event when control key is down? (Windows)

Eran

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #4 on: December 17, 2010, 10:05:18 am »
Hi,

I think I tried it once (to show debugger event only when CTRL is down) however, the problem was that under Windows I did not receive the 'dwell' events from scintilla if CONTROL is down - so I dropped it.

Do you get the dwell event when control key is down? (Windows)

Eran
You are right, I just find this.


from the file: F:\cb\codeblocks_trunk\src\sdk\wxscintilla\src\wxscintilla.cpp
I think it is the point where this message sent.
Code
    case SCN_DWELLSTART:
        evt.SetEventType (wxEVT_SCI_DWELLSTART);
        evt.SetX(scn.x);
        evt.SetY(scn.y);
        break;

    case SCN_DWELLEND:
        evt.SetEventType (wxEVT_SCI_DWELLEND);
        evt.SetX(scn.x);
        evt.SetY(scn.y);
        break;

but not sure the key value is already saved here:
Code
void wxScintilla::NotifyParent (SCNotification* _scn)
{
    SCNotification& scn = *_scn;
    wxScintillaEvent evt (0, GetId());

    evt.SetEventObject(this);
    evt.SetPosition(scn.position);
    evt.SetKey(scn.ch);
    evt.SetModifiers(scn.modifiers);

    switch (scn.nmhdr.code) {

Can we use the evt.GetKey???
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: show debugger tip under curser when ctrl key is pressed
« Reply #5 on: December 17, 2010, 10:44:06 am »
Quote from: ollydbg
Can we use the evt.GetKey???
I think you misunderstood me...

What I meant is:
When the CONTROL key is DOWN you will not receive the wxEVT_SCI_DWELLSTART event. (this is on Windows 7 with the latest wxScintilla)

If you *do* receive the event, then I suggest that you try:

Code
if(wxGetMouseState().ControlDown())

Eran

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #6 on: December 18, 2010, 03:17:04 am »
Quote from: ollydbg
Can we use the evt.GetKey???
I think you misunderstood me...

What I meant is:
When the CONTROL key is DOWN you will not receive the wxEVT_SCI_DWELLSTART event. (this is on Windows 7 with the latest wxScintilla)

thanks, I understand now.

If you *do* receive the event, then I suggest that you try:

Code
if(wxGetMouseState().ControlDown())

Eran
In fact, I never get such event when I press the control key.  :D ,may be, we can hack the scintilla code.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #7 on: December 20, 2010, 03:36:17 am »
@eranif and other devs
from the scintilla maillist, I get the answers, see below:
https://groups.google.com/forum/?fromgroups#!forum/scintilla-interest
Quote
AsmWarrior:

> I would like to receive the dwell( call tip ) event when I hold on the ctrl
> key. currently, In Windows OS, when I hold the ctrl key, the dwel event will
> never sent. but it seems under linux, it works.

   On Windows, keeping the Ctrl key pressed causes multiple key press
events to occur just like holding down an arrow key causes multiple
movements. Each time a key press event occurs, Scintilla resets the
dwell timer as normal key presses are interpreted as the user doing
something and not just hovering the mouse.

   You could try to filter out these key press events, possibly on the
basis of which key is being pressed or on whether its an auto-repeat.

   Neil

So, I will try to find the code snippet where the "multiply key" event occurs, and filter out such key.

BTW: can someone familiar with scintilla core base can give me a point? thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #8 on: December 20, 2010, 05:26:50 am »
Code
Index: plugins/debuggergdb/debuggergdb.cpp
===================================================================
--- plugins/debuggergdb/debuggergdb.cpp (revision 6903)
+++ plugins/debuggergdb/debuggergdb.cpp (working copy)
@@ -2648,6 +2648,11 @@
     if (!Manager::Get()->GetConfigManager(_T("debugger"))->ReadBool(_T("eval_tooltip"), false))
         return;
 
+    if (!::wxGetKeyState(WXK_CONTROL))  // does not work!!!!!
+        return;
+    //if(! (::GetAsyncKeyState(VK_CONTROL)&0x80))
+    //    return;
+
     EditorBase* base = event.GetEditor();
     cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
     if (!ed)
Index: sdk/wxscintilla/src/scintilla/src/Editor.cxx
===================================================================
--- sdk/wxscintilla/src/scintilla/src/Editor.cxx (revision 6903)
+++ sdk/wxscintilla/src/scintilla/src/Editor.cxx (working copy)
@@ -5379,7 +5379,10 @@
 }
 
 int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
- DwellEnd(false);
+
+ if (!ctrl)
+     DwellEnd(false);
+
  int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
          (alt ? SCI_ALT : 0);
  int msg = kmap.Find(key, modifiers);


This patch try to solve the problem, but it failed. when holding the ctrl, the tip show about 0.1 second and disappeared quickly.

any one can help me? thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: show debugger tip under curser when ctrl key is pressed
« Reply #9 on: December 20, 2010, 10:16:03 am »
Works here on windows7.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #10 on: December 20, 2010, 10:56:21 am »
Works here on windows7.
thanks.
can someone tested on win xp???
thanks.
« Last Edit: December 20, 2010, 12:05:19 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9693
Re: show debugger tip under curser when ctrl key is pressed
« Reply #11 on: December 20, 2010, 12:58:54 pm »
can someone tested on win xp???
Works here.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #12 on: December 20, 2010, 01:01:59 pm »
can someone tested on win xp???
Works here.
which wx version did you use?
I use 2.8.11.

did you directly apply my patch? (with out other patch)
I have tested in two PCs, but both the tooltip will disappear quickly. :( :(

what's wrong with my PC???? :(
« Last Edit: December 20, 2010, 01:03:33 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #13 on: December 21, 2010, 06:36:42 am »
@Jens and Morten

I have solved the problem, see the patch:
Code
Index: plugins/debuggergdb/debuggergdb.cpp
===================================================================
--- plugins/debuggergdb/debuggergdb.cpp (revision 6903)
+++ plugins/debuggergdb/debuggergdb.cpp (working copy)
@@ -2648,6 +2648,9 @@
     if (!Manager::Get()->GetConfigManager(_T("debugger"))->ReadBool(_T("eval_tooltip"), false))
         return;
 
+    if (!::wxGetKeyState(WXK_CONTROL))  // does not work!!!!!
+        return;
+
     EditorBase* base = event.GetEditor();
     cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
     if (!ed)
Index: plugins/debuggergdb/gdb_tipwindow.cpp
===================================================================
--- plugins/debuggergdb/gdb_tipwindow.cpp (revision 6903)
+++ plugins/debuggergdb/gdb_tipwindow.cpp (working copy)
@@ -222,9 +222,10 @@
     Close();
 }
 
-void GDBTipWindow::OnKey(wxKeyEvent& /*event*/)
+void GDBTipWindow::OnKey(wxKeyEvent& event)
 {
-    Close();
+    if(!event.ControlDown())
+       Close();
 
     // not using event.Skip() here to save us from a bad crash...
 }
Index: sdk/wxscintilla/src/scintilla/src/Editor.cxx
===================================================================
--- sdk/wxscintilla/src/scintilla/src/Editor.cxx (revision 6903)
+++ sdk/wxscintilla/src/scintilla/src/Editor.cxx (working copy)
@@ -5379,7 +5379,10 @@
 }
 
 int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
- DwellEnd(false);
+
+ if (!ctrl)
+     DwellEnd(false);
+
  int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
          (alt ? SCI_ALT : 0);
  int msg = kmap.Find(key, modifiers);



I need the filter out the control key event on the GDB tip window. I'm really strange why both of your system works correctly with my last patch?? any ideas??

BTW:
From the codelite's change log, eranif has use this feature for debugger:
Quote
rev 4672 of Codelite trunk

- New: debugger tooltip is now enabled only if CTRL key is down (configurable via the debugger settings page)
- Updated various scripts to set the new codelite version to 2.9.0


-------------------------------
M : /trunk/InnoSetup/make_packages.bat 
M : /trunk/Interfaces/debugger.h 
M : /trunk/LiteEditor/app.cpp 
M : /trunk/LiteEditor/cl_editor.cpp 
M : /trunk/LiteEditor/context_cpp.cpp 
M : /trunk/LiteEditor/debuggersettingsbasedlg.cpp 
M : /trunk/LiteEditor/debuggersettingsbasedlg.h 
M : /trunk/LiteEditor/debuggersettingsdlg.cpp 
M : /trunk/LiteEditor/frame.cpp 
M : /trunk/LiteEditor/manager.cpp 
M : /trunk/Runtime/config/debuggers.xml.default 
M : /trunk/Runtime/config/debuggers.xml.gtk 
M : /trunk/formbuilder/DebuggerSettings.fbp 
M : /trunk/make_deb.sh 
M : /trunk/make_src_targz.sh 
M : /trunk/sdk/wxscintilla/src/scintilla/src/Editor.cxx 

Do we need to implement this feature???
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: show debugger tip under curser when ctrl key is pressed
« Reply #14 on: December 22, 2010, 04:24:47 am »
for those want to show the debug information correctly. see like below:


You need to delete(comment out) the code snippet in gdb_types.script (because python pretty printer works better than the old implementation and has more wx and c++ container type support)
more reference can be found in this post:
http://forums.codeblocks.org/index.php/topic,12747.0.html
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.