Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

6.2.1.1.3. Configuration Options

The following Nios® II Software Build Tools for Eclipse configuration options increase the amount of debugging information available for your application image .elf file:

Objdump File

You can direct the Nios® II build process to generate helpful information about your .elf file in an object dump text file (.objdump). The .objdump file contains information about the memory sections and their layout, the addresses of functions, and the original C source code interleaved with the assembly code. The example below shows part of the C and assembly code section of an .objdump file for the Nios® II built-in Hello World Small project.

Piece of Code in .objdump File From Hello World Small Project

06000170 <main>:

include "sys/alt_stdio.h"

int main()
{
6000170:deffff04 addisp,sp,-4
alt_putstr("Hello from 
               Nios® II!\n");
6000174:01018034 movhir4,1536
6000178:2102ba04 addir4,r4,2792
600017c:dfc00015 stwra,0(sp)
6000180:60001c00 call60001c0 <alt_putstr>
6000184:003fff06 br6000184 <main+0x14>

06000188 <alt_main>:
* the users application, i.e. main().
*/

void alt_main (void)
{
6000188:deffff04 addisp,sp,-4
600018c:dfc00015 stwra,0(sp)

static ALT_INLINE void ALT_ALWAYS_INLINE
alt_irq_init (const void* base)
{
NIOS2_WRITE_IENABLE (0);
6000190:000170fa wrctlienable,zero
NIOS2_WRITE_STATUS (NIOS2_STATUS_PIE_MSK);
6000194:00800044 movir2,1
6000198:1001703a wrctlstatus,r2

To enable this option in the Nios® II Software Build Tools for Eclipse, perform the following steps:

  1. In the Project Explorer window, right-click your application project and click Properties.
  2. On the list to the left, click Nios® II Application Properties.
  3. On the Nios® II Application Properties page, turn on Create object dump.
  4. Click Apply.
  5. Click OK.

    After the next build, the .objdump file is found in the same directory as the newly built .elf file.

After the next build generates the .elf file, the build runs the nios2-elf-objdump command with the options --disassemble-all, --source, and --all-headers on the generated .elf file.

In the Nios® II user-managed tool flow, you can edit the settings in the application makefile that determine the options with which the nios2-elf-objdump command runs. Running the create-this-app script, or the nios2-app-generate-makefile script, creates the following lines in the application makefile:

#Options to control objdump.
CREATE_OBJDUMP := 1
OBJDUMP_INCLUDE_SOURCE :=0
OBJDUMP_FULL_CONTENTS := 0

Edit these options to control the .objdump file according to your preferences for the project:

  • CREATE_OBJDUMP—The value 1 directs nios2-elf-objdump to run with the options --disassemble, --syms, --all-header, and --source.
  • OBJDUMP_INCLUDE_SOURCE—The value 1 adds the option --source to the nios2-elf-objdump command line.
  • OBJDUMP_FULL_CONTENTS—The value 1 adds the option --full-contents to the nios2-elf-objdump command line.
For detailed information about the information each command-line option generates, in a Nios® II Command Shell, type the following command:
nios2-elf-objdump --help

Show Make Commands

To enable a verbose mode for the make command, in which the individual Makefile commands appear in the display as they are run, in the Nios® II Software Build Tools for Eclipse, perform the following steps:

  1. In the Project Explorer window, right-click your application project and click Properties.
  2. On the list to the left, click C/C++ Build.
  3. On the C/C++ Build page, turn off Use default build command.
  4. For Build command, type make -d.
  5. Click Apply.
  6. Click OK.

Show Line Numbers

To enable display of C source-code line numbers in the Nios® II Software Build Tools for Eclipse, follow these steps:

  1. On the Window menu, click Preferences.
  2. On the list to the left, under General, under Editors, select Text Editors.
  3. On the Text Editors page, turn on Show line numbers.
  4. Click Apply.
  5. Click OK.