aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--man/swodec.117
-rw-r--r--src/main.c141
3 files changed, 84 insertions, 79 deletions
diff --git a/NEWS b/NEWS
index eb86c77..90b7eb1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,7 @@
News
====
+
+0.1.0 (2017-10-03)
+------------------
+
+ * Initial release.
diff --git a/man/swodec.1 b/man/swodec.1
index d9e39c4..866dddb 100644
--- a/man/swodec.1
+++ b/man/swodec.1
@@ -86,25 +86,26 @@ Hardware source. This is for hardware source packets which could not be decoded
as Data Watchpoint and Trace (DWT) packets.
.TP
.B dwt
-Data Watchpoint and Trace (DWT). This is a shortcut for \fBevcnt\fP,
-\fBexc\fP, \fBpc\fP, \fBdtpc\fP, \fBdtaddr\fP and \fBdtval\fP.
+Data Watchpoint and Trace (DWT). This is a shortcut for \fBevtcnt\fP,
+\fBexctrc\fP, \fBpcsample\fP, \fBpcvalue\fP, \fBaddroffset\fP and
+\fBdatavalue\fP.
.TP
-.B evcnt
+.B evtcnt
Event counter
.TP
-.B exc
+.B exctrc
Exception trace
.TP
-.B pc
+.B pcsample
Periodic PC sample
.TP
-.B dtpc
+.B pcvalue
Data trace PC value
.TP
-.B dtaddr
+.B addroffset
Data trace address offset
.TP
-.B dtval
+.B datavalue
Data trace data value
.TP
.B unknown
diff --git a/src/main.c b/src/main.c
index b303c19..c22e1c2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -106,7 +106,7 @@ static gboolean parse_filter_option(const gchar *option_name,
} else if (!g_ascii_strcasecmp(tokens[i], "sync")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_SYNC);
} else if (!g_ascii_strcasecmp(tokens[i], "of")) {
- tmp |= (1 << LIBSWO_PACKET_TYPE_OVERFLOW);
+ tmp |= (1 << LIBSWO_PACKET_TYPE_OF);
} else if (!g_ascii_strcasecmp(tokens[i], "lts")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_LTS);
} else if (!g_ascii_strcasecmp(tokens[i], "gts")) {
@@ -124,22 +124,22 @@ static gboolean parse_filter_option(const gchar *option_name,
tmp |= (1 << LIBSWO_PACKET_TYPE_HW);
} else if (!g_ascii_strcasecmp(tokens[i], "dwt")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EVTCNT);
- tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRACE);
+ tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRC);
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_PC_SAMPLE);
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_PC_VALUE);
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_ADDR_OFFSET);
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_DATA_VALUE);
- } else if (!g_ascii_strcasecmp(tokens[i], "evcnt")) {
+ } else if (!g_ascii_strcasecmp(tokens[i], "evtcnt")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EVTCNT);
- } else if (!g_ascii_strcasecmp(tokens[i], "exc")) {
- tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRACE);
- } else if (!g_ascii_strcasecmp(tokens[i], "pc")) {
+ } else if (!g_ascii_strcasecmp(tokens[i], "exctrc")) {
+ tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRC);
+ } else if (!g_ascii_strcasecmp(tokens[i], "pcsample")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_PC_SAMPLE);
- } else if (!g_ascii_strcasecmp(tokens[i], "dtpc")) {
+ } else if (!g_ascii_strcasecmp(tokens[i], "pcvalue")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_PC_VALUE);
- } else if (!g_ascii_strcasecmp(tokens[i], "dtaddr")) {
+ } else if (!g_ascii_strcasecmp(tokens[i], "addroffset")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_ADDR_OFFSET);
- } else if (!g_ascii_strcasecmp(tokens[i], "dtval")) {
+ } else if (!g_ascii_strcasecmp(tokens[i], "datavalue")) {
tmp |= (1 << LIBSWO_PACKET_TYPE_DWT_DATA_VALUE);
} else {
g_critical("Invalid packet type: %s.", tokens[i]);
@@ -287,55 +287,6 @@ static GOptionEntry entries[] = {
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
-static void handle_hw_packet(const union libswo_packet *packet)
-{
- printf("Hardware source (address = %u, value = %x, size = %zu bytes)\n",
- packet->hw.address, packet->hw.value, packet->hw.size - 1);
-}
-
-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);
-}
-
-static void handle_overflow_packet(const union libswo_packet *packet)
-{
- (void)packet;
- printf("Overflow\n");
-}
-
-static void handle_ext_packet(const union libswo_packet *packet)
-{
- const char *src;
-
- switch (packet->ext.source) {
- case LIBSWO_EXT_SRC_ITM:
- src = "ITM";
- break;
- case LIBSWO_EXT_SRC_HW:
- src = "HW";
- break;
- default:
- g_warning("Extension packet with invalid source: %u.",
- packet->ext.source);
- return;
- }
-
- printf("Extension (source = %s, value = %x)\n", src,
- packet->ext.value);
-}
-
static void handle_unknown_packet(const union libswo_packet *packet)
{
printf("Unknown data (size = %zu bytes)\n", packet->unknown.size);
@@ -351,6 +302,12 @@ static void handle_sync_packet(const union libswo_packet *packet)
packet->sync.size / 8);
}
+static void handle_overflow_packet(const union libswo_packet *packet)
+{
+ (void)packet;
+ printf("Overflow\n");
+}
+
static void handle_lts_packet(const union libswo_packet *packet)
{
const char *tc;
@@ -389,6 +346,49 @@ static void handle_gts2_packet(const union libswo_packet *packet)
printf("Global timestamp (GTS2) (value = %x)\n", packet->gts2.value);
}
+static void handle_ext_packet(const union libswo_packet *packet)
+{
+ const char *src;
+
+ switch (packet->ext.source) {
+ case LIBSWO_EXT_SRC_ITM:
+ src = "ITM";
+ break;
+ case LIBSWO_EXT_SRC_HW:
+ src = "HW";
+ break;
+ default:
+ g_warning("Extension packet with invalid source: %u.",
+ packet->ext.source);
+ return;
+ }
+
+ printf("Extension (source = %s, value = %x)\n", src,
+ packet->ext.value);
+}
+
+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);
+}
+
+static void handle_hw_packet(const union libswo_packet *packet)
+{
+ printf("Hardware source (address = %u, value = %x, size = %zu bytes)\n",
+ packet->hw.address, packet->hw.value, packet->hw.size - 1);
+}
+
static void handle_dwt_evtcnt_packet(const union libswo_packet *packet)
{
printf("Event counter (CPI = %u, exc = %u, sleep = %u, LSU = %u, "
@@ -397,28 +397,28 @@ static void handle_dwt_evtcnt_packet(const union libswo_packet *packet)
packet->evtcnt.fold, packet->evtcnt.cyc);
}
-static void handle_dwt_exctrace_packet(const union libswo_packet *packet)
+static void handle_dwt_exctrc_packet(const union libswo_packet *packet)
{
uint16_t exception;
const char *func;
const char *name;
char buf[23];
- switch (packet->exctrace.function) {
- case LIBSWO_EXCTRACE_FUNC_ENTER:
+ switch (packet->exctrc.function) {
+ case LIBSWO_EXCTRC_FUNC_ENTER:
func = "enter";
break;
- case LIBSWO_EXCTRACE_FUNC_EXIT:
+ case LIBSWO_EXCTRC_FUNC_EXIT:
func = "exit";
break;
- case LIBSWO_EXCTRACE_FUNC_RETURN:
+ case LIBSWO_EXCTRC_FUNC_RETURN:
func = "return";
break;
default:
func = "reserved";
}
- exception = packet->exctrace.exception;
+ exception = packet->exctrc.exception;
if (exception < NUM_EXCEPTION_NAMES) {
name = exception_names[exception];
@@ -480,7 +480,7 @@ static int packet_cb(struct libswo_context *ctx,
case LIBSWO_PACKET_TYPE_INST:
handle_inst_packet(packet);
break;
- case LIBSWO_PACKET_TYPE_OVERFLOW:
+ case LIBSWO_PACKET_TYPE_OF:
handle_overflow_packet(packet);
break;
case LIBSWO_PACKET_TYPE_EXT:
@@ -501,8 +501,8 @@ static int packet_cb(struct libswo_context *ctx,
case LIBSWO_PACKET_TYPE_DWT_EVTCNT:
handle_dwt_evtcnt_packet(packet);
break;
- case LIBSWO_PACKET_TYPE_DWT_EXCTRACE:
- handle_dwt_exctrace_packet(packet);
+ case LIBSWO_PACKET_TYPE_DWT_EXCTRC:
+ handle_dwt_exctrc_packet(packet);
break;
case LIBSWO_PACKET_TYPE_DWT_PC_SAMPLE:
handle_dwt_pc_sample_packet(packet);
@@ -517,8 +517,7 @@ static int packet_cb(struct libswo_context *ctx,
handle_dwt_data_value_packet(packet);
break;
default:
- g_warning("Invalid packet type: %u.", packet->type);
- break;
+ g_warning("Invalid packet type: %i.", packet->type);
}
return TRUE;
@@ -618,7 +617,7 @@ int main(int argc, char **argv)
/* Disable packet filtering for all packet types by default. */
packet_type_filter = (1 << LIBSWO_PACKET_TYPE_UNKNOWN) | \
(1 << LIBSWO_PACKET_TYPE_SYNC) | \
- (1 << LIBSWO_PACKET_TYPE_OVERFLOW) | \
+ (1 << LIBSWO_PACKET_TYPE_OF) | \
(1 << LIBSWO_PACKET_TYPE_LTS) | \
(1 << LIBSWO_PACKET_TYPE_GTS1) | \
(1 << LIBSWO_PACKET_TYPE_GTS2) | \
@@ -626,7 +625,7 @@ int main(int argc, char **argv)
(1 << LIBSWO_PACKET_TYPE_INST) | \
(1 << LIBSWO_PACKET_TYPE_HW) | \
(1 << LIBSWO_PACKET_TYPE_DWT_EVTCNT) | \
- (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRACE) | \
+ (1 << LIBSWO_PACKET_TYPE_DWT_EXCTRC) | \
(1 << LIBSWO_PACKET_TYPE_DWT_PC_SAMPLE) | \
(1 << LIBSWO_PACKET_TYPE_DWT_PC_VALUE) | \
(1 << LIBSWO_PACKET_TYPE_DWT_ADDR_OFFSET) | \