Allow "tcl_port" to be run after config to simply display the port.
[fw/openocd] / src / server / tcl_server.c
index 30d55cbc348304e94ae03358f3af676d3d177153..b62f1a37e2c99e584e61020f9a13dd0d53fc9206 100644 (file)
@@ -15,7 +15,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -34,7 +34,7 @@ struct tcl_connection {
        int tc_outerror;/* flag an output error */
 };
 
-static const char *tcl_port;
+static char *tcl_port;
 
 /* handlers */
 static int tcl_new_connection(struct connection *connection);
@@ -129,9 +129,8 @@ static int tcl_input(struct connection *connection)
                        tclc->tc_line[tclc->tc_lineoffset-1] = '\0';
                        LOG_DEBUG("Executing script:\n %s", tclc->tc_line);
                        retval = Jim_Eval_Named(interp, tclc->tc_line, "remote:connection", 1);
-                       LOG_DEBUG("Result: %d\n %s", retval,
-                               Jim_GetString(Jim_GetResult(interp), &reslen));
                        result = Jim_GetString(Jim_GetResult(interp), &reslen);
+                       LOG_DEBUG("Result: %d\n %s", retval, result);
                        retval = tcl_output(connection, result, reslen);
                        if (retval != ERROR_OK)
                                return retval;
@@ -177,7 +176,7 @@ static const struct command_registration tcl_command_handlers[] = {
        {
                .name = "tcl_port",
                .handler = handle_tcl_port_command,
-               .mode = COMMAND_CONFIG,
+               .mode = COMMAND_ANY,
                .help = "Specify port on which to listen "
                        "for incoming Tcl syntax.  "
                        "Read help on 'gdb_port'.",