Updated
Wednesday, March 27, 2002 11:18 AM
Notes Regarding CodeWarrior
(This section primarily for those who have already setup Nachos
in CodeWarrior)
- CodeWarrior seems to ignore some of the tabs in the .java source files.
While it seems like this should be configurable within CodeWarrior, there
is a fix for it. Use emacs to open each .java file that you work with. Select
the entire file, then do the following
- <esc>, x, "untabify" <Enter
Working with Nachos in CodeWarrior
Many of you have used CodeWarrior before in your introductory programming and
data structures classes. For those of you who haven't, CodeWarrior is a power
visual development environment.
Some people have the misconception that visual development environments like
CodeWarrior are reserved for programmers who are too weak to handle compiling
and debugging on the command line. This is completely false. Code warrior has
many development support tools which are simply not available when using javac
and jdb on the command line. These features include:
- A powerful visual debugger integrated with an editor that shows you exactly
which line you are currently executing. Furthermore, it automatically displays
the values of all variables local to the current context. You can create breakpoints
either in the editor or in the debugger, simply by clicking next to the line
of code where you want the debugger to stop.
- Extensive syntax highlighting that recognizes different parts of the code
(variables versus functions versus comments) and give each a different color,
improving the readability of the code.
- Dependency management - CodeWarrior detects when you have modified a file,
and only compiles those files that require recompilation, leading to less
time waiting for the compiler. Also has the ability to define different targets,
so that you can build and run several different ways from the same code.
- Class browsers that let you easily see what methods and attributes are defined
for a class and edit those independently
- The ability to right click on a function call and have CodeWarrior take
you to where that function is defined.
- Exceptionally powerful search and replace functionality (i.e. search through
ALL Java files and replace)
- And much more...
I find that when I'm writing code and doing the initial debugging, CodeWarrior
is the best. If I need to run a program with many different arguments, or if
the program generates lots of output that I need to sort through, then working
in UNIX with the command line argument seems a better choice.
The hardest part of CodeWarrior is just getting everything set up. To make
that easy, I have included the directions below. Fallow them and you should
be OK.
- Open CodeWarrior, then File->New. Select "Java Stationary",
and give the project a name. Choose a location on your UNIX drive (for me
this is the Z: drive). Click OK.
- Expand JDK 1.3 (or 1.2, probably doesn't matter). Select "Java Application",
click OK. A new project will be created for you.
- You will see your project window. It has created some default files that
we don't need. Click on the Sources folder, and hit the "Delete"
key. Click OK when you get the confirmation window.
- Click inside the white window to make sure that the project window is selected.
Using the menu item Project->Create Group, create one group for each code
directory in the nachos distribution that you need for the first project.
These directories are ag, threads, machine, security
- Now you need to add the Java source code files to the project. Do this separately
for each code directory. Select the ag group in your project window, then
go to the menu item Project->Add Files. This will open a file browser.
Go to the ag subdirectory of your nachos distribution. Click on the first
file in the directory, then shift-click on the last file in the directory
- this will select all files in the directory. Then hit the add button. Click
the OK button on the next window to dad the files to both targets. A message
will pop up about access paths that have been changed.
- Now repeat the previous step for the machine, security, and threads directories.
- Almost ready to go!
- Click the "Targets" tab. Targets allow you to compile and run
different ways based on the same source code. By default, CodeWarrior has
created two targets for you - one with debugging enable, and one without debugging
enabled. When you change runtime or compile preferences, you need to make
sure that you change them in both targets.
- Double click on the "Java application release" target, to bring
up the settings dialog for that target.
- Click on the Runtime Settings panel. Change the Working directory to point
to the the "proj1" subdirectory of your nachos distribution.
- Click on the Java Target panel. Change the "Main Class" to nachos.machine.Machine.
This tells CodeWarrior that it should start the program by running the "main()"
method of the class nachos.machine.Machine. Click OK.
- Repeat the previous four steps for the "Java application debug"
target.
- One last step to enable the debugger for the "Java application debug"
target: Select "Java application debug" from the drop down list
at the top of the project window. Then select the menu item "Project->enable
debugger". CodeWarrior will tell you that certain target settings need
to be changed. Choose "Yes".
- Now you should be ready to go. In the drop down box at the top of the project
window, select Java Application Release. Then hit the green play button. Nachos
should compile and run.
- Test the debugger by selecting Java Application Debug in the drop down box
and clicking the green play button.
If you want to pass arguments to nachos, such as the '-d' flag, specify them
in target properties, under the runtime setting panel, in the "Program
Arguments" option.
If you have any questions - contact the TA or the instructor.