summaryrefslogtreecommitdiff
path: root/src/target/xscale.h
diff options
context:
space:
mode:
authorMike Dunn <mikedunn@newsguy.com>2010-04-13 13:34:52 -0400
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-04-15 19:17:31 +0200
commitee139164114460d5c4c1a720e28740a7dceca712 (patch)
tree714b398e92a1f9950d35842d29d84b1979e51f10 /src/target/xscale.h
parentd31bbc33fab65a27edfd142202b90011bd471406 (diff)
downloadopenocd+libswd-ee139164114460d5c4c1a720e28740a7dceca712.tar.gz
openocd+libswd-ee139164114460d5c4c1a720e28740a7dceca712.tar.bz2
openocd+libswd-ee139164114460d5c4c1a720e28740a7dceca712.tar.xz
openocd+libswd-ee139164114460d5c4c1a720e28740a7dceca712.zip
xscale: fix analyze_trace for trace data collected in wrap mode
This patch fixes the xscale_analyze_trace() function. This function was defective for a trace collected in 'fill' mode (hiccups with repeated instructions) and completely broken when buffer overflowed in 'wrap' mode. The reason for the latter case is that the checkpoint registers were interpreted incorrectly when two checkpoints are present in the trace (which will be true in 'wrap' mode once the buffer fills). In this case, checkpoint1 register will contain the older entry, and checkpoint0 the newer. The original code assumed the opposite. I eventually gave up trying to understand all the logic of the function, and rewrote it. I think it's much cleaner and understandable now. I have been using and testing this for a few weeks now. I'm confident it hasn't regressed in any way. Also added capability to handle (as best as possible) the case where an instruction can not be read from the loaded trace image; e.g., partial image. This was a 'TODO' comment in the original xscale_analyze_trace(). Outside of xcsale_analyze_trace(), these (related) changes were made: - Remove pc_ok and current_pc elements from struct xscale_trace. These elements and associated logic are useless clutter because the very first entry placed in the trace buffer is always an indirect jump to the address at which execution resumed. This type of trace entry includes the literal address in the trace buffer, so the initial address of the trace is immediately determined from the trace buffer contents and does not need to be recorded when trace is enabled. - Added num_checkpoints to struct xscale_trace_data, which is necessary in order to correctly interpret the checkpoint register contents. - In xscale_read_trace() - Fix potential array out-of-bounds condition. - Eliminate partial address entries when parsing trace (can occur in wrap mode). - Count and record number of checkpoints in trace. - Added small, inlined utility function xscale_display_instruction() to help make the code more concise and clear. TODO: - Save processor state (arm or thumb) in struct xscale_trace when trace is enabled so that trace can be analyzed correctly (currently assumes arm mode). - Add element to struct xscale_trace that records (when trace is enabled) whether vector table is relocated high (to 0xffff0000) or not, so that a branch to an exception vector is traced correctly (curently assumes vectors at 0x0).
Diffstat (limited to 'src/target/xscale.h')
-rw-r--r--src/target/xscale.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/target/xscale.h b/src/target/xscale.h
index f20074fd..82f4e379 100644
--- a/src/target/xscale.h
+++ b/src/target/xscale.h
@@ -67,6 +67,7 @@ struct xscale_trace_data
uint32_t chkpt0;
uint32_t chkpt1;
uint32_t last_instruction;
+ unsigned int num_checkpoints;
struct xscale_trace_data *next;
};
@@ -77,8 +78,6 @@ struct xscale_trace
struct xscale_trace_data *data; /* linked list of collected trace data */
int buffer_enabled; /* whether trace buffer is enabled */
int buffer_fill; /* maximum number of trace runs to read (-1 for wrap-around) */
- int pc_ok;
- uint32_t current_pc;
enum arm_state core_state; /* current core state (ARM, Thumb) */
};