You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@ -0,0 +1,34 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Diagnostics
|
||||
{
|
||||
public static class Debugger
|
||||
{
|
||||
public static readonly string DefaultCategory = "";
|
||||
|
||||
public static bool IsAttached => IsAttached_internal ();
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern static bool IsAttached_internal ();
|
||||
|
||||
public static void Break ()
|
||||
{
|
||||
// The JIT inserts a breakpoint on the caller.
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public static extern bool IsLogging();
|
||||
|
||||
public static bool Launch ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public static extern void Log (int level, string category, string message);
|
||||
|
||||
public static void NotifyOfCrossThreadDependency ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Diagnostics
|
||||
{
|
||||
partial class StackFrame
|
||||
{
|
||||
internal StackFrame (MonoStackFrame monoStackFrame, bool needFileInfo)
|
||||
{
|
||||
_method = monoStackFrame.methodBase;
|
||||
_nativeOffset = monoStackFrame.nativeOffset;
|
||||
_ilOffset = monoStackFrame.ilOffset;
|
||||
|
||||
if (needFileInfo) {
|
||||
_fileName = monoStackFrame.fileName;
|
||||
_lineNumber = monoStackFrame.lineNumber;
|
||||
_columnNumber = monoStackFrame.columnNumber;
|
||||
}
|
||||
|
||||
_isLastFrameFromForeignExceptionStackTrace = monoStackFrame.isLastFrameFromForeignException;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
void BuildStackFrame (int skipFrames, bool needFileInfo)
|
||||
{
|
||||
const int SystemDiagnosticsStackDepth = 3;
|
||||
|
||||
if (skipFrames + SystemDiagnosticsStackDepth < 0 || !get_frame_info (skipFrames + SystemDiagnosticsStackDepth, needFileInfo, out var method, out var ilOffset, out var nativeOffset, out var fileName, out var line, out var column))
|
||||
return;
|
||||
|
||||
_method = method;
|
||||
_ilOffset = ilOffset;
|
||||
_nativeOffset = nativeOffset;
|
||||
|
||||
if (needFileInfo) {
|
||||
_fileName = fileName;
|
||||
_lineNumber = line;
|
||||
_columnNumber = column;
|
||||
}
|
||||
}
|
||||
|
||||
bool AppendStackFrameWithoutMethodBase (StringBuilder sb) => false;
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern bool get_frame_info (int skipFrames, bool needFileInfo,
|
||||
out MethodBase method, out int ilOffset, out int nativeOffset, out string file, out int line, out int column);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Diagnostics
|
||||
{
|
||||
// Need our own stackframe class since the shared version has its own fields
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
class MonoStackFrame
|
||||
{
|
||||
#region Keep in sync with object-internals.h
|
||||
internal int ilOffset;
|
||||
internal int nativeOffset;
|
||||
// Unused
|
||||
internal long methodAddress;
|
||||
// Unused
|
||||
internal uint methodIndex;
|
||||
internal MethodBase methodBase;
|
||||
internal string fileName;
|
||||
internal int lineNumber;
|
||||
internal int columnNumber;
|
||||
// Unused
|
||||
internal string internalMethodName;
|
||||
#endregion
|
||||
|
||||
internal bool isLastFrameFromForeignException;
|
||||
}
|
||||
|
||||
partial class StackTrace
|
||||
{
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal static extern MonoStackFrame[] get_trace (Exception e, int skipFrames, bool needFileInfo);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
void InitializeForCurrentThread (int skipFrames, bool needFileInfo)
|
||||
{
|
||||
skipFrames += 2; // Current method + parent ctor
|
||||
|
||||
StackFrame sf;
|
||||
var frames = new List<StackFrame> ();
|
||||
while (skipFrames >= 0) {
|
||||
sf = new StackFrame (skipFrames, needFileInfo);
|
||||
if (sf.GetMethod () == null) {
|
||||
break;
|
||||
}
|
||||
frames.Add (sf);
|
||||
skipFrames++;
|
||||
}
|
||||
|
||||
_stackFrames = frames.ToArray ();
|
||||
_numOfFrames = _stackFrames.Length;
|
||||
}
|
||||
|
||||
void InitializeForException (Exception e, int skipFrames, bool needFileInfo)
|
||||
{
|
||||
var frames = get_trace (e, skipFrames, needFileInfo);
|
||||
_numOfFrames = frames.Length;
|
||||
|
||||
int foreignFrames;
|
||||
MonoStackFrame[] foreignExceptions = e.foreignExceptionsFrames;
|
||||
|
||||
if (foreignExceptions != null) {
|
||||
foreignFrames = foreignExceptions.Length;
|
||||
_numOfFrames += foreignFrames;
|
||||
|
||||
_stackFrames = new StackFrame [_numOfFrames];
|
||||
|
||||
for (int i = 0; i < foreignExceptions.Length; ++i) {
|
||||
_stackFrames [i] = new StackFrame (foreignExceptions [i], needFileInfo);
|
||||
}
|
||||
} else {
|
||||
_stackFrames = new StackFrame [_numOfFrames];
|
||||
foreignFrames = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < frames.Length; ++i) {
|
||||
_stackFrames [foreignFrames + i] = new StackFrame (frames [i], needFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user