Debug.Trace should not use %s for format string
The current implementation of traceIO in Debug.Trace is as follows:
```
traceIO :: String -> IO ()
traceIO msg = do
withCString "%s\n" $ \cfmt ->
withCString msg $ \cmsg ->
debugBelch cfmt cmsg
```
This is bad news: it means if the String has a null in it, the string will be silently truncated. For example, in GHC, this means that you cannot pretty-print FastString uniques, since the default printing algorithm often results in a null.
Probably the proper thing to do here is to also pass a length indicator for the CString. We should also fix unique pretty-printing to never generate nulls. A good test case would be:
```
main = trace "\0foo" (return ())
```
which should have non-empty output.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 7.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ekmett, hvr |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Debug.Trace should not use %s for format string","status":"New","operating_system":"","component":"libraries/base","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ekmett","hvr"],"type":"Bug","description":"The current implementation of traceIO in Debug.Trace is as follows:\r\n\r\n{{{\r\ntraceIO :: String -> IO ()\r\ntraceIO msg = do\r\n withCString \"%s\\n\" $ \\cfmt ->\r\n withCString msg $ \\cmsg ->\r\n debugBelch cfmt cmsg\r\n}}}\r\n\r\nThis is bad news: it means if the String has a null in it, the string will be silently truncated. For example, in GHC, this means that you cannot pretty-print FastString uniques, since the default printing algorithm often results in a null.\r\n\r\nProbably the proper thing to do here is to also pass a length indicator for the CString. We should also fix unique pretty-printing to never generate nulls. A good test case would be:\r\n\r\n{{{\r\nmain = trace \"\\0foo\" (return ())\r\n}}}\r\n\r\nwhich should have non-empty output.","type_of_failure":"OtherFailure","blocking":[]} -->
issue