Skip to content

Commit dbbeb5c

Browse files
committed
Handle frame buffer flushing
1 parent 0c058f3 commit dbbeb5c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

contrib/plugins/bap-tracing/tracing.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ static void log_insn_reg_access(unsigned int vcpu_index, void *udata) {
4444
g_assert(current_regs->len == vcpu->registers->len);
4545

4646
add_post_state_regs(vcpu, vcpu_index, current_regs);
47-
// Check if buffer should be dumped to file.
47+
48+
g_rw_lock_writer_lock(&state.frame_buffer_lock);
49+
g_rw_lock_writer_lock(&state.file_lock);
50+
FrameBuffer *vcpu_buf = g_ptr_array_index(state.frame_buffer, vcpu_index);
51+
if (frame_buffer_is_full(vcpu_buf)) {
52+
frame_buffer_flush_to_file(vcpu_buf, state.file);
53+
}
54+
g_rw_lock_writer_unlock(&state.file_lock);
55+
g_rw_lock_writer_unlock(&state.frame_buffer_lock);
4856

4957
// Open new one.
5058
Instruction *insn = udata;

contrib/plugins/bap-tracing/tracing.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ FrameBuffer *frame_buffer_init(size_t size);
6868
*/
6969
bool frame_buffer_push(FrameBuffer *buf, Frame *frame);
7070

71-
/**
72-
* \brief Flushs the buffer and returns it's content.
73-
* The size of the returned buffer is written to \p fbuf_size.
74-
*/
75-
Frame **frame_buffer_flush(FrameBuffer *buf, size_t *fbuf_size);
71+
void frame_buffer_flush_to_file(FrameBuffer *buf, FILE *file);
72+
bool frame_buffer_is_full(const FrameBuffer *buf);
7673

7774
void frame_buffer_new_frame(FrameBuffer *buf);
7875
void frame_buffer_append_op_info(FrameBuffer *buf, OperandInfo *oi);

0 commit comments

Comments
 (0)