示例#1
0
        /// <summary>
        /// Creates a data target from an existing IDebugClient interface.  If you created and attached
        /// a dbgeng based debugger to a process you may pass the IDebugClient RCW object to this function
        /// to create the DataTarget.
        /// </summary>
        /// <param name="client">The dbgeng IDebugClient object.  We will query interface on this for IDebugClient.</param>
        /// <returns>A DataTarget instance.</returns>
        public static DataTarget CreateFromDebuggerInterface(IDebugClient client)
        {
            DbgEngDataReader reader     = new DbgEngDataReader(client);
            DataTargetImpl   dataTarget = new DataTargetImpl(reader, reader.DebuggerInterface);

            return(dataTarget);
        }
示例#2
0
 /// <summary>
 /// Creates a DataTarget from a crash dump, specifying the dump reader to use.
 /// </summary>
 /// <param name="fileName">The crash dump's filename.</param>
 /// <param name="dumpReader">The type of dump reader to use.</param>
 /// <returns>A DataTarget instance.</returns>
 public static DataTarget LoadCrashDump(string fileName, CrashDumpReader dumpReader)
 {
     if (dumpReader == CrashDumpReader.DbgEng)
     {
         DbgEngDataReader reader = new DbgEngDataReader(fileName);
         return(CreateFromReader(reader, reader.DebuggerInterface));
     }
     else
     {
         DumpDataReader reader = new DumpDataReader(fileName);
         return(CreateFromReader(reader, null));
     }
 }
示例#3
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);
        }
示例#4
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)
            {
                reader = new LiveDataReader(pid, false);
            }
            else
            {
                DbgEngDataReader dbgeng = new DbgEngDataReader(pid, attachFlag, msecTimeout);
                reader = dbgeng;
                client = dbgeng.DebuggerInterface;
            }

            DataTargetImpl dataTarget = new DataTargetImpl(reader, client);

            return(dataTarget);
        }
示例#5
0
        /// <summary>
        /// Creates a DataTarget from a crash dump.
        /// </summary>
        /// <param name="fileName">The crash dump's filename.</param>
        /// <returns>A DataTarget instance.</returns>
        public static DataTarget LoadCrashDump(string fileName)
        {
            DbgEngDataReader reader = new DbgEngDataReader(fileName);

            return(CreateFromReader(reader, reader.DebuggerInterface));
        }
示例#6
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)
        {
            Microsoft.Diagnostics.Runtime.Interop.IDebugClient client = null;
            IDataReader reader;
            if (attachFlag == AttachFlag.Passive)
            {
                reader = new LiveDataReader(pid);
            }
            else
            {
                var dbgeng = new DbgEngDataReader(pid, attachFlag, msecTimeout);
                reader = dbgeng;
                client = dbgeng.DebuggerInterface;
            }

            DataTargetImpl dataTarget = new DataTargetImpl(reader, client);
            return dataTarget;
        }
示例#7
0
        /// <summary>
        /// Creates a data target from an existing IDebugClient interface.  If you created and attached
        /// a dbgeng based debugger to a process you may pass the IDebugClient RCW object to this function
        /// to create the DataTarget.
        /// </summary>
        /// <param name="client">The dbgeng IDebugClient object.  We will query interface on this for IDebugClient.</param>
        /// <returns>A DataTarget instance.</returns>
        public static DataTarget CreateFromDebuggerInterface(Microsoft.Diagnostics.Runtime.Interop.IDebugClient client)
        {
            DbgEngDataReader reader = new DbgEngDataReader(client);
            DataTargetImpl dataTarget = new DataTargetImpl(reader, reader.DebuggerInterface);

            return dataTarget;
        }
示例#8
0
 /// <summary>
 /// Creates a DataTarget from a crash dump, specifying the dump reader to use.
 /// </summary>
 /// <param name="fileName">The crash dump's filename.</param>
 /// <param name="dumpReader">The type of dump reader to use.</param>
 /// <returns>A DataTarget instance.</returns>
 public static DataTarget LoadCrashDump(string fileName, CrashDumpReader dumpReader)
 {
     if (dumpReader == CrashDumpReader.DbgEng)
     {
         DbgEngDataReader reader = new DbgEngDataReader(fileName);
         return CreateFromReader(reader, reader.DebuggerInterface);
     }
     else
     {
         DumpDataReader reader = new DumpDataReader(fileName);
         return CreateFromReader(reader, null);
     }
 }
示例#9
0
 /// <summary>
 /// Creates a DataTarget from a crash dump.
 /// </summary>
 /// <param name="fileName">The crash dump's filename.</param>
 /// <returns>A DataTarget instance.</returns>
 public static DataTarget LoadCrashDump(string fileName)
 {
     DbgEngDataReader reader = new DbgEngDataReader(fileName);
     return CreateFromReader(reader, reader.DebuggerInterface);
 }