Beispiel #1
0
 public Location(PProfProto.Location item, PProfInfo.Mapping mappingInfo, PProfInfo.Function functionInfo)
     : this(item, mappingInfo, new PProfInfo.Function[1] {
     functionInfo
 })
 {
     Validate.NotNull(functionInfo, nameof(functionInfo));
 }
Beispiel #2
0
        public PProfInfo.Function GetOrCreateFunctionInfo(string moniker, string name, string systemName)
        {
            Validate.NotNull(moniker, nameof(moniker));
            Validate.NotNull(name, nameof(name));
            // systemName may be null

            if (!_functions.TryGetValue(moniker, out PProfInfo.Function functionInfo))
            {
                functionInfo = new PProfInfo.Function(
                    new PProfProto.Function()
                {
                    Id         = NextIdForFunction(),
                    Name       = ProtoConstants.StringTableIndex.Unresolved,
                    SystemName = string.IsNullOrEmpty(systemName)
                                                    ? ProtoConstants.StringTableIndex.Unset
                                                    : ProtoConstants.StringTableIndex.Unresolved,
                    Filename  = ProtoConstants.StringTableIndex.Unset,
                    StartLine = ProtoConstants.NumericValue.UnsetInt64,
                },
                    GetOrCreateStringInfo(name),
                    string.IsNullOrEmpty(systemName) ? null : GetOrCreateStringInfo(systemName),
                    filenameInfo: null);

                _functions.Add(moniker, functionInfo);
            }

            return(functionInfo);
        }
Beispiel #3
0
 public PProfInfo.Location GetOrCreateLocationInfo(
     LocationDescriptor locationDescriptor,
     PProfInfo.Mapping mappingInfo,
     PProfInfo.Function functionInfo)
 {
     return(GetOrCreateLocationInfo(locationDescriptor, mappingInfo, new PProfInfo.Function[1] {
         functionInfo
     }));
 }
Beispiel #4
0
        private void AddToFunctionsList(PProfInfo.Function functionInfo)
        {
            if (functionInfo != null && !functionInfo.IsIncludedInSession)
            {
                PProfBuildSessionState buildState = ValidOwnerBuildState;
                functionInfo.IsIncludedInSession = true;
                buildState.Functions.Add(functionInfo);

                _profile.Function.Add(functionInfo.Item);
            }
        }
Beispiel #5
0
        internal bool TryGetOrResolveCreatePProfLocationInfo(
            LocationDescriptor locationDescriptor,
            PProfBuildSession pprofBuildSession,
            TryResolveLocationSymbolsDelegate tryResolveLocationSymbolsDelegate,
            out PProfInfo.Location locationInfo)
        {
            if (_cache.TryGetLocationInfo(locationDescriptor, out locationInfo))
            {
                return(true);
            }

            if (
                tryResolveLocationSymbolsDelegate == null ||
                !tryResolveLocationSymbolsDelegate(
                    pprofBuildSession,
                    locationDescriptor,
                    out string functionName,
                    out string classTypeName,
                    out string binaryContainerName,
                    out string binaryContainerVersion))
            {
                locationInfo = null;
                return(false);
            }

            BuildMonikers(
                ref functionName,
                ref classTypeName,
                ref binaryContainerName,
                ref binaryContainerVersion,
                out string functionMoniker,
                out string binaryContainerMoniker);

            // system name is not used so pass null (i.e. empty string)
            PProfInfo.Function functionInfo = _cache.GetOrCreateFunctionInfo(functionMoniker, functionMoniker, null);
            PProfInfo.Mapping  mappingInfo  = _cache.GetOrCreateMappingInfo(binaryContainerMoniker, binaryContainerName, binaryContainerVersion);
            locationInfo = _cache.GetOrCreateLocationInfo(locationDescriptor, mappingInfo, functionInfo);

            return(true);
        }
Beispiel #6
0
        public bool TryAddLocationToLastSample(
            LocationDescriptor locationDescriptor,
            PProfBuilder.TryResolveLocationSymbolsDelegate tryResolveLocationSymbolsDelegate)
        {
            if (!OwnerBuilder.TryGetOrResolveCreatePProfLocationInfo(
                    locationDescriptor,
                    this,
                    tryResolveLocationSymbolsDelegate,
                    out PProfInfo.Location locationInfo))
            {
                return(false);
            }

            // Functions:
            for (int i = 0; i < locationInfo.FunctionInfos.Count; i++)
            {
                PProfInfo.Function functionInfo = locationInfo.FunctionInfos[0];

                if (functionInfo.NameInfo != null)
                {
                    AddToStringTable(functionInfo.NameInfo);
                    functionInfo.Item.Name = functionInfo.NameInfo.OffsetInStringTable;
                }

                if (functionInfo.SystemNameInfo != null)
                {
                    AddToStringTable(functionInfo.SystemNameInfo);
                    functionInfo.Item.SystemName = functionInfo.SystemNameInfo.OffsetInStringTable;
                }

                if (functionInfo.FilenameInfo != null)
                {
                    AddToStringTable(functionInfo.FilenameInfo);
                    functionInfo.Item.Filename = functionInfo.FilenameInfo.OffsetInStringTable;
                }

                AddToFunctionsList(functionInfo);
            }

            // Mapping:
            PProfInfo.Mapping mappingInfo = locationInfo.MappingInfo;

            if (mappingInfo.FilenameInfo != null)
            {
                AddToStringTable(mappingInfo.FilenameInfo);
                mappingInfo.Item.Filename = mappingInfo.FilenameInfo.OffsetInStringTable;
            }

            if (mappingInfo.BuildIdInfo != null)
            {
                AddToStringTable(mappingInfo.BuildIdInfo);
                mappingInfo.Item.BuildId = mappingInfo.BuildIdInfo.OffsetInStringTable;
            }

            AddToMappingsList(mappingInfo);

            // Location:
            AddToLocationsList(locationInfo);

            // Sample:
            _lastSample.LocationId.Add(locationInfo.Item.Id);

            return(true);
        }
Beispiel #7
0
        public void ResetSession()
        {
            // Clear Locations:
            {
                var list      = _locations;
                int itemCount = list.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    PProfInfo.Location pprofInfo = list[i];
                    pprofInfo.IsIncludedInSession = false;
                }

                list.Clear();
            }

            // Clear Mappings:
            {
                var list      = _mappings;
                int itemCount = list.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    PProfInfo.Mapping pprofInfo = list[i];
                    pprofInfo.IsIncludedInSession = false;
                    pprofInfo.Item.Filename       = ProtoConstants.StringTableIndex.GetUnresolvedIfSet(pprofInfo.Item.Filename);
                    pprofInfo.Item.BuildId        = ProtoConstants.StringTableIndex.GetUnresolvedIfSet(pprofInfo.Item.BuildId);
                }

                list.Clear();
            }

            // Clear Functions:
            {
                var list      = _functions;
                int itemCount = list.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    PProfInfo.Function pprofInfo = list[i];
                    pprofInfo.IsIncludedInSession = false;
                    pprofInfo.Item.Name           = ProtoConstants.StringTableIndex.GetUnresolvedIfSet(pprofInfo.Item.Name);
                    pprofInfo.Item.SystemName     = ProtoConstants.StringTableIndex.GetUnresolvedIfSet(pprofInfo.Item.SystemName);
                    pprofInfo.Item.Filename       = ProtoConstants.StringTableIndex.GetUnresolvedIfSet(pprofInfo.Item.Filename);
                }

                list.Clear();
            }

            // Clear the String Table:
            {
                var list      = _stringTable;
                int itemCount = list.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    list[i].ResetOffsetInStringTable();
                }

                list.Clear();
            }

            // Finally, clear the Session:
            _currentSession = null;
        }