Make sure we free any memory used for gdb_save_tdesc.
Change-Id: Ia226f6134318c8c6b0ac4fa20fe70a570a08d80d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1619
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
* found in most modern embedded processors.
*/
* found in most modern embedded processors.
*/
+struct target_desc_format {
+ char *tdesc;
+ uint32_t tdesc_length;
+};
+
/* private connection data for GDB */
struct gdb_connection {
char buffer[GDB_BUFFER_SIZE];
/* private connection data for GDB */
struct gdb_connection {
char buffer[GDB_BUFFER_SIZE];
* normally we reply with a S reply via gdb_last_signal_packet.
* as a side note this behaviour only effects gdb > 6.8 */
bool attached;
* normally we reply with a S reply via gdb_last_signal_packet.
* as a side note this behaviour only effects gdb > 6.8 */
bool attached;
+ /* temporarily used for target description support */
+ struct target_desc_format target_desc;
gdb_connection->sync = false;
gdb_connection->mem_write_error = false;
gdb_connection->attached = true;
gdb_connection->sync = false;
gdb_connection->mem_write_error = false;
gdb_connection->attached = true;
+ gdb_connection->target_desc.tdesc = NULL;
+ gdb_connection->target_desc.tdesc_length = 0;
/* send ACK to GDB for debug request */
gdb_write(connection, "+", 1);
/* send ACK to GDB for debug request */
gdb_write(connection, "+", 1);
/* Get a list of available target registers features. feature_list must
* be freed by caller.
*/
/* Get a list of available target registers features. feature_list must
* be freed by caller.
*/
-int get_reg_features_list(struct target *target, char **feature_list[], int *feature_list_size,
+static int get_reg_features_list(struct target *target, char **feature_list[], int *feature_list_size,
struct reg **reg_list, int reg_list_size)
{
int tbl_sz = 0;
struct reg **reg_list, int reg_list_size)
{
int tbl_sz = 0;
-static int gdb_get_target_description_chunk(struct target *target, char **chunk,
- int32_t offset, uint32_t length)
+static int gdb_get_target_description_chunk(struct target *target, struct target_desc_format *target_desc,
+ char **chunk, int32_t offset, uint32_t length)
- static char *tdesc;
- static uint32_t tdesc_length;
+ if (target_desc == NULL) {
+ LOG_ERROR("Unable to Generate Target Description");
+ return ERROR_FAIL;
+ }
+
+ char *tdesc = target_desc->tdesc;
+ uint32_t tdesc_length = target_desc->tdesc_length;
- gdb_generate_target_description(target, &tdesc);
+ int retval = gdb_generate_target_description(target, &tdesc);
+ if (retval != ERROR_OK) {
+ LOG_ERROR("Unable to Generate Target Description");
+ return ERROR_FAIL;
+ }
+
tdesc_length = strlen(tdesc);
}
tdesc_length = strlen(tdesc);
}
transfer_type = 'l';
*chunk = malloc(length + 2);
transfer_type = 'l';
*chunk = malloc(length + 2);
+ if (*chunk == NULL) {
+ LOG_ERROR("Unable to allocate memory");
+ return ERROR_FAIL;
+ }
+
(*chunk)[0] = transfer_type;
if (transfer_type == 'm') {
strncpy((*chunk) + 1, tdesc + offset, length);
(*chunk)[0] = transfer_type;
if (transfer_type == 'm') {
strncpy((*chunk) + 1, tdesc + offset, length);
+ target_desc->tdesc = tdesc;
+ target_desc->tdesc_length = tdesc_length;
+
* there are *more* chunks to transfer. 'l' for it is the *last*
* chunk of target description.
*/
* there are *more* chunks to transfer. 'l' for it is the *last*
* chunk of target description.
*/
- retval = gdb_get_target_description_chunk(target, &xml, offset, length);
+ retval = gdb_get_target_description_chunk(target, &gdb_connection->target_desc,
+ &xml, offset, length);
if (retval != ERROR_OK) {
gdb_error(connection, retval);
return retval;
if (retval != ERROR_OK) {
gdb_error(connection, retval);
return retval;
COMMAND_HANDLER(handle_gdb_save_tdesc_command)
{
COMMAND_HANDLER(handle_gdb_save_tdesc_command)
{
- static char *tdesc;
- static uint32_t tdesc_length;
+ char *tdesc;
+ uint32_t tdesc_length;
struct target *target = get_current_target(CMD_CTX);
char *tdesc_filename;
struct target *target = get_current_target(CMD_CTX);
char *tdesc_filename;
- if (tdesc == NULL) {
- gdb_generate_target_description(target, &tdesc);
- tdesc_length = strlen(tdesc);
+ int retval = gdb_generate_target_description(target, &tdesc);
+ if (retval != ERROR_OK) {
+ LOG_ERROR("Unable to Generate Target Description");
+ return ERROR_FAIL;
+ }
+
+ tdesc_length = strlen(tdesc);
+
+ if (tdesc_length == 0) {
+ LOG_ERROR("Unable to Generate Target Description");
+ return ERROR_FAIL;
tdesc_filename = malloc(strlen(target_type_name(target)) + 5);
sprintf(tdesc_filename, "%s.xml", target_type_name(target));
tdesc_filename = malloc(strlen(target_type_name(target)) + 5);
sprintf(tdesc_filename, "%s.xml", target_type_name(target));
- int retval = fileio_open(&fileio, tdesc_filename, FILEIO_WRITE, FILEIO_TEXT);
+ retval = fileio_open(&fileio, tdesc_filename, FILEIO_WRITE, FILEIO_TEXT);
if (retval != ERROR_OK) {
LOG_WARNING("Can't open %s for writing", tdesc_filename);
if (retval != ERROR_OK) {
LOG_WARNING("Can't open %s for writing", tdesc_filename);
fileio_close(&fileio);
free(tdesc_filename);
fileio_close(&fileio);
free(tdesc_filename);
if (retval != ERROR_OK) {
LOG_WARNING("Error while writing the tdesc file");
if (retval != ERROR_OK) {
LOG_WARNING("Error while writing the tdesc file");
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)