gdb: add default description reg types
[fw/openocd] / src / server / gdb_server.c
index 14925a2bf48329daa6557a7894166d837c52cd4b..a9681c79716ea36f6c91d80b8ce0841e6f4c1ab7 100644 (file)
@@ -702,40 +702,44 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
        int sig_reply_len;
        int signal_var;
 
-       if (gdb_connection->ctrl_c) {
-               signal_var = 0x2;
-               gdb_connection->ctrl_c = 0;
-       } else
-               signal_var = gdb_last_signal(target);
+       if (target->debug_reason == DBG_REASON_EXIT) {
+               sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00");
+       } else {
+               if (gdb_connection->ctrl_c) {
+                       signal_var = 0x2;
+                       gdb_connection->ctrl_c = 0;
+               } else
+                       signal_var = gdb_last_signal(target);
 
-       stop_reason[0] = '\0';
-       if (target->debug_reason == DBG_REASON_WATCHPOINT) {
-               enum watchpoint_rw hit_wp_type;
-               uint32_t hit_wp_address;
+               stop_reason[0] = '\0';
+               if (target->debug_reason == DBG_REASON_WATCHPOINT) {
+                       enum watchpoint_rw hit_wp_type;
+                       uint32_t hit_wp_address;
 
-               if (watchpoint_hit(target, &hit_wp_type, &hit_wp_address) == ERROR_OK) {
+                       if (watchpoint_hit(target, &hit_wp_type, &hit_wp_address) == ERROR_OK) {
 
-                       switch (hit_wp_type) {
-                               case WPT_WRITE:
-                                       snprintf(stop_reason, sizeof(stop_reason),
-                                                       "watch:%08x;", hit_wp_address);
-                                       break;
-                               case WPT_READ:
-                                       snprintf(stop_reason, sizeof(stop_reason),
-                                                       "rwatch:%08x;", hit_wp_address);
-                                       break;
-                               case WPT_ACCESS:
-                                       snprintf(stop_reason, sizeof(stop_reason),
-                                                       "awatch:%08x;", hit_wp_address);
-                                       break;
-                               default:
-                                       break;
+                               switch (hit_wp_type) {
+                                       case WPT_WRITE:
+                                               snprintf(stop_reason, sizeof(stop_reason),
+                                                               "watch:%08x;", hit_wp_address);
+                                               break;
+                                       case WPT_READ:
+                                               snprintf(stop_reason, sizeof(stop_reason),
+                                                               "rwatch:%08x;", hit_wp_address);
+                                               break;
+                                       case WPT_ACCESS:
+                                               snprintf(stop_reason, sizeof(stop_reason),
+                                                               "awatch:%08x;", hit_wp_address);
+                                               break;
+                                       default:
+                                               break;
+                               }
                        }
                }
-       }
 
-       sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s",
-                       signal_var, stop_reason);
+               sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s",
+                               signal_var, stop_reason);
+       }
 
        gdb_put_packet(connection, sig_reply, sig_reply_len);
        gdb_connection->frontend_state = TARGET_HALTED;
@@ -860,6 +864,10 @@ static int gdb_target_callback_event_handler(struct target *target,
 {
        int retval;
        struct connection *connection = priv;
+       struct gdb_service *gdb_service = connection->service->priv;
+
+       if (gdb_service->target != target)
+               return ERROR_OK;
 
        switch (event) {
                case TARGET_EVENT_GDB_HALT:
@@ -898,7 +906,7 @@ static int gdb_new_connection(struct connection *connection)
        gdb_connection->closed = 0;
        gdb_connection->busy = 0;
        gdb_connection->noack_mode = 0;
-       gdb_connection->sync = true;
+       gdb_connection->sync = false;
        gdb_connection->mem_write_error = false;
        gdb_connection->attached = true;
 
@@ -1820,6 +1828,8 @@ static int gdb_memory_map(struct connection *connection,
 static const char *gdb_get_reg_type_name(enum reg_type type)
 {
        switch (type) {
+               case REG_TYPE_INT:
+                       return "int";
                case REG_TYPE_INT8:
                        return "int8";
                case REG_TYPE_INT16:
@@ -1844,6 +1854,8 @@ static const char *gdb_get_reg_type_name(enum reg_type type)
                        return "code_ptr";
                case REG_TYPE_DATA_PTR:
                        return "data_ptr";
+               case REG_TYPE_FLOAT:
+                       return "float";
                case REG_TYPE_IEEE_SINGLE:
                        return "ieee_single";
                case REG_TYPE_IEEE_DOUBLE:
@@ -2928,16 +2940,16 @@ COMMAND_HANDLER(handle_gdb_save_tdesc_command)
 
        int retval = fileio_open(&fileio, tdesc_filename, FILEIO_WRITE, FILEIO_TEXT);
 
-       free(tdesc_filename);
-
        if (retval != ERROR_OK) {
                LOG_WARNING("Can't open %s for writing", tdesc_filename);
+               free(tdesc_filename);
                return ERROR_FAIL;
        }
 
        retval = fileio_write(&fileio, tdesc_length, tdesc, &size_written);
 
        fileio_close(&fileio);
+       free(tdesc_filename);
 
        if (retval != ERROR_OK) {
                LOG_WARNING("Error while writing the tdesc file");