コード例 #1
0
        public async Task LoadSymbols_NullSymbolFileSpecAsync()
        {
            var mockModule = CreateMockModule();

            mockModule.GetSymbolFileSpec().Returns((SbFileSpec)null);
            mockBinaryFileUtil
            .ReadSymbolFileNameAsync(Path.Combine(BINARY_DIRECTORY, BINARY_FILENAME))
            .Returns(SYMBOL_FILE_NAME);

            Assert.IsTrue(await symbolLoader.LoadSymbolsAsync(mockModule, searchLog, true));
        }
コード例 #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);
        }