Implemented "exit" command.

This commit is contained in:
Daniel Beer 2010-10-12 11:44:46 +13:00
parent fc808485c2
commit 99c478d37f
6 changed files with 34 additions and 3 deletions

View File

@ -234,6 +234,13 @@ const struct cmddb_record commands[] = {
"locka [set|clear]\n"
" Show or change the status of the LOCKA flash write-protect bit.\n"
},
{
.name = "exit",
.func = cmd_exit,
.help =
"exit\n"
" Exit from MSPDebug.\n"
}
};
int cmddb_get(const char *name, struct cmddb_record *ret)

View File

@ -174,6 +174,8 @@ bit in the flash memory controller).
Specify "segment" and a memory address to erase an individual flash
segment.
.IP "\fBexit\fR"
Exit from MSPDebug.
.IP "\fBgdb\fR [\fIport\fR]"
Start a GDB remote stub, optionally specifying a TCP port to listen on.
If no port is given, the default port is 2000.

View File

@ -38,6 +38,7 @@
static int modify_flags;
static int in_reader_loop;
static int want_exit;
void mark_modified(int flags)
{
@ -57,7 +58,7 @@ int prompt_abort(int flags)
return 0;
for (;;) {
printc("Symbols have not been saved since modification. "
printf("Symbols have not been saved since modification. "
"Continue (y/n)? ");
fflush(stdout);
@ -141,6 +142,11 @@ static int do_command(char *arg, int interactive)
return 0;
}
void reader_exit(void)
{
want_exit = 1;
}
void reader_loop(void)
{
int old = in_reader_loop;
@ -154,19 +160,25 @@ void reader_loop(void)
}
do {
want_exit = 0;
for (;;) {
char *buf = readline("(mspdebug) ");
if (!buf)
if (!buf) {
printc("\n");
break;
}
add_history(buf);
do_command(buf, 1);
free(buf);
if (want_exit)
break;
}
} while (prompt_abort(MODIFY_SYMS));
printc("\n");
in_reader_loop = old;
}

View File

@ -46,6 +46,9 @@ int prompt_abort(int flags);
/* Run the reader loop */
void reader_loop(void);
/* Cause the reader loop to exit */
void reader_exit(void);
/* Commands can be fed directly to the processor either one at a time,
* or by specifying a file to read from.
*/

View File

@ -242,3 +242,9 @@ int cmd_read(char **arg)
return process_file(filename);
}
int cmd_exit(char **arg)
{
reader_exit();
return 0;
}

View File

@ -23,5 +23,6 @@
int cmd_help(char **arg);
int cmd_read(char **arg);
int cmd_opt(char **arg);
int cmd_exit(char **arg);
#endif