/* only allocate multiples of 4 byte */
if (size % 4)
{
- LOG_ERROR("BUG: code tried to allocate unaligned number of bytes, padding");
- size = CEIL(size, 4);
+ LOG_ERROR("BUG: code tried to allocate unaligned number of bytes (0x%08x), padding", ((unsigned)(size)));
+ size = (size + 3) & (~3);
}
/* see if there's already a matching working area */
if (free_size < size)
{
- LOG_WARNING("not enough working area available(requested %d, free %d)", size, free_size);
+ LOG_WARNING("not enough working area available(requested %u, free %u)",
+ (unsigned)(size), (unsigned)(free_size));
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
int target_write_buffer(struct target_s *target, uint32_t address, uint32_t size, uint8_t *buffer)
{
int retval;
- LOG_DEBUG("writing buffer of %i byte at 0x%8.8x", size, address);
+ LOG_DEBUG("writing buffer of %i byte at 0x%8.8x",
+ (int)size, (unsigned)address);
if (!target_was_examined(target))
{
if ((address + size - 1) < address)
{
/* GDB can request this when e.g. PC is 0xfffffffc*/
- LOG_ERROR("address+size wrapped(0x%08x, 0x%08x)", address, size);
+ LOG_ERROR("address+size wrapped(0x%08x, 0x%08x)",
+ (unsigned)address,
+ (unsigned)size);
return ERROR_FAIL;
}
int target_read_buffer(struct target_s *target, uint32_t address, uint32_t size, uint8_t *buffer)
{
int retval;
- LOG_DEBUG("reading buffer of %i byte at 0x%8.8x", size, address);
+ LOG_DEBUG("reading buffer of %i byte at 0x%8.8x",
+ (int)size, (unsigned)address);
if (!target_was_examined(target))
{
if ((address + size - 1) < address)
{
/* GDB can request this when e.g. PC is 0xfffffffc*/
- LOG_ERROR("address+size wrapped(0x%08x, 0x%08x)", address, size);
+ LOG_ERROR("address+size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")",
+ address,
+ size);
return ERROR_FAIL;
}
buffer = malloc(size);
if (buffer == NULL)
{
- LOG_ERROR("error allocating buffer for section (%d bytes)", size);
+ LOG_ERROR("error allocating buffer for section (%d bytes)", (int)size);
return ERROR_INVALID_ARGUMENTS;
}
retval = target_read_buffer(target, address, size, buffer);
if (retval == ERROR_OK)
{
*value = target_buffer_get_u32(target, value_buf);
- LOG_DEBUG("address: 0x%8.8x, value: 0x%8.8x", address, *value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8" PRIx32 "",
+ address,
+ *value);
}
else
{
*value = 0x0;
- LOG_DEBUG("address: 0x%8.8x failed", address);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 " failed",
+ address);
}
return retval;
if (retval == ERROR_OK)
{
*value = target_buffer_get_u16(target, value_buf);
- LOG_DEBUG("address: 0x%8.8x, value: 0x%4.4x", address, *value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%4.4x",
+ address,
+ *value);
}
else
{
*value = 0x0;
- LOG_DEBUG("address: 0x%8.8x failed", address);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 " failed",
+ address);
}
return retval;
if (retval == ERROR_OK)
{
- LOG_DEBUG("address: 0x%8.8x, value: 0x%2.2x", address, *value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%2.2x",
+ address,
+ *value);
}
else
{
*value = 0x0;
- LOG_DEBUG("address: 0x%8.8x failed", address);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 " failed",
+ address);
}
return retval;
return ERROR_FAIL;
}
- LOG_DEBUG("address: 0x%8.8x, value: 0x%8.8x", address, value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8" PRIx32 "",
+ address,
+ value);
target_buffer_set_u32(target, value_buf, value);
if ((retval = target_write_memory(target, address, 4, 1, value_buf)) != ERROR_OK)
return ERROR_FAIL;
}
- LOG_DEBUG("address: 0x%8.8x, value: 0x%8.8x", address, value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8x",
+ address,
+ value);
target_buffer_set_u16(target, value_buf, value);
if ((retval = target_write_memory(target, address, 2, 1, value_buf)) != ERROR_OK)
return ERROR_FAIL;
}
- LOG_DEBUG("address: 0x%8.8x, value: 0x%2.2x", address, value);
+ LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%2.2x",
+ address, value);
if ((retval = target_write_memory(target, address, 1, 1, &value)) != ERROR_OK)
{
for (i = 0; i < cache->num_regs; i++)
{
value = buf_to_str(cache->reg_list[i].value, cache->reg_list[i].size, 16);
- command_print(cmd_ctx, "(%i) %s (/%i): 0x%s (dirty: %i, valid: %i)", count++, cache->reg_list[i].name, cache->reg_list[i].size, value, cache->reg_list[i].dirty, cache->reg_list[i].valid);
+ command_print(cmd_ctx, "(%i) %s (/%i): 0x%s (dirty: %i, valid: %i)",
+ count++,
+ cache->reg_list[i].name,
+ (int)(cache->reg_list[i].size),
+ value,
+ cache->reg_list[i].dirty,
+ cache->reg_list[i].valid);
free(value);
}
cache = cache->next;
arch_type->get(reg);
}
value = buf_to_str(reg->value, reg->size, 16);
- command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, reg->size, value);
+ command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, (int)(reg->size), value);
free(value);
return ERROR_OK;
}
arch_type->set(reg, buf);
value = buf_to_str(reg->value, reg->size, 16);
- command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, reg->size, value);
+ command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, (int)(reg->size), value);
free(value);
free(buf);
{
output_len += snprintf(output + output_len,
sizeof(output) - output_len,
- "0x%8.8x: ", address + (i*size));
+ "0x%8.8x: ",
+ (unsigned)(address + (i*size)));
}
uint32_t value=0;
buffer = malloc(image.sections[i].size);
if (buffer == NULL)
{
- command_print(cmd_ctx, "error allocating buffer for section (%d bytes)", image.sections[i].size);
+ command_print(cmd_ctx,
+ "error allocating buffer for section (%d bytes)",
+ (int)(image.sections[i].size));
break;
}
break;
}
image_size += length;
- command_print(cmd_ctx, "%u byte written at address 0x%8.8x", length, image.sections[i].base_address+offset);
+ command_print(cmd_ctx, "%u byte written at address 0x%8.8" PRIx32 "",
+ (unsigned int)length,
+ image.sections[i].base_address+offset);
}
free(buffer);
if (retval==ERROR_OK)
{
- command_print(cmd_ctx, "downloaded %u byte in %s", image_size, duration_text);
+ command_print(cmd_ctx, "downloaded %u byte in %s",
+ (unsigned int)image_size,
+ duration_text);
}
free(duration_text);
buffer = malloc(image.sections[i].size);
if (buffer == NULL)
{
- command_print(cmd_ctx, "error allocating buffer for section (%d bytes)", image.sections[i].size);
+ command_print(cmd_ctx,
+ "error allocating buffer for section (%d bytes)",
+ (int)(image.sections[i].size));
break;
}
if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK)
{
if (data[t] != buffer[t])
{
- command_print(cmd_ctx, "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n", t + image.sections[i].base_address, data[t], buffer[t]);
+ command_print(cmd_ctx,
+ "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n",
+ (unsigned)(t + image.sections[i].base_address),
+ data[t],
+ buffer[t]);
free(data);
free(buffer);
retval=ERROR_FAIL;
}
} else
{
- command_print(cmd_ctx, "address 0x%08x length 0x%08x", image.sections[i].base_address, buf_cnt);
+ command_print(cmd_ctx, "address 0x%08" PRIx32 " length 0x%08" PRIx32 "",
+ image.sections[i].base_address,
+ buf_cnt);
}
free(buffer);
if (retval==ERROR_OK)
{
- command_print(cmd_ctx, "verified %u bytes in %s", image_size, duration_text);
+ command_print(cmd_ctx, "verified %u bytes in %s",
+ (unsigned int)image_size,
+ duration_text);
}
free(duration_text);
{
char* buf = buf_to_str(breakpoint->orig_instr,
breakpoint->length, 16);
- command_print(cmd_ctx, "0x%8.8x, 0x%x, %i, 0x%s",
- breakpoint->address, breakpoint->length,
+ command_print(cmd_ctx, "0x%8.8" PRIx32 ", 0x%x, %i, 0x%s",
+ breakpoint->address,
+ breakpoint->length,
breakpoint->set, buf);
free(buf);
}
else
{
- command_print(cmd_ctx, "0x%8.8x, 0x%x, %i",
- breakpoint->address, breakpoint->length, breakpoint->set);
+ command_print(cmd_ctx, "0x%8.8" PRIx32 ", 0x%x, %i",
+ breakpoint->address,
+ breakpoint->length, breakpoint->set);
}
breakpoint = breakpoint->next;
target_t *target = get_current_target(cmd_ctx);
int retval = breakpoint_add(target, addr, length, hw);
if (ERROR_OK == retval)
- command_print(cmd_ctx, "breakpoint set at 0x%8.8x", addr);
+ command_print(cmd_ctx, "breakpoint set at 0x%8.8" PRIx32 "", addr);
else
LOG_ERROR("Failure setting breakpoint");
return retval;
while (watchpoint)
{
- command_print(cmd_ctx, "address: 0x%8.8x, len: 0x%8.8x, r/w/a: %i, value: 0x%8.8x, mask: 0x%8.8x", watchpoint->address, watchpoint->length, watchpoint->rw, watchpoint->value, watchpoint->mask);
+ command_print(cmd_ctx,
+ "address: 0x%8.8" PRIx32 ", len: 0x%8.8x, r/w/a: %i, value: 0x%8.8" PRIx32 ", mask: 0x%8.8" PRIx32 "",
+ watchpoint->address,
+ watchpoint->length,
+ (int)(watchpoint->rw),
+ watchpoint->value,
+ watchpoint->mask);
watchpoint = watchpoint->next;
}
return ERROR_OK;
target_t *target = get_current_target(cmd_ctx);
retval = target->type->virt2phys(target, va, &pa);
if (retval == ERROR_OK)
- command_print(cmd_ctx, "Physical address 0x%08x", pa);
+ command_print(cmd_ctx, "Physical address 0x%08" PRIx32 "", pa);
return retval;
}
} else {
char buf[100];
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- sprintf(buf, "mem2array address: 0x%08x is not aligned for %d byte reads", addr, width);
+ sprintf(buf, "mem2array address: 0x%08" PRIx32 " is not aligned for %" PRId32 " byte reads",
+ addr,
+ width);
Jim_AppendStrings(interp, Jim_GetResult(interp), buf , NULL);
return JIM_ERR;
}
retval = target_read_memory( target, addr, width, count, buffer );
if (retval != ERROR_OK) {
/* BOO !*/
- LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count);
+ LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed",
+ (unsigned int)addr,
+ (int)width,
+ (int)count);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
Jim_AppendStrings(interp, Jim_GetResult(interp), "mem2array: cannot read memory", NULL);
e = JIM_ERR;
} else {
char buf[100];
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- sprintf(buf, "array2mem address: 0x%08x is not aligned for %d byte reads", addr, width);
+ sprintf(buf, "array2mem address: 0x%08x is not aligned for %d byte reads",
+ (unsigned int)addr,
+ (int)width);
Jim_AppendStrings(interp, Jim_GetResult(interp), buf , NULL);
return JIM_ERR;
}
retval = target_write_memory(target, addr, width, count, buffer);
if (retval != ERROR_OK) {
/* BOO !*/
- LOG_ERROR("array2mem: Write @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count);
+ LOG_ERROR("array2mem: Write @ 0x%08x, w=%d, cnt=%d, failed",
+ (unsigned int)addr,
+ (int)width,
+ (int)count);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
Jim_AppendStrings(interp, Jim_GetResult(interp), "array2mem: cannot read memory", NULL);
e = JIM_ERR;
target_t *target;
LOG_DEBUG( "**all*targets: event: %d, %s",
- e,
- Jim_Nvp_value2name_simple( nvp_target_event, e )->name );
+ (int)e,
+ Jim_Nvp_value2name_simple( nvp_target_event, e )->name );
target = all_targets;
while (target){
buffer = malloc(image.sections[i].size);
if (buffer == NULL)
{
- command_print(cmd_ctx, "error allocating buffer for section (%d bytes)", image.sections[i].size);
+ command_print(cmd_ctx, "error allocating buffer for section (%d bytes)",
+ (int)(image.sections[i].size));
break;
}
fastload[i].length=length;
image_size += length;
- command_print(cmd_ctx, "%u byte written at address 0x%8.8x", length, image.sections[i].base_address+offset);
+ command_print(cmd_ctx, "%u byte written at address 0x%8.8x",
+ (unsigned int)length,
+ ((unsigned int)(image.sections[i].base_address+offset)));
}
free(buffer);
duration_stop_measure(&duration, &duration_text);
if (retval==ERROR_OK)
{
- command_print(cmd_ctx, "Loaded %u bytes in %s", image_size, duration_text);
+ command_print(cmd_ctx, "Loaded %u bytes in %s", (unsigned int)image_size, duration_text);
command_print(cmd_ctx, "NB!!! image has not been loaded to target, issue a subsequent 'fast_load' to do so.");
}
free(duration_text);
for (i=0; i<fastload_num;i++)
{
target_t *target = get_current_target(cmd_ctx);
- command_print(cmd_ctx, "Write to 0x%08x, length 0x%08x", fastload[i].address, fastload[i].length);
+ command_print(cmd_ctx, "Write to 0x%08x, length 0x%08x",
+ (unsigned int)(fastload[i].address),
+ (unsigned int)(fastload[i].length));
if (retval==ERROR_OK)
{
retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data);
command_print(cmd_ctx, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
return retval;
}
+
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */