Beispiel #1
0
        /// <summary>
        /// Attaches to a live process.
        /// </summary>
        /// <param name="pid">The process ID of the process to attach to.</param>
        /// <param name="msecTimeout">Timeout in milliseconds.</param>
        /// <param name="attachFlag">The type of attach requested for the target process.</param>
        /// <returns>A DataTarget instance.</returns>
        public static DataTarget AttachToProcess(int pid, uint msecTimeout, AttachFlag attachFlag)
        {
            IDebugClient client = null;
            IDataReader  reader;

            if (attachFlag == AttachFlag.Passive)
            {
#if NET45
                reader = new LiveDataReader(pid, false);
#else
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    reader = new LiveDataReader(pid, false);
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    reader = new Linux.LinuxLiveDataReader((uint)pid);
                }
                else
                {
                    throw new NotSupportedException("Passive attach is not supported on OSX.s");
                }
#endif
            }
            else
            {
#if !NET45
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    throw new PlatformNotSupportedException("Currently only AttachFlag.Passive is supported for AttachToProcess");
                }
#endif

                DbgEngDataReader dbgeng = new DbgEngDataReader(pid, attachFlag, msecTimeout);
                reader = dbgeng;
                client = dbgeng.DebuggerInterface;
            }

            DataTargetImpl dataTarget = new DataTargetImpl(reader, client);
#if !NET45
            if (reader is Linux.LinuxLiveDataReader)
            {
                // TODO: discuss this design of
                // 1) add a method to IDataReader2 to return the list of module full path
                // 2) make DefaultSymbolLocator use that list as hint to load binaries
                dataTarget.SymbolLocator = new Linux.LinuxDefaultSymbolLocator(((Linux.LinuxLiveDataReader)reader).GetModulesFullPath());
            }
#endif
            return(dataTarget);
        }
Beispiel #2
0
 public MemoryVirtualAddressSpace(LinuxLiveDataReader dataReader)
 {
     _dataReader = dataReader;
 }