Skip to content

Commit e91696e

Browse files
committed
Fix incorrect description of m in TOC index.
1 parent d267206 commit e91696e

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ the BAP-frames repository.
6565
| ... | ... | ... | |
6666
| T-0x10 | uint64_t | sizeof(frame_n-1) | |
6767
| T-0x8 | type(frame_n-1) | frame_n-1 | |
68-
| T+0 | uint64_t | m = number of TOC entries | TOC index begin |
68+
| T+0 | uint64_t | m = number of frames per TOC entry | TOC index begin |
6969
| T+0x8 | uint64_t | offset toc_entry(0) | |
7070
| T+0x10 | uint64_t | offset toc_entry(1) | |
7171
| ... | ... | ... | |
72-
| T+0x8+(0x8*m) | uint64_t | offset toc_entry(m-1) | |
72+
| T+0x8+(0x8*ceil(n/m)) | uint64_t | offset toc_entry(ceil(n/m)) | |

contrib/plugins/bap-tracing/tracing.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata) {
221221

222222
// Write the TOC index
223223
SEEK(toc_index_offset);
224-
uint64_t m = state.toc_entries_offsets->len;
225-
WRITE(m);
226-
227-
for (size_t i = 0; i < m - 1; ++i) {
228-
// All except the last address in state.toc_entries_offsets
229-
// point to an entry. The last one points to nothing, because
230-
// we first push the offset and then push the frames later
231-
// when the buffer is full.
232-
// When we dumped the last frames above it lastly
233-
// pushed an additional offset.
234-
// This one we skip here with m - 1.
224+
WRITE(frames_per_toc_entry);
225+
size_t add = state.total_num_frames % frames_per_toc_entry != 0 ? 1 : 0;
226+
size_t entries = ((state.total_num_frames) / frames_per_toc_entry) + add;
227+
228+
for (size_t i = 0; i < entries; ++i) {
235229
uint64_t toc_entry_off =
236230
g_array_index(state.toc_entries_offsets, uint64_t, i);
237231
WRITE(toc_entry_off);

0 commit comments

Comments
 (0)