Let's start with a basic requirements:
- You have a command line program
- The program has several arguments that must be passed at startup time.
- Running dbx without any arguments in the shell only starts the debugging environment, nothing more, nothing less.
- Running dbx with only the executable (program) file name will load the executable into memory but doesn't run the program. This step also doesn't pass any argument(s) to the program.
- DBX has the so-called "subcommands" which are "commands" that you can type in the DBX debugging environment to instruct the debugger to do something. Another way to pass subcommand to DBX is via a text file known as "command file". A command file contains subcommand and the parameters/arguments required by the subcommand.
The gist of the philosophy is: useful thing can be done mostly via DBX subcommands. The following diagram illustrates this philosophy.
|Figure 1 IBM AIX DBX debugger principle of working|
I'll show you how to use -c flag to pass your program arguments at the start of a DBX debugging session. The first thing to do before we can use -c flag is to prepare the Command File. If you just want to pass your program arguments, then the contents of the command file is simply the run subcommand and your program arguments. Below is an example of a valid Command File. Let's name the command file as my_cmd.
run -a 10.10.10.254 -p 8000 -n 2In the command file above, the program (to be debugged) arguments starts at -a, the run statement in the beginning refers to DBX run subcommand. The following diagram shows this:
|Figure 2 Using run subcommand in your command file|
Therefore, to start DBX debugger to use my_cmd command file above, we enter this in the shell:run SubcommandThe run subcommand starts the object file. The Arguments are passed as command-line arguments.Flags
ExampleTo run the application with the arguments blue and 12, enter:
run blue 12
$ dbx -c my_cmd [your_program_name]The -c flag instruct dbx to use my_cmd as the command file, after that you just need to enter your program executable name. Anyway, after dbx parses the command file, it runs your program as if you type run subcommand in a DBX debugging session.
That's it. I hope this post helps those who just started using DBX in AIX or other AIX-like environment.