aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <swo-dev@marcschink.de>2015-02-15 22:14:38 +0100
committerMarc Schink <swo-dev@marcschink.de>2015-02-17 21:10:07 +0100
commit739121505d03abe8cddcd0f10cd336c1901d7d37 (patch)
tree1d5eeb82f84a5652b1b43db30c434510f5a3723a
parent4a00c478c03d007dd14b670b881942740beba2e7 (diff)
Add option to dump instrumentation payload.
This patch adds the command-line option --dump-inst to dump the payload of instrumentation packets. All other packet types are filtered out.
-rw-r--r--src/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 10a784d..c2b2ba1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,7 @@
static gchar *input_file = NULL;
static uint16_t packet_type_filter;
static uint32_t inst_address_filter;
+static gboolean opt_dump_inst;
static gboolean opt_decode_dwt;
void dwt_handle_packet(const struct libswo_packet_hw *packet);
@@ -190,6 +191,8 @@ static GOptionEntry entries[] = {
"Filter for packet types", NULL},
{"filter-inst", 0, 0, G_OPTION_ARG_CALLBACK, &parse_inst_filter_option,
"Filter for instrumentation source addresses", NULL},
+ {"dump-inst", 0, 0, G_OPTION_ARG_NONE, &opt_dump_inst,
+ "Dump instrumentation payload", NULL},
{"dwt", 0, 0, G_OPTION_ARG_NONE, &opt_decode_dwt,
"Enable DWT decoder", NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}
@@ -217,6 +220,12 @@ static void handle_inst_packet(const union libswo_packet *packet)
if (!(inst_address_filter & (1 << packet->inst.address)))
return;
+ if (opt_dump_inst) {
+ fwrite(packet->inst.payload, packet->inst.size - 1, 1, stdout);
+ fflush(stdout);
+ return;
+ }
+
printf("Instrumentation (address = %u, value = %x, size = %zu bytes)\n",
packet->inst.address, packet->inst.value,
packet->inst.size - 1);
@@ -388,6 +397,7 @@ int main(int argc, char **argv)
GIOStatus iostat;
gsize num;
+ opt_dump_inst = FALSE;
opt_decode_dwt = FALSE;
/* Disable packet filtering for all packet types by default. */
@@ -407,6 +417,9 @@ int main(int argc, char **argv)
if (!parse_options(&argc, &argv))
return EXIT_FAILURE;
+ if (opt_dump_inst)
+ packet_type_filter = (1 << LIBSWO_PACKET_TYPE_INST);
+
error = NULL;
if (input_file) {