提交 dd215f64 编写于 作者: L Lluís 提交者: Stefan Hajnoczi

trace: always use the "nop" backend on events with the "disable" keyword

Any event with the keyword/property "disable" generates an empty trace event
using the "nop" backend, regardless of the current backend.
Signed-off-by: NLluís Vilanova <vilanova@ac.upc.edu>
上级 23d15e86
...@@ -12,15 +12,11 @@ for debugging, profiling, and observing execution. ...@@ -12,15 +12,11 @@ for debugging, profiling, and observing execution.
./configure --trace-backend=simple ./configure --trace-backend=simple
make make
2. Enable trace events you are interested in: 2. Run the virtual machine to produce a trace file:
$EDITOR trace-events # remove "disable" from events you want
3. Run the virtual machine to produce a trace file:
qemu ... # your normal QEMU invocation qemu ... # your normal QEMU invocation
4. Pretty-print the binary trace file: 3. Pretty-print the binary trace file:
./simpletrace.py trace-events trace-* ./simpletrace.py trace-events trace-*
...@@ -103,10 +99,11 @@ portability macros, ensure they are preceded and followed by double quotes: ...@@ -103,10 +99,11 @@ portability macros, ensure they are preceded and followed by double quotes:
4. Name trace events after their function. If there are multiple trace events 4. Name trace events after their function. If there are multiple trace events
in one function, append a unique distinguisher at the end of the name. in one function, append a unique distinguisher at the end of the name.
5. Declare trace events with the "disable" property. Some trace events can 5. If specific trace events are going to be called a huge number of times, this
produce a lot of output and users are typically only interested in a subset might have a noticeable performance impact even when the trace events are
of trace events. Marking trace events disabled by default saves the user programmatically disabled. In this case you should declare the trace event
from having to manually disable noisy trace events. with the "disable" property, which will effectively disable it at compile
time (using the "nop" backend).
== Generic interface and monitor commands == == Generic interface and monitor commands ==
...@@ -165,6 +162,9 @@ The "nop" backend generates empty trace event functions so that the compiler ...@@ -165,6 +162,9 @@ The "nop" backend generates empty trace event functions so that the compiler
can optimize out trace events completely. This is the default and imposes no can optimize out trace events completely. This is the default and imposes no
performance penalty. performance penalty.
Note that regardless of the selected trace backend, events with the "disable"
property will be generated with the "nop" backend.
=== Stderr === === Stderr ===
The "stderr" backend sends trace events directly to standard error. This The "stderr" backend sends trace events directly to standard error. This
...@@ -173,6 +173,11 @@ effectively turns trace events into debug printfs. ...@@ -173,6 +173,11 @@ effectively turns trace events into debug printfs.
This is the simplest backend and can be used together with existing code that This is the simplest backend and can be used together with existing code that
uses DPRINTF(). uses DPRINTF().
Note that with this backend trace events cannot be programmatically
enabled/disabled. Thus, in order to trim down the amount of output and the
performance impact of tracing, you might want to add the "disable" property in
the "trace-events" file for those events you are not interested in.
=== Simpletrace === === Simpletrace ===
The "simple" backend supports common use cases and comes as part of the QEMU The "simple" backend supports common use cases and comes as part of the QEMU
......
...@@ -506,21 +506,10 @@ convert() ...@@ -506,21 +506,10 @@ convert()
# Skip comments and empty lines # Skip comments and empty lines
test -z "${str%%#*}" && continue test -z "${str%%#*}" && continue
echo
# Process the line. The nop backend handles disabled lines. # Process the line. The nop backend handles disabled lines.
disable="0"
if has_property "$str" "disable"; then if has_property "$str" "disable"; then
disable="1" "lineto$1_nop" "$str"
fi
echo
if [ "$disable" = "1" ]; then
# Pass the disabled state as an arg for the simple
# or DTrace backends which handle it dynamically.
# For all other backends, call lineto$1_nop()
if [ $backend = "simple" -o "$backend" = "dtrace" ]; then
"$process_line" "$str"
else
"lineto$1_nop" "${str##disable }"
fi
else else
"$process_line" "$str" "$process_line" "$str"
fi fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册