Skip to content

Commit

Permalink
Show the handle value when logging on Linux
Browse files Browse the repository at this point in the history
When SafeHandles were implemented, the ToString() method now prints out only the type name, where before it was the actual pointer. Get the pointer value, just for logging purposes only.

Issue: DOTNET-172
  • Loading branch information
jcurl committed Nov 12, 2018
1 parent 11518d2 commit 7f240c0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions code/Native/UnixNativeSerial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal class UnixNativeSerial : INativeSerial
{
private INativeSerialDll m_Dll;
private SafeSerialHandle m_Handle;
private IntPtr m_HandlePtr;

public UnixNativeSerial()
{
Expand All @@ -26,6 +27,7 @@ public UnixNativeSerial()
if (m_Handle.IsInvalid) {
throw new PlatformNotSupportedException("Can't initialise platform library");
}
m_HandlePtr = m_Handle.DangerousGetHandle();

#if NETSTANDARD15
// On NetStandard 1.5, we must have proper exception handling
Expand Down Expand Up @@ -795,7 +797,7 @@ private unsafe void ReadWriteThread()
} else if (Log.SerialTrace(System.Diagnostics.TraceEventType.Verbose)) {
Log.Serial.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0,
"{0}: ReadWriteThread: serial_waitforevent({1}, {2}) == {3}",
m_Name, m_Handle, rwevent, result);
m_Name, m_HandlePtr, rwevent, result);
}

if ((result & SerialReadWriteEvent.ReadEvent) != 0) {
Expand All @@ -815,7 +817,7 @@ private unsafe void ReadWriteThread()
if (Log.SerialTrace(System.Diagnostics.TraceEventType.Verbose))
Log.Serial.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0,
"{0}: ReadWriteThread: serial_read({1}, {2}, {3}) == {4}",
m_Name, m_Handle, (IntPtr)bo, length, rresult);
m_Name, m_HandlePtr, (IntPtr)bo, length, rresult);
if (rresult > 0) m_Buffer.Serial.ReadBufferProduce(rresult);
}
}
Expand All @@ -839,7 +841,7 @@ private unsafe void ReadWriteThread()
if (Log.SerialTrace(System.Diagnostics.TraceEventType.Verbose))
Log.Serial.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0,
"{0}: ReadWriteThread: serial_write({1}, {2}, {3}) == {4}",
m_Name, m_Handle, (IntPtr)bo, length, wresult);
m_Name, m_HandlePtr, (IntPtr)bo, length, wresult);
if (wresult > 0) {
m_Buffer.Serial.WriteBufferConsume (wresult);
m_Buffer.Serial.TxEmptyEvent ();
Expand Down Expand Up @@ -876,7 +878,7 @@ private void InterruptReadWriteLoop()
if (Log.SerialTrace(System.Diagnostics.TraceEventType.Verbose))
Log.Serial.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0,
"{0}: ReadWriteThread: serial_abortwaitforevent({1}) = {2}",
m_Name, m_Handle, result);
m_Name, m_HandlePtr, result);
}
}
}
Expand Down

0 comments on commit 7f240c0

Please sign in to comment.