summaryrefslogtreecommitdiff
path: root/src/vm/threaddebugblockinginfo.h
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/threaddebugblockinginfo.h
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/threaddebugblockinginfo.h')
-rw-r--r--src/vm/threaddebugblockinginfo.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/vm/threaddebugblockinginfo.h b/src/vm/threaddebugblockinginfo.h
new file mode 100644
index 0000000000..202a1db91e
--- /dev/null
+++ b/src/vm/threaddebugblockinginfo.h
@@ -0,0 +1,81 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+// ThreadDebugBlockingInfo.h
+//
+
+//
+//
+// Threads.h was getting so bloated that it seemed time to refactor a little. Rather than shove in yet another
+// 50 lines of random definitions of things which happened to be per-thread I separated it out here.
+#ifndef __ThreadBlockingInfo__
+#define __ThreadBlockingInfo__
+#include "mscoree.h"
+
+// Different ways thread can block that the debugger will expose
+enum DebugBlockingItemType
+{
+ DebugBlock_MonitorCriticalSection,
+ DebugBlock_MonitorEvent,
+};
+
+typedef DPTR(struct DebugBlockingItem) PTR_DebugBlockingItem;
+
+// Represents something a thread blocked on that is exposed via the debugger
+struct DebugBlockingItem
+{
+ // right now we only do monitor locks but this could be
+ // expanded to other pieces of data if we want to expose
+ // other things that we block on
+ PTR_AwareLock pMonitor;
+ // The app domain of the object we are blocking on
+ PTR_AppDomain pAppDomain;
+ // Indicates how the thread is blocked on the item
+ DebugBlockingItemType type;
+ // blocking timeout in milliseconds or INFINTE for no timeout
+ DWORD dwTimeout;
+ // next pointer for a linked list of these items
+ PTR_DebugBlockingItem pNext;
+};
+
+// A visitor function used when enumerating DebuggableBlockingItems
+typedef VOID (*DebugBlockingItemVisitor)(PTR_DebugBlockingItem item, VOID* pUserData);
+
+// Maintains a stack of DebugBlockingItems that a thread is currently waiting on
+// It is a stack rather than a single item because we wait interruptibly. During the interruptible
+// wait we can run more code for an APC or to handle a windows message that could again block on another lock
+class ThreadDebugBlockingInfo
+{
+private:
+ // head of the linked list which is our stack
+ PTR_DebugBlockingItem m_firstBlockingItem;
+
+public:
+ ThreadDebugBlockingInfo();
+ ~ThreadDebugBlockingInfo();
+
+#ifndef DACCESS_COMPILE
+ // Adds a new blocking item at the front of the list
+ VOID PushBlockingItem(DebugBlockingItem *pItem);
+ // Removes the most recently added item (FIFO)
+ VOID PopBlockingItem();
+#else
+ // Calls the visitor function on each item in the stack from front to back
+ VOID VisitBlockingItems(DebugBlockingItemVisitor vistorFunc, VOID* pUserData);
+#endif //DACCESS_COMPILE
+};
+
+#ifndef DACCESS_COMPILE
+class DebugBlockingItemHolder
+{
+private:
+ Thread *m_pThread;
+
+public:
+ DebugBlockingItemHolder(Thread *pThread, DebugBlockingItem *pItem);
+ ~DebugBlockingItemHolder();
+};
+#endif //!DACCESS_COMPILE
+
+#endif // __ThreadBlockingInfo__