diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-02-17 08:39:08 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-02-17 09:06:11 -0600 |
commit | a82364c9410d35fa9cb5031d553212267c3628c5 (patch) | |
tree | e08ddc95d58c4d589969a330804dc1889130e334 /rts/Trace.c | |
parent | 310b6365c91731a797c7e592ebda9ca881f662d4 (diff) | |
download | haskell-a82364c9410d35fa9cb5031d553212267c3628c5.tar.gz |
Don't truncate traceEvents to 512 bytes (#8309)
Summary:
Don't call postLogMsg to post a user msg, because it truncates messages to
512 bytes.
Rename traceCap_stderr and trace_stderr to vtraceCap_stderr and trace_stderr,
to signal that they take a va_list (similar to vdebugBelch vs debugBelch).
See #3874 for the original reason behind traceFormatUserMsg.
See the commit msg in #9395 (d360d440) for a discussion about using
null-terminated strings vs strings with an explicit length.
Test Plan:
Run `cabal install ghc-events` and inspect the result of `ghc-events show` on
an eventlog file created with `ghc -eventlog Test.hs` and `./Test +RTS -l`,
where Test.hs contains:
```
import Debug.Trace
main = traceEvent (replicate 510 'a' ++ "bcd") $ return ()
```
Depends on D655.
Reviewers: austin
Reviewed By: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D656
GHC Trac Issues: #8309
Diffstat (limited to 'rts/Trace.c')
-rw-r--r-- | rts/Trace.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/rts/Trace.c b/rts/Trace.c index a0783f3400..bd4d332eac 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -622,7 +622,7 @@ void traceTaskDelete_ (Task *task) } #ifdef DEBUG -static void traceCap_stderr(Capability *cap, char *msg, va_list ap) +static void vtraceCap_stderr(Capability *cap, char *msg, va_list ap) { ACQUIRE_LOCK(&trace_utx); @@ -633,6 +633,14 @@ static void traceCap_stderr(Capability *cap, char *msg, va_list ap) RELEASE_LOCK(&trace_utx); } + +static void traceCap_stderr(Capability *cap, char *msg, ...) +{ + va_list ap; + va_start(ap,msg); + vtraceCap_stderr(cap, msg, ap); + va_end(ap); +} #endif void traceCap_(Capability *cap, char *msg, ...) @@ -642,7 +650,7 @@ void traceCap_(Capability *cap, char *msg, ...) #ifdef DEBUG if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { - traceCap_stderr(cap, msg, ap); + vtraceCap_stderr(cap, msg, ap); } else #endif { @@ -653,7 +661,7 @@ void traceCap_(Capability *cap, char *msg, ...) } #ifdef DEBUG -static void trace_stderr(char *msg, va_list ap) +static void vtrace_stderr(char *msg, va_list ap) { ACQUIRE_LOCK(&trace_utx); @@ -672,7 +680,7 @@ void trace_(char *msg, ...) #ifdef DEBUG if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { - trace_stderr(msg, ap); + vtrace_stderr(msg, ap); } else #endif { @@ -682,32 +690,24 @@ void trace_(char *msg, ...) va_end(ap); } -static void traceFormatUserMsg(Capability *cap, char *msg, ...) +void traceUserMsg(Capability *cap, char *msg) { - va_list ap; - va_start(ap,msg); - /* Note: normally we don't check the TRACE_* flags here as they're checked by the wrappers in Trace.h. But traceUserMsg is special since it has no wrapper (it's called from cmm code), so we check TRACE_user here */ #ifdef DEBUG if (RtsFlags.TraceFlags.tracing == TRACE_STDERR && TRACE_user) { - traceCap_stderr(cap, msg, ap); + // Use "%s" as format string to ignore format specifiers in msg (#3874). + traceCap_stderr(cap, "%s", msg); } else #endif { if (eventlog_enabled && TRACE_user) { - postUserMsg(cap, msg, ap); + postUserEvent(cap, EVENT_USER_MSG, msg); } } dtraceUserMsg(cap->no, msg); - va_end(ap); -} - -void traceUserMsg(Capability *cap, char *msg) -{ - traceFormatUserMsg(cap, "%s", msg); } void traceUserMarker(Capability *cap, char *markername) @@ -717,15 +717,12 @@ void traceUserMarker(Capability *cap, char *markername) */ #ifdef DEBUG if (RtsFlags.TraceFlags.tracing == TRACE_STDERR && TRACE_user) { - ACQUIRE_LOCK(&trace_utx); - tracePreface(); - debugBelch("cap %d: User marker: %s\n", cap->no, markername); - RELEASE_LOCK(&trace_utx); + traceCap_stderr(cap, "User marker: %s", markername); } else #endif { if (eventlog_enabled && TRACE_user) { - postUserMarker(cap, markername); + postUserEvent(cap, EVENT_USER_MARKER, markername); } } dtraceUserMarker(cap->no, markername); |