Sunday, December 5, 2010

My SharpDevelop blog

Hey,

I have a SharpDevelop blog (http://community.sharpdevelop.net/blogs/marcueusebiu/) where I will post all my work regarding SharpDevelop.
Stay tunned!

Eusebiu

Thursday, November 25, 2010

Parallel stacks and Common Stacks Algorithm

Hey,
For SharpDevelop I have created a version Parallel stacks. In this post I will present a algorithm that creates this Parallel stacks controls using "Common Stacks Algorithm".

Prerequisites: a debugger that gets you for every thread of the application it's call-stack;

SharpDevelop has a debugger that gives you for every thread of the debugged application it's call stack.
The Common Stacks Algorithms is like this:
1. For every thread, get it's call stack in ThreadStacks structure - just a class that contains the actual call-stack - and save them in some kind of list- List.
2. Get & Split common stacks
2.1. For all ThreadStacks, check if they have stack frames. If not, remove them from the list.
2.2 Get all call-stacks that start with the same stack-frame. This can be a Dictionary>.
2.3. For every group of ThreadStacks, find the place of split.
3. Create the common parent ThreadStack and clear the group of common stack-frames.
4. Link the parent to the children and children to parent.
5. Update the collection of ThreadStacks
6. Repeat from 1, until no split is possible - all are parents or simple leaves = the list of common stacks contains only 1 ThreadStack.

What do you think? Pretty nice!

For an implementation, see my Parallel branch in my github.

Happy coding!

Tuesday, November 23, 2010

CallStack dump in WinDbg debugger

C#
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");

// TODO: Implement Functionality Here
Thread t = new Thread(new ThreadStart(MyMethod));
Thread t1 = new Thread(new ThreadStart(MyMethod1));
t.Start();
t1.Start();
t1.Join();
t.Join();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}

public static void MyMethod()
{
Console.WriteLine("enter");
Console.ReadLine();
Console.WriteLine("exit");
}


public static void MyMethod1()
{
Console.WriteLine("enter1");
Console.ReadLine();
Console.WriteLine("exit1");
}

Parent thread:

0:000> !dumpstack
OS Thread Id: 0x1220 (0)
Current frame: ntdll!KiFastSystemCallRet
ChildEBP RetAddr Caller, Callee
0012f060 7c90df4a ntdll!ZwWaitForMultipleObjects+0xc
0012f064 7c809590 KERNEL32!WaitForMultipleObjectsEx+0x12c, calling ntdll!NtWaitForMultipleObjects
0012f08c 7c910323 ntdll!RtlpImageNtHeader+0x56, calling ntdll!_SEH_epilog
0012f0bc 7c812cfb KERNEL32!GetProcessVersion+0xfa, calling ntdll!RtlImageNtHeader
0012f0c0 7c812d27 KERNEL32!GetProcessVersion+0x12c, calling KERNEL32!_SEH_epilog
0012f100 791f516a clr!WaitForMultipleObjectsEx_SO_TOLERANT+0x56, calling KERNEL32!WaitForMultipleObjectsEx
0012f164 791f4f98 clr!Thread::DoAppropriateAptStateWait+0x4d, calling clr!WaitForMultipleObjectsEx_SO_TOLERANT
0012f184 791f4dd8 clr!Thread::DoAppropriateWaitWorker+0x17d, calling clr!Thread::DoAppropriateAptStateWait
0012f1ac 7c8106f5 KERNEL32!CreateThread+0x1e, calling KERNEL32!CreateRemoteThread
0012f218 791f4e99 clr!Thread::DoAppropriateWait+0x60, calling clr!Thread::DoAppropriateWaitWorker
0012f264 79150d3b clr!LoaderHeap::RealAllocMemUnsafe+0x57, calling clr!ClrLeaveCriticalSection
0012f284 792dcfed clr!Thread::JoinEx+0xd5, calling clr!Thread::DoAppropriateWait
0012f2d4 792dd0db clr!ThreadNative::DoJoin+0xaf, calling clr!Thread::JoinEx
0012f33c 792dd1db clr!ThreadNative::Join+0xf2, calling clr!ThreadNative::DoJoin
0012f388 792dd157 clr!ThreadNative::Join+0x3e, calling clr!LazyMachStateCaptureState
0012f3a4 79161f8e clr!PreStubWorker+0x165, calling clr!_EH_epilog3
0012f3e0 7a053eb5 (MethodDesc 79885160 +0x5 System.Threading.Thread.Join()), calling clr!ThreadNative::Join
0012f3e4 0303013e (MethodDesc 009c37f0 +0xce testc.Program.Main(System.String[])), calling (MethodDesc 79885160 +0 System.Threading.Thread.Join())
0012f414 791421db clr!CallDescrWorker+0x33
0012f418 7914e021 clr!SigParser::GetElemType+0x28, calling clr!SigParser::SkipCustomModifiers
0012f424 79164a2a clr!CallDescrWorkerWithHandler+0x8e, calling clr!CallDescrWorker
0012f478 7915c58d clr!ArgIterator::Init+0x6b, calling clr!MetaSig::HasRetBuffArg
0012f4a0 79164bcc clr!MethodDesc::CallDescr+0x194, calling clr!CallDescrWorkerWithHandler
0012f4cc 791628bb clr!MetaSig::MetaSig+0x3c, calling MSVCR100_CLR0400!memcpy
0012f4dc 79164b0a clr!MethodDesc::CallDescr+0xa8, calling clr!ClrSafeInt::addition
0012f4e8 79164b1a clr!MethodDesc::CallDescr+0xb4, calling clr!_alloca_probe_16
0012f558 7914e30a clr!MethodDesc::GetSigFromMetadata+0x21
0012f59c 79164aa5 clr!MethodDesc::CallDescr+0x21, calling clr!_alloca_probe_16
0012f5e0 79164c01 clr!MethodDesc::CallTargetWorker+0x21, calling clr!MethodDesc::CallDescr
0012f5fc 79164c21 clr!MethodDescCallSite::Call+0x1c, calling clr!MethodDesc::CallTargetWorker
0012f614 7922ce82 clr!ClassLoader::RunMain+0x24c, calling clr!MethodDescCallSite::CallWithValueTypes_RetArgSlot
0012f714 7914e30a clr!MethodDesc::GetSigFromMetadata+0x21
0012f778 7922cf90 clr!Assembly::ExecuteMainMethod+0xc1, calling clr!ClassLoader::RunMain
0012f7a8 79141ad1 clr!_EH_epilog3_GS+0xa, calling clr!__security_check_cookie
0012f7ac 7919d804 clr!SString::ConvertToUnicode+0x8b, calling clr!_EH_epilog3_GS
0012f7dc 7915cd88 clr!HardCodedMetaSig::GetBinarySig+0x130, calling clr!_EH_epilog3_GS
0012f7f4 7915c927 clr!Binder::CheckInit+0xf, calling clr!MethodTable::IsClassInited
0012f804 7915ce4a clr!Binder::GetMethod+0x79, calling clr!_EH_epilog3
0012f82c 79164aa5 clr!MethodDesc::CallDescr+0x21, calling clr!_alloca_probe_16
0012f834 79141d85 clr!UnsafeEETryEnterCriticalSection+0xf, calling ntdll!RtlTryEnterCriticalSection
0012f838 79141d9e clr!UnsafeEETryEnterCriticalSection+0x28, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012f844 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0012f868 7c927784 ntdll!RtlFreeHeapSlowly+0x5c2, calling ntdll!_SEH_epilog
0012f86c 7c927573 ntdll!RtlFreeHeap+0xf9, calling ntdll!RtlFreeHeapSlowly
0012f878 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0012f888 79141c49 clr!UnsafeEELeaveCriticalSection+0xe, calling ntdll!RtlLeaveCriticalSection
0012f88c 79141c5c clr!UnsafeEELeaveCriticalSection+0x21, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012f894 79141c8f clr!CrstBase::Leave+0x2b, calling clr!UnsafeEELeaveCriticalSection
0012f8a8 791d393d clr!SetObjectReferenceUnchecked+0x4e, calling clr!ErectWriteBarrier
0012f8cc 7c9101db ntdll!RtlAllocateHeap+0xeac, calling ntdll!_SEH_epilog
0012f8d0 7919bf7e clr!EEHeapAlloc+0xcb, calling ntdll!RtlAllocateHeap
0012f8dc 7919bf8f clr!EEHeapAlloc+0xe8, calling clr!_EH_epilog3
0012f8fc 7c80262a KERNEL32!WaitForSingleObjectEx+0xe5, calling ntdll!RtlDeactivateActivationContextUnsafeFast
0012f914 79141b19 clr!_EH_epilog3_catch_GS+0xa, calling clr!__security_check_cookie
0012f938 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0012f93c 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0012f950 7919c09d clr!EEHeapFreeInProcessHeap+0x24, calling clr!EEHeapFree
0012f964 7919c06d clr!operator delete[]+0x30, calling clr!EEHeapFreeInProcessHeap
0012f96c 7919c07e clr!operator delete[]+0x41, calling clr!_EH_epilog3
0012f994 7919c07e clr!operator delete[]+0x41, calling clr!_EH_epilog3
0012f998 7929320a clr!AppDomain::SetFriendlyName+0x16c, calling clr!operator delete[]
0012f99c 79293210 clr!AppDomain::SetFriendlyName+0x172, calling clr!_EH_epilog3
0012f9e0 7922cda4 clr!SystemDomain::ExecuteMainMethod+0x4ec, calling clr!Assembly::ExecuteMainMethod
0012fad8 791f6b82 clr!WKS::gc_heap::allocate_more_space+0x13, calling clr!WKS::gc_heap::try_allocate_more_space
0012fb24 7c927784 ntdll!RtlFreeHeapSlowly+0x5c2, calling ntdll!_SEH_epilog
0012fb28 7c927573 ntdll!RtlFreeHeap+0xf9, calling ntdll!RtlFreeHeapSlowly
0012fb34 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0012fb50 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0012fb54 7c911452 ntdll!RtlpFreeDebugInfo+0x5c, calling ntdll!RtlFreeHeap
0012fb58 7c911483 ntdll!RtlpFreeDebugInfo+0x77, calling ntdll!RtlLeaveCriticalSection
0012fb60 7c911460 ntdll!RtlpFreeDebugInfo+0x6a, calling ntdll!_SEH_epilog
0012fb8c 7c911460 ntdll!RtlpFreeDebugInfo+0x6a, calling ntdll!_SEH_epilog
0012fb90 7c9113e1 ntdll!RtlDeleteCriticalSection+0x72, calling ntdll!RtlpFreeDebugInfo
0012fb94 7c9113f2 ntdll!RtlDeleteCriticalSection+0x83, calling ntdll!_SEH_epilog
0012fba4 79141d85 clr!UnsafeEETryEnterCriticalSection+0xf, calling ntdll!RtlTryEnterCriticalSection
0012fba8 79141d9e clr!UnsafeEETryEnterCriticalSection+0x28, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012fbb4 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0012fbc4 79141c49 clr!UnsafeEELeaveCriticalSection+0xe, calling ntdll!RtlLeaveCriticalSection
0012fbc8 79141c5c clr!UnsafeEELeaveCriticalSection+0x21, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012fbd0 79141c8f clr!CrstBase::Leave+0x2b, calling clr!UnsafeEELeaveCriticalSection
0012fbf0 79141d85 clr!UnsafeEETryEnterCriticalSection+0xf, calling ntdll!RtlTryEnterCriticalSection
0012fbf4 79141d9e clr!UnsafeEETryEnterCriticalSection+0x28, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012fc00 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0012fc1c 79141bf3 clr!GCHolderBase<1,0,0,0>::Pop+0x20, calling clr!Thread::DisablePreemptiveGC
0012fc28 7919c345 clr!CrstBase::AcquirePreempLock+0x33, calling clr!_EH_epilog3
0012fc54 7919c345 clr!CrstBase::AcquirePreempLock+0x33, calling clr!_EH_epilog3
0012fc58 79141ad1 clr!_EH_epilog3_GS+0xa, calling clr!__security_check_cookie
0012fc5c 7915cd88 clr!HardCodedMetaSig::GetBinarySig+0x130, calling clr!_EH_epilog3_GS
0012fc74 79141c49 clr!UnsafeEELeaveCriticalSection+0xe, calling ntdll!RtlLeaveCriticalSection
0012fc78 79141c5c clr!UnsafeEELeaveCriticalSection+0x21, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0012fc80 79141c8f clr!CrstBase::Leave+0x2b, calling clr!UnsafeEELeaveCriticalSection
0012fc8c 791632e6 clr!DomainLocalModule::SetClassFlags+0x81, calling clr!_EH_epilog3
0012fda0 790703e5 MSVCR100_CLR0400!_getptd+0x8, calling MSVCR100_CLR0400!_getptd_noexit
0012fdd8 79073b18 MSVCR100_CLR0400!_towlower_l+0x24, calling MSVCR100_CLR0400!_LocaleUpdate::_LocaleUpdate
0012fe50 7919bf7e clr!EEHeapAlloc+0xcb, calling ntdll!RtlAllocateHeap
0012fe5c 7919bf8f clr!EEHeapAlloc+0xe8, calling clr!_EH_epilog3
0012fe98 792963b9 clr!EEStartupHelper+0x9a3, calling clr!_EH_epilog3_catch_GS
0012fe9c 7922c496 clr!EEStartup+0x52, calling clr!EEStartupHelper
0012fec4 7922d199 clr!ExecuteEXE+0x58, calling clr!SystemDomain::ExecuteMainMethod
0012ff18 7922d09a clr!_CorExeMainInternal+0x19f, calling clr!ExecuteEXE
0012ff30 603b5011 mscoreei!BaseWrapper,&DoTheRelease,2>,0,&CompareDefault,2>::~BaseWrapper,&DoTheRelease,2>,0,&CompareDefault,2>+0x30, calling mscoreei!_EH_epilog3
0012ff64 792aaf00 clr!_CorExeMain+0x4e, calling clr!_CorExeMainInternal
0012ff9c 603b55ab mscoreei!_CorExeMain+0x38
0012ffa8 79007f16 mscoree!ShellShim__CorExeMain+0x99
0012ffb8 79004de3 mscoree!_CorExeMain_Exported+0x8, calling mscoree!ShellShim__CorExeMain
0012ffc0 7c817077 KERNEL32!BaseProcessStart+0x23

Child 1 thread stack:

0:003> !dumpstack
OS Thread Id: 0x1588 (3)
Current frame: ntdll!KiFastSystemCallRet
ChildEBP RetAddr Caller, Callee
0315f514 7c90daea ntdll!ZwRequestWaitReplyPort+0xc
0315f518 7c912de8 ntdll!CsrClientCallServer+0x8c, calling ntdll!NtRequestWaitReplyPort
0315f538 7c872a51 KERNEL32!ReadConsoleInternal+0x1be, calling ntdll!CsrClientCallServer
0315f558 7c927784 ntdll!RtlFreeHeapSlowly+0x5c2, calling ntdll!_SEH_epilog
0315f5bc 7914ee15 clr!Precode::GetMethodDesc+0x46, calling clr!FixupPrecode::GetMethodDesc
0315f5e0 79151734 clr!BaseWrapper,&StubRelease,2>,0,&CompareDefault,2>::~BaseWrapper,&StubRelease,2>,0,&CompareDefault,2>+0x2f, calling clr!_EH_epilog3
0315f634 7c872b98 KERNEL32!ReadConsoleA+0x3b, calling KERNEL32!ReadConsoleInternal
0315f678 7916498a clr!SafeHandle::DangerousAddRef+0x111, calling clr!Frame::Pop
0315f67c 7916499f clr!SafeHandle::DangerousAddRef+0x126, calling clr!_EH_epilog3
0315f690 79161e82 clr!MethodDesc::DoPrestub+0x51d, calling clr!_EH_epilog3
0315f6bc 7c8018b7 KERNEL32!ReadFile+0x64, calling KERNEL32!ReadConsoleA
0315f714 79b41c8b (MethodDesc 79902c90 +0x6b DomainNeutralILStubClass.IL_STUB_PInvoke(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte*, Int32, Int32 ByRef, IntPtr))
0315f740 79b41c8b (MethodDesc 79902c90 +0x6b DomainNeutralILStubClass.IL_STUB_PInvoke(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte*, Int32, Int32 ByRef, IntPtr))
0315f774 7a1af7e8 (MethodDesc 799b7628 +0x8c System.IO.__ConsoleStream.ReadFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte[], Int32, Int32, Int32, Int32 ByRef)), calling 79a8141c
0315f794 7a1af7e8 (MethodDesc 799b7628 +0x8c System.IO.__ConsoleStream.ReadFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte[], Int32, Int32, Int32, Int32 ByRef)), calling 79a8141c
0315f7bc 7a1af6d0 (MethodDesc 799b7610 +0x9c System.IO.__ConsoleStream.Read(Byte[], Int32, Int32)), calling (MethodDesc 799b7628 +0 System.IO.__ConsoleStream.ReadFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte[], Int32, Int32, Int32, Int32 ByRef))
0315f7e4 79af8bfb (MethodDesc 798eff48 +0x3b System.IO.StreamReader.ReadBuffer())
0315f800 79ad560a (MethodDesc 798eff50 +0x16e System.IO.StreamReader.ReadLine())
0315f820 7a1b5f45 (MethodDesc 799841b4 +0x19 System.IO.TextReader+SyncTextReader.ReadLine())
0315f830 7a0ac292 (MethodDesc 799084ec +0x12 System.Console.ReadLine())
0315f838 030301a3 (MethodDesc 009c37fc +0x23 testc.Program.MyMethod()), calling (MethodDesc 799084ec +0 System.Console.ReadLine())
0315f840 79b2ae5b (MethodDesc 7996e4d4 +0x63 System.Threading.ThreadHelper.ThreadStart_Context(System.Object))
0315f850 79ab7ff4 (MethodDesc 798f75e8 +0xb0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
0315f86c 79ab7f34 (MethodDesc 798f75dc +0x2c System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling (MethodDesc 798f75e8 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
0315f88c 79b2ade8 (MethodDesc 798e86c0 +0x44 System.Threading.ThreadHelper.ThreadStart()), calling (MethodDesc 798f75dc +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0315f8a4 791421db clr!CallDescrWorker+0x33
0315f8a8 7c91930f ntdll!RtlAllocateHeapSlowly+0x113b, calling ntdll!_SEH_epilog
0315f8ac 7c918f21 ntdll!RtlAllocateHeap+0xe64, calling ntdll!RtlAllocateHeapSlowly
0315f8b4 79164a2a clr!CallDescrWorkerWithHandler+0x8e, calling clr!CallDescrWorker
0315f908 7915c58d clr!ArgIterator::Init+0x6b, calling clr!MetaSig::HasRetBuffArg
0315f930 79164bcc clr!MethodDesc::CallDescr+0x194, calling clr!CallDescrWorkerWithHandler
0315f95c 791628bb clr!MetaSig::MetaSig+0x3c, calling MSVCR100_CLR0400!memcpy
0315f96c 79164b0a clr!MethodDesc::CallDescr+0xa8, calling clr!ClrSafeInt::addition
0315f978 79164b1a clr!MethodDesc::CallDescr+0xb4, calling clr!_alloca_probe_16
0315f9d4 7c918047 ntdll!LdrpSnapThunk+0x317, calling ntdll!LdrpGetProcedureAddress
0315fa00 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0315fa04 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0315fa18 7919c09d clr!EEHeapFreeInProcessHeap+0x24, calling clr!EEHeapFree
0315fa30 79164aa5 clr!MethodDesc::CallDescr+0x21, calling clr!_alloca_probe_16
0315fa74 79164c01 clr!MethodDesc::CallTargetWorker+0x21, calling clr!MethodDesc::CallDescr
0315fa90 792db512 clr!ThreadNative::KickOffThread_Worker+0x1e1, calling clr!MethodDesc::CallTargetWorker
0315fad0 603b43e4 mscoreei!_unlock+0x15, calling ntdll!RtlLeaveCriticalSection
0315fadc 603b43ed mscoreei!_initptd+0xb2, calling mscoreei!_unlock
0315fae4 603b4139 mscoreei!_initptd+0x9b, calling mscoreei!_SEH_epilog4
0315fb00 7c94b1b0 ntdll!RtlpCoalesceFreeBlocks+0x3ed, calling ntdll!RtlCompareMemoryUlong
0315fb28 7c92770a ntdll!RtlFreeHeapSlowly+0x3a0, calling ntdll!RtlpUpdateIndexInsertBlock
0315fb30 7c927784 ntdll!RtlFreeHeapSlowly+0x5c2, calling ntdll!_SEH_epilog
0315fb58 603b4384 mscoreei!_CRT_INIT+0x259, calling mscoreei!_SEH_epilog4
0315fb78 7c80e6cb KERNEL32!BasepGetModuleHandleExW+0x250, calling KERNEL32!_SEH_epilog
0315fb7c 790853d0 MSVCR100_CLR0400!__addlocaleref+0x8a
0315fb84 79085112 MSVCR100_CLR0400!_unlock+0x15, calling ntdll!RtlLeaveCriticalSection
0315fba4 7c91930f ntdll!RtlAllocateHeapSlowly+0x113b, calling ntdll!_SEH_epilog
0315fba8 7c918f21 ntdll!RtlAllocateHeap+0xe64, calling ntdll!RtlAllocateHeapSlowly
0315fbb4 7c9101db ntdll!RtlAllocateHeap+0xeac, calling ntdll!_SEH_epilog
0315fc30 7c918047 ntdll!LdrpSnapThunk+0x317, calling ntdll!LdrpGetProcedureAddress
0315fc5c 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0315fc60 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0315fc74 7919c09d clr!EEHeapFreeInProcessHeap+0x24, calling clr!EEHeapFree
0315fc9c 791f5c05 clr!Thread::DoExtraWorkForFinalizer+0x114
0315fcb0 791f5c87 clr!Thread::ShouldChangeAbortToUnload+0x101, calling clr!Thread::DoExtraWorkForFinalizer+0xb7
0315fcc8 79141d85 clr!UnsafeEETryEnterCriticalSection+0xf, calling ntdll!RtlTryEnterCriticalSection
0315fccc 79141d9e clr!UnsafeEETryEnterCriticalSection+0x28, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0315fcd8 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0315fcf0 7914191f clr!ClrFlsGetValue+0xb, calling 00941ee0
0315fcf8 7914191f clr!ClrFlsGetValue+0xb, calling 00941ee0
0315fd00 79141e36 clr!DecCantStopCount+0xa, calling clr!ClrFlsGetValue
0315fd0c 7919dea7 clr!ThreadStore::UnlockThreadStore+0x4b, calling clr!DecCantStopCount
0315fd60 791f5d42 clr!Thread::ShouldChangeAbortToUnload+0x399, calling clr!Thread::ShouldChangeAbortToUnload+0x34
0315fdc0 791f5dd9 clr!Thread::ShouldChangeAbortToUnload+0x43a, calling clr!Thread::ShouldChangeAbortToUnload+0x33c
0315fde4 792db3e5 clr!ManagedThreadBase::KickOff+0x15, calling clr!Thread::ShouldChangeAbortToUnload+0x403
0315fdfc 792db2e0 clr!ThreadNative::KickOffThread+0x23e, calling clr!ManagedThreadBase::KickOff
0315fe38 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0315fe60 7919c06d clr!operator delete[]+0x30, calling clr!EEHeapFreeInProcessHeap
0315fe94 791f5a08 clr!Thread::intermediateThreadProc+0x4b
0315ffa0 791f59f6 clr!Thread::intermediateThreadProc+0x39, calling clr!_alloca_probe_16
0315ffb4 7c80b729 KERNEL32!BaseThreadStart+0x37

Child 2 thread stack:
0:004> !dumpstack
OS Thread Id: 0x1710 (4)
Current frame: ntdll!KiFastSystemCallRet
ChildEBP RetAddr Caller, Callee
0325f388 7c90df4a ntdll!ZwWaitForMultipleObjects+0xc
0325f38c 7c809590 KERNEL32!WaitForMultipleObjectsEx+0x12c, calling ntdll!NtWaitForMultipleObjects
0325f428 791f516a clr!WaitForMultipleObjectsEx_SO_TOLERANT+0x56, calling KERNEL32!WaitForMultipleObjectsEx
0325f48c 791f4f98 clr!Thread::DoAppropriateAptStateWait+0x4d, calling clr!WaitForMultipleObjectsEx_SO_TOLERANT
0325f4ac 791f4dd8 clr!Thread::DoAppropriateWaitWorker+0x17d, calling clr!Thread::DoAppropriateAptStateWait
0325f540 791f4e99 clr!Thread::DoAppropriateWait+0x60, calling clr!Thread::DoAppropriateWaitWorker
0325f58c 7c80a7ae KERNEL32!CreateEventW+0x9a, calling KERNEL32!SetLastError
0325f5ac 791f4f17 clr!CLREvent::WaitEx+0x106, calling clr!Thread::DoAppropriateWait
0325f5d8 7949df7c clr!CLRGetTickCount64+0x15f, calling clr!_allmul
0325f600 7919d409 clr!CLREvent::Wait+0x19, calling clr!CLREvent::WaitEx
0325f614 792e0160 clr!AwareLock::EnterEpilogHelper+0xa8, calling clr!CLREvent::Wait
0325f668 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0325f67c 79141c5c clr!UnsafeEELeaveCriticalSection+0x21, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0325f684 79141c8f clr!CrstBase::Leave+0x2b, calling clr!UnsafeEELeaveCriticalSection
0325f6a4 792e0256 clr!AwareLock::EnterEpilog+0x42, calling clr!AwareLock::EnterEpilogHelper
0325f6e4 792e029b clr!AwareLock::Enter+0x5f, calling clr!AwareLock::EnterEpilog
0325f704 791e0f78 clr!JIT_MonEnterWorker_Portable+0xf8, calling clr!ObjHeader::EnterObjMonitor
0325f718 79ad7774 (MethodDesc 799080b0 +0x58 System.IO.__ConsoleStream.Write(Byte[], Int32, Int32)), calling (MethodDesc 799b7634 +0 System.IO.__ConsoleStream.WriteFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle, Byte[], Int32, Int32, Int32, Int32 ByRef))
0325f734 79b2e0c4 (MethodDesc 79885774 +0x14 System.Threading.Monitor.Enter(System.Object, Boolean ByRef)), calling clr!JIT_MonReliableEnter
0325f738 79142ec3 clr!JIT_MonExitWorker+0xb, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0325f748 791e0ed7 clr!JIT_MonEnterWorker_Portable+0x21, calling clr!LazyMachStateCaptureState
0325f7a0 7a1b5f3a (MethodDesc 799841b4 +0xe System.IO.TextReader+SyncTextReader.ReadLine()), calling clr!JIT_MonEnterWorker
0325f7b0 7a0ac292 (MethodDesc 799084ec +0x12 System.Console.ReadLine())
0325f7b8 030301f3 (MethodDesc 009c3808 +0x23 testc.Program.MyMethod1()), calling (MethodDesc 799084ec +0 System.Console.ReadLine())
0325f7c0 79b2ae5b (MethodDesc 7996e4d4 +0x63 System.Threading.ThreadHelper.ThreadStart_Context(System.Object))
0325f7d0 79ab7ff4 (MethodDesc 798f75e8 +0xb0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
0325f7ec 79ab7f34 (MethodDesc 798f75dc +0x2c System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling (MethodDesc 798f75e8 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
0325f80c 79b2ade8 (MethodDesc 798e86c0 +0x44 System.Threading.ThreadHelper.ThreadStart()), calling (MethodDesc 798f75dc +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0325f824 791421db clr!CallDescrWorker+0x33
0325f834 79164a2a clr!CallDescrWorkerWithHandler+0x8e, calling clr!CallDescrWorker
0325f888 7915c58d clr!ArgIterator::Init+0x6b, calling clr!MetaSig::HasRetBuffArg
0325f8b0 79164bcc clr!MethodDesc::CallDescr+0x194, calling clr!CallDescrWorkerWithHandler
0325f8dc 791628bb clr!MetaSig::MetaSig+0x3c, calling MSVCR100_CLR0400!memcpy
0325f8ec 79164b0a clr!MethodDesc::CallDescr+0xa8, calling clr!ClrSafeInt::addition
0325f8f8 79164b1a clr!MethodDesc::CallDescr+0xb4, calling clr!_alloca_probe_16
0325f954 7c9101db ntdll!RtlAllocateHeap+0xeac, calling ntdll!_SEH_epilog
0325f980 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0325f984 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0325f998 7919c09d clr!EEHeapFreeInProcessHeap+0x24, calling clr!EEHeapFree
0325f9b0 79164aa5 clr!MethodDesc::CallDescr+0x21, calling clr!_alloca_probe_16
0325f9f4 79164c01 clr!MethodDesc::CallTargetWorker+0x21, calling clr!MethodDesc::CallDescr
0325fa10 792db512 clr!ThreadNative::KickOffThread_Worker+0x1e1, calling clr!MethodDesc::CallTargetWorker
0325fa60 7c917dba ntdll!LdrpGetProcedureAddress+0x186, calling ntdll!LdrpSnapThunk
0325fa80 7c94b065 ntdll!RtlpCoalesceFreeBlocks+0x1a7, calling ntdll!RtlCompareMemoryUlong
0325faa8 7c92770a ntdll!RtlFreeHeapSlowly+0x3a0, calling ntdll!RtlpUpdateIndexInsertBlock
0325fab0 7c927784 ntdll!RtlFreeHeapSlowly+0x5c2, calling ntdll!_SEH_epilog
0325fac4 7c80e6cb KERNEL32!BasepGetModuleHandleExW+0x250, calling KERNEL32!_SEH_epilog
0325fac8 603b41e7 mscoreei!__addlocaleref+0x8a
0325fadc 603b43ed mscoreei!_initptd+0xb2, calling mscoreei!_unlock
0325fae4 603b4139 mscoreei!_initptd+0x9b, calling mscoreei!_SEH_epilog4
0325fb24 7c91930f ntdll!RtlAllocateHeapSlowly+0x113b, calling ntdll!_SEH_epilog
0325fb28 7c918f21 ntdll!RtlAllocateHeap+0xe64, calling ntdll!RtlAllocateHeapSlowly
0325fb34 7c9101db ntdll!RtlAllocateHeap+0xeac, calling ntdll!_SEH_epilog
0325fb4c 603b4358 mscoreei!_CRT_INIT+0x1d0, calling mscoreei!DllMain
0325fbb0 7c9101db ntdll!RtlAllocateHeap+0xeac, calling ntdll!_SEH_epilog
0325fbdc 7c91005d ntdll!RtlFreeHeap+0x647, calling ntdll!_SEH_epilog
0325fbe0 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0325fbf4 7919c09d clr!EEHeapFreeInProcessHeap+0x24, calling clr!EEHeapFree
0325fc1c 791f5c05 clr!Thread::DoExtraWorkForFinalizer+0x114
0325fc30 791f5c87 clr!Thread::ShouldChangeAbortToUnload+0x101, calling clr!Thread::DoExtraWorkForFinalizer+0xb7
0325fc48 79141d85 clr!UnsafeEETryEnterCriticalSection+0xf, calling ntdll!RtlTryEnterCriticalSection
0325fc4c 79141d9e clr!UnsafeEETryEnterCriticalSection+0x28, calling (JitHelp: CORINFO_HELP_GET_THREAD)
0325fc58 79141d55 clr!CrstBase::Enter+0xb4, calling clr!UnsafeEETryEnterCriticalSection
0325fc70 7914191f clr!ClrFlsGetValue+0xb, calling 00941ee0
0325fc78 7914191f clr!ClrFlsGetValue+0xb, calling 00941ee0
0325fc80 79141e36 clr!DecCantStopCount+0xa, calling clr!ClrFlsGetValue
0325fc8c 7919dea7 clr!ThreadStore::UnlockThreadStore+0x4b, calling clr!DecCantStopCount
0325fce0 791f5d42 clr!Thread::ShouldChangeAbortToUnload+0x399, calling clr!Thread::ShouldChangeAbortToUnload+0x34
0325fd40 791f5dd9 clr!Thread::ShouldChangeAbortToUnload+0x43a, calling clr!Thread::ShouldChangeAbortToUnload+0x33c
0325fd64 792db3e5 clr!ManagedThreadBase::KickOff+0x15, calling clr!Thread::ShouldChangeAbortToUnload+0x403
0325fd7c 792db2e0 clr!ThreadNative::KickOffThread+0x23e, calling clr!ManagedThreadBase::KickOff
0325fdb8 7919c036 clr!EEHeapFree+0x36, calling ntdll!RtlFreeHeap
0325fde0 7919c06d clr!operator delete[]+0x30, calling clr!EEHeapFreeInProcessHeap
0325fe14 791f5a08 clr!Thread::intermediateThreadProc+0x4b
0325ffa0 791f59f6 clr!Thread::intermediateThreadProc+0x39, calling clr!_alloca_probe_16
0325ffb4 7c80b729 KERNEL32!BaseThreadStart+0x37

Sunday, November 14, 2010

SharpDevelop improvements(2): Pinned data-tips

Hey everybody,
I've developed a data-pins version in SharpDevelop IDE. See my github for implementation.
You can:
- add a data pin with variables
- refresh data inside pins
- save and load data pins
- move pin grid independent of the pin location and pin location independent of pin grid - this is not supported in VS 2010
- add comment to a data pin.

Friday, November 12, 2010

SharpDevelop improvements(1)

Hey everybody,

SharpDevelop is at 4.1 pre-alpha and some of my contributions are inside.
These are:
- WPF breakpoints pad with code completion
- WPF bookmark pad
- WPF watch pad with code completion
- WPF local vars pad
- change Reflector path in Options panels.
- spell checker based on (N)hunspell - this addin is not inside the release but you can find it on my github.

The next improvements concerns pin data tips and edit value in debug tooltips.

Give #D a try! :)

Happy programming!

Thursday, November 4, 2010

My SharpDevelop wish list

1. Parallel Tasks window/pad
2. Parallel Stacks window/pad
3. Format code on save(C#, VB, X(A)ML,)


I'll add others in the future...

Create Git new remote branch script

if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
branch_name=$1
git push origin master:refs/heads/$branch_name
echo "git push origin master:refs/heads/$branch_name"
git fetch origin
git checkout --track -b $branch_name origin/$branch_name
git pull

Wednesday, October 13, 2010

Disassemble and assemble .NET files

Hey,

Today I wanted to edit some resources in some .NET assembly. For that I used ildasm, Resourcer and ilasm tools.

Step 1. disassemble: ildasm /out=assembly_name.il assembly_name.dll
This will output the il file and the resources.
Step 2. edit resources with Resourcer.
Step 3. assemble the result:
ilasm assembly_name.il /dll /resource:asssembly_name.res /output=assembly_name.dll
This order is important. Otherwise you will get some errors like "Could not create output file, error code=0x80004005".

Tuesday, October 12, 2010

SharpDevelop Ideas

Hey...
I started playing/developing with SharpDevelop IDE and I made/proposed some very nice changes:
- expand regions with double click - implemented with the help of Daniel Grunwald
- drag and drop current yellow line in debugger - implemented with the help of Daniel
- focus/select the member in the combo in editor
- update position of completion window - implemented with the help of Daniel
- tooltip for folding elements - implemented with the help of Daniel
- remove all breakpoints
- remove project from recent list
- watchpad features + code completion when adding a watch variable - implemented with the help of Daniel Grunwald
- partial fix for x:Name in XAML
- search for type names in Add Reference window - with some suggestions for using Mono.Cecil from Daniel
- fix some issues.

Now I'm working on a spell checker... :D

Check #D out! It's very cool! :)

Spell checker

Hey all...

Today I found a very nice "tool" for spell checking. It is called hunspell and it looks like it is used by major applications like OppenOffice, Mozilla Firefox, Google Chrome, Opera, etc. It's using OpenOffice dictionaries...
For .NET developers there is a wrapper called NHunspell. For usage see this article.

Very nice and easy to use...

Happy coding!

Thursday, September 23, 2010

Translate Excel files using Google or Bing services

Hey...
I've "created" (based on some other blog - I can't remember the address, sorry) a vbs that translated the an excel sheet.
Also, it is better to execute the vbs in console - a bat file:
cscript "path\translate.vbs"
Code for "path\translate.vbs":
Option Explicit
REM We use "Option Explicit" to help us check for coding mistakes

REM the Excel Application
Dim objExcel
REM the path to the excel file
Dim excelPath
REM how many worksheets are in the current excel file
Dim worksheetCount
Dim counter
REM the worksheet we are currently getting data from
Dim currentWorkSheet
REM the number of columns in the current worksheet that have data in them
Dim usedColumnsCount
REM the number of rows in the current worksheet that have data in them
Dim usedRowsCount
Dim row
Dim column
REM the topmost row in the current worksheet that has data in it
Dim top
REM the leftmost row in the current worksheet that has data in it
Dim left
Dim Cells
dim currentCell
REM the current row and column of the current worksheet we are reading
Dim curCol
Dim curRow
REM the value of the current row and column of the current worksheet we are reading
Dim word, tabname

rem tab name
if Wscript.Arguments.Count = 2 then
tabname = Wscript.Arguments(1)
excelPath = Wscript.Arguments(0)
end if
REM where is the Excel file located?
excelPath = "path"
tabname = "sheet"
WScript.Echo "Reading Data from " & excelPath & " " & tabname
REM Create an invisible version of Excel
Set objExcel = CreateObject("Excel.Application")

REM don't display any messages about documents needing to be converted
REM from old Excel file formats
objExcel.DisplayAlerts = 0

REM open the excel document as read-only
REM open (path, confirmconversions, readonly)
objExcel.Workbooks.open excelPath, false, false


REM How many worksheets are in this Excel documents
workSheetCount = objExcel.Worksheets.Count

dim name
Dim objSvrHTTP
dim translateWord
Set objSvrHTTP = CreateObject("Msxml2.XMLHTTP.4.0")

REM Loop through each worksheet
For counter = 1 to workSheetCount
WScript.Echo "-----------------------------------------------"

Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(counter)
currentWorkSheet.Unprotect
name = CStr(currentWorksheet.Name)
WScript.Echo "Reading data from worksheet " & name & vbCRLF
If StrComp(Trim(CStr(name)), Trim(CStr(tabname)), vbTextCompare) = 0 then
REM how many columns are used in the current worksheet
usedColumnsCount = currentWorkSheet.UsedRange.Columns.Count
REM how many rows are used in the current worksheet
usedRowsCount = currentWorkSheet.UsedRange.Rows.Count

REM What is the topmost row in the spreadsheet that has data in it
top = currentWorksheet.UsedRange.Row
REM What is the leftmost column in the spreadsheet that has data in it
left = currentWorksheet.UsedRange.Column


Set Cells = currentWorksheet.Cells
REM Loop through each row in the worksheet
For row = 0 to (usedRowsCount-1)
REM Loop through each column in the worksheet
For column = 0 to usedColumnsCount-1
REM only look at rows that are in the "used" range
curRow = row+top
REM only look at columns that are in the "used" range
curCol = column+left
REM get the value/word that is in the cell
set currentCell = Cells(curRow,curCol)
word = currentCell.Value
REM display the column on the screen
if word <> "" then
'WScript.Echo (word)
'objSvrHTTP.open "GET", "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=nl|en&q=" & word, false
objSvrHTTP.open "GET", "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=your_own_id&from=nl&to=en&text=" & word, false
objSvrHTTP.send
translateWord = objSvrHTTP.responseText
translateWord = Replace(translateWord, "", "")
translateWord = Replace(translateWord, "", "")
REM translateWord3 = Replace(translateWord2, """responseDetails""", "")
REM translateWord4 = Replace(translateWord3, """responseStatus""", "")
REM translateWord5 = Replace(translateWord4, "null", "")
REM translateWord6 = Replace(translateWord5, "200", "")
REM translateWord7 = Replace(translateWord6, "{", "")
REM translateWord8 = Replace(translateWord7, "}", "")
REM translateWord9 = Replace(translateWord8, ":", "")
REM translateWord10 = Replace(translateWord9, ": ", "")
REM translateWord11 = Replace(translateWord10, ",", "")
REM translateWord12 = Replace(translateWord11, ", ", "")
REM translateWord13 = Replace(translateWord12, """", "")
if Trim(CStr(word)) <> Trim(CStr(translateWord)) then
WScript.Echo Trim(CStr(translateWord))
if currentCell.Comment Is Nothing then
currentCell.AddComment()
end if
currentCell.Comment.Text Trim(CStr(translateWord))
currentCell.Comment.Shape.Width = 220
currentCell.Comment.Shape.Height = 50
end if
Wscript.Sleep 500
end if
Next
Next
end if
REM We are done with the current worksheet, release the memory
Set currentWorkSheet = Nothing
Next

objExcel.Workbooks(1).Save
objExcel.Workbooks(1).Close
objExcel.Quit

Set currentWorkSheet = Nothing
REM We are done with the Excel object, release it from memory
Set objExcel = Nothing

Friday, August 20, 2010

Run/Execute EVERYTHING in the cloud

Hey there...
Image this... everything runs/executes inside the cloud... you can read/update your documents from a web page (I know, Google Docs or Office live)... read/update pdf documents... play games (I mean games like... Age of Empires, Half life... etc)... copy/save files from the web (images, docs, you name it...)... or even develop apps (using your preferred IDE).
All this without having any data on your hard drive... of course, if you want to have data on your drive, it's your choice...

Won't this be perfect? :)

[For those who have ears to listen...]

Monday, February 8, 2010

Install Windows Mobile 6.5 (WM 6.5) on Samsung Omnia SGH-i900

Here are some links:

Regarding the installation, follow this steps:
Prerequisites: Before you do that you need to install Samsung modem and active sync ..... and have Win XP on the computer, it's simpler on Win XP;
Actions: Unzip the archive / click or double click on the exe file / hang up the phone / connect phone to PC (data cable) / start phone / Click the Start button and expect "Job Done" message
(thanks to maja_ro).

Have fun! :)

Thursday, February 4, 2010

Connection between human senses and file formats

Hi there...
Humans have 5 basics senses: sight, hearing, taste, smell and touch.
If we think at file formats that we can interact, are using only a part of them. In general, files are divided as: text, images, waves and movies (moving images with sound).
With text and images we are using only sight; with movies we are using sight and hearing.

Let's see how many formats can exist for our senses. We basically all senses apart, all senses grouped in 2, in 3, in 4 and all together. The formula for this is:
where n is the number of senses. For humans, there are 2^5 - 1 = 31 formats.

Now, we only know 4 of them!!!

What's the next one? :)