[Tizen] Search symbol directories recursively (#27)
authorSangwook Kim <swift.kim@samsung.com>
Wed, 22 Apr 2020 09:01:00 +0000 (18:01 +0900)
committerMikhail Kurinnoi <m.kurinnoi@samsung.com>
Tue, 5 Dec 2023 16:31:16 +0000 (19:31 +0300)
The SOS command 'setsymbolserver -directory' will automatically search
all subdirectories of the specified directory.

src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs

index 4b5ad2b9ba7fdd5aeed469a1a1020d49f0ea6e27..d0abb2da08539e140d6cbecf544d8c039647202a 100644 (file)
@@ -4,6 +4,7 @@
 using System;
 using System.Collections.Generic;
 using System.Collections.Immutable;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
@@ -339,9 +340,20 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
             SymbolStore.SymbolStores.SymbolStore store = _symbolStore;
             symbolDirectoryPath = Path.GetFullPath(symbolDirectoryPath);
 
-            if (!IsDuplicateSymbolStore<DirectorySymbolStore>(store, (directorySymbolStore) => IsPathEqual(symbolDirectoryPath, directorySymbolStore.Directory)))
+            var probingPaths = new List<string> { symbolDirectoryPath };
+            if (Directory.Exists(symbolDirectoryPath))
+            {
+                // Add all subdirectories.
+                probingPaths.AddRange(Directory.GetDirectories(symbolDirectoryPath, "*", SearchOption.AllDirectories));
+            }
+            // Make sure the root directory is enumerated last so that it comes first in the fallback tree.
+            foreach (var path in Enumerable.Reverse(probingPaths))
             {
-                SetSymbolStore(new DirectorySymbolStore(Tracer.Instance, store, symbolDirectoryPath));
+                if (!IsDuplicateSymbolStore<DirectorySymbolStore>(store, (directorySymbolStore) => IsPathEqual(path, directorySymbolStore.Directory)))
+                {
+                    SetSymbolStore(new DirectorySymbolStore(Tracer.Instance, store, symbolDirectoryPath));
+                    store = _symbolStore;
+                }
             }
         }