[PATCH 1/2] ntdll: Add +microsecs channel for precise timestamps.

Rémi Bernon rbernon at codeweavers.com
Tue Nov 17 04:57:15 CST 2020


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

I think these can be useful for profiling / debugging. The client-side
request tracking may seem a bit redundant with the +server channel.

I however think that knowing in which functions the requests were made,
as well as the time they took from the client perspective can greatly
help debugging, especially in high load situations where the server is
busy and doesn't read the requests fast enough.

 dlls/ntdll/unix/debug.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/unix/debug.c b/dlls/ntdll/unix/debug.c
index 368baac46f4..2fd4c435ddf 100644
--- a/dlls/ntdll/unix/debug.c
+++ b/dlls/ntdll/unix/debug.c
@@ -42,6 +42,7 @@
 
 WINE_DECLARE_DEBUG_CHANNEL(pid);
 WINE_DECLARE_DEBUG_CHANNEL(timestamp);
+WINE_DECLARE_DEBUG_CHANNEL(microsecs);
 
 static BOOL init_done;
 static struct debug_info initial_info;  /* debug info for initial thread */
@@ -272,7 +273,14 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_
 
     if (init_done)
     {
-        if (TRACE_ON(timestamp))
+        if (TRACE_ON(microsecs))
+        {
+            LARGE_INTEGER counter, frequency, microsecs;
+            NtQueryPerformanceCounter(&counter, &frequency);
+            microsecs.QuadPart = counter.QuadPart * 1000000 / frequency.QuadPart;
+            pos += sprintf( pos, "%3u.%06u:", (unsigned int)(microsecs.QuadPart / 1000000), (unsigned int)(microsecs.QuadPart % 1000000) );
+        }
+        else if (TRACE_ON(timestamp))
         {
             ULONG ticks = NtGetTickCount();
             pos += sprintf( pos, "%3u.%03u:", ticks / 1000, ticks % 1000 );
-- 
2.29.2




More information about the wine-devel mailing list