6.0b2 strange debug behavior

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

6.0b2 strange debug behavior

WingIDE - User mailing list
Hi folks,

Short version:  
---------------
When stopped at a breakpoint, floating the mouse over a variable in the code invokes a tooltip showing the value of the variable. Does that IDE tooltip function by any chance run code in the python process of the paused program? Specifically the regular expression library re?

Longer version
--------------
Trying to debug why it takes tens of seconds for Django 1.8.14 to get to its first prompt, when running in the WingIDE debugger. Now using WingIDE 6.0 beta2, where debugging works much better than beta1.

I have narrowed the issue down to django module validators.py, specifically the initialization of class member URLValidator.regex = re.compile([very complicated regex for URLs]) during the initial cascade of module imports/loads.

In an effort to explore *why* that function is so slow, I quick-and-dirty added some diagnostic print statements to various functions in standard modules re and sre_compile, for example this revision of re.py compile() to add a call counter and print statements:

----------------------
compi = 0
def compile(pattern, flags=0):
    "Compile a regular expression pattern, returning a pattern object."
    global compi
    mycompi = compi
    compi   += 1

    print(str(mycompi) + ' re.compile: ' + str(pattern), flush=True)
    result = _compile(pattern, flags)
    print(str(mycompi) + ' re.compile end: ', flush=True)
    return result
----------------------

Such print statements are very informative, except that they're also subject to weird behavior in the debugger, which turns out to be unrelated to django per se.  

The behavior appears just running any trivial python code module up to a breakpoint, then use the mouseover function on a variable, and the Debug I/O window shows printouts from the "instrumented" compile() function. That is, somehow code gets run despite the debugger being in pause mode at a breakpoint.

Bottom line: I would like some confirmation that this is intended IDE debugger behavior.

Thanks

Reference
===========

FWIW, those "extraneous" regex compile()s are for pattern:

\f\t]*((\\\r?\n|\Z|#[^\r\n]*|((?:[bB][rR]?|[rR][bB]?|[uU])?'''|(?:[bB][rR]?|[rR][bB]?|[uU])?"""))|(([0-9]+[jJ]|(([0-9]+\.[0-9]*|\.[0-9]+)([eE][-+]?[0-9]+)?|[0-9]+[eE][-+]?[0-9]+)[jJ])|(([0-9]+\.[0-9]*|\.[0-9]+)([eE][-+]?[0-9]+)?|[0-9]+[eE][-+]?[0-9]+)|(0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:0+|[1-9][0-9]*)))|((\*\*=?|>>=?|<<=?|!=|//=?|->|[+\-*/%&@|^=<>]=?|~)|[][(){}]|(\r?\n|\.\.\.|[:;.,@]))|((?:[bB][rR]?|[rR][bB]?|[uU])?'[^\n'\\]*(?:\\.[^\n'\\]*)*('|\\\r?\n)|(?:[bB][rR]?|[rR][bB]?|[uU])?"[^\n"\\]*(?:\\.[^\n"\\]*)*("|\\\r?\n))|\w+)








_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: 6.0b2 strange debug behavior

WingIDE - User mailing list
On 9/27/16 4:18 AM, Graham Wideman via wingide-users wrote:
> When stopped at a breakpoint, floating the mouse over a variable in the code invokes a tooltip showing the value of the variable. Does that IDE tooltip function by any chance run code in the python process of the paused program? Specifically the regular expression library re?

Hi,

Do you have Hover Over Selection in the Debugger preferences set to All?
  This defaults to Symbols so that code is not run just by selecting it
and hovering over it.

If this isn't the problem, could you send us a test case?

Thanks,

John

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: 6.0b2 strange debug behavior

WingIDE - User mailing list
Hi John,

I'm not entirely sure from your response which settings you think should or should not execute statements in the stopped process. However, here's a test:

1. Modify re.compile to add a print statement. Mine looks like this so I can distinguish one call from the previous:

--------------------
re.py
--------------------
compi = 0
def compile(pattern, flags=0):
    "Compile a regular expression pattern, returning a pattern object."

    # Original:
##    return _compile(pattern, flags)

    # Debugging:
    global compi
    mycompi = compi
    compi += 1
    print(str(mycompi) + ' re.compile: ' + str(pattern), flush=True)
    result = _compile(pattern, flags)
    print(str(mycompi) + ' re.compile end: ', flush=True)
    return result
--------------------

2. Some trivial code with variables:
--------------------
test.py
--------------------
a = 1
b = a + 1
c = b + 1
print(str(b), str(c))
--------------------

3. Debugger settings:

Hover Over Symbols: Enabled
Hover Over Selection: Symbols Only

 From you comments (John) I think this is a case that should not execute code on hover.

4. Test:

Set breakpoint on line 'c = b + 1'

Run to breakpoint

a. In Debug window, some calls to re.compile() will show briefly corresponding to Python startup, then disappear as test.py starts to run, leaving Debug window clear.

b. Now hover cursor over variables a or b.  A call to re.compile() will display in the Debug window, once for each variable. (And no further call for each variable on later hovers.)

Comment:

With Debugger set to "Hover Over Symbols: Disabled", then re.compile does not get called in the test. (But variable values are still available in the Stack Data window).

Hope that helps.

Graham

At 9/27/2016 06:46 AM, Wing IDE Support wrote:

>On 9/27/16 4:18 AM, Graham Wideman via wingide-users wrote:
>>When stopped at a breakpoint, floating the mouse over a variable in the code invokes a tooltip showing the value of the variable. Does that IDE tooltip function by any chance run code in the python process of the paused program? Specifically the regular expression library re?
>
>Hi,
>
>Do you have Hover Over Selection in the Debugger preferences set to All?  This defaults to Symbols so that code is not run just by selecting it and hovering over it.
>
>If this isn't the problem, could you send us a test case?
>
>Thanks,
>
>John

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: 6.0b2 strange debug behavior

WingIDE - User mailing list
The compile calls are being made from internal debugger code, not from
from the code being debugged.  Wing's debugger is written in Python
(with some C as well) so there is Python code run when the program being
debugged.  The scanner objects returned from compile could probably be
cached and we may do so in the future.

Thanks,

John

On 9/27/16 6:10 PM, Graham Wideman via wingide-users wrote:

> Hi John,
>
> I'm not entirely sure from your response which settings you think should or should not execute statements in the stopped process. However, here's a test:
>
> 1. Modify re.compile to add a print statement. Mine looks like this so I can distinguish one call from the previous:
>
> --------------------
> re.py
> --------------------
> compi = 0
> def compile(pattern, flags=0):
>     "Compile a regular expression pattern, returning a pattern object."
>
>     # Original:
> ##    return _compile(pattern, flags)
>
>     # Debugging:
>     global compi
>     mycompi = compi
>     compi += 1
>     print(str(mycompi) + ' re.compile: ' + str(pattern), flush=True)
>     result = _compile(pattern, flags)
>     print(str(mycompi) + ' re.compile end: ', flush=True)
>     return result
> --------------------
>
> 2. Some trivial code with variables:
> --------------------
> test.py
> --------------------
> a = 1
> b = a + 1
> c = b + 1
> print(str(b), str(c))
> --------------------
>
> 3. Debugger settings:
>
> Hover Over Symbols: Enabled
> Hover Over Selection: Symbols Only
>
>  From you comments (John) I think this is a case that should not execute code on hover.
>
> 4. Test:
>
> Set breakpoint on line 'c = b + 1'
>
> Run to breakpoint
>
> a. In Debug window, some calls to re.compile() will show briefly corresponding to Python startup, then disappear as test.py starts to run, leaving Debug window clear.
>
> b. Now hover cursor over variables a or b.  A call to re.compile() will display in the Debug window, once for each variable. (And no further call for each variable on later hovers.)
>
> Comment:
>
> With Debugger set to "Hover Over Symbols: Disabled", then re.compile does not get called in the test. (But variable values are still available in the Stack Data window).
>
> Hope that helps.
>
> Graham
>
> At 9/27/2016 06:46 AM, Wing IDE Support wrote:
>> On 9/27/16 4:18 AM, Graham Wideman via wingide-users wrote:
>>> When stopped at a breakpoint, floating the mouse over a variable in the code invokes a tooltip showing the value of the variable. Does that IDE tooltip function by any chance run code in the python process of the paused program? Specifically the regular expression library re?
>>
>> Hi,
>>
>> Do you have Hover Over Selection in the Debugger preferences set to All?  This defaults to Symbols so that code is not run just by selecting it and hovering over it.
>>
>> If this isn't the problem, could you send us a test case?
>>
>> Thanks,
>>
>> John
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide