Пример #1
0
        /// <summary>
        /// Opens a new SymbolReader.   All diagnostics messages about symbol lookup go to 'log'.  
        /// </summary>
        public SymbolReader(TextWriter log, string nt_symbol_path = null)
        {
            SymbolPath = nt_symbol_path;
            if (SymbolPath == null)
                SymbolPath = SymPath._NT_SYMBOL_PATH;
            log.WriteLine("Created SymbolReader with SymbolPath {0}", nt_symbol_path);

            // TODO FIX NOW.  the code below does not support probing a file extension directory.  
            // we work around this by adding more things to the symbol path
            var symPath = new SymPath(SymbolPath);
            var newSymPath = new SymPath();
            foreach (var symElem in symPath.Elements)
            {
                newSymPath.Add(symElem);
                if (!symElem.IsSymServer)
                {
                    var probe = Path.Combine(symElem.Target, "dll");
                    if (Directory.Exists(probe))
                        newSymPath.Add(probe);
                    probe = Path.Combine(symElem.Target, "exe");
                    if (Directory.Exists(probe))
                        newSymPath.Add(probe);
                }
            }
            var newSymPathStr = newSymPath.ToString();
            // log.WriteLine("Morphed Symbol Path: {0}", newSymPathStr);

            this.m_log = log;

            SymbolReaderNativeMethods.SymOptions options = SymbolReaderNativeMethods.SymGetOptions();
            SymbolReaderNativeMethods.SymSetOptions(
            SymbolReaderNativeMethods.SymOptions.SYMOPT_DEBUG |
                // SymbolReaderNativeMethods.SymOptions.SYMOPT_DEFERRED_LOADS |
            SymbolReaderNativeMethods.SymOptions.SYMOPT_LOAD_LINES |
            SymbolReaderNativeMethods.SymOptions.SYMOPT_EXACT_SYMBOLS |
            SymbolReaderNativeMethods.SymOptions.SYMOPT_UNDNAME
            );

            m_currentProcess = Process.GetCurrentProcess();  // Only here to insure processHandle does not die.  TODO get on safeHandles. 
            m_currentProcessHandle = m_currentProcess.Handle;

            bool success = SymbolReaderNativeMethods.SymInitializeW(m_currentProcessHandle, newSymPathStr, false);
            if (!success)
            {
                // This captures the GetLastEvent (and has to happen before calling CloseHandle()
                m_currentProcessHandle = IntPtr.Zero;
                throw new Win32Exception();
            }
            m_callback = new SymbolReaderNativeMethods.SymRegisterCallbackProc(this.StatusCallback);
            success = SymbolReaderNativeMethods.SymRegisterCallbackW64(m_currentProcessHandle, m_callback, 0);

            Debug.Assert(success);
        }
Пример #2
0
        /// <summary>
        /// Removes all references to remote paths.  This insures that network issues don't cause grief.
        /// </summary>
        public SymPath LocalOnly()
        {
            var ret = new SymPath();

            foreach (var elem in Elements)
            {
                ret.Add(elem.LocalOnly());
            }
            return(ret);
        }
Пример #3
0
        /// <summary>
        /// People can use symbol servers without a local cache.  This is bad, add one if necessary.
        /// </summary>
        public SymPath InsureHasCache(string defaultCachePath)
        {
            var ret = new SymPath();

            foreach (var elem in Elements)
            {
                ret.Add(elem.InsureHasCache(defaultCachePath));
            }
            return(ret);
        }
Пример #4
0
        public SymPath CacheFirst()
        {
            var ret = new SymPath();

            foreach (var elem in Elements)
            {
                if (elem.IsSymServer && elem.IsRemote)
                {
                    continue;
                }
                ret.Add(elem);
            }
            foreach (var elem in Elements)
            {
                if (elem.IsSymServer && elem.IsRemote)
                {
                    ret.Add(elem);
                }
            }
            return(ret);
        }
Пример #5
0
 public SymPath CacheFirst()
 {
     var ret = new SymPath();
     foreach (var elem in Elements)
     {
         if (elem.IsSymServer && elem.IsRemote)
             continue;
         ret.Add(elem);
     }
     foreach (var elem in Elements)
     {
         if (elem.IsSymServer && elem.IsRemote)
             ret.Add(elem);
     }
     return ret;
 }
Пример #6
0
 /// <summary>
 /// Removes all references to remote paths.  This insures that network issues don't cause grief.  
 /// </summary>
 public SymPath LocalOnly()
 {
     var ret = new SymPath();
     foreach (var elem in Elements)
         ret.Add(elem.LocalOnly());
     return ret;
 }
Пример #7
0
 /// <summary>
 /// People can use symbol servers without a local cache.  This is bad, add one if necessary. 
 /// </summary>
 public SymPath InsureHasCache(string defaultCachePath)
 {
     var ret = new SymPath();
     foreach (var elem in Elements)
         ret.Add(elem.InsureHasCache(defaultCachePath));
     return ret;
 }