server: gdb_server: fix memory map generation on a 32-bit BE host
Due to lack of printf format check wrong specifier was used and it actually broke operation on a 32-bit BE host. So fix this and add the necessary function attributes so that the bugs like that can be uncovered automaticaly. Reported and pinpointed by Karl Palsson on IRC. Change-Id: I254ec28fcd9bb30594d607f74a6dba5456c2c7a1 Tested-by: Karl Palsson <karlp@tweak.net.au> Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5342 Tested-by: jenkins Reviewed-by: Karl Palsson <karlp@tweak.net.au> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
678fb4f60b
commit
1e427fd580
|
@ -95,7 +95,8 @@ int log_add_callback(log_callback_fn fn, void *priv);
|
|||
int log_remove_callback(log_callback_fn fn, void *priv);
|
||||
|
||||
char *alloc_vprintf(const char *fmt, va_list ap);
|
||||
char *alloc_printf(const char *fmt, ...);
|
||||
char *alloc_printf(const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2)));
|
||||
|
||||
extern int debug_level;
|
||||
|
||||
|
|
|
@ -1729,8 +1729,8 @@ static int gdb_breakpoint_watchpoint_packet(struct connection *connection,
|
|||
/* print out a string and allocate more space as needed,
|
||||
* mainly used for XML at this point
|
||||
*/
|
||||
static void xml_printf(int *retval, char **xml, int *pos, int *size,
|
||||
const char *fmt, ...)
|
||||
static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))) void xml_printf(int *retval,
|
||||
char **xml, int *pos, int *size, const char *fmt, ...)
|
||||
{
|
||||
if (*retval != ERROR_OK)
|
||||
return;
|
||||
|
@ -1871,7 +1871,7 @@ static int gdb_memory_map(struct connection *connection,
|
|||
if (ram_start < p->base)
|
||||
xml_printf(&retval, &xml, &pos, &size,
|
||||
"<memory type=\"ram\" start=\"" TARGET_ADDR_FMT "\" "
|
||||
"length=\"0x%x\"/>\n",
|
||||
"length=\"" TARGET_ADDR_FMT "\"/>\n",
|
||||
ram_start, p->base - ram_start);
|
||||
|
||||
/* Report adjacent groups of same-size sectors. So for
|
||||
|
@ -2469,7 +2469,7 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
|
|||
xml_printf(&retval, &thread_list, &pos, &size,
|
||||
", ");
|
||||
xml_printf(&retval, &thread_list, &pos, &size,
|
||||
thread_detail->extra_info_str);
|
||||
"%s", thread_detail->extra_info_str);
|
||||
}
|
||||
|
||||
xml_printf(&retval, &thread_list, &pos, &size,
|
||||
|
@ -3555,7 +3555,7 @@ static int gdb_target_add_one(struct target *target)
|
|||
if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
|
||||
free(gdb_port_next);
|
||||
if (portnumber) {
|
||||
gdb_port_next = alloc_printf("%d", portnumber+1);
|
||||
gdb_port_next = alloc_printf("%ld", portnumber+1);
|
||||
} else {
|
||||
/* Don't increment if gdb_port is 0, since we're just
|
||||
* trying to allocate an unused port. */
|
||||
|
|
Loading…
Reference in New Issue