Example #1
0
        private void WriteCallInstruction(HtmlWriter writer, Instruction inst, ref MethodContext context)
        {
            // we should be able to find the call targets for R11/relative immediate
            ulong callTarget = GetBranchTarget(inst, context.R11?.LvalUQWord ?? 0);

            StartNote(writer, ref context);
            if (callTarget != 0)
            {
                var target = Mono.GetJitInfoAnyDomain((IntPtr)callTarget, out _);
                if (target.Method != null)
                {
                    if (target.Method.IsConstructor)
                    {
                        WriteCtorPrefix(writer, target.Method);
                        writer.Write(" ");
                        WriteCtorDeclaration(writer, target.Method as ConstructorInfo);
                    }
                    else if (target.Method != null)
                    {
                        WriteMethodPrefix(writer, target.Method);
                        writer.Write(" ");
                        WriteMethodReturnType(writer, target.Method as MethodInfo);
                        writer.Write(" ");
                        if (target.Method.DeclaringType != null)
                        {
                            TypeLink(writer, target.Method.DeclaringType);
                            writer.Write(".");
                        }

                        WriteMethodDeclaration(writer, target.Method as MethodInfo);
                    }
                }
                else
                {
                    writer.Write("unknown target @ " + callTarget.ToString("X16"));
                }
            }
            else if (context.DebugEnabled)
            {
                var     r11 = context.R11;
                ud_type stackFrameRegister = context.HasBasePointer ? ud_type.UD_R_RBP : ud_type.UD_R_RSP;
                if (r11 != null && r11.Base == stackFrameRegister && r11.Type == ud_type.UD_OP_MEM && r11.Value == context.SinglestepTrampolineOffset)
                {
                    writer.Write("check for singlestep");
                    return;
                }

                writer.Write("unknown target; native, virtual, or unpatched JIT trampoline");
            }
            else
            {
                writer.Write("unknown target; native, virtual, or unpatched JIT trampoline");
            }
        }