2.3.6. ARGUMENTS

Enables you to specify the command-line arguments for the application. These are used for each subsequent run on this connection.

Note

You can also specify arguments as part of the LOAD command.

Syntax

ARGUMENTS [{,delete | ,prompt}]

ARGUMENTS [,default] string

where:

delete

Delete the currently set ARGUMENTS list, so the argv list for the next run of a program is only the program filename.

default

Make the defined arguments the default, so they apply to new connections created in this session.

prompt

Display a dialog to prompt you for the arguments when the ARGUMENTS command is executed.

string

Defines the command line that the application sees when it inspects the argv[] array, or equivalent.

Description

The ARGUMENTS command enables you to specify arguments that the target application might require when it starts execution. The specified string is made available to the application running on the target through the semihosting mechanism. Any previous argument definition is overwritten.

If a literal double-quotation mark character is required in the arguments, you must escape it using the backslash character and embed it in single quotation marks, for example:

ARGUMENTS '-f \"my file.c\"'

If you enter this command without any parameters, the current argument definition is displayed.

About using the ARGUMENTS command

You must issue the ARGUMENTS command after loading and reloading an image:

  • This sequence works:

    LOAD .....
    ARGUMENTS "hello"
    
  • This sequence does not work:

    ARGUMENTS "hello"
    LOAD
    
  • This sequence works initially, but the argument setttings are lost after the reload:

    LOAD
    ARGUMENTS "hello"
    GO
    RELOAD
    

    After reloading the image, enter this command again to specify the arguments before running the image.

Examples

The following examples show how to use ARGUMENTS:

ARGUMENTS '-f file.c -o file.o'

Sets the command line so that, if the line is parsed in the normal way by _main(), the argv[] array contains:

argv[0]

target program filename, for example: com.axf

argv[1]

-f

argv[2]

file.c

argv[3]

-o

argv[4]

file.o

argv[5]

NUL

ARGUMENTS '-f \"my file.c\" -o \"my file.o\"'

Sets the command line so that, if the line is parsed in the normal way by _main(), the argv[] array contains:

argv[0]

target program filename, for example: "com.axf"

argv[1]

-f

argv[2]

"my file.c"

argv[3]

-o

argv[4]

"my file.o"

argv[5]

NUL

load /pd/r 'com.axf;;-f file.c -o file.o' go arguments '-f \"my file.c\" -o \"my file.o\"' restart go

Changes the arguments without unloading the image. Table 2.16 shows the argument assignments in the original LOAD command, and the new assignments specified by the ARGUMENTS command.

Table 2.16.  Changed argument assignments

ArgumentOriginal valueNew value
argv[0]com.axfcom.axf
argv[1]-f-f
argv[2]file.c"my file.c"
argv[3]-o-o
argv[4]file.o"my file.o"
argv[5]NULNUL

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N
Non-ConfidentialID052111