Allow the default input radix to be specified (iradix).
This commit is contained in:
parent
fd98116298
commit
fc808485c2
34
devcmd.c
34
devcmd.c
|
@ -175,16 +175,19 @@ int cmd_erase(char **arg)
|
|||
int cmd_step(char **arg)
|
||||
{
|
||||
char *count_text = get_arg(arg);
|
||||
int count = 1;
|
||||
address_t count = 1;
|
||||
int i;
|
||||
|
||||
if (count_text)
|
||||
count = atoi(count_text);
|
||||
if (count_text) {
|
||||
if (expr_eval(stab_default, count_text, &count) < 0) {
|
||||
printc_err("step: can't parse count: %s\n", count_text);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
while (count > 0) {
|
||||
for (i = 0; i < count; i++)
|
||||
if (device_default->ctl(device_default, DEVICE_CTL_STEP) < 0)
|
||||
return -1;
|
||||
count--;
|
||||
}
|
||||
|
||||
return cmd_regs(NULL);
|
||||
}
|
||||
|
@ -557,13 +560,15 @@ int cmd_setbreak(char **arg)
|
|||
}
|
||||
|
||||
if (index_text) {
|
||||
index = atoi(index_text);
|
||||
address_t val;
|
||||
|
||||
if (index < 0 || index >= device_default->max_breakpoints) {
|
||||
printc_err("setbreak: invalid breakpoint "
|
||||
"slot: %d\n", index);
|
||||
if (expr_eval(stab_default, index_text, &val) < 0 ||
|
||||
val >= device_default->max_breakpoints) {
|
||||
printc("setbreak: invalid breakpoint slot: %d\n", val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
index = val;
|
||||
}
|
||||
|
||||
index = device_setbrk(device_default, index, 1, addr);
|
||||
|
@ -583,11 +588,12 @@ int cmd_delbreak(char **arg)
|
|||
int ret = 0;
|
||||
|
||||
if (index_text) {
|
||||
int index = atoi(index_text);
|
||||
address_t index;
|
||||
|
||||
if (index < 0 || index >= device_default->max_breakpoints) {
|
||||
printc_err("delbreak: invalid breakpoint "
|
||||
"slot: %d\n", index);
|
||||
if (expr_eval(stab_default, index_text, &index) < 0 ||
|
||||
index >= device_default->max_breakpoints) {
|
||||
printc("delbreak: invalid breakpoint slot: %d\n",
|
||||
index);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
14
expr.c
14
expr.c
|
@ -28,6 +28,7 @@
|
|||
#include "stab.h"
|
||||
#include "util.h"
|
||||
#include "output.h"
|
||||
#include "opdb.h"
|
||||
|
||||
/************************************************************************
|
||||
* Address expression parsing.
|
||||
|
@ -52,14 +53,19 @@ static int addr_exp_data(stab_t stab,
|
|||
}
|
||||
|
||||
/* Hex value */
|
||||
if (*text == '0' && text[1] == 'x')
|
||||
if (*text == '0' && text[1] == 'x') {
|
||||
value = strtoul(text + 2, NULL, 16);
|
||||
else if (isdigit(*text))
|
||||
value = atoi(text);
|
||||
else if (stab_get(stab, text, &value) < 0) {
|
||||
} else if (*text == '0' && text[1] == 'd') {
|
||||
value = atoi(text + 2);
|
||||
} else if (stab_get(stab, text, &value) < 0) {
|
||||
char *end;
|
||||
|
||||
value = strtol(text, &end, opdb_get_numeric("iradix"));
|
||||
if (*end) {
|
||||
printc_err("can't parse token: %s\n", text);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->data_stack_size + 1 > ARRAY_LEN(s->data_stack)) {
|
||||
printc_err("data stack overflow at token %s\n", text);
|
||||
|
|
9
gdb.c
9
gdb.c
|
@ -33,6 +33,7 @@
|
|||
#include "gdb.h"
|
||||
#include "output.h"
|
||||
#include "reader.h"
|
||||
#include "expr.h"
|
||||
|
||||
#define MAX_MEM_XFER 8192
|
||||
|
||||
|
@ -698,10 +699,12 @@ static int gdb_server(int port)
|
|||
int cmd_gdb(char **arg)
|
||||
{
|
||||
char *port_text = get_arg(arg);
|
||||
int port = 2000;
|
||||
address_t port = 2000;
|
||||
|
||||
if (port_text)
|
||||
port = atoi(port_text);
|
||||
if (port_text && expr_eval(stab_default, port_text, &port) < 0) {
|
||||
printc_err("gdb: can't parse port: %s\n", port_text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (port <= 0 || port > 65535) {
|
||||
printc_err("gdb: invalid port: %d\n", port);
|
||||
|
|
10
mspdebug.man
10
mspdebug.man
|
@ -389,8 +389,10 @@ Any command which accepts a memory address, length or register value
|
|||
as an argument may be given an address expression. An address
|
||||
expression consists of an algebraic combination of values.
|
||||
|
||||
An address value may be either a decimal value, a hexadecimal value
|
||||
preceeded by the prefix \fB0x\fR, or a symbol name.
|
||||
An address value may be either a symbol name, a hex value preceeded
|
||||
with the specifier "0x", a decimal value preceeded with the specifier
|
||||
"0d", or a number in the default input radix (without a specifier). See
|
||||
the option \fBiradix\fR for more information.
|
||||
|
||||
The operators recognised are the usual algebraic operators: \fB+\fR, \fB-\fR,
|
||||
\fB*\fR, \fB/\fR, \fB%\fR, \fB(\fR and \fB)\fR. Operator precedence is the
|
||||
|
@ -416,6 +418,10 @@ If true, MSPDebug will colorize debugging output.
|
|||
Automatically restart the GDB server after disconnection. If this
|
||||
option is set, then the GDB server keeps running until an error occurs,
|
||||
or the user interrupts with Ctrl+C.
|
||||
.IP "\fBiradix\fR (numeric)"
|
||||
Default input radix for address expressions. For address values with
|
||||
no radix specifier, this value gives the input radix, which is
|
||||
10 (decimal) by default.
|
||||
.IP "\fBquiet\fR (boolean)"
|
||||
If set, MSPDebug will supress most of its debug-related output. This option
|
||||
defaults to false, but can be set true on start-up using the \fB-q\fR
|
||||
|
|
10
opdb.c
10
opdb.c
|
@ -43,10 +43,18 @@ const static struct opdb_key keys[] = {
|
|||
{
|
||||
.name = "quiet",
|
||||
.type = OPDB_TYPE_BOOLEAN,
|
||||
.help = "Supress debugging output\n",
|
||||
.help = "Supress debugging output.\n",
|
||||
.defval = {
|
||||
.boolean = 0
|
||||
}
|
||||
},
|
||||
{
|
||||
.name = "iradix",
|
||||
.type = OPDB_TYPE_NUMERIC,
|
||||
.help = "Default input radix.\n",
|
||||
.defval = {
|
||||
.numeric = 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue