Esempio n. 1
0
 public void Load(string filename, Target target)
 {
     using (var reader = new StreamReader(filename)) {
         string line;
         Symbol current = null;
         while ((line = reader.ReadLine()) != null)
         {
             if (line.Length == 0)
             {
                 continue;
             }
             if (line [0] == '\t')
             {
                 var      asm = line.Substring(1);
                 Assembly assembly;
                 if (!target.Assemblies.TryGetValue(Assembly.GetIdentity(asm), out assembly))
                 {
                     throw ErrorHelper.CreateError(99, $"Internal error: serialized assembly {asm} for symbol {current.Name}, but no such assembly loaded. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new).");
                 }
                 current.AddAssembly(assembly.AssemblyDefinition);
             }
             else
             {
                 var eq      = line.IndexOf('=');
                 var typestr = line.Substring(0, eq);
                 var name    = line.Substring(eq + 1);
                 current = new Symbol {
                     Name = name, Type = (SymbolType)Enum.Parse(typeof(SymbolType), typestr)
                 };
                 Add(current);
             }
         }
     }
 }
Esempio n. 2
0
        public static IList <string> GetAotArguments(Application app, string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile)
        {
            string fname                = Path.GetFileName(filename);
            var    args                 = new List <string> ();
            bool   enable_llvm          = (abi & Abi.LLVM) != 0;
            bool   enable_thumb         = (abi & Abi.Thumb) != 0;
            bool   enable_debug         = app.EnableDebug;
            bool   enable_debug_symbols = app.PackageManagedDebugSymbols;
            bool   llvm_only            = app.EnableLLVMOnlyBitCode;
            bool   interp               = app.IsInterpreted(Assembly.GetIdentity(filename));
            bool   interp_full          = !interp && app.UseInterpreter;
            bool   is32bit              = (abi & Abi.Arch32Mask) > 0;
            string arch                 = abi.AsArchString();

            args.Add("--debug");

            if (enable_llvm)
            {
                args.Add("--llvm");
            }

            if (!llvm_only && !interp)
            {
                args.Add("-O=gsharedvt");
            }
            if (app.AotOtherArguments != null)
            {
                args.AddRange(app.AotOtherArguments);
            }
            var aot = new StringBuilder();

            aot.Append("--aot=mtriple=");
            aot.Append(enable_thumb ? arch.Replace("arm", "thumb") : arch);
            aot.Append("-ios,");
            aot.Append("data-outfile=").Append(dataFile).Append(",");
            aot.Append(app.AotArguments);
            if (llvm_only)
            {
                aot.Append("llvmonly,");
            }
            else if (interp)
            {
                if (fname != "mscorlib.dll")
                {
                    throw ErrorHelper.CreateError(99, Errors.MX0099, fname);
                }
                aot.Append("interp,");
            }
            else if (interp_full)
            {
                aot.Append("interp,full,");
            }
            else
            {
                aot.Append("full,");
            }

            var aname          = Path.GetFileNameWithoutExtension(fname);
            var sdk_or_product = Profile.IsSdkAssembly(aname) || Profile.IsProductAssembly(aname);

            if (enable_llvm)
            {
                aot.Append("nodebug,");
            }
            else if (!(enable_debug || enable_debug_symbols))
            {
                aot.Append("nodebug,");
            }
            else if (app.DebugAll || app.DebugAssemblies.Contains(fname) || !sdk_or_product)
            {
                aot.Append("soft-debug,");
            }

            aot.Append("dwarfdebug,");

            /* Needed for #4587 */
            if (enable_debug && !enable_llvm)
            {
                aot.Append("no-direct-calls,");
            }

            if (!app.UseDlsym(filename))
            {
                aot.Append("direct-pinvoke,");
            }

            if (app.EnableMSym)
            {
                var msymdir = Path.Combine(outputDir, "Msym");
                aot.Append($"msym-dir={msymdir},");
            }

            if (enable_llvm)
            {
                aot.Append("llvm-path=").Append(GetFrameworkCurrentDirectory(app)).Append("/LLVM/bin/,");
            }

            aot.Append("outfile=").Append(outputFile);
            if (enable_llvm)
            {
                aot.Append(",llvm-outfile=").Append(llvmOutputFile);
            }
            args.Add(aot.ToString());
            args.Add(filename);
            return(args);
        }