[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.2 Starting your Program
-
run
-
r
Use the
run
command to start your program under No value for GDBN. You must first specify the program name (except on VxWorks) with an argument to No value for GDBN (see section Getting In and Out of No value for GDBN), or by using thefile
orexec-file
command (see section Commands to Specify Files).
If you are running your program in an execution environment that
supports processes, run
creates an inferior process and makes
that process run your program. (In environments without processes,
run
jumps to the start of your program.)
The execution of a program is affected by certain information it receives from its superior. No value for GDBN provides ways to specify this information, which you must do before starting your program. (You can change it after starting your program, but such changes only affect your program the next time you start it.) This information may be divided into four categories:
- The arguments.
Specify the arguments to give your program as the arguments of the
run
command. If a shell is available on your target, the shell is used to pass the arguments, so that you may use normal conventions (such as wildcard expansion or variable substitution) in describing the arguments. In Unix systems, you can control which shell is used with theSHELL
environment variable. See section Your Program's Arguments.- The environment.
Your program normally inherits its environment from No value for GDBN, but you can use the No value for GDBN commands
set environment
andunset environment
to change parts of the environment that affect your program. See section Your Program's Environment.- The working directory.
Your program inherits its working directory from No value for GDBN. You can set the No value for GDBN working directory with the
cd
command in No value for GDBN. See section Your Program's Working Directory.- The standard input and output.
Your program normally uses the same device for standard input and standard output as No value for GDBN is using. You can redirect input and output in the
run
command line, or you can use thetty
command to set a different device for your program. See section Your Program's Input and Output.Warning: While input and output redirection work, you cannot use pipes to pass the output of the program you are debugging to another program; if you attempt this, No value for GDBN is likely to wind up debugging the wrong program.
When you issue the run
command, your program begins to execute
immediately. See section Stopping and Continuing, for discussion
of how to arrange for your program to stop. Once your program has
stopped, you may call functions in your program, using the print
or call
commands. See section Examining Data.
If the modification time of your symbol file has changed since the last time No value for GDBN read its symbols, No value for GDBN discards its symbol table, and reads it again. When it does this, No value for GDBN tries to retain your current breakpoints.
-
start
-
The name of the main procedure can vary from language to language. With C or C++, the main procedure name is always
main
, but other languages such as Ada do not require a specific name for their main procedure. The debugger provides a convenient way to start the execution of the program and to stop at the beginning of the main procedure, depending on the language used.The ‘start’ command does the equivalent of setting a temporary breakpoint at the beginning of the main procedure and then invoking the ‘run’ command.
Some programs contain an elaboration phase where some startup code is executed before the main procedure is called. This depends on the languages used to write your program. In C++, for instance, constructors for static and global objects are executed before
main
is called. It is therefore possible that the debugger stops before reaching the main procedure. However, the temporary breakpoint will remain to halt execution.Specify the arguments to give to your program as arguments to the ‘start’ command. These arguments will be given verbatim to the underlying ‘run’ command. Note that the same arguments will be reused if no argument is provided during subsequent calls to ‘start’ or ‘run’.
It is sometimes necessary to debug the program during elaboration. In these cases, using the
start
command would stop the execution of your program too late, as the program would have already completed the elaboration phase. Under these circumstances, insert breakpoints in your elaboration code before running your program.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |