* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
return 0;
}
-static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *cmd_ctx)
+static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocation *cmd)
{
int retval;
struct arm_instruction instruction;
ctx->capture_driver->read_trace(ctx);
if (ctx->trace_depth == 0) {
- command_print(cmd_ctx, "Trace is empty.");
+ command_print(cmd->ctx, "Trace is empty.");
return ERROR_OK;
}
int current_pc_ok = ctx->pc_ok;
if (ctx->trace_data[ctx->pipe_index].flags & ETMV1_TRIGGER_CYCLE)
- command_print(cmd_ctx, "--- trigger ---");
+ command_print(cmd->ctx, "--- trigger ---");
/* instructions execute in IE/D or BE/D cycles */
if ((pipestat == STAT_IE) || (pipestat == STAT_ID))
next_pc = ctx->last_branch;
break;
case 0x1: /* tracing enabled */
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"--- tracing enabled at 0x%8.8" PRIx32 " ---",
ctx->last_branch);
ctx->current_pc = ctx->last_branch;
continue;
break;
case 0x2: /* trace restarted after FIFO overflow */
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"--- trace restarted after FIFO overflow at 0x%8.8" PRIx32 " ---",
ctx->last_branch);
ctx->current_pc = ctx->last_branch;
continue;
break;
case 0x3: /* exit from debug state */
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"--- exit from debug state at 0x%8.8" PRIx32 " ---",
ctx->last_branch);
ctx->current_pc = ctx->last_branch;
* we have to move on with the next trace cycle
*/
if (!current_pc_ok) {
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"--- periodic synchronization point at 0x%8.8" PRIx32 " ---",
next_pc);
ctx->current_pc = next_pc;
|| ((ctx->last_branch >= 0xffff0000) &&
(ctx->last_branch <= 0xffff0020))) {
if ((ctx->last_branch & 0xff) == 0x10)
- command_print(cmd_ctx, "data abort");
+ command_print(cmd->ctx, "data abort");
else {
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"exception vector 0x%2.2" PRIx32 "",
ctx->last_branch);
ctx->current_pc = ctx->last_branch;
ctx->ptr_ok = 1;
if (ctx->ptr_ok)
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"address: 0x%8.8" PRIx32 "",
ctx->last_ptr);
}
uint32_t data;
if (etmv1_data(ctx, 4, &data) != 0)
return ERROR_ETM_ANALYSIS_FAILED;
- command_print(cmd_ctx,
+ command_print(cmd->ctx,
"data: 0x%8.8" PRIx32 "",
data);
}
if (etmv1_data(ctx, arm_access_size(&instruction),
&data) != 0)
return ERROR_ETM_ANALYSIS_FAILED;
- command_print(cmd_ctx, "data: 0x%8.8" PRIx32 "", data);
+ command_print(cmd->ctx, "data: 0x%8.8" PRIx32 "", data);
}
}
(cycles == 1) ? "cycle" : "cycles");
}
- command_print(cmd_ctx, "%s%s%s",
+ command_print(cmd->ctx, "%s%s%s",
instruction.text,
(pipestat == STAT_IN) ? " (not executed)" : "",
cycles_text);
COMMAND_HANDLER(handle_etm_dump_command)
{
- struct fileio file;
+ struct fileio *file;
struct target *target;
struct arm *arm;
struct etm_context *etm_ctx;
if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
return ERROR_FAIL;
- fileio_write_u32(&file, etm_ctx->capture_status);
- fileio_write_u32(&file, etm_ctx->control);
- fileio_write_u32(&file, etm_ctx->trace_depth);
+ fileio_write_u32(file, etm_ctx->capture_status);
+ fileio_write_u32(file, etm_ctx->control);
+ fileio_write_u32(file, etm_ctx->trace_depth);
for (i = 0; i < etm_ctx->trace_depth; i++) {
- fileio_write_u32(&file, etm_ctx->trace_data[i].pipestat);
- fileio_write_u32(&file, etm_ctx->trace_data[i].packet);
- fileio_write_u32(&file, etm_ctx->trace_data[i].flags);
+ fileio_write_u32(file, etm_ctx->trace_data[i].pipestat);
+ fileio_write_u32(file, etm_ctx->trace_data[i].packet);
+ fileio_write_u32(file, etm_ctx->trace_data[i].flags);
}
- fileio_close(&file);
+ fileio_close(file);
return ERROR_OK;
}
COMMAND_HANDLER(handle_etm_load_command)
{
- struct fileio file;
+ struct fileio *file;
struct target *target;
struct arm *arm;
struct etm_context *etm_ctx;
return ERROR_FAIL;
size_t filesize;
- int retval = fileio_size(&file, &filesize);
+ int retval = fileio_size(file, &filesize);
if (retval != ERROR_OK) {
- fileio_close(&file);
+ fileio_close(file);
return retval;
}
if (filesize % 4) {
command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data");
- fileio_close(&file);
+ fileio_close(file);
return ERROR_FAIL;
}
{
uint32_t tmp;
- fileio_read_u32(&file, &tmp); etm_ctx->capture_status = tmp;
- fileio_read_u32(&file, &tmp); etm_ctx->control = tmp;
- fileio_read_u32(&file, &etm_ctx->trace_depth);
+ fileio_read_u32(file, &tmp); etm_ctx->capture_status = tmp;
+ fileio_read_u32(file, &tmp); etm_ctx->control = tmp;
+ fileio_read_u32(file, &etm_ctx->trace_depth);
}
etm_ctx->trace_data = malloc(sizeof(struct etmv1_trace_data) * etm_ctx->trace_depth);
if (etm_ctx->trace_data == NULL) {
command_print(CMD_CTX, "not enough memory to perform operation");
- fileio_close(&file);
+ fileio_close(file);
return ERROR_FAIL;
}
for (i = 0; i < etm_ctx->trace_depth; i++) {
uint32_t pipestat, packet, flags;
- fileio_read_u32(&file, &pipestat);
- fileio_read_u32(&file, &packet);
- fileio_read_u32(&file, &flags);
+ fileio_read_u32(file, &pipestat);
+ fileio_read_u32(file, &packet);
+ fileio_read_u32(file, &flags);
etm_ctx->trace_data[i].pipestat = pipestat & 0xff;
etm_ctx->trace_data[i].packet = packet & 0xffff;
etm_ctx->trace_data[i].flags = flags;
}
- fileio_close(&file);
+ fileio_close(file);
return ERROR_OK;
}
return ERROR_FAIL;
}
- retval = etmv1_analyze_trace(etm_ctx, CMD_CTX);
+ retval = etmv1_analyze_trace(etm_ctx, CMD);
if (retval != ERROR_OK) {
/* FIX! error should be reported inside etmv1_analyze_trace() */
switch (retval) {