Skip to content

Commit a040e41

Browse files
committed
Enable bap-tracing plugin build with meson.
1 parent b96ce6a commit a040e41

File tree

8 files changed

+373
-296
lines changed

8 files changed

+373
-296
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ This QEMU fork implements the TCG plugin to generate execution traces in the
66
Previous traces were generated with a patched QEMU.
77
You can find these in the branches tracewrap-6.2.0 for ARM and x86 and tracewrap-8.1 for Hexagon.
88

9+
## Dependencies
10+
11+
1. Install [piqi](https://piqi.org/downloads/) so you have the `piqi` binary in `PATH`.
12+
2. Install the developer package of `protobuf-c`. E.g. `protobuf-c-devel` (Fedora), `libprotobuf-c-dev` (Debian).
13+
3. QEMU dependencies (see [QEMU docs](https://www.qemu.org/docs/master/devel/build-environment.html)).
14+
915
## Building
1016

1117
```bash
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This just does:
4+
sed -i 's/->base/->__base/g' <file>
5+
sed -i 's/ProtobufCMessage base;/ProtobufCMessage __base;/g' <file>
6+
"""
7+
8+
import sys
9+
import re
10+
11+
if len(sys.argv) != 6 or sys.argv[3] != "-o":
12+
print("usage: fix_proto_src.py frame.piqi.pb-c.c frame.piqi.pb-c.h -o frame.piqi.pb-c-fixed.c frame.piqi.pb-c-fixed.h")
13+
exit(1)
14+
15+
for (in_file, out_file) in zip(sys.argv[1:3], sys.argv[4:6]):
16+
with open(in_file, "r") as i:
17+
contents = i.read()
18+
contents = contents.replace("->base", "->__base")
19+
contents = contents.replace("ProtobufCMessage base;", "ProtobufCMessage __base;")
20+
contents = re.sub(r'".*frame.piqi.pb-c.h"', '"frame.piqi.pb-c-patched.h"', contents)
21+
with open(out_file, "w") as o:
22+
o.write(contents)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
piqi = find_program('piqi')
2+
protoc_c = find_program('protoc-c')
3+
4+
# piqi -> protobuf file.
5+
piqi_src = custom_target('piqi',
6+
input: 'bap-frames/piqi/frame.piqi',
7+
output: 'frame.piqi.proto',
8+
command: [piqi, 'to-proto', '@INPUT@', '-o', '@OUTPUT@'])
9+
10+
# protobuf file -> C code
11+
proto_src_raw = custom_target('proto',
12+
input: piqi_src,
13+
output: ['frame.piqi.pb-c.c', 'frame.piqi.pb-c.h'],
14+
command: [protoc_c, '--c_out=.', '@INPUT@'],
15+
depends: piqi_src)
16+
17+
# Patch protobuf header: base -> __base.
18+
# Necessary for the C build.
19+
# See fix_proto_src.py
20+
proto_src = custom_target(
21+
input: proto_src_raw,
22+
output: ['frame.piqi.pb-c-patched.c', 'frame.piqi.pb-c-patched.h'],
23+
command: [files('fix_proto_src.py'), '@INPUT@', '-o', '@OUTPUT@'],
24+
depends: proto_src_raw
25+
)
26+
27+
libprotobuf = static_library('protobuf', [proto_src], pic: true)
28+
dep_libprotobuf = declare_dependency(
29+
sources : proto_src,
30+
link_with : [libprotobuf],
31+
)
32+
33+
bap_tracing_src = files(
34+
'tracing.c',
35+
'tracewrap.c',
36+
)
37+
38+
if host_os == 'windows'
39+
plugin_modules += shared_module('bap_tracing', bap_tracing_src,
40+
include_directories: '../../../include/qemu',
41+
link_depends: [win32_qemu_plugin_api_lib],
42+
link_args: win32_qemu_plugin_api_link_flags,
43+
dependencies: [glib, dep_libprotobuf])
44+
else
45+
plugin_modules += shared_module('bap_tracing', bap_tracing_src,
46+
include_directories: '../../../include/qemu',
47+
dependencies: [glib, dep_libprotobuf])
48+
endif

contrib/plugins/bap-tracing/trace_consts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "trace_info.h"
3+
// #include "trace_info.h"
44

55
const uint64_t magic_number = 7456879624156307493LL;
66
const uint64_t magic_number_offset = 0LL;

0 commit comments

Comments
 (0)