File tree Expand file tree Collapse file tree 3 files changed +84
-14
lines changed
contrib/plugins/bap-tracing Expand file tree Collapse file tree 3 files changed +84
-14
lines changed Original file line number Diff line number Diff line change
1
+ #include "tracing.h"
2
+
3
+ Frame * frame_new_std (uint64_t addr , int vcpu_id ) {
4
+ Frame * frame = g_new (Frame , 1 );
5
+ frame__init (frame );
6
+
7
+ StdFrame * sframe = g_new (StdFrame , 1 );
8
+ std_frame__init (sframe );
9
+ frame -> std_frame = sframe ;
10
+
11
+ sframe -> address = addr ;
12
+ sframe -> thread_id = vcpu_id ;
13
+
14
+ OperandValueList * ol_in = g_new (OperandValueList , 1 );
15
+ operand_value_list__init (ol_in );
16
+ ol_in -> n_elem = 0 ;
17
+ sframe -> operand_pre_list = ol_in ;
18
+
19
+ OperandValueList * ol_out = g_new (OperandValueList , 1 );
20
+ operand_value_list__init (ol_out );
21
+ ol_out -> n_elem = 0 ;
22
+ sframe -> operand_post_list = ol_out ;
23
+ return frame ;
24
+ }
Original file line number Diff line number Diff line change 1
1
// SPDX-FileCopyrightText: 2025 Rot127 <[email protected] >
2
2
// SPDX-License-Identifier: GPL-2.0-only
3
3
4
- #include <qemu-plugin .h>
4
+ #include <glib .h>
5
5
6
- QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION ;
7
-
8
- typedef struct {
9
- // Current instruction related things.
10
- } VCPU ;
11
-
12
- typedef struct {
13
- GRWLock vcpus_array_lock ;
14
- GArray * vcpus ;
15
-
16
- GRWLock frame_buffer_lock ;
17
- GPtrArray * frame_buffer ;
18
- } TraceState ;
6
+ #include "tracing.h"
19
7
20
8
static TraceState state ;
21
9
Original file line number Diff line number Diff line change
1
+ #ifndef BAP_TRACING_H
2
+ #define BAP_TRACING_H
3
+
4
+ #include <qemu-plugin.h>
5
+ #include <stdio.h>
6
+
7
+ #include "tracewrap.h"
8
+
9
+ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION ;
10
+
11
+ #define FRAME_BUFFER_SIZE 1024
12
+
13
+ typedef struct {
14
+ Frame * * fbuf ;
15
+ size_t len ;
16
+ } FrameBuffer ;
17
+
18
+ typedef struct {
19
+ // Current instruction related things.
20
+ } VCPU ;
21
+
22
+ typedef struct {
23
+ GRWLock vcpus_array_lock ;
24
+ GArray * vcpus ;
25
+
26
+ GRWLock frame_buffer_lock ;
27
+ FrameBuffer * frame_buffer ;
28
+
29
+ GRWLock file_lock ;
30
+ FILE * file ;
31
+ } TraceState ;
32
+
33
+ VCPU * vcpu_new (void );
34
+
35
+ /**
36
+ * \brief Initializes a frame buffer with space for \p size frames.
37
+ * Returns the buffer or NULL in case of failure.
38
+ */
39
+ FrameBuffer * frame_buffer_init (size_t size );
40
+
41
+ /**
42
+ * \brief Push a frame into the buffer.
43
+ * Returns true on success. False otherwise.
44
+ */
45
+ bool frame_buffer_push (FrameBuffer * buf , Frame * frame );
46
+
47
+ /**
48
+ * \brief Flusehs the buffer and returns it's content.
49
+ * The size of the returned buffer is written to \p fbuf_size.
50
+ */
51
+ Frame * * frame_buffer_flush (FrameBuffer * buf , size_t * fbuf_size );
52
+
53
+ /**
54
+ * \brief Create new std frame
55
+ */
56
+ Frame * frame_new_std (uint64_t addr , int vcpu_id );
57
+
58
+ #endif
You can’t perform that action at this time.
0 commit comments