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

Virgile Bello virgile.bello at gmail.com
Tue Jan 25 11:51:52 EST 2011


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.bello at gmail.com>wrote:

> 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.bello at gmail.com>wrote:
>
>> 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.bello at gmail.com>wrote:
>>
>>> 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 00002054) 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:
>>>  [00000410] Thread started, obj=04702F20, tls=004CDA60.
>>> [00000410] Suspended.
>>> [00000410] Resumed.
>>> [00000410] Suspending vm...
>>> [00000410] Sent event VM_START, suspend=2.
>>> [00000410] Suspended.
>>> [dbg] Agent thread started, pid=00001260
>>> [00002054] Thread started, obj=04702E70, tls=004EC1D8. < Finalizer thread
>>> [00002054] 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.
>>> ...............
>>> [00000410] Suspended.
>>> [dbg] Received command TYPE(1), id=1785.
>>> [dbg] Received command TYPE(6), id=1786.
>>> [00002054] Received single step event for suspending.
>>> [00002054] Suspended.
>>> [dbg] Received command VM(RESUME), id=1787.
>>> [00001260] Resuming vm...
>>> [00002054] Resumed.
>>> [00000410] Resumed.
>>> [00000410] Suspending vm...
>>> [00000410] Interrupting 00002054...
>>> [00000410] Sent event TYPE_LOAD, suspend=2.
>>> [00000410] Suspended.
>>> [dbg] Received command TYPE(1), id=1788.
>>> [dbg] Received command TYPE(6), id=1789.
>>> [00002054] Received single step event for suspending.
>>> [00002054] Suspended.
>>> [dbg] Received command VM(RESUME), id=1790.
>>> [00001260] Resuming vm...
>>> [00002054] Resumed.
>>> [00000410] Resumed.
>>> [00000410] Suspending vm...
>>>  [00000410] Interrupting 00002054...
>>> [00000410] Sent event TYPE_LOAD, suspend=2.
>>> [00000410] Suspended.
>>> [dbg] Received command TYPE(1), id=1791.
>>> [dbg] Received command TYPE(6), id=1792.
>>> [dbg] Received command VM(RESUME), id=1793.
>>> [00002054] Received single step event for suspending.
>>> [00002054] Suspended.
>>> [00001260] Resuming vm...
>>> [00000410] Resumed.
>>> [00002054] Resumed.
>>> [00000410] Suspending vm...
>>> [00000410] Interrupting 00002054...
>>> [00000410] Sent event TYPE_LOAD, suspend=2.
>>> [00000410] Suspended.
>>> [dbg] Received command TYPE(1), id=1794.
>>> [dbg] Received command TYPE(6), id=1795.
>>> [dbg] Received command VM(RESUME), id=1796.
>>> [00001260] Resuming vm...
>>> [00000410] Resumed.
>>> [00000410] Breakpoint hit, method=Step, offset=0x1e.
>>> [00000410] Suspending vm...
>>> [00000410] Interrupting 00002054...
>>> [00000410] Sent event BREAKPOINT, suspend=2.
>>> [00000410] 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...
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110126/fa96bf77/attachment-0001.html 


More information about the Mono-devel-list mailing list