Added RC file processing on startup.
This commit is contained in:
parent
757a9fb799
commit
b12e0f5ddb
33
main.c
33
main.c
|
@ -34,10 +34,10 @@
|
|||
static void usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s -R [-v voltage] [command ...]\n"
|
||||
" %s -u <device> [-j] [-v voltage] [command ...]\n"
|
||||
" %s -B <device> [command ...]\n"
|
||||
" %s -s [command ...]\n"
|
||||
"Usage: %s [options] -R [-v voltage] [command ...]\n"
|
||||
" %s [options] -u <device> [-j] [-v voltage] [command ...]\n"
|
||||
" %s [options] -B <device> [command ...]\n"
|
||||
" %s [options] -s [command ...]\n"
|
||||
"\n"
|
||||
" -R\n"
|
||||
" Open the first available RF2500 device on the USB bus.\n"
|
||||
|
@ -51,6 +51,10 @@ static void usage(const char *progname)
|
|||
" Debug the FET itself through the bootloader.\n"
|
||||
" -s\n"
|
||||
" Start in simulation mode.\n"
|
||||
" -n\n"
|
||||
" Do not read ~/.mspdebug on startup.\n"
|
||||
" -?\n"
|
||||
" Show this help text.\n"
|
||||
"\n"
|
||||
"By default, the first RF2500 device on the USB bus is opened.\n"
|
||||
"\n"
|
||||
|
@ -59,6 +63,18 @@ static void usage(const char *progname)
|
|||
progname, progname, progname, progname);
|
||||
}
|
||||
|
||||
static void process_rc_file(void)
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
char text[256];
|
||||
|
||||
if (!home)
|
||||
return;
|
||||
|
||||
snprintf(text, sizeof(text), "%s/.mspdebug", home);
|
||||
process_file(text);
|
||||
}
|
||||
|
||||
#define MODE_RF2500 0x01
|
||||
#define MODE_UIF 0x02
|
||||
#define MODE_UIF_BSL 0x04
|
||||
|
@ -71,6 +87,7 @@ int main(int argc, char **argv)
|
|||
const char *bsl_device = NULL;
|
||||
const struct device *msp430_dev = NULL;
|
||||
int opt;
|
||||
int no_rc = 0;
|
||||
int ret = 0;
|
||||
int flags = 0;
|
||||
int want_jtag = 0;
|
||||
|
@ -84,7 +101,7 @@ int main(int argc, char **argv)
|
|||
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
|
||||
/* Parse arguments */
|
||||
while ((opt = getopt(argc, argv, "u:jv:B:sR?")) >= 0)
|
||||
while ((opt = getopt(argc, argv, "u:jv:B:sR?n")) >= 0)
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
mode |= MODE_RF2500;
|
||||
|
@ -112,6 +129,10 @@ int main(int argc, char **argv)
|
|||
mode |= MODE_SIM;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
no_rc = 1;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
|
@ -171,6 +192,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
device_init(msp430_dev);
|
||||
if (!no_rc)
|
||||
process_rc_file();
|
||||
|
||||
/* Process commands */
|
||||
if (optind < argc) {
|
||||
|
|
17
mspdebug.man
17
mspdebug.man
|
@ -2,13 +2,13 @@
|
|||
.SH NAME
|
||||
MSPDebug - debugging tool for MSP430 MCUs
|
||||
.SH SYNOPSIS
|
||||
\fBmspdebug\fR \-R [\-v \fIvoltage\fR] [\fIcommand\fR ...]
|
||||
\fBmspdebug\fR [options] \-R [\-v \fIvoltage\fR] [\fIcommand\fR ...]
|
||||
.br
|
||||
\fBmspdebug\fR \-u \fIdevice\fR [\-j] [\-v \fIvoltage\fR] [\fIcommand\fR ...]
|
||||
\fBmspdebug\fR [options] \-u \fIdevice\fR [\-j] [\-v \fIvoltage\fR] [\fIcommand\fR ...]
|
||||
.br
|
||||
\fBmspdebug\fR \-B \fIdevice\fR [\fIcommand\fR ...]
|
||||
\fBmspdebug\fR [options] \-B \fIdevice\fR [\fIcommand\fR ...]
|
||||
.br
|
||||
\fBmspdebug\fR \-s [\fIcommand\fR ...]
|
||||
\fBmspdebug\fR [options] \-s [\fIcommand\fR ...]
|
||||
.SH DESCRIPTION
|
||||
MSPDebug is a command-line tool designed for debugging and programming
|
||||
the MSP430 family of MCUs. It supports the eZ430-F2013, eZ430-RF2500
|
||||
|
@ -24,6 +24,11 @@ run to breakpoint).
|
|||
It supports ELF32, Intel HEX and BSD-style symbol tables (such as the
|
||||
output produced by \fBnm\fR(1)). It can also be used as a remote stub
|
||||
for \fBgdb\fR(1).
|
||||
|
||||
On startup, MSPDebug will look for a file called .mspdebug in the user's
|
||||
home directory. If it exists, commands will be read and executed from this
|
||||
file before executing any other commands or starting the interactive
|
||||
reader.
|
||||
.SH OPTIONS
|
||||
Command-line options accepted by MSPDebug are described below. If
|
||||
commands are specified on the end of the command-line, then they are
|
||||
|
@ -75,6 +80,10 @@ request and stop execution.
|
|||
This mode is intended for testing of changes to MSPDebug, and for
|
||||
aiding the disassembly of MSP430 binaries (as all binary and symbol
|
||||
table formats are still usable in this mode).
|
||||
.IP "\-n"
|
||||
Do not process the startup file (~/.mspdebug).
|
||||
.IP "\-?"
|
||||
Display a brief help message and exit.
|
||||
.SH COMMANDS
|
||||
MSPDebug can accept commands either through an interactive prompt, or
|
||||
non-interactively when specified on the command line. The supported
|
||||
|
|
27
util.c
27
util.c
|
@ -410,16 +410,11 @@ static struct command command_opt = {
|
|||
" available options.\n"
|
||||
};
|
||||
|
||||
static int cmd_read(char **arg)
|
||||
int process_file(const char *filename)
|
||||
{
|
||||
char *filename = get_arg(arg);
|
||||
FILE *in;
|
||||
char buf[1024];
|
||||
|
||||
if (!filename) {
|
||||
fprintf(stderr, "read: filename must be specified\n");
|
||||
return -1;
|
||||
}
|
||||
int line_no = 0;
|
||||
|
||||
in = fopen(filename, "r");
|
||||
if (!in) {
|
||||
|
@ -431,6 +426,8 @@ static int cmd_read(char **arg)
|
|||
while (fgets(buf, sizeof(buf), in)) {
|
||||
char *cmd = buf;
|
||||
|
||||
line_no++;
|
||||
|
||||
while (*cmd && isspace(*cmd))
|
||||
cmd++;
|
||||
|
||||
|
@ -438,8 +435,8 @@ static int cmd_read(char **arg)
|
|||
continue;
|
||||
|
||||
if (process_command(cmd, 0) < 0) {
|
||||
fprintf(stderr, "read: error processing %s\n",
|
||||
filename);
|
||||
fprintf(stderr, "read: error processing %s (line %d)\n",
|
||||
filename, line_no);
|
||||
fclose(in);
|
||||
return -1;
|
||||
}
|
||||
|
@ -449,6 +446,18 @@ static int cmd_read(char **arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_read(char **arg)
|
||||
{
|
||||
char *filename = get_arg(arg);
|
||||
|
||||
if (!filename) {
|
||||
fprintf(stderr, "read: filename must be specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return process_file(filename);
|
||||
}
|
||||
|
||||
static struct command command_read = {
|
||||
.name = "read",
|
||||
.func = cmd_read,
|
||||
|
|
Loading…
Reference in New Issue