Exemplo n.º 1
0
        /// <summary>
        /// Opens a new SymbolReader.   All diagnostics messages about symbol lookup go to 'log'.  
        /// </summary>
        public SymbolReader(TextWriter log, SymPath nt_symbol_path)
        {
            SymbolPath = 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 newSymPath = new SymPath();
            foreach (var symElem in SymbolPath.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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new symbol path which first search all machine local locations (either explicit location or symbol server cache locations)
        /// folloed by all non-local symbol server.   This produces better behavior (If you can find it locally it will be fast)
        /// </summary>
        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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Opens a new SymbolReader.   All diagnostics messages about symbol lookup go to 'log'.  
        /// </summary>
        public SymbolReader(TextWriter log, SymPath nt_symbol_path)
        {
            SymbolPath = 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 newSymPath = new SymPath();
            foreach (var symElem in SymbolPath.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._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
            );

            if (newSymPathStr != s_symPath)
                StaticInit(newSymPathStr);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Create a new symbol path which first search all machine local locations (either explicit location or symbol server cache locations)
 /// folloed by all non-local symbol server.   This produces better behavior (If you can find it locally it will be fast)
 /// </summary>
 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;
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
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;
 }