Example #1
0
 /// <summary>
 /// This 'cleans up' a symbol path.  In particular
 /// Empty ones are replaced with good defaults (symweb or msdl)
 /// All symbol server specs have local caches (%Temp%\symbols if nothing else is specified).  
 /// 
 /// Note that this routine does NOT update _NT_SYMBOL_PATH.  
 /// </summary>
 public static SymPath CleanSymbolPath()
 {
     string symPathStr = _NT_SYMBOL_PATH;
     if (symPathStr.Length == 0)
         symPathStr = MicrosoftSymbolServerPath;
     var symPath = new SymPath(symPathStr);
     return symPath.InsureHasCache(symPath.DefaultSymbolCache).CacheFirst();
 }
Example #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);
        }
Example #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);
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// This 'cleans up' a symbol path.  In particular
        /// Empty ones are replaced with good defaults (symweb or msdl)
        /// All symbol server specs have local caches (%Temp%\symbols if nothing else is specified).
        ///
        /// Note that this routine does NOT update _NT_SYMBOL_PATH.
        /// </summary>
        public static SymPath CleanSymbolPath()
        {
            string symPathStr = _NT_SYMBOL_PATH;

            if (symPathStr.Length == 0)
            {
                symPathStr = MicrosoftSymbolServerPath;
            }
            var symPath = new SymPath(symPathStr);

            return(symPath.InsureHasCache(symPath.DefaultSymbolCache).CacheFirst());
        }
Example #6
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);
        }
Example #7
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;
 }
Example #8
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;
 }
Example #9
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;
 }