private void CanResolveStacktraces(string abi)
    {
        if (!AndroidBridge.AndroidExtensionsInstalled)
        {
            System.Console.WriteLine("Test ignored, because Android Support is not installed");
            return;
        }

        if (!AndroidLogcatTestsSetup.AndroidSDKAndNDKAvailable())
        {
            System.Console.WriteLine("Test ignored");
            return;
        }
        var          tools      = new AndroidTools();
        const string symbolName = "JNI_OnLoad";

        var expectedOutput = symbolName + " at ??:?";
        var symbolPath     = GetSymbolPath(abi, "libmain.so");
        var targetAddress  = GetSymbolAddress(tools, symbolPath, symbolName);

        Assert.IsNotEmpty(targetAddress, "Failed to find address for " + symbolName);
        var resolvedSymbols = tools.RunAddr2Line(symbolPath, new[] { targetAddress });

        Assert.IsTrue(resolvedSymbols.Length == 1, "Expected to resolve one symbol");
        Assert.AreEqual(expectedOutput, resolvedSymbols[0],
                        string.Format("Failed to resolve symbol '{0}' for address '{1}'", symbolName, targetAddress));
    }
Esempio n. 2
0
    private void CanResolveStacktraces(string abi)
    {
        if (!AndroidLogcatTestsSetup.AndroidSDKAndNDKAvailable())
        {
            System.Console.WriteLine("Test ignored");
            return;
        }
        var          tools          = new AndroidTools();
        const string symbolName     = "JNI_OnLoad";
        var          playerPackage  = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.Android, BuildOptions.None);
        var          expectedOutput = symbolName + " at ??:?";
        var          symbolPath     = Path.GetFullPath(Path.Combine(playerPackage, "Variations/il2cpp/Development/Symbols/" + abi + "/libmain.sym.so"));

#if UNITY_2019_3_OR_NEWER
        var targetAddress = GetSymbolAddressUsingNM(tools, symbolPath, symbolName);
#else
        var targetAddress = GetSymbolAddressUsingReadElf(tools, symbolPath, symbolName);
#endif

        Assert.IsNotEmpty(targetAddress, "Failed to find address for " + symbolName);
        var resolvedSymbols = tools.RunAddr2Line(symbolPath, new[] { targetAddress });
        Assert.IsTrue(resolvedSymbols.Length == 1, "Expected to resolve one symbol");
        Assert.AreEqual(expectedOutput, resolvedSymbols[0],
                        string.Format("Failed to resolve symbol '{0}' for address '{1}'", symbolName, targetAddress));
    }
    public void CanCorrectlyPickSymbol()
    {
        if (!AndroidBridge.AndroidExtensionsInstalled)
        {
            System.Console.WriteLine("Test ignored, because Android Support is not installed");
            return;
        }

        if (!AndroidLogcatTestsSetup.AndroidSDKAndNDKAvailable())
        {
            System.Console.WriteLine("Test ignored, SDK & NDK are not available.");
            return;
        }

        var tools            = new AndroidTools();
        var playerPackage    = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.Android, BuildOptions.None);
        var symbolsDirectory = Path.Combine(playerPackage, $"Variations/il2cpp/Development/Symbols");
        var symbolPaths      = new List <ReordableListItem>(new[] { new ReordableListItem()
                                                                    {
                                                                        Enabled = true, Name = symbolsDirectory
                                                                    } });
        var symbolPathsArmV7 = new List <ReordableListItem>(new[] { new ReordableListItem()
                                                                    {
                                                                        Enabled = true, Name = Path.Combine(symbolsDirectory, AndroidLogcatUtilities.kAbiArmV7)
                                                                    } });
        var symbolPathsArm64 = new List <ReordableListItem>(new[] { new ReordableListItem()
                                                                    {
                                                                        Enabled = true, Name = Path.Combine(symbolsDirectory, AndroidLogcatUtilities.kAbiArm64)
                                                                    } });
        var libunity = "libunity";

        AssertStringContains(libunity, AndroidLogcatUtilities.GetSymbolFile(symbolPathsArmV7, string.Empty, libunity + ".so"));
        AssertStringContains(libunity, AndroidLogcatUtilities.GetSymbolFile(symbolPathsArm64, string.Empty, libunity + ".so"));
        // Since ABI is empty, we cannot resolve symbol path, thus the result will be empty
        Assert.AreEqual(string.Empty, AndroidLogcatUtilities.GetSymbolFile(symbolPaths, string.Empty, libunity + ".so"));

        var armv7Result = AndroidLogcatUtilities.GetSymbolFile(symbolPaths, AndroidLogcatUtilities.kAbiArmV7, libunity + ".so");

        AssertStringContains(libunity, armv7Result);
        AssertStringContains(AndroidLogcatUtilities.kAbiArmV7, armv7Result);

        var arm64Result = AndroidLogcatUtilities.GetSymbolFile(symbolPaths, AndroidLogcatUtilities.kAbiArm64, libunity + ".so");

        AssertStringContains(libunity, arm64Result);
        AssertStringContains(AndroidLogcatUtilities.kAbiArm64, arm64Result);
    }