connection->priv = tclc;
- struct target *target = get_target_by_num(connection->cmd_ctx->current_target);
+ struct target *target = get_current_target_or_null(connection->cmd_ctx);
if (target != NULL)
tclc->tc_laststate = target->state;
for (i = 0; i < rlen; i++) {
/* buffer the data */
tclc->tc_line[tclc->tc_lineoffset] = in[i];
- if (tclc->tc_lineoffset < tclc->tc_line_size) {
+ if (tclc->tc_lineoffset + 1 < tclc->tc_line_size) {
tclc->tc_lineoffset++;
} else if (tclc->tc_line_size >= TCL_LINE_MAX) {
/* maximum line size reached, drop line */
retval = tcl_output(connection, result, reslen);
if (retval != ERROR_OK)
return retval;
- /* Always output ctrl-d as end of line to allow multiline results */
+ /* Always output ctrl-z as end of line to allow multiline results */
tcl_output(connection, "\x1a", 1);
}
{
.name = "tcl_port",
.handler = handle_tcl_port_command,
- .mode = COMMAND_ANY,
+ .mode = COMMAND_CONFIG,
.help = "Specify port on which to listen "
"for incoming Tcl syntax. "
"Read help on 'gdb_port'.",
tcl_port = strdup("6666");
return register_commands(cmd_ctx, NULL, tcl_command_handlers);
}
+
+void tcl_service_free(void)
+{
+ free(tcl_port);
+}