You've already forked linux-packaging-mono
Imported Upstream version 5.12.0.220
Former-commit-id: c477e03582759447177c6d4bf412cd2355aad476
This commit is contained in:
parent
8bd104cef2
commit
8fc30896db
@ -56,6 +56,7 @@ namespace System.Diagnostics {
|
||||
}
|
||||
|
||||
public const int METHODS_TO_SKIP = 0;
|
||||
const string prefix = " at ";
|
||||
|
||||
private StackFrame[] frames;
|
||||
readonly StackTrace[] captured_traces;
|
||||
@ -198,31 +199,25 @@ namespace System.Diagnostics {
|
||||
|
||||
bool AddFrames (StringBuilder sb)
|
||||
{
|
||||
string debugInfo, indentation;
|
||||
string unknown = Locale.GetText ("<unknown method>");
|
||||
bool any_frame = false;
|
||||
|
||||
indentation = " ";
|
||||
debugInfo = Locale.GetText (" in {0}:{1} ");
|
||||
|
||||
var newline = String.Format ("{0}{1}{2} ", Environment.NewLine, indentation,
|
||||
Locale.GetText ("at"));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < FrameCount; i++) {
|
||||
for (int i = 0; i < FrameCount; i++) {
|
||||
StackFrame frame = GetFrame (i);
|
||||
if (i == 0)
|
||||
sb.AppendFormat ("{0}{1} ", indentation, Locale.GetText ("at"));
|
||||
else
|
||||
sb.Append (newline);
|
||||
|
||||
if (frame.GetMethod () == null) {
|
||||
if (any_frame)
|
||||
sb.Append (Environment.NewLine);
|
||||
sb.Append (prefix);
|
||||
|
||||
string internal_name = frame.GetInternalMethodName ();
|
||||
if (internal_name != null)
|
||||
sb.Append (internal_name);
|
||||
else
|
||||
sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> {2}", frame.GetMethodAddress (), frame.GetNativeOffset (), unknown);
|
||||
sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> <unknown method>", frame.GetMethodAddress (), frame.GetNativeOffset ());
|
||||
} else {
|
||||
GetFullNameForStackTrace (sb, frame.GetMethod ());
|
||||
GetFullNameForStackTrace (sb, frame.GetMethod (), any_frame, out var skipped);
|
||||
if (skipped)
|
||||
continue;
|
||||
|
||||
if (frame.GetILOffset () == -1) {
|
||||
sb.AppendFormat (" <0x{0:x5} + 0x{1:x5}>", frame.GetMethodAddress (), frame.GetNativeOffset ());
|
||||
@ -243,34 +238,48 @@ namespace System.Diagnostics {
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendFormat (debugInfo, filename, frame.GetFileLineNumber ());
|
||||
sb.AppendFormat (" in {0}:{1} ", filename, frame.GetFileLineNumber ());
|
||||
}
|
||||
|
||||
any_frame = true;
|
||||
}
|
||||
|
||||
return i != 0;
|
||||
return any_frame;
|
||||
}
|
||||
|
||||
internal void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi)
|
||||
void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi, bool needsNewLine, out bool skipped)
|
||||
{
|
||||
var declaringType = mi.DeclaringType;
|
||||
if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
|
||||
declaringType = declaringType.GetGenericTypeDefinition ();
|
||||
|
||||
// Get generic definition
|
||||
const BindingFlags bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
foreach (var m in declaringType.GetMethods (bindingflags)) {
|
||||
if (m.MetadataToken == mi.MetadataToken) {
|
||||
mi = m;
|
||||
break;
|
||||
if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition) {
|
||||
declaringType = declaringType.GetGenericTypeDefinition ();
|
||||
|
||||
const BindingFlags bindingflags = BindingFlags.Instance | BindingFlags.Static |
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
|
||||
foreach (var m in declaringType.GetMethods (bindingflags)) {
|
||||
if (m.MetadataToken == mi.MetadataToken) {
|
||||
mi = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skipped = mi.IsDefined (typeof(StackTraceHiddenAttribute)) || declaringType.IsDefined (typeof(StackTraceHiddenAttribute));
|
||||
if (skipped)
|
||||
return;
|
||||
|
||||
if (needsNewLine)
|
||||
sb.Append (Environment.NewLine);
|
||||
sb.Append (prefix);
|
||||
|
||||
sb.Append (declaringType.ToString ());
|
||||
|
||||
sb.Append (".");
|
||||
sb.Append (mi.Name);
|
||||
|
||||
if (mi.IsGenericMethod) {
|
||||
mi = ((MethodInfo)mi).GetGenericMethodDefinition ();
|
||||
Type[] gen_params = mi.GetGenericArguments ();
|
||||
sb.Append ("[");
|
||||
for (int j = 0; j < gen_params.Length; j++) {
|
||||
@ -300,7 +309,7 @@ namespace System.Diagnostics {
|
||||
}
|
||||
}
|
||||
sb.Append (")");
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
|
Reference in New Issue
Block a user