Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/debugger-libs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mikkrg@microsoft.com>2022-06-30 10:50:59 +0300
committerMike Krüger <mikkrg@microsoft.com>2022-06-30 10:50:59 +0300
commit7bda4714d11e86bd878f446b3d484c592d9324f2 (patch)
tree571da9ab14cb425f39cb817e0d6c12a0c0adeb0d
parent64fddf5f3d757cbc4efb655be6130a152352bf89 (diff)
Implemented simpler approach to resolve paths.
Benchmarked both variants they've the same performance.
-rw-r--r--Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs59
1 files changed, 9 insertions, 50 deletions
diff --git a/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs b/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs
index 1994ade..79ab670 100644
--- a/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs
+++ b/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs
@@ -469,55 +469,8 @@ namespace Mono.Debugging.Client
OnBreakEventsAdded (loadedBreakpoints);
}
-
- sealed class LinkResolver
- {
- const int PATHMAX = 4096 + 1;
- const int MAX_BUFFERS = 42;
-
- [DllImport("libc")]
- static extern IntPtr realpath(string path, IntPtr buffer);
-
- public static string ResolveLinks(string path)
- {
- // If there is no path given, return the same path back
- if (string.IsNullOrEmpty (path))
- return path;
- var buffer = GetBuffer();
- try
- {
- var result = realpath(path, buffer);
- return result == IntPtr.Zero ? Path.GetFullPath(path) : Marshal.PtrToStringAuto(buffer);
- }
- finally
- {
- Release(buffer);
- }
- }
-
- static ConcurrentStack<IntPtr> s_bufferStack = new ConcurrentStack<IntPtr>();
-
- static IntPtr GetBuffer()
- {
- if (!s_bufferStack.TryPop(out var result))
- {
- result = Marshal.AllocHGlobal(PATHMAX);
- }
- return result;
- }
-
- static void Release(IntPtr buffer)
- {
- if (s_bufferStack.Count >= MAX_BUFFERS)
- {
- if (buffer != IntPtr.Zero)
- Marshal.FreeHGlobal(buffer);
- return;
- }
- if (buffer != IntPtr.Zero)
- s_bufferStack.Push(buffer);
- }
- }
+ [DllImport("libc")]
+ static extern string realpath(string path, IntPtr buffer);
/// <summary>
/// Resolves the full path of the given file
@@ -526,7 +479,13 @@ namespace Mono.Debugging.Client
/// <returns>The full path if a file is given, or returns the parameter if it is null or empty</returns>
static string ResolveFullPath (string path)
{
- return LinkResolver.ResolveLinks(path);
+ // If there is no path given, return the same path back
+ if (string.IsNullOrEmpty(path))
+ return path;
+ var result = realpath(path, IntPtr.Zero);
+ if (result == null)
+ return Path.GetFullPath(path);
+ return result;
}
public static bool FileNameEquals (string file1, string file2)