Skip to content

Commit daa47ab

Browse files
committed
Fix typos, extend docs add tracing helper script
1 parent adb35d9 commit daa47ab

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,31 @@ The plugin takes two required arguments:
4141

4242
`bin_path`: The path to the binary emulated. Due to a [QEMU bug](https://gitlab.com/qemu-project/qemu/-/issues/3014) this cannot be inferred.
4343
`out`: The output file to save the trace into.
44+
`endianness`: The architecture endanness.
4445

4546
```bash
46-
./qemu-sparc64 -plugin file=./contrib/plugins/bap-tracing/libbap_tracing.so,bin_path=<bin_path>,out=<output-file> -d plugin <bin_path>
47+
./qemu-sparc64 -plugin file=buil/contrib/plugins/bap-tracing/libbap_tracing.so,bin_path=<bin_path>,out=<output-file>,endianness=[b/l] -d plugin <bin_path>
4748
ls <output-file>
4849
```
4950

51+
You can also use the helper shell script:
52+
53+
```bash
54+
./gen-trace.sh ./build/ sparc64 b <path_to_bin>
55+
```
56+
57+
> [!NOTE]
58+
> The trace plugin currently only generates standard frames.
59+
> This is due to the limitations of the QEMU plugin API.
60+
>
61+
> If the traced binary exits due to an exception it can only indirectly be observed.
62+
> It will produce a standard frame without any logged post register state.
63+
> Any completed memory read/write might still be logged.
64+
>
65+
> If you suspect this, execute the binary with the `execlog` plugin (see `gen-trace.sh`)
66+
> to check of the execution stops earlier than expected.
67+
68+
5069
## Trace format
5170

5271
The generated trace consists of three parts: the header,

contrib/plugins/bap-tracing/tracing.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
404404
qemu_plugin_outs("Pass it with 'out=<output_file>'.\n\n");
405405
exit(1);
406406
}
407-
char *endianess = get_argv_val(argv, argc, "endianess");
408-
if (!endianess || (strcmp(endianess, "b") && strcmp(endianess, "l"))) {
409-
qemu_plugin_outs("'endianess' argument is missing or is not 'b' or 'l'.\n");
407+
char *endianness = get_argv_val(argv, argc, "endianness");
408+
if (!endianness || (strcmp(endianness, "b") && strcmp(endianness, "l"))) {
409+
qemu_plugin_outs("'endianness' argument is missing or is not 'b' or 'l'.\n");
410410
qemu_plugin_outs("This is required until QEMU plugins get a richer API.\n");
411-
qemu_plugin_outs("Pass it with 'endianess=[b/l]'.\n\n");
411+
qemu_plugin_outs("Pass it with 'endianness=[b/l]'.\n\n");
412412
exit(1);
413413
}
414-
state.is_big_endian = endianess[0] == 'b';
414+
state.is_big_endian = endianness[0] == 'b';
415415

416416
state.target_name = g_strdup(info->target_name);
417417
state.frame_buffer = g_ptr_array_new();

gen-trace.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh -x
2+
3+
if [ "$#" -lt 4 ]; then
4+
echo "$0 <build_dir> <arch> <endianess=[b/l]> <bin_path> [args...]"
5+
echo "<arch> is attached to qemu-<arch>"
6+
exit 1
7+
fi
8+
9+
BUILDIR=$1
10+
ARCH=$2
11+
EN=$3
12+
BIN=$4
13+
BNAME=$(basename $BIN)
14+
15+
$BUILDIR/qemu-$ARCH -plugin file="$BUILDIR/contrib/plugins/bap-tracing/libbap_tracing.so,bin_path=$BIN",out="$BNAME.trace",endianess="$EN" -d plugin "$BIN" ""${@:5}""
16+
ls -lh "$BNAME.trace"
17+
# $BUILDIR/qemu-$ARCH -plugin file="$BUILDIR/contrib/plugins/libexeclog.so" -d plugin "$BIN"

0 commit comments

Comments
 (0)