Implemented repeat execution for reader.
Repeat execution is supported by the commands "step", "md" and "dis".
This commit is contained in:
parent
5e39d82784
commit
b2d2da6cb6
4
devcmd.c
4
devcmd.c
|
@ -79,6 +79,8 @@ int cmd_md(char **arg)
|
||||||
length = 0x10000 - offset;
|
length = 0x10000 - offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reader_set_repeat("md 0x%x 0x%x", offset + length, length);
|
||||||
|
|
||||||
while (length) {
|
while (length) {
|
||||||
uint8_t buf[128];
|
uint8_t buf[128];
|
||||||
int blen = length > sizeof(buf) ? sizeof(buf) : length;
|
int blen = length > sizeof(buf) ? sizeof(buf) : length;
|
||||||
|
@ -189,6 +191,7 @@ int cmd_step(char **arg)
|
||||||
if (device_default->ctl(device_default, DEVICE_CTL_STEP) < 0)
|
if (device_default->ctl(device_default, DEVICE_CTL_STEP) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
reader_set_repeat("step");
|
||||||
return cmd_regs(NULL);
|
return cmd_regs(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +318,7 @@ int cmd_dis(char **arg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reader_set_repeat("dis 0x%x 0x%x", offset + length, length);
|
||||||
disassemble(offset, buf, length);
|
disassemble(offset, buf, length);
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
14
mspdebug.man
14
mspdebug.man
|
@ -131,6 +131,11 @@ Commands take arguments separated by spaces. Any text string enclosed
|
||||||
in double-quotation marks is considered to be a single argument, even
|
in double-quotation marks is considered to be a single argument, even
|
||||||
if it contains space characters. Within a quoted string, the usual
|
if it contains space characters. Within a quoted string, the usual
|
||||||
C-style backslash substitutions can be used.
|
C-style backslash substitutions can be used.
|
||||||
|
|
||||||
|
Commands can be specified by giving the first few characters of the
|
||||||
|
command name, provided that the prefix is unambiguous. Some commands
|
||||||
|
support automatic repeat. For these commands, pressing enter at the
|
||||||
|
reader prompt without typing anything will cause repeat execution.
|
||||||
.IP "\fB=\fR \fIexpression\fR"
|
.IP "\fB=\fR \fIexpression\fR"
|
||||||
Evaluate an address expression and show both its value, and the result
|
Evaluate an address expression and show both its value, and the result
|
||||||
when the value is looked up in reverse in the current symbol
|
when the value is looked up in reverse in the current symbol
|
||||||
|
@ -166,6 +171,9 @@ length (64 bytes) is disassembled and shown.
|
||||||
|
|
||||||
If symbols are available, then all addresses used as operands are
|
If symbols are available, then all addresses used as operands are
|
||||||
translated into \fIsymbol\fR+\fIoffset\fR form.
|
translated into \fIsymbol\fR+\fIoffset\fR form.
|
||||||
|
|
||||||
|
This command supports repeat execution. If repeated, it continues to
|
||||||
|
disassemble another block of memory following that last printed.
|
||||||
.IP "\fBerase\fR [\fBall\fR|\fBsegment\fR] [\fIaddress\fR]"
|
.IP "\fBerase\fR [\fBall\fR|\fBsegment\fR] [\fIaddress\fR]"
|
||||||
Erase the device under test. With no arguments, all code memory is erased
|
Erase the device under test. With no arguments, all code memory is erased
|
||||||
(but not information or boot memory). With the argument "all", a mass
|
(but not information or boot memory). With the argument "all", a mass
|
||||||
|
@ -293,6 +301,9 @@ The output is split into three columns. The first column shows the
|
||||||
starting address for the line. The second column lists the hexadecimal
|
starting address for the line. The second column lists the hexadecimal
|
||||||
values of the bytes. The final column shows the ASCII characters
|
values of the bytes. The final column shows the ASCII characters
|
||||||
corresponding to printable bytes, and . for non-printing characters.
|
corresponding to printable bytes, and . for non-printing characters.
|
||||||
|
|
||||||
|
This command supports repeat execution. If repeated, it continues to
|
||||||
|
print another block of memory following that last printed.
|
||||||
.IP "\fBmw\fR \fIaddress\fR \fIbytes\fR ..."
|
.IP "\fBmw\fR \fIaddress\fR \fIbytes\fR ..."
|
||||||
Write a sequence of bytes at the given memory address. The address given
|
Write a sequence of bytes at the given memory address. The address given
|
||||||
may be an address expression. Bytes values are two-digit hexadecimal
|
may be an address expression. Bytes values are two-digit hexadecimal
|
||||||
|
@ -354,7 +365,8 @@ register values are displayed, as well as a disassembly of the
|
||||||
instructions at the address selected by the program counter.
|
instructions at the address selected by the program counter.
|
||||||
|
|
||||||
An optional count can be specified to step multiple times. If no
|
An optional count can be specified to step multiple times. If no
|
||||||
argument is given, the CPU steps once.
|
argument is given, the CPU steps once. This command supports repeat
|
||||||
|
execution.
|
||||||
.IP "\fBsym clear\fR"
|
.IP "\fBsym clear\fR"
|
||||||
Clear the symbol table, deleting all symbols.
|
Clear the symbol table, deleting all symbols.
|
||||||
.IP "\fBsym set\fR \fIname\fR \fIvalue\fR"
|
.IP "\fBsym set\fR \fIname\fR \fIvalue\fR"
|
||||||
|
|
28
reader.c
28
reader.c
|
@ -36,9 +36,12 @@
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "opdb.h"
|
#include "opdb.h"
|
||||||
|
|
||||||
|
#define MAX_READER_LINE 1024
|
||||||
|
|
||||||
static int modify_flags;
|
static int modify_flags;
|
||||||
static int in_reader_loop;
|
static int in_reader_loop;
|
||||||
static int want_exit;
|
static int want_exit;
|
||||||
|
static char repeat_buf[MAX_READER_LINE];
|
||||||
|
|
||||||
void mark_modified(int flags)
|
void mark_modified(int flags)
|
||||||
{
|
{
|
||||||
|
@ -147,6 +150,15 @@ void reader_exit(void)
|
||||||
want_exit = 1;
|
want_exit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reader_set_repeat(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(repeat_buf, sizeof(repeat_buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
void reader_loop(void)
|
void reader_loop(void)
|
||||||
{
|
{
|
||||||
int old = in_reader_loop;
|
int old = in_reader_loop;
|
||||||
|
@ -164,15 +176,27 @@ void reader_loop(void)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char *buf = readline("(mspdebug) ");
|
char *buf = readline("(mspdebug) ");
|
||||||
|
char tmpbuf[MAX_READER_LINE];
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
printc("\n");
|
printc("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_history(buf);
|
/* Copy into our local buffer and free */
|
||||||
do_command(buf, 1);
|
strncpy(tmpbuf, buf, sizeof(tmpbuf));
|
||||||
|
tmpbuf[sizeof(tmpbuf) - 1] = 0;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
buf = tmpbuf;
|
||||||
|
|
||||||
|
if (*buf) {
|
||||||
|
add_history(buf);
|
||||||
|
repeat_buf[0] = 0;
|
||||||
|
} else {
|
||||||
|
memcpy(tmpbuf, repeat_buf, sizeof(tmpbuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
do_command(buf, 1);
|
||||||
|
|
||||||
if (want_exit)
|
if (want_exit)
|
||||||
break;
|
break;
|
||||||
|
|
8
reader.h
8
reader.h
|
@ -49,6 +49,14 @@ void reader_loop(void);
|
||||||
/* Cause the reader loop to exit */
|
/* Cause the reader loop to exit */
|
||||||
void reader_exit(void);
|
void reader_exit(void);
|
||||||
|
|
||||||
|
/* Set up the command to be repeated. When the user presses enter without
|
||||||
|
* typing anything, the last executed command is repeated, by default.
|
||||||
|
*
|
||||||
|
* Using this function, a command can specify an alternate command for
|
||||||
|
* the next execution.
|
||||||
|
*/
|
||||||
|
void reader_set_repeat(const char *fmt, ...);
|
||||||
|
|
||||||
/* Commands can be fed directly to the processor either one at a time,
|
/* Commands can be fed directly to the processor either one at a time,
|
||||||
* or by specifying a file to read from.
|
* or by specifying a file to read from.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue