Imported Upstream version 4.6.0.150

Former-commit-id: 73e3bb1e96dd09dc931c1dfe559d2c7f7b8b02c7
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-23 13:20:38 +00:00
parent 02ac915603
commit b95516a3dd
239 changed files with 4096 additions and 1544 deletions

View File

@@ -256,10 +256,30 @@ class MakeBundle {
}
if (fetch_target != null){
var truntime = Path.Combine (targets_dir, fetch_target, "mono");
Directory.CreateDirectory (Path.GetDirectoryName (truntime));
var wc = new WebClient ();
var uri = new Uri ($"{target_server}{fetch_target}");
try {
if (!quiet){
Console.WriteLine ($"Downloading runtime {uri} to {truntime}");
}
wc.DownloadFile (uri, truntime);
} catch {
Console.Error.WriteLine ($"Failure to download the specified runtime from {uri}");
File.Delete (truntime);
return 1;
}
return 0;
}
if (!quiet) {
Console.WriteLine (os_message);
Console.WriteLine ("Sources: {0} Auto-dependencies: {1}", sources.Count, autodeps);
}
if (sources.Count == 0 || output == null) {
Help ();
Environment.Exit (1);
@@ -271,33 +291,31 @@ class MakeBundle {
if (!QueueAssembly (files, file))
return 1;
if (fetch_target != null){
var truntime = Path.Combine (targets_dir, fetch_target, "mono");
Directory.CreateDirectory (Path.GetDirectoryName (truntime));
var wc = new WebClient ();
var uri = new Uri ($"{target_server}{fetch_target}");
try {
wc.DownloadFile (uri, truntime);
} catch {
Console.Error.WriteLine ($"Failure to download the specified runtime from {uri}");
File.Delete (truntime);
return 1;
}
return 0;
}
if (custom_mode)
GenerateBundles (files);
else {
if (cross_target == "default")
runtime = null;
else {
var truntime = Path.Combine (targets_dir, cross_target, "mono");
if (!File.Exists (truntime)){
Console.Error.WriteLine ($"The runtime for the {cross_target} does not exist, use --fetch-target {cross_target} to download first");
return 1;
if (runtime == null){
if (cross_target == null){
Console.Error.WriteLine ("you should specify either a --runtime or a --cross compilation target");
Environment.Exit (1);
}
runtime = Path.Combine (targets_dir, cross_target, "mono");
if (!File.Exists (runtime)){
Console.Error.WriteLine ($"The runtime for the {cross_target} does not exist, use --fetch-target {cross_target} to download first");
return 1;
}
} else {
if (!File.Exists (runtime)){
Console.Error.WriteLine ($"The Mono runtime specified with --runtime does not exist");
return 1;
}
}
}
Console.WriteLine ("Using runtime {0}", runtime);
}
GeneratePackage (files);
}

View File

@@ -6,7 +6,7 @@ namespace Mono
{
class StackFrameData
{
static Regex regex = new Regex (@"\w*at (?<Method>.+) *(\[0x(?<IL>.+)\]|<0x.+ \+ 0x(?<NativeOffset>.+)>( (?<MethodIndex>\d+)|)) in <filename unknown>:0");
static Regex regex = new Regex (@"\w*at (?<Method>.+) *(\[0x(?<IL>.+)\]|<0x.+ \+ 0x(?<NativeOffset>.+)>( (?<MethodIndex>\d+)|)) in <(?<MVID>[^>#]+)(#(?<AOTID>[^>]+)|)>:0");
public readonly string TypeFullName;
public readonly string MethodSignature;
@@ -14,13 +14,13 @@ namespace Mono
public readonly bool IsILOffset;
public readonly uint MethodIndex;
public readonly string Line;
public readonly bool IsValid;
public readonly string Mvid;
public readonly string Aotid;
public string File { get; private set; }
public int LineNumber { get; private set; }
private StackFrameData (string line, string typeFullName, string methodSig, int offset, bool isILOffset, uint methodIndex)
private StackFrameData (string line, string typeFullName, string methodSig, int offset, bool isILOffset, uint methodIndex, string mvid, string aotid)
{
LineNumber = -1;
@@ -30,15 +30,8 @@ namespace Mono
Offset = offset;
IsILOffset = isILOffset;
MethodIndex = methodIndex;
IsValid = true;
}
private StackFrameData (string line)
{
LineNumber = -1;
Line = line;
Mvid = mvid;
Aotid = aotid;
}
public static bool TryParse (string line, out StackFrameData stackFrame)
@@ -46,13 +39,8 @@ namespace Mono
stackFrame = null;
var match = regex.Match (line);
if (!match.Success) {
if (line.Trim ().StartsWith ("at ", StringComparison.InvariantCulture)) {
stackFrame = new StackFrameData (line);
return true;
}
if (!match.Success)
return false;
}
string typeFullName, methodSignature;
var methodStr = match.Groups ["Method"].Value.Trim ();
@@ -67,7 +55,10 @@ namespace Mono
if (!string.IsNullOrEmpty (match.Groups ["MethodIndex"].Value))
methodIndex = uint.Parse (match.Groups ["MethodIndex"].Value, CultureInfo.InvariantCulture);
stackFrame = new StackFrameData (line, typeFullName, methodSignature, offset, isILOffset, methodIndex);
var mvid = match.Groups ["MVID"].Value;
var aotid = match.Groups ["AOTID"].Value;
stackFrame = new StackFrameData (line, typeFullName, methodSignature, offset, isILOffset, methodIndex, mvid, aotid);
return true;
}
@@ -106,11 +97,9 @@ namespace Mono
LineNumber = lineNumber;
}
public override string ToString () {
if (Line.Contains ("<filename unknown>:0") && LineNumber != -1)
return Line.Replace ("<filename unknown>:0", string.Format ("{0}:{1}", File, LineNumber));
return Line;
public override string ToString ()
{
return string.Format ("{0} in {1}:{2} ", Line.Substring (0, Line.IndexOf(" in <", StringComparison.Ordinal)), File, LineNumber);
}
}
}

View File

@@ -1,36 +0,0 @@
using System.Text.RegularExpressions;
namespace Mono
{
class StackTraceMetadata
{
static Regex regex = new Regex (@"\[(?<Id>.+)\] (?<Value>.+)");
public readonly string Id;
public readonly string Value;
public readonly string Line;
private StackTraceMetadata (string line, string id, string val)
{
Line = line;
Id = id;
Value = val;
}
public static bool TryParse (string line, out StackTraceMetadata metadata)
{
metadata = null;
var match = regex.Match (line);
if (!match.Success)
return false;
string id = match.Groups ["Id"].Value;
string val = match.Groups ["Value"].Value;
metadata = new StackTraceMetadata (line, id, val);
return true;
}
}
}

View File

@@ -19,18 +19,18 @@ namespace Mono
this.logger = logger;
}
internal bool TryResolveLocation (StackFrameData sfData, string mvid, string aotid)
internal bool TryResolveLocation (StackFrameData sfData)
{
if (mvid == null)
if (sfData.Mvid == null)
return false;
var assemblyLocProvider = GetOrCreateAssemblyLocationProvider (mvid);
var assemblyLocProvider = GetOrCreateAssemblyLocationProvider (sfData.Mvid);
if (assemblyLocProvider == null)
return false;
SeqPointInfo seqPointInfo = null;
if (!sfData.IsILOffset && aotid != null)
seqPointInfo = GetOrCreateSeqPointInfo (aotid);
if (!sfData.IsILOffset && sfData.Aotid != null)
seqPointInfo = GetOrCreateSeqPointInfo (sfData.Aotid);
return assemblyLocProvider.TryResolveLocation (sfData, seqPointInfo);
}

View File

@@ -2,7 +2,6 @@ symbolicate.cs
LocationProvider.cs
SeqPointInfo.cs
StackFrameData.cs
StackTraceMetadata.cs
SymbolManager.cs
Logger.cs
../../class/Mono.Options/Mono.Options/Options.cs

View File

@@ -80,8 +80,16 @@ namespace Mono
var symbolManager = new SymbolManager (msymDir, logger);
using (StreamReader r = new StreamReader (inputFile)) {
var sb = Process (r, symbolManager);
Console.Write (sb.ToString ());
for (var line = r.ReadLine (); line != null; line = r.ReadLine ()) {
StackFrameData sfData;
if (StackFrameData.TryParse (line, out sfData) &&
symbolManager.TryResolveLocation (sfData)) {
Console.WriteLine (sfData.ToString ());
continue;
}
Console.WriteLine (line);
}
}
}
@@ -94,88 +102,5 @@ namespace Mono
symbolManager.StoreSymbols (lookupDirs);
}
public static StringBuilder Process (StreamReader reader, SymbolManager symbolManager)
{
List<StackFrameData> stackFrames = new List<StackFrameData>();
List<StackTraceMetadata> metadata = new List<StackTraceMetadata>();
StringBuilder sb = new StringBuilder ();
bool linesEnded = false;
for (var line = reader.ReadLine (); line != null; line = reader.ReadLine ()) {
StackFrameData sfData;
if (!linesEnded && StackFrameData.TryParse (line, out sfData)) {
stackFrames.Add (sfData);
continue;
}
if (stackFrames.Count > 0) {
linesEnded = true;
StackTraceMetadata stMetadata;
if (StackTraceMetadata.TryParse (line, out stMetadata)) {
metadata.Add (stMetadata);
continue;
}
DumpStackTrace (symbolManager, sb, stackFrames, metadata);
// Clear lists for next stack trace
stackFrames.Clear ();
metadata.Clear ();
}
linesEnded = false;
// Append last line
sb.AppendLine (line);
}
if (stackFrames.Count > 0)
DumpStackTrace (symbolManager, sb, stackFrames, metadata);
return sb;
}
private static void DumpStackTrace (SymbolManager symbolManager, StringBuilder sb, List<StackFrameData> stackFrames, List<StackTraceMetadata> metadata)
{
string aotid = null;
var aotidMetadata = metadata.FirstOrDefault ( m => m.Id == "AOTID" );
if (aotidMetadata != null)
aotid = aotidMetadata.Value;
var linesMvid = ProcessLinesMVID (metadata);
var lineNumber = -1;
foreach (var sfData in stackFrames) {
string mvid = null;
lineNumber++;
if (!sfData.IsValid)
continue;
if (linesMvid.ContainsKey (lineNumber))
mvid = linesMvid [lineNumber];
symbolManager.TryResolveLocation (sfData, mvid, aotid);
sb.AppendLine (sfData.ToString ());
}
foreach (var m in metadata)
sb.AppendLine (m.Line);
}
private static Dictionary<int, string> ProcessLinesMVID (List<StackTraceMetadata> metadata)
{
var linesMvid = new Dictionary<int, string> ();
var mvidData = metadata.Where ( m => m.Id == "MVID" ).Select ( m => m.Value );
foreach (var m in mvidData) {
var s1 = m.Split (new char[] {' '}, 2);
var mvid = s1 [0];
var lines = s1 [1].Split (',');
foreach (var line in lines)
linesMvid.Add (int.Parse (line), mvid);
}
return linesMvid;
}
}
}