コード例 #1
0
        public async Task LoadSymbols_SymbolFileCustomDirSuccessAsync(bool useSymbolStores)
        {
            string customFileName  = "x.debug";
            string customFileDir   = @"C:\custom";
            string expectedCommand =
                "target symbols add -s \"/path/bin/test\" \"C:\\\\custom\\\\x.debug\"";

            var mockModule = CreateMockModule();

            mockModule.GetSymbolFileSpec().Returns(mockBinaryFileSpec);
            mockBinaryFileUtil
            .ReadSymbolFileNameAsync(Path.Combine(BINARY_DIRECTORY, BINARY_FILENAME))
            .Returns(customFileName);
            mockBinaryFileUtil
            .ReadSymbolFileDirAsync(Path.Combine(BINARY_DIRECTORY, BINARY_FILENAME))
            .Returns(customFileDir);
            mockBinaryFileUtil.ReadBuildIdAsync(Path.Combine(customFileDir, customFileName))
            .Returns(UUID);

            SetHandleCommandReturnValue(mockCommandInterpreter, expectedCommand,
                                        ReturnStatus.SuccessFinishResult,
                                        mockSuccessCommandReturnObject);

            Assert.IsTrue(
                await symbolLoader.LoadSymbolsAsync(mockModule, searchLog, useSymbolStores));
        }
コード例 #2
0
ファイル: SymbolLoader.cs プロジェクト: googlestadia/vsi-lldb
        async Task <(string, string)> GetSymbolFileDirAndNameAsync(
            SbModule lldbModule, TextWriter log)
        {
            var symbolFileSpec      = lldbModule.GetSymbolFileSpec();
            var symbolFileDirectory = symbolFileSpec?.GetDirectory();
            var symbolFileName      = symbolFileSpec?.GetFilename();

            var binaryFileSpec  = lldbModule.GetFileSpec();
            var binaryDirectory = binaryFileSpec?.GetDirectory();
            var binaryFilename  = binaryFileSpec?.GetFilename();

            // If there is no path to the binary, there is nothing we can do.
            if (string.IsNullOrEmpty(binaryDirectory) || string.IsNullOrEmpty(binaryFilename))
            {
                return(symbolFileDirectory, symbolFileName);
            }

            // When lldb can't find the symbol file, it sets the symbol file spec to the path of
            // the binary file. If the file name or path is different, we just return the filename
            // (if it is not empty).
            if (!string.IsNullOrEmpty(symbolFileName) &&
                (symbolFileDirectory != binaryDirectory || symbolFileName != binaryFilename))
            {
                return(symbolFileDirectory, symbolFileName);
            }

            symbolFileDirectory = null;
            symbolFileName      = null;

            // Let us look up the symbol file name and directory in the binary.
            string binaryPath;

            try
            {
                binaryPath = Path.Combine(binaryDirectory, binaryFilename);
            }
            catch (ArgumentException e)
            {
                var errorString = ErrorStrings.InvalidBinaryPathOrName(binaryDirectory,
                                                                       binaryFilename, e.Message);
                Trace.WriteLine(errorString);
                await log.WriteLineAsync(errorString);

                return(null, null);
            }

            // Read the symbol file name from the binary.
            try
            {
                symbolFileName = await binaryFileUtil.ReadSymbolFileNameAsync(binaryPath);
            }
            catch (BinaryFileUtilException e)
            {
                Trace.WriteLine(e.ToString());
                await log.WriteLineAsync(e.Message);

                return(null, null);
            }

            // Try to read the debug info directory.
            try
            {
                symbolFileDirectory = await binaryFileUtil.ReadSymbolFileDirAsync(binaryPath);
            }
            catch (BinaryFileUtilException e)
            {
                // Just log the message (the directory section is optional).
                Trace.WriteLine(e.Message);
                await log.WriteLineAsync(e.Message);
            }

            return(symbolFileDirectory, symbolFileName);
        }