Now that the project has no errors and builds correctly, we can turn our attention to uncovering exactly how our application fits in memory and how to navigate around it.
Using Project Explorer features
The Project Explorer is the central focus for arranging your source code into projects, and it's a good place to show ancillary information gathered when CrossStudio builds your applications. This section will cover the features that the Project Explorer offers to give you an overview of your project.
Project code and data sizes
Developers are always interested in how much memory their applications take up, and with small embedded microcontrollers this is especially true. The Project Explorer can display the code and data sizes for each project and individual source file that is successfully compiled. To do this, click the Options dropdown on the Project Explorer tool bar and make sure that Show Code/Data Size is checked. Once checked, the Project Explorer displays two additional columns, Code and Data.
The Code column displays the total code space required for the project and the Data column displays the total data space required. The code and data sizes for each C and assembly source file are estimates, but good estimates nontheless. Because the linker removes any unreferenced code and data and performs a number of optimizations, the sizes for the linked project may not be the sum of the sizes of each individual file. The code and data sizes for the project, however, are accurate. As before, your numbers may not match these exactly.
Dependencies
The Project Explorer is very versatile: not only can you display the code and data sizes for each element of a project and the project as a whole, you can also configure the Project Explorer to show the dependencies for a file. As part of the compilation process, CrossStudio finds and records the relationships between files—that is, it finds which files are dependent upon other files. CrossStudio uses these relationships when it comes to build the project again so that it does the minimum amount of work to bring the project up to date.
To show the dependencies for a project, click the Options button on the Project Explorer tool bar and ensure that Show Dependencies is checked in the menu. Once checked, dependent files are shown as sub-nodes of the file which depends upon them.
In this case, main.c is dependent upon cross_studio_io.h because it it includes it with a #include directive. It is also dependent on __crossworks.h because this file is included by cross_studio_io.h. You can open cross_studio_io.h or __crossworks.h in an editor by double clicking on them, so having dependencies turned on is an effective way of navigating to and summarising the files that a source file includes.
Output files
Another useful piece of information is knowing the files output files when compiling and linking the application. Needless to say, CrossStudio can display this information too. To turn on output file display, click the Options button on the Project Explorer tool bar and ensure that Show Output Files is checked in the menu. Once checked, output files are shown in an Output Files folder underneath the node that generates them.
In the above figure, we can see that the object files main.o, and crt0.o are object files produced by compiling their corresponding source files; the linker script Tutorial.ld, the map file Tutorial.map and the linked executable Tutorial.elf are produced by the linker. As a convenience, double clicking an object file or a linked executable file in the Project Explorer will open an editor showing the disassembled contents of the file.
Disassembling a project or file
You can disassemble a project either by double clicking the corresponding file as described above, or you can use the Disassemble tool to do it.
To disassemble a project or file, do one of the following:
- Click the appropriate project or file in the Project Explorer view.
-
On the Project Explorer tool bar, click the Disassemble tool
button —
.
—or—
- Right click the appropriate project or file in the Project Explorer view.
- From the popup menu, click the Disassemble.
CrossStudio opens a new read-only editor and places a disassembled listing into it. If you change your project and rebuild it, causing a change in the object or executable file, the disassembly updates to keep the display up-to-date with the file on disk.
Using Memory Usage Window features
The Memory Usage Window can be used to display a graphical summary of how memory has been used in each memory segment of a linked application.
Displaying the Memory Usage Window
To display the Memory Usage Window if it is hidden, do one of the following:
- From the View menu, click Memory Usage.
—or—
- Type Ctrl+Alt+Z.
The Tutorial project shows this in the Memory Usage Window:
From this you can see:
- The SRAM segment is located at 0x00000000.
- The SRAM segment is 64kB in length.
- There is 60kB of unused memory in the SRAM segment.
If you expand the SRAM segment, CrossStudio will display the program sections contained within the segment:
From this you can see:
- The .vectors section is located at 0x00000000 and is 60 bytes in length.
- The .init section is located at 0x0000003C and is 512 bytes in length.
- The .text section is located at 0x0000023C and is 916 bytes in length.
- The .rodata section is located at 0x000005D0 and is 24 bytes in length.
- The .heap section is located at 0x000005E8 and is 1 K bytes in length.
- The .stack section is located at 0x000009E8 and is 1 K bytes in length.
- The .stack_irq section is located at 0x00000DE8 and is 256 bytes in length.
- The .stack_fiq section is located at 0x00000EE8 and is 256 bytes in length.
Using Symbol Browser features
If you need a more detailed view of how your application is laid out in memory than the Memory Usage Window provides, you can use the Symbol Browser. The Symbol Browser allows you to navigate your application, see which data objects and functions have been linked into your application, what their sizes are, which section they are in, and where they are placed in memory.
Displaying the Symbol Browser
To display the Symbol Browser window if it is hidden, do one of the following:
- From the View menu, click Symbol Browser.
—or—
- Type Ctrl+Alt+Y.
—or—
- Right click the tool bar area to display the View menu.
- From the popup menu, click Symbol Browser.
Drilling down into the application
The Tutorial project shows this in the Symbol Browser:
From this you can see:
- The .vectors section containing the ARM exception vectors is placed in memory between address 0x00000000 and 0x0000003B.
- The .init section containing the system startup code is placed in memory between address 0x0000003C and 0x0000023B.
- The .text section containing the program code is placed in memory between address 0x0000023C and 0x000005BF.
- The .rodata section containing read-only data is placed in memory between address 0x000005C0-0x000005D7.
- The .heap section is 1024 bytes in length and located at 0x000005D8. Note that the size of the heap can be adjusted by modifying the Linker > Heap Size project property.
- The .stack section which contains the User/System mode stack is 1024 bytes in length and located at 0x000009D8. Note that the size of the stacks can be adjusted by modifying the Linker > Stack Size properties.
- The .stack_irq section which contains the IRQ mode stack is 256 bytes in length and located at 0x00000DD8.
- The .stack_fiq section which contains the FIQ mode stack is 256 bytes in length and located at 0x00000ED8.
To drill down, open the .text node by double clicking it: CrossStudio displays the individual functions that have been placed in memory and their sizes:
Here, we can see that main is 96 bytes in size and is placed in memory between addresses 0x00000298 and 0x000002F7 inclusive. Just as in the Project Explorer, you can double click a function and CrossStudio moves the cursor to the line containing the definition of that function, so you can easily navigate around your application using the Symbol Browser.
Printing Symbol Browser contents
You can print the contents of the Symbol Browser by focusing the Symbol Browser window and selecting Print from the File menu, or Print Preview if you want to see what it will look like before printing. CrossStudio prints only the columns that you have selected for display, and prints items in the same order they are displayed in the Symbol Browser, so you can choose which columns to print and how to print symbols by configuring the Symbol Browser display before you print.
We have touched on only some of the features that the Symbol Browser offers; to find out more, refer to Symbol browser where it is described in detail.