Skip to content

Instantly share code, notes, and snippets.

View Criteo-dotnet-blog's full-sized avatar

Criteo-dotnet-blog

View GitHub Profile
// decypher the callback details
val = GetFieldValue(heap, currentTimerQueueTimerRef, "m_timerCallback");
if (val != null)
{
ulong elementAddress = (ulong)val;
if (elementAddress == 0)
continue;
var elementType = _heap.GetObjectType(elementAddress);
if (elementType != null)
private string BuildTimerCallbackMethodName(ClrRuntime runtime, ulong timerCallbackRef)
{
var heap = runtime.GetHeap();
var methodPtr = GetFieldValue(heap, timerCallbackRef, "_methodPtr");
if (methodPtr != null)
{
ClrMethod method = runtime.GetMethodByAddress((ulong)(long)methodPtr);
if (method != null)
{
// figure out the real callback implementor type thanks to _target
private static ulong GetTaskStateFromAddress(ulong address)
{
    var type = Runtime.GetHeap().GetObjectType(address);
    if ((type != null) && (type.Name.StartsWith("System.Threading.Task")))
    {
        // try to get the m_stateFlags field value
        ClrInstanceField field = type.GetFieldByName("m_stateFlags");
        if (field != null)
        {
private static string GetTaskState(ulong flag)
{
    TaskStatus rval;
    if ((flag & TASK_STATE_FAULTED) != 0) rval = TaskStatus.Faulted;
    else if ((flag & TASK_STATE_CANCELED) != 0) rval = TaskStatus.Canceled;
    else if ((flag & TASK_STATE_RAN_TO_COMPLETION) != 0) rval = TaskStatus.RanToCompletion;
    else if ((flag & TASK_STATE_WAITING_ON_CHILDREN) != 0) rval = TaskStatus.WaitingForChildrenToComplete;
    else if ((flag & TASK_STATE_DELEGATE_INVOKED) != 0) rval = TaskStatus.Running;
    else if ((flag & TASK_STATE_STARTED) != 0) rval = TaskStatus.WaitingToRun;
public static void MyCommand(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
// Must be the first thing in our extension.
if (!InitApi(client))
    return;
public partial class DebuggerExtensions
{
    public static IDebugClient DebugClient { get; private set; }
    public static DataTarget DataTarget { get; private set; }
    public static ClrRuntime Runtime { get; private set; }
[DllExport("tks")]
public static void tks(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
    OnTkState(client, args);
}
[DllExport("tkstate")]
public static void tkstate(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
    OnTkState (client, args);
public partial class DebuggerExtensions
{
    [DllExport("Help")]
    public static void Help(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
    {
        OnHelp(client, args);
    }
   [DllExport("help")]
   public static void help(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
@inproceedings{DiemertMeynet2017,
author = {{Diemert Eustache, Meynet Julien} and Galland, Pierre and Lefortier, Damien},
title={Attribution Modeling Increases Efficiency of Bidding in Display Advertising},
publisher = {ACM},
pages={To appear},
booktitle = {Proceedings of the AdKDD and TargetAd Workshop, KDD, Halifax, NS, Canada, August, 14, 2017},
year = {2017}
}