MATLAB Runtime Server    

Testing While Emulating the Runtime Server (GUI)

Once you have compiled all of the M-files of a MATLAB runtime GUI application, you can test the application with the Runtime Server. However, since the Runtime Server does not provide a command window, for the purpose of debugging it is much easier to have your development version of MATLAB emulate the Runtime Server as a first step in the testing process. You should still test the application with the actual Runtime Server variant later. This section discusses both kinds of testing and includes a troubleshooting section.

Moving P-Files to Final Locations

If you store your source M-files outside of the toolbox directory, then at some point during your testing you should move the corresponding P-files to their final destinations under toolbox. Then use rehash toolboxreset to register the changes.

Each time you change the source M-files, remember to delete, regenerate, and move the P-files to their toolbox destination. Again, use rehash toolboxreset as necessary to register the changes to toolbox subdirectories.

Emulating the Runtime Server

Commercial MATLAB can emulate the Runtime Server environment by disabling the MATLAB ability to read M-files and standard P-files. The command window remains active, however. This section describes the procedure and some tips for testing while MATLAB emulates the Runtime Server.

To test and debug while MATLAB emulates the Runtime Server, follow this procedure:

  1. At the MATLAB prompt, type
  1. runtime on

    to start emulating the Runtime Server.

    To find out whether MATLAB is emulating the Runtime Server at a given time, type

    at the command line.

  1. Run your application from the command line. For the most accurate simulation of the Runtime Server environment, launch the application through matlabrt.p, as the Runtime Server does. At the command line type
  2. If there are errors, the usual error report in the MATLAB command window shows you where they occurred. To execute M-files and debug your functions, first turn off Runtime Server emulation by typing
  1. and then debug the problematic M-files as you normally would.

  1. Whenever you change an M-file, be sure that runtime MATLAB registers those changes: If the M-file is under the toolbox directory, then use rehash toolboxreset. Then, use buildp to recompile the M-file into a runtime P-file. Finally, test the application again with MATLAB emulating the Runtime Server.
  2. To exit the application without quitting MATLAB, close the application's GUI from the command line by typing
  1. close force

Runtime Server Emulation Considerations

There are a few things you should keep in mind when using MATLAB to emulate the Runtime Server:

Troubleshooting

If the application runs normally with commercial MATLAB but does not run as expected with MATLAB emulating the Runtime Server, then the problem might be one of the following:

You might be able to determine the source of the problem by running the application using the runtime path with commercial MATLAB. Type

If the application now runs as expected, then there are probably uncompiled M-files. If the problem persists even with commercial MATLAB, then the path specification in pathdefrt might be incomplete. In either case, the MATLAB error messages should provide a good indication of which files are not being found.

Analyzing Functions Called by eval.   Calls to buildp or depfun might not find functions whose names are assembled at runtime within the calling function, and which are executed using eval, evalc, or evalin. For example, if your application calls a function named action1.m by concatenating the strings 'action' and '1' in an eval statement,

then depfun does not recognize that there is a function called action1.m.

To make certain that depfun does analyze this file, insert the following code in one of the other application files, such as matlabrt.

The if statement above does not execute at runtime, but it allows depfun to see the full action1 function name when it analyzes matlabrt.

Using inmem to Find Files That depfun Misses.   To find out whether buildp or depfun is missing certain application functions, you can compare the depfun diagnostics to the list of functions that are in MATLAB memory after the application is executed. You can view this list by using the inmem function, as described below.

  1. Type rehash toolboxreset to renew the session, and then type
  1. to launch the application.

  1. Use the application as thoroughly as possible by pressing buttons, selecting menus, etc. The goal of this is to force MATLAB to load all or most of the application's functions into memory. If there is a particular area of the application that is a source of problems for depfun, then use it especially heavily to make sure that MATLAB loads all the relevant functions.
  2. When you have used the application sufficiently to load the relevant functions into memory, quit the application without exiting MATLAB.
  3. Generate the list of functions in memory by typing
  1. The listed functions are those that MATLAB used to carry out the tasks that you just performed in Step 2.

  1. Use depfun, as before, to generate a list of the application's dependent functions.
  2. Compare the functions in list and memlist. You can do this visually, or by using a script like the one below.

The memfiles variable contains a list of functions found by inmem but not by depfun. To force depfun to analyze these functions, you can place a nonexecuting if conditional in an application file such as matlabrt.m, as shown in Analyzing Functions Called by eval.

The depfiles variable contains a list of functions found by depfun but not by inmem. These are probably valid application files that were not called by MATLAB (and not loaded into memory) when you ran the application.

Compiling Extra M-Files.   If you cannot anticipate what functions might be invoked via an evaluation command, then you might decide to compile some extra M-files. As a last resort, you can compile all functions on the path and in the current directory, using the pcodeall function.


  Compiling the Application (GUI) Testing with the Runtime Server Variant (GUI)