aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-options.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-08-10 14:26:33 +0000
committerNick Clifton <nickc@redhat.com>2007-08-10 14:26:33 +0000
commitf40f1a01c5b348fa521f058e32f4a275c33c5be3 (patch)
treea663fa85af969435b7a05a691774ed190ccda2c2 /sim/common/sim-options.c
parentec8cbbf6de9fb719b1985b7373b5a82890712c3e (diff)
downloadgdb-f40f1a01c5b348fa521f058e32f4a275c33c5be3.zip
gdb-f40f1a01c5b348fa521f058e32f4a275c33c5be3.tar.gz
gdb-f40f1a01c5b348fa521f058e32f4a275c33c5be3.tar.bz2
* sim-memopt.c (memory_options): Mention that the memory-size switch accepts suffixes.
(parse_size): Handle a suffix on the size value. * sim-options.c (standard_options): Mention that the mem-size switch accepts suffixes. (standard_option_handler): Handle a suffix on the size value.
Diffstat (limited to 'sim/common/sim-options.c')
-rw-r--r--sim/common/sim-options.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index 51d3136..614cde8 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -167,8 +167,8 @@ static const OPTION standard_options[] =
#ifdef SIM_HAVE_FLATMEM
{ {"mem-size", required_argument, NULL, OPTION_MEM_SIZE},
- 'm', "MEMORY SIZE", "Specify memory size",
- standard_option_handler },
+ 'm', "<size>[in bytes, Kb (k suffix), Mb (m suffix) or Gb (g suffix)]",
+ "Specify memory size", standard_option_handler },
#endif
{ {"do-command", required_argument, NULL, OPTION_DO_COMMAND},
@@ -381,7 +381,21 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
#ifdef SIM_HAVE_FLATMEM
case OPTION_MEM_SIZE:
{
- unsigned long ul = strtol (arg, NULL, 0);
+ char * endp;
+ unsigned long ul = strtol (arg, &endp, 0);
+
+ switch (* endp)
+ {
+ case 'k': case 'K': size <<= 10; break;
+ case 'm': case 'M': size <<= 20; break;
+ case 'g': case 'G': size <<= 30; break;
+ case ' ': case '\0': case '\t': break;
+ default:
+ if (ul > 0)
+ sim_io_eprintf (sd, "Ignoring strange character at end of memory size: %c\n", * endp);
+ break;
+ }
+
/* 16384: some minimal amount */
if (! isdigit (arg[0]) || ul < 16384)
{