[Mono-dev] Soft Debugger issues (can't suspend threads in wait_for_suspend)

2011-01-25 Thread Virgile Bello
I am having trouble with mono soft debugger.
- I embed Mono runtime in my program, and I got MonoDevelop to act as
SoftDebugger client
- Mono soft debugger is loading properly (first breakpoint usually works --
if already set beforehand -- I can see callstacks, etc...)
- As soon as I press F5 -- to execute until this breakpoint is reached again
next iteration -- or if I disable/reenable this breakpoint, program hang
(see log)
- Main loop is in C and Mono functions are called regularly.

I traced down the problem to thread(s) not suspending (cf log).
Usually, it seems it is the Finalizer thread (in this case 2054) that
doesn't get suspended.

In mono sources, I tried to call mono_gc_collect/mono_gc_invoke_finalizers
in the suspend_thread loop. In that case, I can manage to have F5 working
(breakpoint trigger every step inside the loop).
However it doesn't work as soon as I do anything else (such as removing 
adding again the breakpoint).

I remember seeing this problem on more than 1 thread when I had other
threads active (i.e. Waiting for 3(4) threads to suspend...)

Does anyone have an idea? Maybe there is something special to do if Mono
doesn't keep hand (often back to full unmanaged world since main loop is in
C)

Debugger log:
[0410] Thread started, obj=04702F20, tls=004CDA60.
[0410] Suspended.
[0410] Resumed.
[0410] Suspending vm...
[0410] Sent event VM_START, suspend=2.
[0410] Suspended.
[dbg] Agent thread started, pid=1260
[2054] Thread started, obj=04702E70, tls=004EC1D8.  Finalizer thread
[2054] Suspended.
[dbg] Received command VM(VERSION), id=1.
[dbg] Received command VM(SET_PROTOCOL_VERSION), id=2.
[dbg] Protocol version 2.2, client protocol version 2.2.
[dbg] Received command APPDOMAIN(1), id=3.
...
[0410] Suspended.
[dbg] Received command TYPE(1), id=1785.
[dbg] Received command TYPE(6), id=1786.
[2054] Received single step event for suspending.
[2054] Suspended.
[dbg] Received command VM(RESUME), id=1787.
[1260] Resuming vm...
[2054] Resumed.
[0410] Resumed.
[0410] Suspending vm...
[0410] Interrupting 2054...
[0410] Sent event TYPE_LOAD, suspend=2.
[0410] Suspended.
[dbg] Received command TYPE(1), id=1788.
[dbg] Received command TYPE(6), id=1789.
[2054] Received single step event for suspending.
[2054] Suspended.
[dbg] Received command VM(RESUME), id=1790.
[1260] Resuming vm...
[2054] Resumed.
[0410] Resumed.
[0410] Suspending vm...
[0410] Interrupting 2054...
[0410] Sent event TYPE_LOAD, suspend=2.
[0410] Suspended.
[dbg] Received command TYPE(1), id=1791.
[dbg] Received command TYPE(6), id=1792.
[dbg] Received command VM(RESUME), id=1793.
[2054] Received single step event for suspending.
[2054] Suspended.
[1260] Resuming vm...
[0410] Resumed.
[2054] Resumed.
[0410] Suspending vm...
[0410] Interrupting 2054...
[0410] Sent event TYPE_LOAD, suspend=2.
[0410] Suspended.
[dbg] Received command TYPE(1), id=1794.
[dbg] Received command TYPE(6), id=1795.
[dbg] Received command VM(RESUME), id=1796.
[1260] Resuming vm...
[0410] Resumed.
[0410] Breakpoint hit, method=Step, offset=0x1e.
[0410] Suspending vm...
[0410] Interrupting 2054...
[0410] Sent event BREAKPOINT, suspend=2.
[0410] Suspended.
[dbg] Received command VM(ALL_THREADS), id=1797.
[dbg] Received command THREAD(1), id=1798.
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
Waiting for 1(2) threads to suspend...
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Soft Debugger issues (can't suspend threads in wait_for_suspend)

2011-01-25 Thread Virgile Bello
Just as a small addition, to confirm what I said earlier concerning
situation with additional threads.

After adding 2 threads that don't actually call mono (simply register them
with mono_thread_attach(mono_get_root_domain())), I end up having:
Waiting for 2(4) threads to suspend... which mean 1 of the fully native
threads is also blocking it.

Maybe it can't detect well when threads are running in native mode?
I will continue to investigate as well.

On Wed, Jan 26, 2011 at 12:58 AM, Virgile Bello virgile.be...@gmail.comwrote:

 I am having trouble with mono soft debugger.
 - I embed Mono runtime in my program, and I got MonoDevelop to act as
 SoftDebugger client
 - Mono soft debugger is loading properly (first breakpoint usually works --
 if already set beforehand -- I can see callstacks, etc...)
 - As soon as I press F5 -- to execute until this breakpoint is reached
 again next iteration -- or if I disable/reenable this breakpoint, program
 hang (see log)
 - Main loop is in C and Mono functions are called regularly.

 I traced down the problem to thread(s) not suspending (cf log).
 Usually, it seems it is the Finalizer thread (in this case 2054) that
 doesn't get suspended.

 In mono sources, I tried to call mono_gc_collect/mono_gc_invoke_finalizers
 in the suspend_thread loop. In that case, I can manage to have F5 working
 (breakpoint trigger every step inside the loop).
 However it doesn't work as soon as I do anything else (such as removing 
 adding again the breakpoint).

 I remember seeing this problem on more than 1 thread when I had other
 threads active (i.e. Waiting for 3(4) threads to suspend...)

 Does anyone have an idea? Maybe there is something special to do if Mono
 doesn't keep hand (often back to full unmanaged world since main loop is in
 C)

 Debugger log:
  [0410] Thread started, obj=04702F20, tls=004CDA60.
 [0410] Suspended.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Sent event VM_START, suspend=2.
 [0410] Suspended.
 [dbg] Agent thread started, pid=1260
 [2054] Thread started, obj=04702E70, tls=004EC1D8.  Finalizer thread
 [2054] Suspended.
 [dbg] Received command VM(VERSION), id=1.
 [dbg] Received command VM(SET_PROTOCOL_VERSION), id=2.
 [dbg] Protocol version 2.2, client protocol version 2.2.
 [dbg] Received command APPDOMAIN(1), id=3.
 ...
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1785.
 [dbg] Received command TYPE(6), id=1786.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1787.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1788.
 [dbg] Received command TYPE(6), id=1789.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1790.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
  [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1791.
 [dbg] Received command TYPE(6), id=1792.
 [dbg] Received command VM(RESUME), id=1793.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [1260] Resuming vm...
 [0410] Resumed.
 [2054] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1794.
 [dbg] Received command TYPE(6), id=1795.
 [dbg] Received command VM(RESUME), id=1796.
 [1260] Resuming vm...
 [0410] Resumed.
 [0410] Breakpoint hit, method=Step, offset=0x1e.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event BREAKPOINT, suspend=2.
 [0410] Suspended.
 [dbg] Received command VM(ALL_THREADS), id=1797.
 [dbg] Received command THREAD(1), id=1798.
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...



___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Soft Debugger issues (can't suspend threads in wait_for_suspend)

2011-01-25 Thread Virgile Bello
Sorry, last small update, if I simply disable the waiting loop
in wait_for_suspend() and make is_suspended() always return TRUE,
breakpoints/tracing work as expected (except maybe playing with other
threads of course).
This seems to confirm there might be some false positive when trying to
detect threads that run in native mode (mono think they are managed).

On Wed, Jan 26, 2011 at 1:06 AM, Virgile Bello virgile.be...@gmail.comwrote:

 Just as a small addition, to confirm what I said earlier concerning
 situation with additional threads.

 After adding 2 threads that don't actually call mono (simply register them
 with mono_thread_attach(mono_get_root_domain())), I end up having:
 Waiting for 2(4) threads to suspend... which mean 1 of the fully native
 threads is also blocking it.

 Maybe it can't detect well when threads are running in native mode?
  I will continue to investigate as well.

 On Wed, Jan 26, 2011 at 12:58 AM, Virgile Bello 
 virgile.be...@gmail.comwrote:

 I am having trouble with mono soft debugger.
 - I embed Mono runtime in my program, and I got MonoDevelop to act as
 SoftDebugger client
 - Mono soft debugger is loading properly (first breakpoint usually works
 -- if already set beforehand -- I can see callstacks, etc...)
 - As soon as I press F5 -- to execute until this breakpoint is reached
 again next iteration -- or if I disable/reenable this breakpoint, program
 hang (see log)
 - Main loop is in C and Mono functions are called regularly.

 I traced down the problem to thread(s) not suspending (cf log).
 Usually, it seems it is the Finalizer thread (in this case 2054) that
 doesn't get suspended.

 In mono sources, I tried to call mono_gc_collect/mono_gc_invoke_finalizers
 in the suspend_thread loop. In that case, I can manage to have F5 working
 (breakpoint trigger every step inside the loop).
 However it doesn't work as soon as I do anything else (such as removing 
 adding again the breakpoint).

 I remember seeing this problem on more than 1 thread when I had other
 threads active (i.e. Waiting for 3(4) threads to suspend...)

 Does anyone have an idea? Maybe there is something special to do if Mono
 doesn't keep hand (often back to full unmanaged world since main loop is in
 C)

 Debugger log:
  [0410] Thread started, obj=04702F20, tls=004CDA60.
 [0410] Suspended.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Sent event VM_START, suspend=2.
 [0410] Suspended.
 [dbg] Agent thread started, pid=1260
 [2054] Thread started, obj=04702E70, tls=004EC1D8.  Finalizer thread
 [2054] Suspended.
 [dbg] Received command VM(VERSION), id=1.
 [dbg] Received command VM(SET_PROTOCOL_VERSION), id=2.
 [dbg] Protocol version 2.2, client protocol version 2.2.
 [dbg] Received command APPDOMAIN(1), id=3.
 ...
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1785.
 [dbg] Received command TYPE(6), id=1786.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1787.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1788.
 [dbg] Received command TYPE(6), id=1789.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1790.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
  [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1791.
 [dbg] Received command TYPE(6), id=1792.
 [dbg] Received command VM(RESUME), id=1793.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [1260] Resuming vm...
 [0410] Resumed.
 [2054] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1794.
 [dbg] Received command TYPE(6), id=1795.
 [dbg] Received command VM(RESUME), id=1796.
 [1260] Resuming vm...
 [0410] Resumed.
 [0410] Breakpoint hit, method=Step, offset=0x1e.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event BREAKPOINT, suspend=2.
 [0410] Suspended.
 [dbg] Received command VM(ALL_THREADS), id=1797.
 [dbg] Received command THREAD(1), id=1798.
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...
 Waiting for 1(2) threads to suspend...




___

Re: [Mono-dev] Soft Debugger issues (can't suspend threads in wait_for_suspend)

2011-01-25 Thread Virgile Bello
Turns out it might be due to Win32 limitations (QueueUserAPC works only if
SleepEx/WaitForMultipleObjectsEx etc... are used), as notify_thread_apc is
never called back.
I can fix that on my own threads. However, finalizer thread should use such
functions as well otherwise it will always hang internally.
Sorry for the trouble.

On Wed, Jan 26, 2011 at 1:26 AM, Virgile Bello virgile.be...@gmail.comwrote:

 Sorry, last small update, if I simply disable the waiting loop
 in wait_for_suspend() and make is_suspended() always return TRUE,
 breakpoints/tracing work as expected (except maybe playing with other
 threads of course).
 This seems to confirm there might be some false positive when trying to
 detect threads that run in native mode (mono think they are managed).

 On Wed, Jan 26, 2011 at 1:06 AM, Virgile Bello virgile.be...@gmail.comwrote:

 Just as a small addition, to confirm what I said earlier concerning
 situation with additional threads.

 After adding 2 threads that don't actually call mono (simply register them
 with mono_thread_attach(mono_get_root_domain())), I end up having:
 Waiting for 2(4) threads to suspend... which mean 1 of the fully native
 threads is also blocking it.

 Maybe it can't detect well when threads are running in native mode?
  I will continue to investigate as well.

 On Wed, Jan 26, 2011 at 12:58 AM, Virgile Bello 
 virgile.be...@gmail.comwrote:

 I am having trouble with mono soft debugger.
 - I embed Mono runtime in my program, and I got MonoDevelop to act as
 SoftDebugger client
 - Mono soft debugger is loading properly (first breakpoint usually works
 -- if already set beforehand -- I can see callstacks, etc...)
 - As soon as I press F5 -- to execute until this breakpoint is reached
 again next iteration -- or if I disable/reenable this breakpoint, program
 hang (see log)
 - Main loop is in C and Mono functions are called regularly.

 I traced down the problem to thread(s) not suspending (cf log).
 Usually, it seems it is the Finalizer thread (in this case 2054) that
 doesn't get suspended.

 In mono sources, I tried to call
 mono_gc_collect/mono_gc_invoke_finalizers in the suspend_thread loop. In
 that case, I can manage to have F5 working (breakpoint trigger every step
 inside the loop).
 However it doesn't work as soon as I do anything else (such as removing 
 adding again the breakpoint).

 I remember seeing this problem on more than 1 thread when I had other
 threads active (i.e. Waiting for 3(4) threads to suspend...)

 Does anyone have an idea? Maybe there is something special to do if Mono
 doesn't keep hand (often back to full unmanaged world since main loop is in
 C)

 Debugger log:
  [0410] Thread started, obj=04702F20, tls=004CDA60.
 [0410] Suspended.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Sent event VM_START, suspend=2.
 [0410] Suspended.
 [dbg] Agent thread started, pid=1260
 [2054] Thread started, obj=04702E70, tls=004EC1D8.  Finalizer thread
 [2054] Suspended.
 [dbg] Received command VM(VERSION), id=1.
 [dbg] Received command VM(SET_PROTOCOL_VERSION), id=2.
 [dbg] Protocol version 2.2, client protocol version 2.2.
 [dbg] Received command APPDOMAIN(1), id=3.
 ...
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1785.
 [dbg] Received command TYPE(6), id=1786.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1787.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1788.
 [dbg] Received command TYPE(6), id=1789.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [dbg] Received command VM(RESUME), id=1790.
 [1260] Resuming vm...
 [2054] Resumed.
 [0410] Resumed.
 [0410] Suspending vm...
  [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1791.
 [dbg] Received command TYPE(6), id=1792.
 [dbg] Received command VM(RESUME), id=1793.
 [2054] Received single step event for suspending.
 [2054] Suspended.
 [1260] Resuming vm...
 [0410] Resumed.
 [2054] Resumed.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event TYPE_LOAD, suspend=2.
 [0410] Suspended.
 [dbg] Received command TYPE(1), id=1794.
 [dbg] Received command TYPE(6), id=1795.
 [dbg] Received command VM(RESUME), id=1796.
 [1260] Resuming vm...
 [0410] Resumed.
 [0410] Breakpoint hit, method=Step, offset=0x1e.
 [0410] Suspending vm...
 [0410] Interrupting 2054...
 [0410] Sent event BREAKPOINT, suspend=2.
 [0410] Suspended.
 [dbg] Received command VM(ALL_THREADS), id=1797.
 [dbg] Received command THREAD(1), id=1798.
 Waiting for 1(2) threads to suspend...
 Waiting 

[Mono-dev] AOT + the osx installer.

2011-01-25 Thread Brian Luczkiewicz
When I build mono from source and install on linux, I've noticed that I end
up with .so's next to some of the installed dll's and exe's. This provides a
nice speedup when running compilers/tools from the mono distribution. Now
that we have AOT working on osx, the same optimization makes sense there,
too.

I decided to try this out with mono 2.8.2 on an intel mac. I manually AOT'd:

/Library/Frameworks/Mono.Framework/Versions/Current/lib/mono/*/*.exe
/Library/Frameworks/Mono.Framework/Versions/Current/lib/mono/gac/*/*/*.dll

I have a project that is about 500kloc of C# and builds with gmcs. AOT'ing
the mono distribution as I've described dropped the build time for this
project from 84s to 46s on my c2d macbook pro. This is a 44% speedup!

I'm unsure who owns the OSX build/packaging, but it seems like this should
be a simple change to make since we already do it on linux, and it would be
great to get this kind of performance out of the box.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT + the osx installer.

2011-01-25 Thread Miguel de Icaza
Hello,

 I'm unsure who owns the OSX build/packaging, but it seems like this should
 be a simple change to make since we already do it on linux, and it would be
 great to get this kind of performance out of the box.

It would consume more disk space.

Perhaps we could provide the option for the user to toggle those on
and off at install time.

Miguel
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT + the osx installer.

2011-01-25 Thread Geoff Norton
Hello,


On 2011-01-25, at 4:39 PM, Brian Luczkiewicz wrote:

 When I build mono from source and install on linux, I've noticed that I end 
 up with .so's next to some of the installed dll's and exe's. This provides a 
 nice speedup when running compilers/tools from the mono distribution. Now 
 that we have AOT working on osx, the same optimization makes sense there, too.
 
 I decided to try this out with mono 2.8.2 on an intel mac. I manually AOT'd:
 
 /Library/Frameworks/Mono.Framework/Versions/Current/lib/mono/*/*.exe
 /Library/Frameworks/Mono.Framework/Versions/Current/lib/mono/gac/*/*/*.dll
 
 I have a project that is about 500kloc of C# and builds with gmcs. AOT'ing 
 the mono distribution as I've described dropped the build time for this 
 project from 84s to 46s on my c2d macbook pro. This is a 44% speedup!
 
  This is great news, as we just recently enabled this.

Was this with LLVM or with the regular AOT?

-g


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] C++ Interop

2011-01-25 Thread Sebastian Good
It was with great interest I read about the upcoming FOSDEM presentation on 
Mono C++ Interop. I was unaware such an project had been started. I looked at 
http://www.mono-project.com/Interop_with_Native_Libraries and 
http://www.mono-project.com/CPlusPlus and didn't see any mention of it. Is the 
result of the summer-of-code project documented somewhere?

Many thanks,

Sebastian

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] C++ Interop

2011-01-25 Thread Alex Corrado
On Tue, Jan 25, 2011 at 5:54 PM, Sebastian Good 
sebast...@palladiumconsulting.com wrote:

 It was with great interest I read about the upcoming FOSDEM presentation on
 Mono C++ Interop. I was unaware such an project had been started. I looked
 at http://www.mono-project.com/Interop_with_Native_Libraries and
 http://www.mono-project.com/CPlusPlus and didn't see any mention of it. Is
 the result of the summer-of-code project documented somewhere?


I am also excited to hear about this talk. There isn't much written
documentation on the project yet, though perhaps the pages you mention
should be updated to mention it. For now, there's the code at
https://github.com/nirvanai/cppinterop, which holds the work I've done over
the summer and since. I'd also be happy to answer any questions about it.

Best,

Alex Corrado
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list