IRAM NOINSTR static void handle_exception(struct regfile *regs) { xthal_set_intenable(0); #if defined(ESP_COREDUMP) && !defined(ESP_COREDUMP_NOAUTO) fprintf(stderr, "Dumping core\n"); esp_dump_core(regs); #else printf("if you want to dump core, type 'y'"); #ifdef ESP_GDB_SERVER printf(", or "); #endif #endif #ifdef ESP_GDB_SERVER printf("connect with gdb now\n"); #endif #if defined(ESP_COREDUMP_NOAUTO) || defined(ESP_GDB_SERVER) { int ch; while ((ch = blocking_read_uart())) { if (ch == 'y') { esp_dump_core(regs); } else if (ch == '$') { /* we got a GDB packet, speed up retransmission by nacking */ printf("-"); gdb_server(regs); break; } } } #endif }
void *gdb_listener(void *arg) { int fd; if ((fd = socket_listen_tcp(5555)) < 0) { xprintf(XGDB, "gdb_listener() cannot bind to 5555\n"); return NULL; } for (;;) { int s = accept(fd, NULL, NULL); if (s >= 0) { gdb_server(s); close(s); } } return NULL; }
int cmd_gdb(char **arg) { char *port_text = get_arg(arg); address_t port = 2000; if (port_text && expr_eval(port_text, &port) < 0) { printc_err("gdb: can't parse port: %s\n", port_text); return -1; } if (port <= 0 || port > 65535) { printc_err("gdb: invalid port: %d\n", port); return -1; } do { if (gdb_server(port) < 0) return -1; } while (opdb_get_boolean("gdb_loop")); return 0; }