diff options
author | Fabrizio Iannetti | 2022-12-22 16:30:21 +0000 |
---|---|---|
committer | Bernd Hufmann | 2022-12-23 20:27:49 +0000 |
commit | 983563654bc9f7991315b7e0553e577d225fa876 (patch) | |
tree | 2ac040ea249697052af4a1cc53317c12cc116a02 | |
parent | e56d7c2dc1bd4051b54aabcb684f9cfaf44df546 (diff) | |
download | org.eclipse.tracecompass.incubator-stable-8.2.tar.gz org.eclipse.tracecompass.incubator-stable-8.2.tar.xz org.eclipse.tracecompass.incubator-stable-8.2.zip |
ftrace: fix trace entry size computation when header len is 0stable-8.2
In a trace.dat files, trace entries have a 32 bit header that contains
the payload len (in 32 bit words) in the lower 5 bits.
A len of 0 is a special case: the actual entry length is in the next
32 bit word, and that length includes the length field itself, so:
- the event data starts after the length fields
- the event data is len_in_next_word - 4
For documentation see:
https://elixir.bootlin.com/linux/latest/source/include/linux/ring_buffer.h#L51
Change-Id: I91a459deb11c63f606406b6a1dac9b2b4fcf9130
Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/197834
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Hoang Thuan Pham <hoangpham.eclipse@gmail.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
(cherry picked from commit 5f6ec6acf629f8d2ead867f06d7049b47c50cff8)
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/197807
-rw-r--r-- | tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/binary/iterator/BinaryFTraceCPUPageIterator.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/binary/iterator/BinaryFTraceCPUPageIterator.java b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/binary/iterator/BinaryFTraceCPUPageIterator.java index fdbbfad9a..1623b66bb 100644 --- a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/binary/iterator/BinaryFTraceCPUPageIterator.java +++ b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/binary/iterator/BinaryFTraceCPUPageIterator.java @@ -178,10 +178,14 @@ public class BinaryFTraceCPUPageIterator implements Closeable { // Now we have a data event, we store the event type length, we save // the event type length and delta time // to load the event lazily later - fEventDef = new BinaryFTraceEventDefinition(fCurrentOffset, getCurrentEventPayloadSize()); + int payloadSize = getCurrentEventPayloadSize(); + + // fCurrentOffset may have been modified by getCurrentEventPayloadSize(), pass it + // after calling the function above + fEventDef = new BinaryFTraceEventDefinition(fCurrentOffset, payloadSize); // Move the pointer to the next event - skip(fEventDef.getPayloadSize()); + skip(payloadSize); // We peek the next event, to see if the event is an time extended // event @@ -297,7 +301,8 @@ public class BinaryFTraceCPUPageIterator implements Closeable { // length BinaryFTraceByteBuffer buffer = fBuffer; if (buffer != null) { - payloadSize = buffer.getNextInt(); + // the size includes the size field itself, subtract it to get the actual event length + payloadSize = buffer.getNextInt() - 4; this.fCurrentOffset += 4; } } else if (fCurrentTypeLen <= fFileHeader.getHeaderEventInfo().getDataMaxTypeLen()) { |