INTEGRATED DEVELOPMENT ENVIRONMENT USER’S GUIDE Q N X

INTEGRATED DEVELOPMENT ENVIRONMENT USER’S GUIDE Q N X
Q N X® M O M E N T I C S® D E V E L O P M E N T
SUITE
INTEGRATED DEVELOPMENT
ENVIRONMENT
USER’S GUIDE
V 6.3


QNX Momentics PE 6.3
IDE User’s Guide
For Windows, Linux, Solaris, and QNX  Neutrino hosts
 2004, QNX Software Systems Ltd.
QNX Software Systems Ltd.
175 Terence Matthews Crescent
Kanata, Ontario
K2M 1W8
Canada
Voice: +1 613 591-0931
Fax: +1 613 591-3579
Email: [email protected]
Web: http://www.qnx.com/
 2004, QNX Software Systems Ltd. All rights reserved.
Publishing history
July 30, 2004
First edition
Technical support options
To obtain technical support for any QNX product, visit the Technical Support section in the Services area on our website
(www.qnx.com). You’ll find a wide range of support options, including our free web-based Developer Support Center.
QNX, Momentics, Neutrino, and Photon microGUI are registered trademarks of QNX Software Systems Ltd. in certain jurisdictions. All other trademarks and
trade names belong to their respective owners.
Printed in Canada.
Part Number: 002501
Contents
About This Guide
xv
Typographical conventions xvii
How to use this guide xix
Assumptions xxi
Note to Windows users xxi
1
IDE Concepts
1
What is an IDE?
3
An IDE for building embedded systems
Starting the IDE
4
Starting the IDE from the command line
Workbench
5
Workbench menus
6
Help system
7
Opening the IDE Help
7
Navigating the Help
7
Help bookmarks
8
Tips and tricks
9
Perspectives
9
Views and editors
10
Views
10
Editors
11
Projects and workspace
11
Specifying a workspace location
12
How the IDE looks at projects
13
July 30, 2004
3
4
Contents
iii
 2004, QNX Software Systems Ltd.
Host and target machines
14
14
Target agent (the qconn daemon)
Launcher
15
Resources
15
Wizards
15
Keyboard shortcuts
15
Preferences
16
Version coexistence
17
Specifying which OS version to build for
Environment variables
19
2
Preparing Your Target
21
Host-target communications
23
IP communications
23
Serial communications
24
Example: Serial debugging via PPP
Connecting with Phindows
29
3
18
Developing C/C++ Programs
25
31
The C/C++ Development perspective
33
Wizards and Launch Configurations
34
Controlling your projects
34
Opening files
35
Opening projects
35
Filtering files
36
Outlines of source and executable files
37
Creating projects
38
Building projects
39
Build terminology
40
Turning off the autobuild feature
40
Configuring project build order
42
Creating personal build options
43
Running projects
44
iv
Contents
July 30, 2004
 2004, QNX Software Systems Ltd.
Deleting projects
46
Writing code
47
C/C++ Editor layout
47
Finishing function names
48
Inserting code snippets
49
50
Adding #include directives
Hover help
50
Commenting-out code
51
Customizing the C/C++ Editor
52
Using other editors
52
Creating files from scratch
54
More development features
54
Tracking remaining work
55
Code synopsis
58
Checking your build
59
Accessing source files for functions
60
Opening headers
60
4
Managing Source Code
65
CVS and the IDE
67
Local history feature
68
68
Project files (.project and .cdtproject)
Core Eclipse documentation on using CVS in the IDE
Importing existing source code into the IDE
70
Projects within projects?
71
Using container projects
75
Creating a container project
75
Setting up a build configuration
78
Editing existing configurations
79
Importing a BSP or other QNX source packages
83
Step 1: Use File→Import. . .
83
Step 2: Select the package
85
Step 3: Select the source projects
86
July 30, 2004
68
Contents
v
 2004, QNX Software Systems Ltd.
Step 4: Select a working set
87
Step 5: Build
88
Exporting projects
90
Using the Export. . . command
90
5
Debugging Programs
95
Introduction
97
Debugging your program
98
Building an executable for debugging
98
Starting your debugging session 100
Controlling your debug session 101
Using the controls 102
Debug launch controls 106
Disassembly mode 107
More debugging features 108
Inspecting variables 108
Using breakpoints and watchpoints 111
Evaluating your expressions 118
Inspecting your registers 119
Inspecting a process’s memory 120
Inspecting shared-library usage 123
Monitoring signal handling 124
Viewing your output 125
Debugging with GDB 126
6
Building OS and Flash Images 129
Introducing the QNX System Builder
Toolbar buttons 133
Binary Inspector 134
Boot script files 135
Builder projects 136
The scope of the Builder 136
Overview of images 137
vi
Contents
131
July 30, 2004
 2004, QNX Software Systems Ltd.
The components of an image, in order of booting
Types of images you can create 140
Project layout 145
Overview of workflow 146
Creating a project for an OS image 147
Creating a project for a flash filesystem image 147
Building an OS image 148
Downloading an image to your target 149
Downloading via a serial link 149
Downloading via TFTP 151
Downloading using other methods 153
Configuring your Builder projects 154
Managing your images 155
Configuring image properties 158
Configuring project properties 163
Optimizing your system 168
Optimizing all libraries in your image 169
Optimizing a single library 170
Restoring a slimmed-down library 171
Moving files between the host and target 171
Moving files to the target 172
Moving files from the target to the host 173
7
Developing Photon Applications 175
What is PhAB? 177
PhAB and the IDE 178
Using PhAB 179
Creating a QNX Photon Appbuilder project
Closing PhAB 180
Reopening PhAB 180
Editing code 181
Building a QNX Photon Appbuilder project
Starting Photon applications 182
July 30, 2004
137
179
182
Contents
vii
 2004, QNX Software Systems Ltd.
8
Profiling an Application 185
Introducing the Application Profiler 187
Types of profiling 188
Profiling your programs 189
Building a program for profiling 190
Running and profiling a process 192
Profiling a running process 194
Postmortem profiling 196
Controlling your profiling sessions 198
Understanding your profiling data 200
Usage by line 200
Usage by function 202
Usage by thread 203
Call counts 204
9
Using Code Coverage 207
Code coverage in the IDE 209
Types of code coverage 209
How the coverage tool works 210
Enabling code coverage 212
Enabling code coverage for non-QNX projects
Starting a coverage-enabled program 213
Controlling your session 216
Examining data line-by-line 218
Examining your coverage report 219
Seeing your coverage at a glance 221
10
212
Finding Memory Errors 223
Introduction 225
Memory management in QNX Neutrino 226
What the Memory Analysis perspective can reveal 233
Analyzing your program 236
Manually launching a program for memory tracing 238
viii
Contents
July 30, 2004
 2004, QNX Software Systems Ltd.
Preparing your host and the target agent 239
Tracing memory events 240
Error events tree 241
Event backtrace pane 242
Allocation Trace tab 243
Unmatched allocations tab 245
Unmatched deallocations 245
Controlling your memory analysis session 245
Examining your target’s memory 246
Malloc Information view 246
Virtual address space 249
11
Getting System Information 253
Introduction 255
What the System Information perspective reveals 256
Key terms 256
The views in this perspective 259
Controlling your system information session 260
Sending a signal 261
Updating the views 261
Adding views to the System Information perspective
Examining your target system’s attributes 263
System Specifications pane 264
System Memory pane 264
Processes pane 264
Watching your processes 264
Arguments pane 266
Thread Details pane 266
Environment Variables pane 266
Identification Details pane 266
Tracking thread activity 266
Inspecting virtual address space 269
Tracking heap usage 269
July 30, 2004
262
Contents
ix
 2004, QNX Software Systems Ltd.
Examining process signals 270
Getting channel information 271
Tracking file descriptors 273
Tracking resource usage 274
System Uptime display 274
General Resources display 275
Memory Resources display 276
12
Analyzing Your System with Kernel
Tracing 279
Introducing the QNX System Profiler 281
Before you begin 284
Configuring a target for system profiling 285
Launching the System Profiler Configuration wizard
Selecting options in the wizard 286
Capturing instrumentation data in event log files 289
Viewing and interpreting the captured data 291
The System Profiler editor 291
Other views in the System Profiler 297
13
Common Wizards Reference 299
Introduction 301
Creating a C/C++ project 303
How to create a C/C++ project 304
Tabs in the New C/C++ Project wizard
Creating a target 316
Converting projects 318
Converting to a QNX project 319
Completing the conversion 320
14
286
310
Launch Configurations Reference 331
What is a launch configuration? 333
Types of launch configurations 333
x
Contents
July 30, 2004
 2004, QNX Software Systems Ltd.
Running and debugging the first time 335
Debugging a program the first time 335
Running a program the first time 337
Running and debugging subsequent times 339
Launching a selected program 339
Launching from a list of favorites 339
Launching the last-launched program 341
Setting execution options 341
Main tab 341
Arguments tab 343
Environment tab 344
Download tab 344
Debugger tab 345
Source tab 348
Common tab 348
Tools tab 349
A
Tutorials 353
Before you start. . . 355
Tutorial 1 — creating a standard make C/C++ project 355
Tutorial 2 — creating a QNX C/C++ project 358
Tutorial 3 — importing an existing project into the IDE 360
Tutorial 4 — importing a QNX BSP into the IDE 361
Step 1: Use File→Import. . . 361
Step 2: Select the package 363
Step 3: Select the source projects 364
Step 4: Select a working set 365
Step 5: Build 366
B
Where Files Are Stored 369
C
Utilities Used by the IDE 373
July 30, 2004
Contents
xi
 2004, QNX Software Systems Ltd.
D
Migrating to the 6.3 Release 377
Introduction 379
From 6.2.1 to 6.3.0 380
Migrating your workspace 380
Migrating your projects 381
From 6.2.0 to 6.3.0 383
Migrating your projects 384
Glossary
Index
xii
Contents
387
393
July 30, 2004
List of Figures
The IDE User’s Guide at a glance.
xix
This chapter introduces key concepts used in the IDE.
3
The first thing you see.
6
This chapter explains how to set up host-target communications.
23
This chapter shows you how to create and manage your C or C++
projects.
33
This chapter describes managing source code from within the
IDE.
67
This chapter shows you how to work with the debugger.
97
Use the System Builder to create OS and flash images for your
target. 131
Typical boot order. 138
Use the PhAB visual design tool to develop Photon apps. 177
This chapter shows you how to use the application profiler. 187
QNX Application Profiler perspective. 188
Use the Code Coverage tool to help test your code. 209
Use the QNX Memory Analysis perspective to solve memory
problems. 225
Process memory layout on an x86. 228
This chapter shows you how to work with the System Information
perspective. 255
Use the System Profiler to analyze your system via
instrumentation. 281
This chapter describes the IDE’s wizards. 301
You must set up a Launch Configuration before you can run or
debug a program. 333
July 30, 2004
List of Figures
xiii
 2004, QNX Software Systems Ltd.
Here are several tutorials to help you get going with the IDE.
355
This appendix shows you where to find key files used by the IDE.
371
This appendix lists the utilities used by the IDE. 375
You can easily migrate your old workspace and projects to this
release. 379
xiv
List of Figures
July 30, 2004
About This Guide
July 30, 2004
About This Guide
xv
Typographical conventions
 2004, QNX Software Systems Ltd.
Typographical conventions
Throughout this manual, we use certain typographical conventions to
distinguish technical terms. In general, the conventions we use
conform to those found in IEEE POSIX publications. The following
table summarizes our conventions:
Reference
Example
Code examples
if( stream == NULL )
Command options
-lR
Commands
make
Environment variables
PATH
File and pathnames
/dev/null
Function names
exit()
Keyboard chords
Ctrl – Alt – Delete
Keyboard input
something you type
Keyboard keys
Enter
Program output
login:
Programming constants
NULL
Programming data types
unsigned short
Programming literals
0xFF, "message string"
Variable names
stdin
User-interface components
Cancel
We format single-step instructions like this:
➤ To reload the current page, press Ctrl – R.
We use an arrow (→) in directions for accessing menu items, like this:
July 30, 2004
About This Guide
xvii
Typographical conventions
 2004, QNX Software Systems Ltd.
You’ll find the Other... menu item under
Perspective→Show View.
We use notes, cautions, and warnings to highlight important
messages:
☞
!
Notes point out something important or useful.
CAUTION: Cautions tell you about commands or procedures that
may have unwanted or undesirable side effects.
WARNING: Warnings tell you about commands or procedures
that could be dangerous to your files, your hardware, or even
yourself.
xviii
About This Guide
July 30, 2004
How to use this guide
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
The IDE User’s Guide at a glance.
How to use this guide
This User’s Guide describes the Integrated Development Environment
(IDE), which is part of the QNX Momentics development suite. The
guide introduces you to the IDE and shows you how to use it
effectively to build your QNX Neutrino-based systems.
The workflow diagram above shows how the guide is structured and
suggests how you might use the IDE. Once you understand the basic
concepts, you’re ready to begin the typical cycle of setting up your
projects, writing code, debugging, testing, and finally fine-tuning your
target system.
Each chapter begins with the workflow diagram, but with the
chapter’s bubble highlighted to show where you are in the book. Note
that in the online version each bubble is a link.
July 30, 2004
About This Guide
xix
How to use this guide
!
 2004, QNX Software Systems Ltd.
CAUTION: This release of the IDE is based on Eclipse 2.1. If you
have an older version of the IDE, see Appendix C: Migrating to the
6.3 Release in this guide.
The following table may help you find information quickly:
To:
Go to:
Learn about the
workspace,
perspectives, views,
and editors
IDE Concepts
Use the IDE’s help
system
IDE Concepts
Connect your host
and target
Preparing Your Target
Import existing
code into the IDE
Managing Source Code
Import a QNX BSP
source package
Managing Source Code
Set execution
options for your
programs
Launch Configurations Reference
Check code into
CVS
Managing Source Code
Run QNX Neutrino
on your target
Building OS and Flash Images
Examine execution
stats (e.g. call
counts) in your
programs
Profiling an Application
continued. . .
xx
About This Guide
July 30, 2004
Assumptions
 2004, QNX Software Systems Ltd.
To:
Go to:
Exercise a test suite
Using Code Coverage
Find and fix a
memory leak in a
program
Finding Memory Errors
See process or
thread states,
memory allocation.
etc.
Getting System Information
Examine your
system’s
performance,
kernel events, etc.
Analyzing Your System with Kernel Tracing
Look up a keyboard
shortcut
IDE Concepts
Find the meaning
of a special term
used in the IDE
Glossary
Assumptions
This guide assumes the following:
On your host you’ve already installed the QNX Momentics suite,
which includes a complete QNX Neutrino development
environment.
You’re familiar with the architecture of the QNX Neutrino RTOS.
You can write code in C or C++.
Note to Windows users
In our documentation, we use a forward slash (/) as a delimiter in all
pathnames, including those pointing to Windows files.
July 30, 2004
About This Guide
xxi
Note to Windows users
 2004, QNX Software Systems Ltd.
We also generally follow POSIX/UNIX filesystem conventions.
xxii
About This Guide
July 30, 2004
Chapter 1
IDE Concepts
In this chapter. . .
What is an IDE?
3
Starting the IDE
4
Workbench
5
Help system
7
Perspectives
9
Views and editors
10
Projects and workspace
11
Host and target machines
14
Target agent (the qconn daemon)
Launcher
15
Resources
15
Wizards
15
Keyboard shortcuts
15
Preferences
16
Version coexistence
17
July 30, 2004
14
Chapter 1 IDE Concepts
1
What is an IDE?
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter introduces key concepts used in the IDE.
What is an IDE?
Welcome to the Integrated Development Environment (IDE), a
powerful set of tools in the QNX Momentics Professional Edition
development suite. The IDE is based on the Eclipse Platform
developed by Eclipse.org, an open consortium of tools vendors
(including QNX Software Systems).
The IDE incorporates into the Eclipse framework several
QNX-specific plugins designed for building projects for target
systems running the QNX Neutrino RTOS. The tools suite provides a
single, consistent, integrated environment, regardless of the host
platform you’re using (Windows, Linux, Solaris, or QNX Neutrino).
Note that all plugins from any vendor work within the Eclipse
framework in the same way.
An IDE for building embedded systems
The IDE provides a coherent, easy-to-use work environment for
building your applications. If you’ve used an IDE before, then you
already have a good idea of the convenience and power this kind of
toolset can offer.
July 30, 2004
Chapter 1 IDE Concepts
3
Starting the IDE
 2004, QNX Software Systems Ltd.
Through a set of related windows, the IDE presents various ways of
viewing and working with all the pieces that comprise your system. In
terms of the tasks you can perform, the toolset lets you:
organize your resources (projects, folders, files)
edit resources
collaborate on projects with a team
compile, run, and debug your programs
build OS and flash images for your embedded systems
analyze and fine-tune your system’s performance.
☞
The IDE doesn’t force you to abandon the standard QNX tools and
makefile structure. On the contrary, it relies on those tools. And even
if you continue to build your programs at the command line, you can
also benefit from the IDE’s unique and powerful tools, such as the
QNX System Analysis tool and the QNX System Profiler, which
can literally show you, in dynamic, graphical ways, exactly what your
system is up to.
Starting the IDE
After you install QNX Momentics, you’ll see — depending on which
host you’re using — a desktop icon and/or a menu item labeled
“Integrated Development Environment” in the start or launch menu.
To start the IDE, simply click the icon or the menu item.
Starting the IDE from the command line
You can also start the IDE by running the qde command:
4
1
Go to the directory where the qde.exe executable (Windows)
or the qde script (all other hosts) resides. For example,
C:\QNX630\host\win32\x86\usr\qde\eclipse.
2
Run this command:
Chapter 1 IDE Concepts
July 30, 2004
 2004, QNX Software Systems Ltd.
Workbench
qde
☞
Don’t run the eclipse command, even thought it may seem to work.
Always use qde instead, because it sets up the proper QNX-specific
environment.
You can also direct the IDE at a particular workspace location. For
details, see the section “Specifying a workspace location” in this
chapter.
For more information on starting the IDE, including advanced
execution options for developing or debugging parts of Eclipse itself,
see Tasks→Running Eclipse in the Workbench User Guide.
Workbench
When you first run the IDE, you should see the workbench, which
looks like this:
July 30, 2004
Chapter 1 IDE Concepts
5
Workbench
 2004, QNX Software Systems Ltd.
The first thing you see.
Workbench menus
At the top of the workbench you’ll see a menu bar that contains
several menus:
For details on each menu, see Reference→Workbench Menus in the
Workbench User Guide. For a basic tutorial on using the workbench
UI, see Getting Started→Basic tutorial→The Workbench in the
Workbench User Guide.
6
Chapter 1 IDE Concepts
July 30, 2004
Help system
 2004, QNX Software Systems Ltd.
Help system
The IDE contains its own Help system, which is an HTML server that
runs in its own window “above” the workbench (i.e. the Help isn’t a
perspective or a view).
Opening the IDE Help
From the main menu, select Help→Help Contents:
☞
The Help Contents menu item is enabled by default. If for some
reason you don’t see the menu item:
1
From the main menu, select Window→Customize
Perspective.
2
In the left pane of the Customize Perspective dialog, select
Other→Help.
3
In the left pane, click the Help box.
4
Click OK. The Help Contents menu item is now available.
Navigating the Help
The left pane of the Help window is the bookshelf , which has links to
the various documentation sets. Click one of the links to view a
document. Note that you can return to the bookshelf at any time by
clicking the Table of Contents button (
).
The Contents pane includes at least the following titles:
July 30, 2004
Chapter 1 IDE Concepts
7
Help system
 2004, QNX Software Systems Ltd.
Workbench User Guide
Written by Eclipse.org, the book explains Eclipse concepts and
core IDE functionality, and includes tutorials on using the
workbench. Although some of the workbench topics are
covered lightly here in this IDE User’s Guide, you can find full
documentation on using the workbench in the Eclipse
Workbench User Guide.
QNX Momentics Professional Edition
The QNX documentation set, which includes several titles:
Welcome to QNX Momentics
QNX Neutrino User’s Guide
Utilities Reference
Library Reference
Documentation for BSPs, DDKs, and much, much more
(over 11,000 pages in all!).
☞
Some title pages have content on them, some don’t. If you click a
title, and the right side of the window remains blank, you’ve hit a
“placeholder” title page. Simply expand the title entry to see its
contents.
Help bookmarks
You can create a bookmark for any help page:
1
On the Help browser’s toolbar, click the Bookmark Document
button (
2
).
To see your bookmarks, click the Bookmarks (
bottom of the contents pane.
) tab at the
To learn more about the IDE’s Help system, follow these links in the
Eclipse Workbench User Guide: Concepts→Help system.
8
Chapter 1 IDE Concepts
July 30, 2004
Perspectives
 2004, QNX Software Systems Ltd.
Tips and tricks
The Help menu contains a Tips and tricks item:
.
When you select this item, you’ll see a list of tips and tricks pages.
Select the page for the Eclipse platform, which covers several topics:
workbench (fast views, opening an editor with drag-and-drop,
navigation, global find/replace, etc.)
help (help bookmarks, help working sets)
CVS (CVS working sets, restoring deleted files, quick sync, etc.).
Perspectives
A perspective is a task-oriented arrangement of the workbench
window.
For example, if you’re debugging, you can use the preconfigured
Debug perspective, which sets up the IDE to show all the tools related
to debugging. If you wanted to work with the elements and tools
related to profiling, you’d open the Profiler perspective.
You can customize a perspective by adding or removing elements. For
example, if you wanted to have certain profiling tools available
whenever you’re debugging, you could add those elements to the
Debug perspective.
Perspectives generally consist of these components:
toolbars
views
editors.
July 30, 2004
Chapter 1 IDE Concepts
9
Views and editors
 2004, QNX Software Systems Ltd.
Perspectives govern which views appear on your workbench. For
example, when you’re in the Debug perspective, the following main
views are available (in the default configuration):
Debug
Processes
Breakpoints
Inspector
Variables
Console
Tasks.
Views and editors
Views
Views organize information in various convenient ways. For example,
the Outline view shows you a list of all the function names when
you’re editing a C file in the C/C++ Editor. The Outline view is
dynamic; if you declare a function called mynewfunc(), the Outline
view immediately lists it.
Views give you different presentations of your resources. For
example, the Navigator view shows the resources (projects, folders,
files) you’re working on. Like individual panes in a large window,
views let you see different aspects of your entire set of resources.
Views provide:
insight into editor contents (e.g. Outline view)
navigation (e.g. Navigator view)
information (e.g. Tasks view)
control (e.g. Debug view).
10
Chapter 1 IDE Concepts
July 30, 2004
 2004, QNX Software Systems Ltd.
Projects and workspace
Editors
You use editors to browse or change the content of your files. Each
editor in the IDE is designed for working with a specific type of file.
The editor that you’ll likely use the most is the C/C++ Editor.
The editor area is a section of the workbench window reserved for
editors. Note that views can be anywhere on the workbench except in
the editor area.
The IDE lets you rearrange views and editors so they’re beside each
other (tiled) or stacked on top of each other (tabbed).
☞
If you wish to use a different text editor than the one that’s built into
the IDE, you can do so, but you’ll lose the integration of the various
views and perspectives. For example, within the IDE’s text editor, you
can set breakpoints and then see them in the Breakpoints view, or put
“to-do” markers on particular lines and see them in the Tasks view, or
get context-sensitive help as you pause your cursor over a function
name in your code, and much, much more.
But if you want to use your own editor, we recommend that you:
1
Edit your files outside of the IDE.
2
Make sure that you save your files in the right place, e.g.:
C:\QNXsdk\host\win32\x86\usr\Eclipse\workspace\project name
3
From within the IDE, use the Refresh command (right-click
menu in the Navigator view or the C/C++ Projects view).
Projects and workspace
Projects are generic containers for your source code, makefiles, and
binaries. Before you do any work in the IDE, you must first create
projects to store your work. One of the more common projects is a
QNX C/C++ Application Project.
July 30, 2004
Chapter 1 IDE Concepts
11
Projects and workspace
☞
 2004, QNX Software Systems Ltd.
Throughout this guide, we use the term “C/C++” as shorthand to
cover both C and C++ projects. The titles of elements within the IDE
itself are often explicit (e.g. “QNX C Application Project,” “QNX
C++ Application Project,” etc.).
When you create a file within a project, the IDE also creates a record
(local history) of every time you changed that file and how you
changed it.
Your workspace is a folder where you keep your projects. For the
exact location of your workspace folder on your particular host, see
the appendix Where Files Are Stored in this guide.
Specifying a workspace location
You can redirect the IDE to point at different workspaces:
➤ From the directory where the qde.exe executable (Windows)
or the qde script (all other hosts) resides, run this command:
qde -data path to workspace
This command launches the IDE and specifies where you want the
IDE to create (or look for) the workspace folder.
☞
Don’t use spaces when naming a project or file — they can cause
problems with some tools, such as the make utility.
Also, don’t use case alone to distinguish files and projects. On
Unix-style hosts (i.e. Solaris, Linux, QNX Neutrino), filenames are
case-sensitive, but in Windows they’re not. For example, Hello.c
and hello.c would refer to the same file in Windows, but would be
separate filenames in Unix-style systems.
12
Chapter 1 IDE Concepts
July 30, 2004
 2004, QNX Software Systems Ltd.
Projects and workspace
How the IDE looks at projects
The IDE associates projects with natures that define the
characteristics of a given project. For example, a Standard Make C
Application Project will have a “C nature,” whereas a QNX C
Application Project will have a C nature as well as a QNX C nature,
and so on. Note that QNX C or C++ projects assume the QNX
recursive makefile hierarchy to support multiple target architectures;
standard make projects don’t.
☞
For more on the QNX recursive makefile hierarchy, see the
Conventions for Makefiles and Directories appendix in the
Programmer’s Guide.
The natures tell the IDE what can and can’t be done with each project.
The IDE also uses the natures to filter out projects that would be
irrelevant in certain contexts (e.g. a list of QNX System Builder
projects won’t contain any C++ library projects).
Here are the most common projects and their associated natures:
July 30, 2004
Chapter 1 IDE Concepts
13
Host and target machines
 2004, QNX Software Systems Ltd.
Project
Associated natures
Simple Project
n/a
Standard Make C Application Project
C
Standard Make C++ Application Project
C, C++
QNX C Application Project
C, QNX C
QNX C Library Project
C, QNX C
QNX C++ Application Project
C, C++, QNX C
QNX C++ Library Project
C, C++, QNX C
QNX System Builder Project
QNX System Builder
The IDE saves these natures and other information in .project and
.cdtproject files in each project. To ensure that these natures
persist in CVS, include these files when you commit your project.
☞
The IDE doesn’t support nested projects; each project must be
organized as a discrete entity. However, the IDE does support project
dependencies by allowing a project to reference other projects that
reside in your workspace.
Host and target machines
The host is the machine where the IDE resides (e.g. Windows). The
target is the machine where QNX Neutrino and your program actually
run.
Target agent (the qconn daemon)
The qconn daemon is the target agent written specifically to support
the IDE. It facilitates communication between the host and target
machines.
14
Chapter 1 IDE Concepts
July 30, 2004
 2004, QNX Software Systems Ltd.
Launcher
If you’re running the IDE on a QNX Neutrino PC (self-hosted), your
target machine may also be the host machine. In this case, you must
still run qconn, even though your host machine is “connecting to
itself.”
For more information about connection methods, see the Launch
Configurations Reference chapter in this guide.
Launcher
Before you can run a program, you must tell the IDE’s launcher what
program to run, what target to run it on, what arguments to pass to the
program, and so on.
If you want to run the program on another target or run with different
options (e.g. with profiling enabled), you must create a new launch
configuration or copy a previous one and modify it.
Resources
Resources is a collective term for your projects, folders, and files. You
store all your resources in your workspace.
Wizards
Wizards guide you through a sequence of tasks. For example, to
create a QNX C Application Project, you run a wizard that takes you
through all the steps and gathers all the necessary information before
creating the project. For more information, see the Common Wizards
Reference chapter in this guide.
Keyboard shortcuts
You’ll find many keyboard shortcuts for various UI tasks throughout
the IDE. The Window menu includes an item for the main shortcuts:
July 30, 2004
Chapter 1 IDE Concepts
15
Preferences
 2004, QNX Software Systems Ltd.
You can easily create your own shortcuts. For instructions, follow
these links in the Workbench User Guide:
Reference→Preferences→Keys
☞
Some existing shortcuts and some commands that can be assigned to
shortcuts only apply to Java code and projects. For example, the
“Search for Declaration in Workspace” command, which is bound to
Ctrl – G only works with Java code.
Preferences
The Preferences dialog (under the Window menu) lets you customize
the behavior of your environment — when to build your projects, how
to open new perspectives, which target processors to build for, etc.
16
Chapter 1 IDE Concepts
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Version coexistence
Besides global preferences, you can also set preferences on a
per-project basis via the Properties item in right-click menus.
Version coexistence
The QNX Momentics 6.3.0 development suite lets you install and
work with multiple versions of Neutrino (from 6.2.1 and later) — you
can choose which version of the OS to build programs for.
When you install QNX Momentics, you get a set of configuration files
that indicate where you’ve installed the software. The
QNX CONFIGURATION environment variable stores the location
of the configuration files for the installed versions of Neutrino; on a
self-hosted Neutrino machine, the default is /etc/qconfig.
July 30, 2004
Chapter 1 IDE Concepts
17
Version coexistence
 2004, QNX Software Systems Ltd.
QWinCfg for Windows hosts
On Windows hosts, you’ll find a configuration program (QWinCfg)
for switching between versions of QNX Momentics.
You launch QWinCfg via the start menu (e.g. All Programs→QNX
Momentics 6.3.0→Configuration).
For details on using QWinCfg, see its entry in the Utilities Reference.
qconfig utility for non-Windows hosts
The qconfig utility lets you configure your machine to use a specific
version of Neutrino:
If you run it without any options, qconfig lists the versions that
are installed on your machine.
If you specify the -e option, you can set up the environment for
building software for a specific version of the OS. For example, if
you’re using the Korn shell (ksh), you can configure your machine
like this:
eval `qconfig -n "QNX 6.3.0 Install" -e`
☞
In the above command, you must use the “back tick” character (`),
not the single quote character (’).
When you start the IDE, it uses your current qconfig choice as the
default version of the OS; if you haven’t chosen a version, the IDE
chooses an entry from the directory identified by
QNX CONFIGURATION. If you want to override the IDE’s choice,
you can choose the appropriate build target.
Specifying which OS version to build for
To specify which version of Neutrino you want the IDE to build for:
18
1
Open the Preferences dialog (Window→Preferences).
2
Select QNX.
Chapter 1 IDE Concepts
July 30, 2004
Version coexistence
 2004, QNX Software Systems Ltd.
3
Using the dropdown list in the Select Install field, choose the
OS version you want to build for.
4
Click Apply, then OK.
Environment variables
Neutrino uses these environment variables to locate files on the host
machine:
QNX HOST
The location of host-specific files.
QNX TARGET
The location of target backends on the host
machine.
QNX CONFIGURATION
The location of the qconfig configuration files.
MAKEFLAGS The location of included *.mk files.
TMPDIR
The directory to use for temporary files. GCC uses
temporary files to hold the output of one stage of
compilation used as input to the next stage: for
example, the output of the preprocessor, which is
the input to the compiler proper.
The qconfig utility sets these variables according to the version of
QNX Momentics that you specified.
July 30, 2004
Chapter 1 IDE Concepts
19
Chapter 2
Preparing Your Target
In this chapter. . .
Host-target communications
Connecting with Phindows
July 30, 2004
23
29
Chapter 2 Preparing Your Target
21
Host-target communications
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Common
Wizards
Tutorials
Where Files
Are Stored
This chapter explains how to set up host-target communications.
Host-target communications
Regardless of whether you’re connecting to a remote or a local target,
you have to prepare your target machine so that the IDE can interact
with the QNX Neutrino image running on the target.
The IDE supports host-target communications using either an IP or a
serial connection. We recommend both. If you have only a serial link
you’ll be able to debug a program, but you’ll need an IP link in order
to use any of the advanced diagnostic tools in the IDE.
IP communications
Before you can configure your target for IP communications, you
must connect the target and host machines to the same network.
To configure your target for IP communications:
July 30, 2004
1
Open a terminal window on your target.
2
Log in as root.
3
Start the target agent by entering this command:
Chapter 2 Preparing Your Target
23
Host-target communications
 2004, QNX Software Systems Ltd.
qconn
☞
The version of QNX Momentics on your host must match the version
of QNX Neutrino on your target, or unexpected behavior may occur.
4
You’ll need the target machine’s IP address (e.g.
10.12.3.200) when you connect to your target. To get the
address, enter:
netstat -in
When you set up a launch configuration, select C/C++ QNX QConn
(IP). (See the Launch Configurations Reference chapter in this guide
for more information.)
☞
pdebug must be present on the target system in /usr/bin for all
debugging sessions. qconn will launch it as needed.
Serial communications
Before you can configure your target for serial communications, you
must establish a working serial connection between your host and
target machines.
To configure your target for serial communications:
1
Open a terminal window on your target.
2
Log in as root.
3
If it’s not already running, start the serial device driver that’s
appropriate for your target. Intel x86-based machines usually
use the devc-ser8250 driver.
4
Once the serial driver is running, you’ll see a serial device listed
in the /dev directory. To confirm it’s running, enter:
ls /dev/ser*
You’ll see an entry such as /dev/ser1 or /dev/ser2.
24
Chapter 2 Preparing Your Target
July 30, 2004
Host-target communications
 2004, QNX Software Systems Ltd.
5
Start the pseudo-terminal communications manager
(devc-pty):
devc-pty &
6
Start the debug agent by entering this command (assuming
you’re using the first serial port on your target):
pdebug /dev/ser1 &
The target is now fully configured.
7
Determine the serial port parameters by entering this command
(again assuming the first serial port):
stty
</dev/ser1
This command gives a lot of output. Look for the
baud=baudrate entry; you’ll need this information to properly
configure the host side of the connection.
When you set up a launch configuration, select C/C++ QNX PDebug
(Serial). (See the Launch Configurations Reference chapter in this
guide for more information.)
Example: Serial debugging via PPP
This example shows you how to prepare your target and host for serial
debugging using a PPP connection.
Before you begin, make sure the serial ports on both the host and
target systems are configured properly and can talk to each other
through a null-modem serial cable.
Setting up your target
To configure your target for serial communication using PPP:
1
Create a /etc/ppp/options file containing the following:
debug
57600
/dev/ser1
11.0.0.1:11.0.0.0
July 30, 2004
Chapter 2 Preparing Your Target
25
Host-target communications
☞
 2004, QNX Software Systems Ltd.
You may need to try a slower baud rate if you have any problems at
57600.
2
If it’s not already running, start io-net with this command:
io-net -ptcpip -ppppmgr
3
Now start the PPP daemon:
pppd
4
Finally, start the qconn target agent:
qconn
QNX Neutrino host
To configure your QNX Neutrino host for serial communication using
PPP:
1
Create a /etc/ppp/options file containing the following:
debug
57600
/dev/ser1
11.0.0.1:11.0.0.0
☞
You may need to try a slower baud rate if you have any problems at
57600.
2
If it’s not already running, start io-net with this command:
io-net -ptcpip -ppppmgr
3
Start the PPP daemon with the passive option:
pppd passive
26
Chapter 2 Preparing Your Target
July 30, 2004
 2004, QNX Software Systems Ltd.
Host-target communications
Windows host
To configure your Windows XP host for serial communication using
PPP:
☞
July 30, 2004
The names of menu items and other details differ slightly on other
supported versions of Windows.
1
In the Control Panel, select Network Connections.
2
In the New Connection Wizard dialog, click Set up an
advanced connection, then click Next:
3
Select Connect directly to another computer, then click Next.
4
When prompted for the role of your target, choose Guest:
Chapter 2 Preparing Your Target
27
Host-target communications
28
 2004, QNX Software Systems Ltd.
5
Name your connection (e.g. “ppp biscayne”).
6
When prompted to select a device, choose Communications
Port (COM1), then click Next.
7
When prompted to specify whether you want this connection to
be for your use only, or for anyone’s, select Anyone’s use.
8
If you want Windows to create a desktop shortcut, click the
option on the last page of the wizard. If not, simply click
Finish.
9
In the Connect name of target dialog, enter your user ID and
password, the select Properties.
10
Select the Options tab.
11
Turn off the option Prompt for name and password,
certificate, etc., then click OK.
Chapter 2 Preparing Your Target
July 30, 2004
Connecting with Phindows
 2004, QNX Software Systems Ltd.
Connecting with Phindows
The IDE lets you connect to a Photon session on a target from a
Windows host machine and interact with the remote Photon system as
if you were sitting in front of the target machine.
To prepare your target for a Phindows connection:
1
Open a terminal window and log in as root.
2
Edit the /etc/inetd.conf file and add the following line (or
uncomment it if it’s already there):
phrelay stream tcp nowait root /usr/bin/phrelay phrelay -x
3
Save the file and exit the editor.
4
If it’s running, kill the inetd daemon:
slay inetd
5
Now restart inetd:
inetd
The inetd daemon starts and you can connect to your target
using Phindows.
For details on using Phindows, see the Phindows Connectivity User’s
Guide in your QNX Momentics documentation set.
July 30, 2004
Chapter 2 Preparing Your Target
29
Chapter 3
Developing C/C++ Programs
In this chapter. . .
The C/C++ Development perspective
Controlling your projects
34
Creating projects
38
Building projects
39
Running projects
44
Deleting projects
46
Writing code
47
More development features
54
July 30, 2004
33
Chapter 3 Developing C/C++ Programs
31
 2004, QNX Software Systems Ltd.
Getting
Started
Development
The C/C++ Development perspective
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter shows you how to create and manage your C or C++ projects.
The C/C++ Development perspective
The C/C++ Development perspective is where you develop and build
your projects. As mentioned in the Concepts chapter, a project is a
container for organizing and storing your files.
Besides writing code and building your projects, you may also debug
and analyze your programs from the C/C++ Development perspective.
☞
You’ll find complete documentation on the C/C++ Development
perspective, including several tutorials to help you get started, in the
core Eclipse platform docset: Help→Help Contents→C/C++
Development User Guide.
The views in the C/C++ Development perspective are driven
primarily by selections you make in the C/C++ Editor and the C/C++
Projects view, which is a specialized version of the Navigator view.
Since the Navigator view is part of the core Eclipse platform, you’ll
find full documentation on the Navigator in the Workbench User
Guide:
July 30, 2004
Chapter 3 Developing C/C++ Programs
33
Controlling your projects
 2004, QNX Software Systems Ltd.
For information on the Navigator’s:
See these sections in the Workbench
User Guide:
toolbar and icons
Concepts→Views→Navigator view
right-click context menu
Reference→User interface
information→Views and
Editors→Navigator View
Wizards and Launch Configurations
To create and run your first program, you’ll use two major facilities
within the IDE:
wizards — for quickly creating a new project
launch configurations — for setting up how your program should
run.
Once you’ve used these parts of the IDE for the first time, you’ll be
able to create, build, and run your programs very quickly. For details,
see the Common Wizards Reference and Launch Configurations
Reference chapters in this guide.
Controlling your projects
The C/C++ Development perspective’s C/C++ Projects view is
perhaps the most important view in the IDE because you can control
your projects with it. The selections you make in the C/C++ Projects
view greatly affect what information the other views display.
The C/C++ Projects view gives a “virtual” or filtered presentation of
all the executables, source, and shared objects that comprise your
project. You can set filters for the types of files you want shown in
this view.
The C/C++ Projects view has many of the same features as the
Navigator view, but is configured specifically for C and C++
34
Chapter 3 Developing C/C++ Programs
July 30, 2004
Controlling your projects
 2004, QNX Software Systems Ltd.
development. At first glance, the two may seem identical, but the
C/C++ Projects view:
shows only open C/C++ projects
presents the project’s executables as if they reside in a subdirectory
called bin
for a library project, presents the project’s libraries as if they reside
in subdirectory called lib
hides certain files
includes Build Project and related commands in its right-click
menu
gives an outline of *.c, *.cc, *.cpp, *.h, and binary files.
Opening files
To open files and display them in the editor area:
➤ In the C/C++ Projects view, double-click the file to be opened.
The file — even if it’s executable — opens in the editor area.
Opening projects
Since the C/C++ Projects view hides closed projects, you must use
the Navigator view to open them.
➤ In the Navigator view, right-click your project, then select
Open Project.
The project opens — you can see it in the C/C++ Projects view.
July 30, 2004
Chapter 3 Developing C/C++ Programs
35
Controlling your projects
 2004, QNX Software Systems Ltd.
Filtering files
To hide certain files from the C/C++ Projects view:
1
In the C/C++ Projects view, click the menu dropdown button
(
36
).
2
Select Filter. The File Filter dialog appears:
3
In the filter pane, select the types of files you wish to hide. For
example, if you select .*, then all files that start with a period
(e.g. .cdtproject, .project, etc.) won’t appear in the
C/C++ Projects view.
Chapter 3 Developing C/C++ Programs
July 30, 2004
Controlling your projects
 2004, QNX Software Systems Ltd.
4
Click OK. The C/C++ Projects view automatically refreshes
and shows only the files you haven’t filtered.
Outlines of source and executable files
The C/C++ Projects view shows you an outline of the .c, .cc, and
.h files in your project:
Note that you can also use the Outline view to see the structure of
your projects. (For more on the Outline view, see the “Code synopsis”
section in this chapter.)
The C/C++ Projects view shows you the outlines of executables as
well. You can examine the structure of executables to see the
functions that you declared and used in the file, as well as the
elements that were called indirectly, such as malloc(), init(), and
errno:
July 30, 2004
Chapter 3 Developing C/C++ Programs
37
Creating projects
 2004, QNX Software Systems Ltd.
Creating projects
If you’re creating an application from scratch, you’ll probably want to
create a QNX C/C++ Application Project, which relies on the QNX
recursive makefile hierarchy to support multiple CPU targets. For
more on the QNX recursive makefile hierarchy, see the Conventions
for Makefiles and Directories appendix in the Programmer’s Guide.
☞
If you want to import an existing project, see the section “Importing
existing source code into the IDE” in the Managing Source Code
chapter in this guide.
You use the New Project wizard whenever you create a new project in
the IDE. Here are the steps to create a simple “hello world” type of
program:
38
Chapter 3 Developing C/C++ Programs
July 30, 2004
Building projects
 2004, QNX Software Systems Ltd.
1
In the C/C++ Development perspective, click the New QNX C
Project button in the toolbar:
The New Project wizard appears.
☞
There are actually several ways to open the New Project wizard. See
the Common Wizards Reference chapter in this guide for details.
2
Name your project, then select the type:
3
Click Next – but don’t press Enter! (Pressing Enter at this point
amounts to clicking the Finish button, which will cause the IDE
to create the project for all CPU variants, which you may not
want.)
4
In the Build Variants tab, check the build variant that matches
your target type, such as X86 (Little Endian), PPC (Big
Endian), etc.
Also, check Build debug version and Build release version.
5
Click Finish. The IDE creates your project and displays the
source file in the editor.
Building projects
Once you’ve created your project, you’ll want to build it. Note that
the IDE uses the same make utility and makefiles that are used on the
command line.
July 30, 2004
Chapter 3 Developing C/C++ Programs
39
Building projects
 2004, QNX Software Systems Ltd.
The IDE can build projects automatically (i.e. whenever you change
your source) or let you build them manually. When you do manual
builds, you can also decide on the scope of the build.
You can watch a build’s progress and see output from the build
command in the C-Build view. If a build generates any errors or
warnings, you can see them in the Tasks view.
Build terminology
The IDE uses a number of terms to describe the scope of the build:
Build
Build only the components affected by modified files in
that particular project (i.e. make all).
Clean
Delete all the built components (i.e. .o, .so, .exe, and
so on) without building anything (i.e. make clean).
Rebuild
Delete all the built components, then build each one
from scratch. A Rebuild is really a Clean followed by a
Build (i.e. make clean; make all).
Turning off the autobuild feature
By default, the IDE automatically rebuilds your project every time
you change a file or other resource in any way (e.g. delete, copy, save,
etc.). This feature is handy if you have only a few open projects and if
they’re small. But for large projects, you might want to turn this
feature off.
To turn off autobuilding:
40
1
From the main menu, select Window→Preferences.
2
In the left pane, select Workbench.
3
In the right pane, disable the Perform build automatically on
resource modification option. The IDE now builds your
projects only when you ask it to.
Chapter 3 Developing C/C++ Programs
July 30, 2004
Building projects
 2004, QNX Software Systems Ltd.
Building everything
The IDE lets you manually choose to rebuild all your open projects.
Depending on the number of projects, the size of the projects, and the
number of target platforms, this could take a significant amount of
time.
To rebuild all your open projects:
➤ From the main menu, select Project→Rebuild All.
Building selected projects
To rebuild a single project:
➤ In the C/C++ Projects view, right-click a project and select one
of:
Build
Rebuild
July 30, 2004
Chapter 3 Developing C/C++ Programs
41
Building projects
 2004, QNX Software Systems Ltd.
Autosave before building
To have the IDE automatically save all your changed resources before
you do a manual build:
1
From the main menu, select Window→Preferences.
2
In the left pane, select Workbench.
3
In the right pane, check the Save all modified resources
automatically prior to manual build option. The IDE saves
your resources before it builds your project.
Configuring project build order
You can tell the IDE to build certain projects before others. And if a
given project refers to another project, the IDE builds that project
first.
☞
Setting the build order doesn’t necessarily cause the IDE to rebuild all
projects that depend on a given project. You must rebuild all projects
to ensure that all dependencies are resolved.
To manually configure the project build order:
42
1
From the main menu, select Window→Preferences.
2
In the left pane, select Build Order.
3
Disable the Use default build order option.
4
Select a project in the list, then use the Up or Down buttons to
position the project where you want in the list.
5
When you’re done, click Apply, then OK.
Chapter 3 Developing C/C++ Programs
July 30, 2004
Building projects
 2004, QNX Software Systems Ltd.
Creating personal build options
☞ In this section, the term “targets” refers to operations that the make
command executes during a build, not to target machines.
A make target is an action called by the make utility to perform a
build-related task. For example, QNX makefiles support a target
named clean, which gets called as make clean. The IDE lets you
set up your own make targets (e.g. myMakeStuff ). You can also use a
make target to pass options such as CPULIST=x86, which causes the
make utility to build only for x86. Of course, such an option would
work only if it’s already defined in the makefile.
To add your own custom make target to the C/C++ Project view’s
right-click menu:
1
In the C/C++ Projects view, right-click a project and select
Create Make Target. . . .
2
Type the name of your make target (e.g. myMakeStuff).
3
Click OK.
You’ll see your target option listed in the Build Targets dialog, which
appears when you select the Build Make Target. . . item of the
right-click menu of the C/C++ Projects view. Your targets also appear
in the Make Targets view.
To build your custom make target:
July 30, 2004
1
In the C/C++ Projects view, right-click a project.
2
In the context menu, select Build Make Target. . . item. The
Build Targets dialog appears.
3
Select your custom target, then click Build.
Chapter 3 Developing C/C++ Programs
43
Running projects
☞
 2004, QNX Software Systems Ltd.
To remove a make target:
1
Open the Make Targets view (Window→Show View→Make
Targets). Expand your project to see your make targets.
2
Right-click the target you want to remove, then select Delete
Build Target.
Running projects
☞
Before running an application, you must prepare your target. If it isn’t
already prepared, you must do so now. See the previous chapter
(Preparing Your Target) in this guide.
Once you’ve built your project, you’re ready to run it. The IDE lets
you run or debug your executables on either a local or a remote QNX
Neutrino target machine. (For a description of local and remote
targets, see the IDE Concepts chapter.)
To run or debug your program, you must create both of the following:
a QNX Target System Project, which specifies how the IDE
communicates with your target; once you’ve created a QNX Target
System Project, you can reuse it for every program that runs on
that particular target.
a Launch Configuration, which describes how the program runs
on your target; you’ll need to set this up only once for that
particular program.
44
Chapter 3 Developing C/C++ Programs
July 30, 2004
Running projects
 2004, QNX Software Systems Ltd.
☞
For a complete description of how to create a QNX Target System
Project, see the Common Wizards Reference chapter in this guide.
For a complete description of the Launch Configurations dialog and
its available options, see the Launch Configurations Reference
chapter in this guide.
To create a QNX Target System Project:
1
From the menu, select File→New→Other. . . .
2
In the left pane, select QNX.
3
In the right pane, select QNX Target System Project.
4
Click Next.
5
Name your target.
6
Enter your target’s Hostname or IP address.
7
Click Finish.
You’ll see your new QNX Target System Project in the Navigator
view.
To create a launch configuration so you can run your “hello world”
QNX C Application Project:
☞
July 30, 2004
Make sure you build your project first before you create a launch
configuration for it. See “Building projects” above.
1
In the C/C++ Projects view, select your project.
2
From the Run workbench menu, click the Run. . . menu item:
Chapter 3 Developing C/C++ Programs
45
Deleting projects
 2004, QNX Software Systems Ltd.
3
In the Launch Configurations dialog, select C/C++ QNX
QConn (IP) in the left pane.
4
Click New.
5
In the Name field, give your launch configuration a name.
6
Click the Search button beside the C/C++ Application field.
The Program Selection dialog appears.
7
Select a program to run; the g indicates it was compiled for
debugging.
8
Click OK.
9
In the Target Options pane, select your target.
10
Click the Run button.
Your program runs — you should see its output in the Console view.
Deleting projects
To delete a project:
46
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Writing code
1
In the C/C++ Projects view, right-click a project and select
Delete from the context menu. The IDE then prompts you to
confirm, like this:
2
Decide whether you want to delete just the project framework,
or its contents as well.
When you delete a project in the IDE, any launch configurations for
that project are not deleted. This feature lets you delete and recreate a
project without also having to repeat that operation for any
corresponding launch configurations you may have created.
For more on launch configurations, see the Launch Configurations
Reference chapter in this guide.
Writing code
The C/C++ Editor is where you write and modify your code. As you
work in the editor, the IDE dynamically updates many of the other
views (even if you haven’t saved your file).
C/C++ Editor layout
The C/C++ Editor has a gray border on each side. The border on the
left margin might contain icons that indicate errors or other problems
detected by the IDE, as well as icons for any bookmarks, breakpoints,
or tasks (from the Tasks view). The icons in the left margin
correspond to the line of code.
July 30, 2004
Chapter 3 Developing C/C++ Programs
47
Writing code
 2004, QNX Software Systems Ltd.
The border on the right margin displays red and yellow bars that
correspond to the errors and warnings from the Tasks view. Unlike the
left margin, the right margin displays the icons for the entire length of
the file.
Finishing function names
The Content Assist feature can help you finish the names of functions
if they’re long or if you can’t remember the exact spelling.
To use Content Assist:
1
In the C/C++ Editor, type one or two letters of a function’s
name.
2
Press Ctrl – Space. (Or, right-click near the cursor and select
Content Assist.) A menu with the available functions appears:
3
You may do one of the following:
Continue typing. The list shortens. When there’s only one
function that matches, it’s automatically inserted.
Scroll with the up and down arrows. Press Enter to select the
function.
Scroll with your mouse. Double-click a function to insert it.
48
Chapter 3 Developing C/C++ Programs
July 30, 2004
Writing code
 2004, QNX Software Systems Ltd.
To close the Content Assist window, press Esc.
Inserting code snippets
The IDE has another code-completion feature that can insert canned
snippets of code such as an empty do-while structure. If you’ve
already used the Content Assist feature, you may have already noticed
the Code Templates feature; you access it the same way.
To use Code Templates:
1
As with Content Assist, start typing, then press Ctrl – Space.
(Or, right-click near the cursor and select Content Assist).
2
Any code templates that match the letters you’ve typed will
appear first in the list:
The IDE lets you enable as many of these templates as you like, edit
them as you see fit, create your own templates, and so on.
To edit a template or add one of your own:
July 30, 2004
1
From the main menu, select Window→Preferences.
2
In the left pane, select C/C++→Code Templates.
Chapter 3 Developing C/C++ Programs
49
Writing code
 2004, QNX Software Systems Ltd.
3
To edit a template, select it, then click Edit.
4
To add you own template, click New. A dialog for adding new
templates appears:
Adding #include directives
To insert the appropriate #include directive for any documented
QNX Neutrino function:
1
In the C/C++ Editor, double-click the function name, but don’t
highlight the parentheses or any leading tabs or spaces.
2
Right-click and select Add Include. The IDE automatically
adds the #include statement to the top of the file, if it isn’t
already there.
Hover help
The IDE’s hover help feature gives you the synopsis for a function
while you’re coding. To use hover help:
50
Chapter 3 Developing C/C++ Programs
July 30, 2004
Writing code
 2004, QNX Software Systems Ltd.
➤ In the C/C++ Editor, pause your pointer over a function. You’ll
see a text box showing the function’s summary and synopsis:
Commenting-out code
You can easily add comments using either the C or C++ style, even to
large sections of code. You can add // characters to the beginning of
lines, letting you comment out large sections, even if they have /* */
comments.
When you uncomment lines, the editor removes the leading //
characters from all lines that have them, so be careful not to
accidentally uncomment sections. Also, the editor can comment or
uncomment selected lines — if you highlight a partial line, the editor
comments out the entire line, not just the highlighted section.
To comment or uncomment a block of code:
July 30, 2004
1
In the C/C++ Editor, highlight a section of code to be
commented or uncommented. For one line, place your cursor
on that line.
2
Right-click and select Comment or Uncomment.
Chapter 3 Developing C/C++ Programs
51
Writing code
 2004, QNX Software Systems Ltd.
Customizing the C/C++ Editor
You can change the font, set the background color, show line
numbers, and control many other visual aspects of the C/C++ Editor.
You can also configure context highlighting and change how the Code
Assist feature works. You do all this in the C/C++ Editor preferences
dialog:
To access the C/C++ Editor preferences dialog:
1
Select Window→Preferences.
2
In the left pane, select C/C++→C/C++ Editor.
Using other editors
If you wish to use a different text editor than the one that’s built into
the IDE, you can do so, but you’ll lose the integration of the various
views and perspectives. For example, within the C/C++ Editor, you
52
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
Writing code
can set breakpoints and then see them in the Breakpoints view, or put
“to-do” markers on particular lines and see them in the Tasks view, or
get hover help as you pause your cursor over a function name in your
code, and so on.
If you want to use other editors, you can do so either outside or inside
the IDE.
Outside the IDE
You can edit your code with an editor started outside of the IDE (e.g.
from the command line). When you’re done editing, you’ll have to
synchronize the IDE with the changes.
To synchronize the IDE with changes you’ve made using an editor
outside of the IDE:
➤ In the C/C++ Projects view, right-click the tree pane and select
Refresh. The IDE updates the display to reflect any changes
you’ve made (such as creating new files).
Within the IDE
You can specify file associations that determine the editor you want to
use for each file type. For example, you can tell the IDE to use an
external program such as WordPad to edit all .h files. Once that
preference is set, you can double-click a file in the C/C++ Projects
view, and the IDE automatically opens the file in your selected
program.
If the IDE doesn’t have an association set for a certain file type, it uses
the host OS defaults. For example, on a Windows host, if you
double-click a .DOC file, Word or WordPad automatically launches
and opens the file.
July 30, 2004
Chapter 3 Developing C/C++ Programs
53
More development features
☞
 2004, QNX Software Systems Ltd.
For more information about file associations, follow these links in the
Eclipse Workbench User Guide: Reference→Preferences→File
Associations.
Creating files from scratch
By default, the IDE creates a simple “hello world” C/C++ source file
for you, which you may or may not want to use as a template for your
own code.
To create a new C/C++ file:
1
Highlight the project that will contain the new file you’re
creating.
2
Click the Create a File button on the toolbar:
3
Enter (or select) the name of the folder where the file will
reside.
4
Name your file, then click Finish.
You should now see an empty text editor window, ready for you to
begin working on your new file. Notice your filename highlighted in
blue in the title bar above the editor.
More development features
Besides the features already described above, the IDE has several
other helpful facilities worth exploring.
54
Chapter 3 Developing C/C++ Programs
July 30, 2004
More development features
 2004, QNX Software Systems Ltd.
Tracking remaining work
The Tasks view gives you a list of errors and warnings related to your
projects. These are typically syntax errors, typos, and other
programming errors found by the compiler:
The Tasks view is part of the core Eclipse platform. For more
information about this view, follow these links in the Workbench User
Guide: Reference→User interface information→View and
Editors→Tasks view.
Error markers
The IDE also shows corresponding markers in several other locations:
C/C++ Projects view — on both the file that contained compile
errors and on the project itself
Outline view — in the method (e.g. main())
C/C++ Editor — on the left side, beside the offending line of code.
Jumping to errors
To quickly go to the source of an error (if the IDE can determine
where it is):
) or
➤ In the Tasks view, double-click the error marker (
warning marker ( ). The file opens in the editor area, with
the cursor on the offending line.
To jump to errors sequentially:
July 30, 2004
Chapter 3 Developing C/C++ Programs
55
More development features
 2004, QNX Software Systems Ltd.
➤ Click the Jump to next error marker button (
Jump to previous error marker button ( ).
) or the
Filtering errors
Depending on the complexity and stage of your program, the IDE can
generate an overwhelming number of errors. But you can customize
the Tasks view so you’ll see only the errors you want to see.
To access the error-filtering dialog:
➤ In the Tasks view, click the Filter icon (
).
The Filter Tasks dialog lets you adjust the scope of the errors shown in
the Tasks view. The more boxes checked, the more errors you’ll see.
56
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More development features
Setting reminders
The Tasks view lets you create your own tasks. Besides automatically
listing build errors, the view lets you set personal reminders for the
unfinished function you’re writing, the error-handling routine you
want to check, or whatever.
You use the New Tasks dialog to add a personal task:
July 30, 2004
Chapter 3 Developing C/C++ Programs
57
More development features
☞
 2004, QNX Software Systems Ltd.
1
In the Tasks view, right-click the tasks pane and select New
Task.
2
Complete the dialog for your task:
To remove a personal task:
➤ In the Tasks view, right-click the task and select either Delete or
Mark Completed.
Code synopsis
The Outline view gives you a structural view of your C/C++ source
code:
58
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More development features
The view shows the elements in the source file in the order they occur,
including functions, libraries, and variables. You may also sort the list
alphabetically, or hide certain items (fields, static members, and
nonpublic members).
If you click an entry in the Outline view, the editor’s cursor moves to
the start of the item selected.
Checking your build
The C-Build view displays the output from the make utility:
Customizing the C-Build view
You can choose to clear the C-Build view before each new build or let
the output of each subsequent build grow in the display. You can also
have the C-Build view appear on top of the other stacked views
whenever you build.
July 30, 2004
Chapter 3 Developing C/C++ Programs
59
More development features
 2004, QNX Software Systems Ltd.
To set the preferences for the C-Build view:
1
From the main menu, select Window→Preferences.
2
In the left pane, select C/C++→Build Console:
Accessing source files for functions
While editing source code in the editor, you can select a function
name, press F3, and the editor immediately jumps to the source file
for that function (if the file is also in your project).
☞
For more information on the C/C++ Development perspective, go to:
Help→Help Contents→C/C++ Development User Guide.
Opening headers
You can select a header (such as stdio.h) in the C/C++ editor and
press Ctrl – Shift – o to open the header file in the editor. You can also
right-click the header file’s name in the Outline view, then choose
Open.
Many of the enhanced source navigation and code development
accelerators available in the C/C++ editor are extracted from the
source code. To provide the most accurate data representation, the
project must be properly configured with the include paths and
defines used to compile the source.
60
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More development features
For QNX projects the standard include paths and defines are set
automatically based on the compiler and architecture. Additional
values can be set using the project’s properties.
For Standard C/C++ Make projects, you must define the values
yourself. These values can be set manually using the Paths and
Symbols tab of the project’s properties, or they can bet set
automatically using the Set QNX Build Environment. . . item in the
project’s context menu.
Set the the include paths and defines for a Standard C/C++ Make
project:
1
In the C/C++ Projects view, right-click your project and select
Set QNX Build Environment. . . .
The Set QNX Build Environment wizard appears.
July 30, 2004
Chapter 3 Developing C/C++ Programs
61
More development features
2
 2004, QNX Software Systems Ltd.
Select one or more Standard C/C++ Make projects to update
and click Next.
The Compiler/Architecture Selection panel appears.
62
Chapter 3 Developing C/C++ Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
3
July 30, 2004
More development features
Select the appropriate Compiler, Language, and Architecture
for your project, and click Finish.
Chapter 3 Developing C/C++ Programs
63
Chapter 4
Managing Source Code
In this chapter. . .
CVS and the IDE
67
Importing existing source code into the IDE
70
Using container projects
75
Importing a BSP or other QNX source packages
83
Exporting projects
90
July 30, 2004
Chapter 4 Managing Source Code
65
CVS and the IDE
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter describes managing source code from within the IDE.
CVS and the IDE
CVS is the default source-management system in the IDE. Other
systems (e.g. ClearCase) are also supported.
The CVS Repository Exploring perspective lets you bring code from
CVS into your workspace. If another developer changes the source in
CVS while you’re working on it, the IDE helps you synchronize with
CVS and resolve any conflicts. You can also choose to automatically
notify the CVS server whenever you start working on a file. The CVS
server will then notify other developers who work on that file as well.
Finally, the CVS Repository Exploring perspective lets you check
your modified code back into CVS.
☞
July 30, 2004
The IDE connects to CVS repositories that reside only on remote
servers — you can’t have a local CVS repository (i.e. one that resides
on your host computer).
Chapter 4 Managing Source Code
67
CVS and the IDE
 2004, QNX Software Systems Ltd.
Local history feature
The IDE has a builtin “undo” file-management facility called local
history. While you’re working on your code, the IDE automatically
keeps track of the changes you make to your file; it lets you roll back
to an earlier version of a file that you saved but didn’t commit to CVS.
For more on the IDE’s local history feature, follow these links in the
Workbench User Guide: Reference→User interface
information→Development environment→Local history.
Project files (.project and .cdtproject)
For each project, the IDE stores important information in these two
files:
.project
.cdtproject
You must include both files with your project when you commit it to
CVS.
Core Eclipse documentation on using CVS in the IDE
Since the CVS Repository Exploring perspective is a core Eclipse
feature, you’ll find complete documentation in the Eclipse Workbench
User Guide. Follow these links:
Tips and Ticks→Team - CVS
Tasks→Working in the team environment
This table may help you find information quickly in the Workbench
User Guide:
68
Chapter 4 Managing Source Code
July 30, 2004
CVS and the IDE
 2004, QNX Software Systems Ltd.
If you want to:
Go to:
Connect to a CVS repository
Tasks→Working in the team
environment→Working with
a CVS repository→Creating a
CVS repository location
Check code out of CVS
Tasks→Working in the team
environment→Working with
projects shared with
CVS→Checking out a project
from a CVS repository
Synchronize with a CVS
repository
Tasks→Working in the team
environment→Synchronizing
with the repository, especially
the Updating section
See who’s also working on a file
Tasks→Working in the team
environment→Finding out
who’s working on what:
watch/edit
Resolve CVS conflicts
Tasks→Working in the team
environment→Synchronizing
with the
repository→Resolving
conflicts
Prevent certain files from being
committed to CVS
Tasks→Working in the team
environment→Synchronizing
with the repository→Version
control life cycle: adding and
ignoring resources
Create and apply a patch
Tasks→Working in the team
environment→Working with
patches
continued. . .
July 30, 2004
Chapter 4 Managing Source Code
69
Importing existing source code into the IDE
 2004, QNX Software Systems Ltd.
If you want to:
Go to:
Track code changes that haven’t
been committed to CVS
Tasks→Working with local
history, especially the
Comparing resources with the
local history section
View an online FAQ about the
CVS Repository Exploring
perspective
Reference→Team
Support→CVS
Importing existing source code into the IDE
As with many tasks within the IDE, there’s more than one way to
bring existing source files into your workspace:
filesystem drag-and-drop — from a Windows host you can drag
and drop (or copy and paste) individual files from the filesystem
into your project in your workspace.
CVS repository — you can use the CVS Repositories view to
connect to a CVS repository and check out projects, folders, or
files into your workspace.
Import wizard — this IDE wizard lets you import existing projects,
files, even files from ZIP archives into your workspace.
linked resources — this IDE facility lets you work with files and
folders that reside in the filesystem outside your project’s location
in the workspace. You might use linked resources, for example, if
you have a source tree that’s handled by some other
source-management tool outside of the IDE. (For more on linked
resources, follow these links in the Workbench User Guide:
Concepts→Workbench→Linked resources.)
Whatever method you use, you always need to set up an IDE project
in your workspace in order to work with the resources you’re
importing.
70
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Importing existing source code into the IDE
Projects within projects?
Suppose you have an existing source hierarchy that looks something
like this:
In order to work efficiently with this source in the IDE, each
component and subcomponent should be a “subproject” within the
one main project. (You could keep an entire hierarchy as a single
project if you wish, but you’d probably find it cumbersome to build
and work with such a monolith.)
Unfortunately, the current version of Eclipse (2.1) in QNX
Momentics 6.3 doesn’t support nesting projects as such. So how
would you import such a source tree into Eclipse 2.1?
Step 1
First, in your workspace create a single project that reflects all the
components that reside in your existing source tree:
July 30, 2004
1
Select File→New→Project. . . .
2
Select the type of project (e.g. Standard Make C project).
3
Name your project (e.g. “EntireSourceProjectA”).
Chapter 4 Managing Source Code
71
Importing existing source code into the IDE
 2004, QNX Software Systems Ltd.
4
Unselect Use Default Location, because we need to tell the
IDE where the resources reside in the filesystem (since they
don’t reside in your workspace).
5
In the Location: field, type in the path to your source (or click
Browse. . . ).
6
Click Finish. You should now have a project that looks
something like this in the C/C++ Projects view:
Step 2
Now we’ll create an individual project (via File→New→Project. . . )
for each of the existing projects (or components) in your source tree.
In this example, we’d create a separate project for each of the
following source components:
72
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Importing existing source code into the IDE
ComponentA
ComponentB
SubcomponentC
SubcomponentD
1
Select File→New→Project. . . .
2
Select the type of project (e.g. Standard Make C project).
3
Name your project (e.g. “Project ComponentA”).
4
Check Use default location, because we want the IDE to create
a project in your workspace for this and all the other
components that comprise your EntireSourceProjectA. In the
next step, we’ll be linking each project to the actual location of
the directories in your source tree.
5
Click Finish, and you’ll see Project ComponentA in the C/C++
Projects view.
Step 3
Next we’ll link each individual project in the IDE to its corresponding
directory in the source tree:
July 30, 2004
1
Select File→New→Folder.
2
Make sure your new project (Project ComponentA) is selected
as the parent folder.
3
Name the folder (e.g. “ComponentA”).
4
Click the Advanced>> button.
5
Check Link to folder in the file system.
6
Enter the path to that folder in your source tree (or use
Browse. . . ).
Chapter 4 Managing Source Code
73
Importing existing source code into the IDE
7
 2004, QNX Software Systems Ltd.
Click Finish. Your Project ComponentA project should now
show a folder called ComponentA, the contents of which
actually reside in your source tree:
Link
Step 4
Now we’ll need to tell the IDE to build Project ComponentA in the
ComponentA linked folder that you just created in your workspace:
1
In the C/C++ Projects view, right-click
Project ComponentA, then select Properties from the
context menu.
2
Select C/C++ Make Project.
3
In the Make Builder tab, set the Build Directory to
ComponentA in your workspace.
Now when you go to build Project ComponentA, the IDE will
build it in the ComponentA folder in your workspace (even though
the source actually resides in a folder outside your workspace).
74
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
!
Using container projects
CAUTION: The linked resources facility lets you overlap files in
your workspace, so files from one project can appear in another
project. But keep in mind that if you change a file or other resource in
one place, the duplicate resource will also be affected. If you delete a
duplicate resource, its original will also be deleted!
Special rules apply when working with linked resources. Since a
linked resource must reside directly below a project, you can’t copy or
move a linked resource into other folders. If you delete a linked
resource from your project, this will not cause the corresponding
resource in the filesystem to also be deleted. But if you delete child
resources of linked folders, this will delete those child resources from
the filesystem!
Using container projects
A container is a project that creates a logical grouping of subprojects.
Containers can ease the building of large multiproject systems. You
can have containers practically anywhere you want on the filesystem,
with one exception: containers can’t appear in the parent folders of
other projects (because this would create a projects-in-projects
problem).
Containers let you specify just about any number of build
configurations (which are analogous to build variants in C/C++
projects). Each build configuration contains a list of subprojects and
specifies which variant to be built for each of those projects. Note that
each build configuration may contain a different list and mix of
subprojects (e.g. QNX C/C++ projects, standard make projects, or
other container projects.)
Creating a container project
☞ In order to create a container, you must have at least one subproject
that you want to contain.
To create a container project:
July 30, 2004
Chapter 4 Managing Source Code
75
Using container projects
76
 2004, QNX Software Systems Ltd.
1
Select File→New→Other. . . , then QNX→C/C++ Container
Project:
2
Name the container.
3
Click Next.
4
Click Add Project. . . .
5
Now select all the projects (which could be other containers)
that you want included in this container:
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Using container projects
Each subproject has a make-targets entry under the Target field.
The “Default” entry means don’t pass any targets to the make
command. QNX C/C++ projects will interpret this as “build”.
If a subproject is also a container project, this field represents
build configuration for that container.
6
☞
July 30, 2004
Select the build variant for each project you wish to build. You
can choose All (for every variant) or All Enabled (for just the
variants you’ve selected). Note that the concept of variants
makes sense only for QNX C/C++ projects.
The Stop on error column controls whether the build process for the
container will stop at the first subproject to have an error or will
continue to build all the remaining subprojects.
Chapter 4 Managing Source Code
77
Using container projects
7
 2004, QNX Software Systems Ltd.
If you want to reduce clutter in the C/C++ Projects view, then
create a working set for your container. The working set will
contain all the projects initially added to the container.
To select a working set, click the down-arrow at the top of the
C/C++ Projects view pane and select the working set you want.
Note that the working set created when the container was
created will have the same name as the container.
☞
If you add or remove elements to a container project later, the
working set is not updated automatically.
8
Click Finish. The IDE creates your container project.
Setting up a build configuration
Just as QNX C/C++ projects have build variants, container projects
have build configurations. Each configuration can be entirely distinct
from other configurations in the same container. For example, you
could have two separate configurations, say “Development” and
“Released,”, in your top-level container. The “Development”
configuration would build the “Development” configuration of any
subcontainers, as well as the appropriate build variant for any
subprojects. The “Released” configuration would be identical, except
that it would build the “Released” variants of subprojects.
☞
Note that the default configuration is the first configuration that was
created when the container project was created.
To create a build configuration for a container:
78
1
In the C/C++ Projects view, right-click the container.
2
Select Create Container Configuration. . . .
3
In the Container Build Configuration dialog, name the
configuration.
Chapter 4 Managing Source Code
July 30, 2004
Using container projects
 2004, QNX Software Systems Ltd.
☞
4
Click Add Project, then select all the projects to be included in
this configuration.
5
Change the Variant and Stop on error entries for each
included project as appropriate.
If you want to change the build order, use the Shift Up or Shift Down
buttons.
6
Click OK.
Editing existing configurations
There are two ways to change existing configurations for a container
project, both of which appear in the right-click menu:
Properties
Build Container Configuration
☞
Although you can use either method to edit a configuration, you
might find the Properties facility easier because it shows you a
tree-view of your entire container project.
Note also that you can edit only those configurations that are
immediate children of the root container.
Editing via project Properties
You can use the container project’s Properties facility to:
add new configurations
add projects to existing configurations
specify which variant of a subproject should be built.
To edit a configuration:
1
July 30, 2004
Right-click the container project and select Properties.
Chapter 4 Managing Source Code
79
Using container projects
☞
 2004, QNX Software Systems Ltd.
2
In the left pane, select Container Build Configurations.
3
Expand the project in the tree-view on the right.
4
Select the configuration you want to edit. Configurations are
listed as children of the container.
5
Click the Edit button at the right of the dialog. This opens the
familiar Container Build Configuration dialog (from the New
Container wizard), which you used when you created the
container.
6
Make any necessary changes — add, delete, reorder projects, or
change which make target or variant you want built for any
given project.
While editing a configuration, you can include or exclude a
component from the build just by checking or unchecking the
component. Note that if you exclude a component from being built,
it’s not removed from your container.
7
Click OK, then click OK again (to close the Properties dialog).
Editing via the Build Container Configuration. . . item
You can access the Container Build Configuration dialog from the
container project’s right-click menu:
80
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
July 30, 2004
Using container projects
Chapter 4 Managing Source Code
81
Using container projects
 2004, QNX Software Systems Ltd.
Note that this method doesn’t show you a tree-view of your container.
To edit the configuration:
1
Right-click the container project, then select Build Container
Configuration. . . .
2
Select the configuration you want to edit from the list.
3
Click the Edit button. This opens the familiar Container Build
Configuration dialog (from the New Container wizard), which
you used when you created the container.
4
Make any necessary changes — add, delete, reorder projects, or
change which make target or variant you want built for any
given project.
5
Click OK, then click OK again (to save your changes and close
the dialog).
Building a container project
Once you’ve finished setting up your container project and its
configurations, it’s very simple to build your container:
82
1
In the C/C++ Projects view, right-click your container project.
2
Select Build Container Configuration. . . .
3
Choose the appropriate configuration from the dialog.
4
Click Build.
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Importing a BSP or other QNX source packages
A project’s build variant selected in the container configuration will
be built, regardless of whether the variant is selected in the C/C++
project’s properties. In other words, the container project overrides
the individual project’s build-variant setting during the build.
The one exception to this is the All Enabled variant in the container
configuration. If the container configuration is set to build all enabled
variants of a project, then only those variants that you’ve selected in
the project’s build-variant properties will be built.
To build the default container configuration, you can also use the
Build item in the right-click menu.
Importing a BSP or other QNX source
packages
QNX BSPs and other source packages (e.g. DDKs) are distributed as
.zip archives. The IDE lets you import both kinds of packages into
the IDE:
When you import:
The IDE creates:
QNX BSP source package
A System Builder project.
QNX C/C++ source package
A C or C++ application or library
project.
Step 1: Use File→Import. . .
You import a QNX source archive using the standard Eclipse import
dialog:
July 30, 2004
Chapter 4 Managing Source Code
83
Importing a BSP or other QNX source packages
☞
 2004, QNX Software Systems Ltd.
If you’re importing a BSP, select QNX Board Support Package. If
you’re importing a DDK, select QNX Source Package.
As you can see, you can choose to import either a QNX BSP or a
“source package.” Although a BSP is, in fact, a package that contains
source code, the two types are structured differently and will generate
different types of projects. If you try to import a BSP archive as a
QNX Source Package, the IDE won’t create a System Builder project.
84
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Importing a BSP or other QNX source packages
Step 2: Select the package
After you choose the type of package you’re importing, the wizard
then presents you with a list of the packages found in
$QNX TARGET/usr/src/archives on your host:
Notice that as you highlight a package in the list, a description for that
package is displayed.
To add more packages to the list:
1
July 30, 2004
Click the Select Package. . . button.
Chapter 4 Managing Source Code
85
Importing a BSP or other QNX source packages
2
 2004, QNX Software Systems Ltd.
Select the .zip source archive you want to add.
Step 3: Select the source projects
Each source package contains several components (or projects, in IDE
terms). For the package you selected, the wizard then gives you a list
of each source project contained in the archive:
You can decide to import only certain parts of the source package —
simply uncheck the entries you don’t want (they’re all selected by
86
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Importing a BSP or other QNX source packages
default). Again, as you highlight a component, you’ll see its
description in the bottom pane.
Step 4: Select a working set
The last page of the import wizard lets you name your source
projects. You can specify:
Working Set Name — to group all related imported projects
together as a set
Project Name Prefix — for BSPs, this becomes the name of the
System Builder project; for other source projects, this prefix allows
the same source to be imported several times without any conflicts.
July 30, 2004
Chapter 4 Managing Source Code
87
Importing a BSP or other QNX source packages
☞
 2004, QNX Software Systems Ltd.
If you plan to import a source BSP and a binary BSP into the IDE,
remember to give each project a different name.
Step 5: Build
When you finish with the wizard, it creates all the projects and brings
in the sources from the archive. It will then ask if you want to build
all the projects you’ve just imported.
88
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Importing a BSP or other QNX source packages
If you answer Yes, the IDE will begin the build process, which may
take several minutes (depending on how much source you’ve
imported).
If you decide not to build now, you can always do a Rebuild All from
the main toolbar’s Project menu at a later time.
If you didn’t import all the components from a BSP package, you can
bring in the rest of them by selecting the System Builder project and
opening the import wizard (right-click the project, then select
Import. . . ). The IDE detects your selection and then extends the
existing BSP (rather than making a new one).
QNX BSP Perspective
When you import a QNX Board Support Package, the IDE opens the
QNX BSP Perspective. This perspective combines the minimum
elements from both the C/C++ Development Perspective and the
System Builder Perspective:
July 30, 2004
Chapter 4 Managing Source Code
89
Exporting projects
 2004, QNX Software Systems Ltd.
Exporting projects
You can export projects to your filesystem or to .zip files:
drag a file or folder from a project to your filesystem
☞
press Alt while dragging to copy the file or folder instead of moving it
out of the project.
use the Copy (to copy) or Cut (to move) context menu items, then
Paste the file into your filesystem
export to the filesystem using the Export. . . command
export to a .zip file using the Export. . . command.
Using the Export. . . command
The Export wizard helps you export entire projects to your filesystem
or a .zip file.
To export one or more projects:
1
Choose File→Export. . . (or Export. . . from the Navigator
context menu).
The Export wizard appears.
90
Chapter 4 Managing Source Code
July 30, 2004
Exporting projects
 2004, QNX Software Systems Ltd.
2
To export your project to the filesystem, choose File system. To
export your project to a .zip file, choose Zip file. Click Next.
The Export wizard’s next panel appears.
July 30, 2004
Chapter 4 Managing Source Code
91
Exporting projects
3
 2004, QNX Software Systems Ltd.
Select the projects you want to export. You can also select or
deselect specific files in each project.
To select files based on their extensions, click the Select
Types. . . button. The Select Types dialog box appears.
92
Chapter 4 Managing Source Code
July 30, 2004
 2004, QNX Software Systems Ltd.
Exporting projects
Click one or more extensions, then click OK to filter the
selected files in the Export wizard.
4
July 30, 2004
When you’re done selecting projects and files, click Finish.
Chapter 4 Managing Source Code
93
Exporting projects
☞
94
 2004, QNX Software Systems Ltd.
If you export more than one project, and someone imports from the
resulting filesystem or .zip file, they’ll get one project containing all
of the projects you exported.
Chapter 4 Managing Source Code
July 30, 2004
Chapter 5
Debugging Programs
In this chapter. . .
Introduction
97
Debugging your program
98
Controlling your debug session 101
More debugging features 108
July 30, 2004
Chapter 5 Debugging Programs
95
Introduction
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter shows you how to work with the debugger.
Introduction
One of the most frequently used tools in the traditional
design-develop-debug cycle is the source-level debugger. In the IDE,
this powerful tool provides an intuitive debugging environment that’s
completely integrated with the other workbench tools, giving you the
flexibility you need to best address the problems at hand.
Have you ever had to debug several programs simultaneously? Did
you have to use separate tools when the programs were written in
different languages or for different processors? The IDE’s source
debugger provides a unified environment for multiprocess and
multithreaded debugging of programs written in C, C++, Embedded
C++, or Java. You can debug such programs concurrently on one or
multiple remote target systems, or locally if you’re doing Neutrino
self-hosted development.
In order to use the full power of the Debug perspective, you must use
executables compiled for debugging. These executables contain
additional debug information that lets the debugger make direct
associations between the source code and the binaries generated from
July 30, 2004
Chapter 5 Debugging Programs
97
Debugging your program
 2004, QNX Software Systems Ltd.
that original source. An executable compiled for debugging has “ g”
appended to its filename.
The IDE debugger uses GDB as the underlying debug engine. It
translates each GUI action into a sequence of GDB commands, then
processes the output from GDB to display the current state of the
program being debugged.
The IDE updates the views in the Debug perspective only when the
program is suspended.
☞
Editing your source after compiling causes the line numbering to be
out of step because the debug information is tied directly to the
source. Similarly, debugging an optimized binary can also cause
unexpected jumps in the execution trace.
Debugging your program
Building an executable for debugging
Although you can debug a regular executable, you’ll get far more
control by building debug variants of the executables. When you
created your project, you may have already set the option to cause the
IDE to build an executable that’s ready for debugging. If so, you
should have executables with g appended to the filename. If not, you
must tell the IDE to build debug variants:
98
1
In the C/C++ Projects view (or the Navigator view), right-click
the project and select Properties.
2
In the left pane, select QNX C/C++ Project.
3
In the right pane, select the Options tab.
4
Under Build Type, make sure Build debug version is enabled:
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
Debugging your program
5
Click Apply.
6
Click OK.
7
Rebuild your project (unless you’re using the IDE’s autobuild
feature).
For more information about setting project options, see the Common
Wizards Reference chapter.
July 30, 2004
Chapter 5 Debugging Programs
99
Debugging your program
 2004, QNX Software Systems Ltd.
Starting your debugging session
☞ For a full description of starting your programs and the launch
configuration options, see the Launch Configurations Reference
chapter.
After building a debug-enabled executable, your next step is to create
a launch configuration for that executable so you can run and debug it:
1
From the main menu, select Run→Debug. . . . The launch
configurations dialog appears.
2
Create a launch configuration as you normally would, but don’t
click OK.
3
Select the Debugger tab.
4
Make sure both of the following are set:
Run program in debugger
Stop at main() on startup.
☞
5
Click Apply.
6
Click Debug.
By default, the IDE automatically changes to the Debug perspective
when you debug a program. If the default is no longer set, or if you
wish to change to a different perspective when you debug, see the
“Setting execution options” section in the Launch Configurations
Reference chapter.
If launching a debugging session doesn’t work when connected to the
target with qconn, make sure pdebug is on the target in /usr/bin.
100
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
Controlling your debug session
Controlling your debug session
☞
The contents of all views in the Debug perspective are driven by the
selections you make in the Debug view.
The Debug view lets you manage the debugging or running of a
program in the workbench. This view displays the stack frame for the
suspended threads for each target you’re debugging. Each thread in
your program appears as a node in the tree. The view displays the
process for each program you’re running.
The Debug view shows the target information in a tree hierarchy as
follows (shown here with a sample of the possible icons):
Session item
Description
Launch instance
Launch configuration
name and type (e.g.
Possible icons
Stack Builder
[C/C++ QNX QConn
(IP)])
Debugger instance
Debugger name and state
(e.g. QNX GDB
Debugger
(Breakpoint hit))
continued. . .
July 30, 2004
Chapter 5 Debugging Programs
101
Controlling your debug session
☞
 2004, QNX Software Systems Ltd.
Session item
Description
Thread instance
Thread number and state
(e.g. Thread[1]
(Suspended))
Stack frame instance
Stack frame number,
function, filename, and
line number
Possible icons
The number beside the thread label is a reference counter for the IDE,
not a thread ID (TID) number.
The IDE displays stack frames as child elements, and gives the reason
for the suspension (e.g. end of stepping range, breakpoint hit, signal
received, and so on). When a program exits, the IDE displays the exit
code.
The label includes the thread’s state. In the example above, the thread
was suspended because the program hit a breakpoint. You can’t
suspend only one thread in a process; suspension affects all threads.
The Debug view also drives the C/C++ Editor; as you step through
your program, the C/C++ Editor highlights the location of the
execution pointer.
Using the controls
After you start the debugger, it stops (by default) in main() and waits
for your input. (For information about changing this setting, see the
“Debugger tab” section in the Launch Configurations Reference
chapter.)
The debugging controls appear in the following places (but not all
together in any one place):
at the top of the Debug view as buttons
in the Debug view’s right-click context menu
102
Chapter 5 Debugging Programs
July 30, 2004
Controlling your debug session
 2004, QNX Software Systems Ltd.
in the main menu under Run (with hotkeys)
in the C/C++ Editor.
The controls are superseded by breakpoints. For example, if you ask
the program to step over a function (i.e. run until it finishes that
function) and the program hits a breakpoint, the program pauses on
that breakpoint, even though it hasn’t finished the function.
The icons and menu items are context-sensitive. For example, you can
use the Terminate action to kill a process, but not a stack frame.
Action
Resume
Icon
Hotkey
Description
F8
Run the process
freely from current
point
Suspend
Regain control of the
running process
Terminate
Kill the process
Restart
Rerun the process
from the beginning
Resume without signal
Resume the
execution of a
process without
delivering a pending
signal
Step Into
F5
Step forward one
line, going into
function calls
Step Over
F6
Step forward one
line without going
into function calls
Run to return
F7
Finish this function
continued. . .
July 30, 2004
Chapter 5 Debugging Programs
103
Controlling your debug session
Action
 2004, QNX Software Systems Ltd.
Icon
Resume at line
Hotkey
Description
Resume the
execution of the
process at the
specified line. Using
this action to change
into a different
function may cause
unpredictable
results.
You can control your debug session in various ways:
from the Debug view
using hotkeys
from the C/C++ Editor
From the Debug view
You’ll probably use the Debug view primarily to control your
program flow.
To control your debug execution:
1
In the Debug view, select the thread you wish to control.
2
Click one of the stepping icons (e.g. Step Into) in the Debug
view’s toolbar. Repeat as desired.
3
Finish the debug session by choosing one of the debug launch
controls (e.g. Disconnect). For details, see the section “Debug
launch controls” in this chapter.
Using hotkeys
Even if you’re running your debug session without the Debug view
showing, you can use the hotkeys or (the Run menu) to step through
your program. You can enable the debug hotkeys in any perspective.
104
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Controlling your debug session
You can easily customize these keys (via
Window→Preferences→Workbench→Keys):
To enable the debug hotkeys:
1
Open the perspective you want to enable the hotkeys for (e.g.
QNX Application Profiler perspective).
2
From the menu, select Window→Customize Perspective.
3
In the left pane, select Other, then check Debug.
4
Click OK.
The hotkeys are enabled for that particular perspective. You can also
access the controls from the Run menu.
July 30, 2004
Chapter 5 Debugging Programs
105
Controlling your debug session
 2004, QNX Software Systems Ltd.
From the C/C++ Editor
You can control your debug session using the C/C++ Editor by having
the program run until it hits the line your cursor is sitting on (i.e. the
gdb until command). If the program never hits that line, the
program runs until it finishes.
You enable this option in any perspective. The option is enabled by
default in the Debug perspective.
To enable debug execution using the C/C++ Editor:
1
From the menu, select Window→Customize Perspective.
2
In the left pane, select Other, then check C/C++ Debug.
3
Click OK.
To use the C/C++ Editor to debug a program:
1
In the editor, select a file associated with the process being
debugged. li>Left-click to insert the cursor where you want to
interrupt the execution.
2
Right-click near the cursor and select Run To Line
Debug launch controls
In addition to controlling the individual stepping of your programs,
you can also control the debug session itself (e.g. terminate the
session, stop the program, and so on) using the debug launch controls
available in the Debug view (or in the view’s right-click menu).
As with the other debug controls, these are context-sensitive; some
are disabled depending on whether you’ve selected a thread, a
process, and so on, in the Debug view.
106
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
Controlling your debug session
Action
Icon
Description
Terminate
Kill the selected
process.
Terminate & Remove
Kill the selected
process and remove
it from the Debug
view.
Terminate All
Kill all active
processes in the
Debug view.
Disconnect
Detach the debugger
(i.e. gdb) from the
selected process
(useful for
debugging attached
processes).
Remove All Terminated Launches
Clear all the killed
processes from the
Debug view.
Relaunch
Restart the process.
Disassembly mode
You can also examine your program as it steps into functions that you
don’t have source code for, such as printf(). Normally, the debugger
steps over these functions, even when you click Step Into. When the
instruction pointer enters functions for which it doesn’t have the
source, the IDE shows the function in the Assembly Editor.
To step into assembly-language functions during debugging:
➤ In the Debug view, click the Disassembly Mode On/Off toggle
button ( ). As you Step Into assembler functions, the IDE
shows the execution trace in the Assembly Editor.
July 30, 2004
Chapter 5 Debugging Programs
107
More debugging features
 2004, QNX Software Systems Ltd.
More debugging features
Besides the Debug view, you’ll find several other useful views in the
Debug perspective:
To:
Use this view:
Inspect variables
Variables
Using breakpoints and watchpoints
Breakpoints
Evaluate expressions
Expressions
Inspect registers
Registers
Inspect a process’s memory
Memory
Inspect shared library usage
Shared Libraries
Monitor signal handling
Signals
View your output
Console
Debug with GDB
Console
Inspecting variables
The Variables view displays information about the variables in the
currently selected stack frame:
At the bottom of the view, the Detail pane displays the value of the
selected variable (as evaluated by gdb).
108
Chapter 5 Debugging Programs
July 30, 2004
More debugging features
 2004, QNX Software Systems Ltd.
☞
If you happen to have multiple variables of the same name, the one
most in scope is evaluated.
When the execution stops, the changed values are highlighted in red
(by default). Like the other debug-related views, the Variables view
doesn’t try to keep up with the execution of a running program; it
updates the display only when execution stops.
You can decide whether or not to display the variable type (e.g. int)
by clicking the Show Type Names toggle button (
).
You can also control whether or not the IDE tracks your program’s
variables. See the “Debugger tab” section in the Launch
Configurations Reference chapter.
Customizing the Variables view
You can customize the look of the Variables view and set the color of
changed variables (red by default).
To access the Variables view preferences:
July 30, 2004
1
From the main menu, select Window→Preferences.
2
In the left pane, select Debug→Variable Views:
Chapter 5 Debugging Programs
109
More debugging features
 2004, QNX Software Systems Ltd.
Changing variable values
While debugging a program, you may wish to manually change the
value of a variable to test how your program handles the setting or to
speed through a loop.
To change a variable value while debugging:
1
In the Variables view, right-click the variable and select
Change Variable Value.
2
Enter the new value in the field.
Controlling the display of variables
You can prevent the debugger from reading the value of variables
from the target. You might use this feature for variables that are either
very sensitive or specified as volatile.
110
Chapter 5 Debugging Programs
July 30, 2004
More debugging features
 2004, QNX Software Systems Ltd.
To enable or disable a variable:
➤ In the Variables view, right-click the variable and select either
Enable or Disable. (You can disable all the variables in your
launch configuration. See the “Debugger tab” section in the
Launch Configurations Reference chapter.)
To change a variable to a different type:
1
In the Variables view, right-click the variable.
2
Select one of the following:
Cast To Type
Casts the variable to the type you specify in
the field (e.g. int).
Restore Original Type
Cancels your Cast To Type command.
Format, followed by a type
Displays the variable in a different format
(e.g. hexadecimal).
Display As Array
Displays the variable as an array with a
length and start index that you specify. This
option is available only for pointers.
Using breakpoints and watchpoints
The Breakpoints view lists all the breakpoints and watchpoints you’ve
set in your open projects:
July 30, 2004
Chapter 5 Debugging Programs
111
More debugging features
 2004, QNX Software Systems Ltd.
A breakpoint makes your program stop whenever a certain point in
the program is reached. For each breakpoint, you can add conditions
to better control whether or not your program stops.
A watchpoint is a special breakpoint that stops the program’s
execution whenever the value of an expression changes, without
specifying where this may happen. Unlike breakpoints, which are
line-specific, watchpoints are event-specific and take effect whenever
a specified condition is true, regardless of when or where it occurred.
Object
Icon
Breakpoint
Watchpoint (read)
Watchpoint (write)
Watchpoint (read and write)
If the breakpoint or watchpoint is for a connected target, the IDE
places a check mark ( ) on the icon.
The rest of this section describes how to:
add breakpoints
add watchpoints
set properties of breakpoints and watchpoints
disable/enable breakpoints and watchpoints
Adding breakpoints
You set breakpoints on an executable line of a program. When you
debug the program, the execution suspends before that line of code
executes.
To add a breakpoint:
1
112
In the editor area, open the file that you want to add the
breakpoint to.
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More debugging features
2
Notice that the left edge of the C/C++ Editor has a blank space
called a marker bar.
3
Hover your pointer over the marker bar beside the exact line of
code where you want to add a breakpoint. Right-click the
marker bar and select Add Breakpoint:
A dot appears, indicating the breakpoint:
July 30, 2004
Chapter 5 Debugging Programs
113
More debugging features
 2004, QNX Software Systems Ltd.
A corresponding dot also appears in the Breakpoints view,
along with the name of the file in which you set the breakpoint:.
To add a breakpoint at the entry of a function:
➤ In either the Outline or C/C++ Projects view, right-click a
function and select Add/Remove Breakpoint.
To add a breakpoint at a specific address:
1
In the Debug view’s title bar, click the Disassembly Mode
On/Off button (
assembler.
2
☞
). The code in the C/C++ Editor appears as
You can now add a breakpoint as you normally would.
The debugger disables all address breakpoints when you relaunch
your debugger session. You can enable a breakpoint by right-clicking
it and selecting Enable Breakpoint.
Adding watchpoints
To add a watchpoint:
1
114
From the main menu, select Run→Add C/C++ Watchpoint.
(If this option isn’t available, select Window→Customize
Perspective. In the left pane, select Other, then check C/C++
Debug. Click OK.)
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More debugging features
2
Enter an expression in the field. The expression may be
anything that can be evaluated inside an if statement. (e.g.
y==1)
3
If you want the program to stop when it reads the watch
expression, check Read; to have the program stop when it
writes the expression, check Write.
4
Click OK. The watchpoint appears in the Breakpoints view list.
Setting properties of breakpoints and watchpoints
After you’ve set your breakpoint or watchpoint, the IDE
unconditionally halts the program when:
it reaches a line of code that the breakpoint is set on
or:
the expression specified by the watchpoint becomes true.
To set the properties for a breakpoint or watchpoint:
1
July 30, 2004
In the Breakpoints view, right-click the breakpoint or
watchpoint and select Properties. (For breakpoints only, in the
C/C++ Editor, right-click the breakpoint and select Breakpoint
Properties.) You need to fill in at least one field:
Chapter 5 Debugging Programs
115
More debugging features
 2004, QNX Software Systems Ltd.
2
In the Condition field, enter the Boolean expression to
evaluate. The expression may be anything that can be evaluated
inside an if statement (e.g. x > y ). The default is TRUE.
3
In the Ignore Count field, enter the number of times the
breakpoint or watchpoint may be hit before it begins to take
effect (not the number of times the condition is true). The
default is 0.
4
Click OK. When in debug mode, your program stops when it
meets the conditions you’ve set for the breakpoint or
watchpoint.
Disabling/enabling breakpoints and watchpoints
You may wish to temporarily deactivate a breakpoint or watchpoint
without losing the information it contains.
To disable or enable a breakpoint or watchpoint:
116
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More debugging features
➤ In the Breakpoints view, right-click the breakpoint or
watchpoint and select Disable or Enable (For breakpoints only,
right-click the breakpoint in the editor area and select Disable
Breakpoint or Enable Breakpoint):
To disable or enable multiple breakpoints or watchpoints:
1
In the Breakpoints view, use any of the following methods to
select the breakpoints:
Select breakpoints and watchpoints while holding down the
Ctrl key.
Select a range of breakpoints and watchpoints while holding
down the Shift key.
From the main menu, select Edit→Select All.
Right-click in the Breakpoints view and select Select All.
2
July 30, 2004
Right-click the highlighted breakpoints/watchpoints and select
Disable or Enable.
Chapter 5 Debugging Programs
117
More debugging features
☞
 2004, QNX Software Systems Ltd.
To remove one or more breakpoints/watchpoints:
➤ Select the breakpoint or watchpoint, right-click, then select
Remove or Remove All.
Evaluating your expressions
The Expressions view lets you evaluate and examine the value of
expressions:
☞
The behavior of the Detail pane and many of the options in the
right-click menu are the same as that of the Variables view. (See the
“Inspecting variables” section in this chapter.)
To evaluate an expression:
1
118
From the menu, select Run→Add Expression (C/C++). (Or
right-click in the C/C++ Editor and select Add Expression.)
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More debugging features
2
Enter the expression you want to evaluate (e.g. (x-5)*3 ).
3
Click OK. The expression and its value appear in the
Expressions view. When the debugger suspends the program’s
execution, it reevaluates all expressions and highlights the
changed values.
Inspecting your registers
The Registers view displays information about the registers in the
currently selected stack frame. When the execution stops, the changed
values are highlighted.
☞
July 30, 2004
The functionality of the Registers view is very similar to that of the
Variables view; for more information, see the “Inspecting variables”
section in this chapter.
Chapter 5 Debugging Programs
119
More debugging features
 2004, QNX Software Systems Ltd.
You can also customize the colors in the Registers view and change
the default value of the Show Type Names option.
To access the Registers view customization dialog:
1
From the main menu, select Window→Preferences.
2
In the left pane, select Debug→Registers View.
Inspecting a process’s memory
The Memory view lets you inspect and change your process’s
memory. The view consists of four tabs that let you inspect multiple
sections of memory:
120
Chapter 5 Debugging Programs
July 30, 2004
More debugging features
 2004, QNX Software Systems Ltd.
☞
QNX Neutrino uses a virtual-addressing model wherein each process
has its own range of valid virtual addresses. This means that the
address you enter into the Memory view must be a virtual address
that’s valid for the process you’re debugging (e.g. the address of any
variable). For more on QNX Neutrino’s memory management, see the
Process Manager chapter in the System Architecture guide.
Inspecting memory
The Memory view supports the same addressing as the C language.
You can address memory using expressions such as 0x0847d3c,
(&y)+1024, and *ptr.
To inspect the memory of a process:
1
In the Debug view, select a process. Selecting a thread
automatically selects its associated process.
2
In the Memory view, select one of the four tabs (labeled
Memory 1, Memory 2, etc.).
3
In the Address field, type the address, then press Enter.
Changing memory
!
CAUTION: Changing a process’s memory can make your program
crash.
To change the memory of a process:
July 30, 2004
1
Follow the procedure for inspecting a process’s memory.
2
In the memory pane, type the new value for the memory. The
Memory view works in “typeover” mode; use the arrow keys to
jump from byte to byte:
Chapter 5 Debugging Programs
121
More debugging features
 2004, QNX Software Systems Ltd.
The changed memory appears in red.
Configuring output format
You can configure your output to display hexadecimal or decimal.
You can also set the number of display columns and the memory unit
size. You can configure each memory tab independently.
To configure the output format:
122
1
In the Memory view, select one of the four tabs labeled
Memory 1, Memory 2, and so on.
2
Right-click the pane and select the item you want to configure
(Format, Memory Unit Size, or Number of Columns).
3
Choose your desired format; the output reflects your selection:
Chapter 5 Debugging Programs
July 30, 2004
 2004, QNX Software Systems Ltd.
More debugging features
Note that some output formats look best in a nonproportional
font such as Courier.
Customizing the Memory view
You can customize the Memory view’s colors and fonts. You can also
customize some of its behavior.
To access the view’s customization dialog:
1
From the menu, select Window→Preferences.
2
In the left pane, select Debug→Memory View.
3
You can now change the colors, font, and behavior of the
Memory view. When you’re done, click Apply, then OK.
Inspecting shared-library usage
The Shared Libraries view shows you information about the shared
libraries for the session you select in the Debug view. The view shows
the name, start address, and end address of each library.
To load a library’s symbols:
➤ Right-click a library and select Load Symbols (or Load
Symbols for All for all your libraries).
To control how the IDE polls for new libraries, do one of the
following:
July 30, 2004
Chapter 5 Debugging Programs
123
More debugging features
 2004, QNX Software Systems Ltd.
Manually refresh the display using the Refresh button.
To refresh the display every time your program is suspended, click
the Auto-Refresh button.
To auto-refresh by default:
1
From the main menu, select Window→Preferences.
2
In the left pane of the Preferences dialog, select
Debug→Shared-Libraries View.
3
In the right pane, enable Auto-refresh by default.
Monitoring signal handling
The Signals view provides a summary of how your debugger handles
signals that are intercepted before they’re received by your program.
The view contains the following fields:
Name
The name of the signal
Pass
The debugger can filter out signals. If the signal is set to
“no”, the debugger prevents it from reaching your
program.
Suspend
Upon receipt of a signal, the debugger can suspend your
program as if it reached a breakpoint. Thus, you can step
through your code and watch how your program handles
the signal.
To change how the debugger handles a signal:
124
Chapter 5 Debugging Programs
July 30, 2004
More debugging features
 2004, QNX Software Systems Ltd.
1
In the Signals view, select a signal (e.g. SIGINT) in the Name
column.
2
Click the signal’s setting in either the Pass or Suspend column
and select the new setting from the dropdown list.
To send a signal to a suspended program:
☞
1
In the Debug view, select a program.
2
If the program isn’t suspended, click the Suspend button (
3
In the Signals view, right-click your desired signal and select
Resume With Signal. Your program resumes and the debugger
immediately sends the signal.
).
You can see a thread-by-thread summary of how your program
handles signals using the Signal Information view. To learn more, see
the “Mapping process signals” section in the Getting System
Information chapter.
Viewing your output
The Console view shows you the output of the execution of your
program and lets you supply input to your program:
The console shows three different kinds of text, each in a different
default color:
standard output (blue)
July 30, 2004
Chapter 5 Debugging Programs
125
More debugging features
 2004, QNX Software Systems Ltd.
standard error (red)
standard input (green)
You can choose different colors for these kinds of text on the
preferences pages.
To access the Console view customization dialog:
1
From the menu, select Window→Preferences.
2
In the left pane, select Debug→Console.
Debugging with GDB
The IDE lets you use a subset of the commands that the gdb utility
offers:
To learn more about the gdb utility, see its entry in the Utilities
Reference
Enabling the QNX GDB Console view
The QNX GDB Console view is part of the regular Console view but
isn’t accessible until you toggle to it. Once you do, GDB output
appears in place of the regular Console view output.
To enable the QNX GDB Console view:
126
1
In the Debug view, select a debug session.
2
Click the Show Debugger Console on Target Selection button
( ). The Console view changes to the QNX GDB Console
view.
Chapter 5 Debugging Programs
July 30, 2004
More debugging features
 2004, QNX Software Systems Ltd.
Using the QNX GDB Console view
The QNX GDB Console view lets you bypass the IDE and talk
directly to GDB; the IDE is unaware of anything done in the QNX
GDB Console view. Items such as breakpoints that you set from the
QNX GDB Console view don’t appear in the C/C++ Editor.
☞
You can’t use the Tab key for line completion because the commands
are sent to GDB only when you press Enter.
To use the QNX GDB Console view:
➤ In the QNX GDB Console view, enter a command (e.g. nexti
to step one instruction):
July 30, 2004
Chapter 5 Debugging Programs
127
Chapter 6
Building OS and Flash Images
In this chapter. . .
Introducing the QNX System Builder 131
Overview of images 137
Creating a project for an OS image 147
Creating a project for a flash filesystem image 147
Building an OS image 148
Downloading an image to your target 149
Configuring your Builder projects 154
Optimizing your system 168
Moving files between the host and target 171
July 30, 2004
Chapter 6 Building OS and Flash Images
129
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Introducing the QNX System Builder
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
Use the System Builder to create OS and flash images for your target.
Introducing the QNX System Builder
One of the more distinctive tools within the IDE is the QNX System
Builder, which simplifies the job of building OS images for your
embedded systems. Besides generating images intended for your
target board’s RAM or flash, the QNX System Builder can also help
reduce the size of your images (e.g. by reducing the size of shared
libraries). The Builder also takes care of tracking library
dependencies for you, prompting you for any missing components.
The Builder contains a Serial Terminal for interacting with your
board’s ROM monitor or QNX Initial Program Loader (IPL) and for
transferring images (using the QNX sendnto protocol). The Builder
also has an integrated TFTP Server that lets you transfer your images
to network-aware targets that can boot via the TFTP protocol.
When you open the Builder to create a project, you have the choice of
importing/customizing an existing buildfile to generate an image or of
creating one from scratch. The Builder’s editor lets you select which
components (binaries, DLLs, libs) you want to incorporate into your
system image. As you add a component, the Builder automatically
adds any shared libraries required for runtime loading. For example,
July 30, 2004
Chapter 6 Building OS and Flash Images
131
Introducing the QNX System Builder
 2004, QNX Software Systems Ltd.
if you add the telnet application to a project, then the Builder
knows to add libsocket.so in order to ensure that telnet can run.
And when you select a binary, a you’ll see relevant information for
that item, including its usage message, in the Binary Inspector view.
Using standard QNX embedding utilities (mkifs, mkefs), the
Builder can generate configuration files for these tools that can be
used outside of the IDE for scripted/automated system building. As
you do a build, a Console view displays the output from the
underlying build command. The mksbp utility can be used to build a
System Builder project.bld from the command-line. mksbp
automatically calls mkifs or mkefs depending on the kind of image
being built.
Here’s what the QNX System Builder perspective looks like:
One of the main areas in the Builder is the editor, which presents two
panes side by side:
132
Chapter 6 Building OS and Flash Images
July 30, 2004
Introducing the QNX System Builder
 2004, QNX Software Systems Ltd.
Images
Shows all the images you’re building. You can add or
remove binaries and other components, view their
properties, etc.
Filesystem
Shows the components of your image arranged in a
hierarchy, as they would appear in a filesystem on
your target.
Toolbar buttons
Above the Images and Filesystem panes in the editor you’ll find
several buttons for working with your image:
Add a new binary.
Add a new shared library.
Add a new DLL.
Add a new symbolic link.
Add a new file.
Add a new directory.
Add an EFS (embedded filesystem) image.
July 30, 2004
Chapter 6 Building OS and Flash Images
133
Introducing the QNX System Builder
 2004, QNX Software Systems Ltd.
Run the System Optimizer.
Rebuild the current project.
Binary Inspector
Below the Images and Filesystem panes is the QNX Binary
Inspector view, which shows the usage message for any binary you
select:
The Binary Inspector also has a Use Info tab that gives the selected
binary’s name, a brief description, the date it was built, and so on.
134
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Introducing the QNX System Builder
Boot script files
All QNX BSPs ship with a buildfile, which is a type of “control” file
that gives instructions to the mkifs command-line utility to generate
an OS image. The buildfile specifies the particular startup program,
environment variables, drivers, etc. to use for creating the image. The
boot script portion of a buildfile contains the sequence of commands
that the Process Manager will execute when your completed image
starts up on the target.
☞
For details on the components and grammar of buildfiles, see the
section “Configuring an OS image” in the chapter Making an OS
Image in Building Embedded Systems as well as the entry for mkifs
in the Utilities Reference.
The QNX System Builder provides a convenient graphical alternative
to the text-based buildfile method. While it hides most of the
“gruesome” details from you, the Builder also lets you see and work
with things like boot scripts.
The Builder stores the boot script for your project in a .bsh file:
If you double-click a .bsh file in the Navigator or System Builder
Projects view, you’ll see its contents in the editor.
July 30, 2004
Chapter 6 Building OS and Flash Images
135
Introducing the QNX System Builder
 2004, QNX Software Systems Ltd.
Builder projects
Like other tools within the IDE, the System Builder is
project-oriented — it organizes your resources into a project of
related items. Whenever you create a project in the Builder, you’ll see
a project.bld file in the Navigator or System Builder Projects
view:
The project.bld file drives the Builder’s editor area — if you
select the project.bld, you’ll see your project’s components in the
Images and Filesystem panes, where you can add/remove items for
the image you’ll be building.
☞
As with most other tools in the IDE, you build your QNX System
Builder projects using the standard Eclipse build mechanism via
Project→Rebuild Project.
The scope of the Builder
You can use the QNX System Builder throughout your
product-development cycle:
At the outset — to import a QNX BSP, generate a minimal OS
image, and transfer the image to your board, just to make sure
everything works.
During development — to create an image along with your suite of
programs and download everything to your eval board.
136
Chapter 6 Building OS and Flash Images
July 30, 2004
Overview of images
 2004, QNX Software Systems Ltd.
For your final product — to strip out the extra utilities you needed
during development, reduce libraries to their bare minimum size,
and produce your final, customized, optimized embedded system.
☞
For details on importing a BSP, see the section “Importing a BSP or
other QNX source packages” in the chapter Managing Source Code in
this guide.
Overview of images
Before you use the QNX System Builder to create OS and flash
images for your hardware, let’s briefly describe the concepts involved
in building images so you can better understand the Builder in
context.
This section covers the following topics:
The components of an image, in order of booting
Types of images you can create
Project layout
Overview of workflow
The components of an image, in order of booting
Neutrino supports a wide variety of CPUs and hardware
configurations. Some boards require more effort than others to embed
the OS. For example, x86-based machines usually have a BIOS,
which greatly simplifies your job, while other platforms require that
you create a complete IPL. Embedded systems can range from a tiny
memory-constrained handheld computer that boots from flash to an
industrial robot that boots through a network to an SMP system with
lots of memory that boots from a hard disk.
Whatever your particular platform or configuration, the System
Builder helps simplify the process of building images and transferring
them from your host to your target.
July 30, 2004
Chapter 6 Building OS and Flash Images
137
Overview of images
☞
 2004, QNX Software Systems Ltd.
For a complete description of OS and flash images, see the Building
Embedded Systems guide.
The goal of the boot process is to get the system into a state that lets
your program run. Initially, the system might not recognize disks,
memory, or other hardware, so each section of code needs to perform
whatever setup is needed in order to run the subsequent section:
1
The IPL initializes the hardware, makes the OS image
accessible, and then jumps into it.
2
The startup code performs further initializations, then loads and
transfers control to the microkernel/process manager
(procnto), the core runtime component of the QNX Neutrino
OS.
3
The procnto module then runs the boot script, which performs
any final setup required and runs your programs.
IPL (at
reset vector)
Startup
procnto
Boot script
Drivers
and your
program
Typical boot order.
At reset, a typical processor has only a minimal configuration that lets
code be executed from a known linearly addressable device (e.g.
flash, ROM). When your system first powers on, it automatically runs
the IPL code at a specific address called the reset vector.
IPL
When the IPL loads, the system memory usually isn’t fully accessible.
It’s up to the IPL to configure the memory controller, but the method
depends on the hardware — some boards need more initialization
than others.
138
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Overview of images
When the memory is accessible, the IPL scans the flash memory for
the image filesystem, which contains the startup code (described in
the next section). The IPL loads the startup header and startup code
into RAM, and then jumps to the startup code.
The IPL is usually board-specific (it contains some assembly code)
and as small as possible.
Startup
The startup code initializes the hardware by setting up interrupt
controllers, cache controllers, and base timers. The code detects
system resources such as the processor(s), and puts information about
these resources into a centrally accessible area called the system page.
The code can also copy and decompress the image filesystem
components, if necessary. Finally, the startup code passes control, in
virtual memory mode, to the procnto module.
The startup code is board-specific and is generally much larger than
the IPL. Although a larger procnto module could do the setup, we
separate the startup code so that procnto can be board-independent.
Once the startup code sets up the hardware, the system can reuse a
part of the memory used by startup because the code won’t be needed
again.
The procnto module
The procnto module is the core runtime component of the QNX
Neutrino OS. It consists of the microkernel, the process manager, and
some initialization code that sets up the microkernel and creates the
process-manager threads. The procnto module is a required
component of all bootable images.
The process manager handles (among other things) processes,
memory, and the image filesystem. The process manager lets other
processes see the image filesystem’s contents. Once the procnto
module is running, the operating system is essentially up and running.
One of the process manager’s threads runs the boot script.
Several variants of procnto are available (e.g. procnto-400 for
PowerPC 400 series, procnto-smp for x86 SMP machines, etc.).
July 30, 2004
Chapter 6 Building OS and Flash Images
139
Overview of images
 2004, QNX Software Systems Ltd.
Boot script
If you want your system to load any drivers or to run your program
automatically after power up, you should run those utilities and
programs from the boot script. For example, you might have the boot
script run a devf driver to access a flash filesystem image and then
run your program from that flash filesystem.
When you build your image, the boot script is converted from text to a
tokenized form and saved as /proc/boot/.script. The process
manager runs this tokenized script.
Types of images you can create
The IDE lets you create the following images:
OS image (.ifs file)
An image filesystem. A bootable image filesystem holds the
procnto module, your boot script, and possibly other
components such as drivers and shared objects.
Flash image (.efs file)
A flash filesystem. (The “e” stands for “embedded.”) You can
use your flash memory like a hard disk to store programs and
data.
Combined image
An image created by joining together any combination of
components (IPL, OS image, embedded filesystem image) into
a single image. You might want to combine an IPL with an OS
image, for example, and then download that single image to the
board’s memory via a ROM monitor, which you could use to
burn the image into flash. A combined image’s filename
extension indicates the file’s format (e.g. (.elf, .srec, etc.).
If you plan on debugging applications on the target, you must include
pdebug in /usr/bin. If the target has no other forms of storage,
include it in the OS image or Flash image.
140
Chapter 6 Building OS and Flash Images
July 30, 2004
Overview of images
 2004, QNX Software Systems Ltd.
BSP filename conventions
In our BSP docs, buildfiles, and scripts, we use a certain filename
convention that relies on a name’s prefixes and suffixes to distinguish
types:
Part of filename
Description
Example
.bin
Suffix for binary format file.
ifs-artesyn.bin
.build
Suffix for buildfile.
sandpoint.build
efs-
Prefix for QNX Embedded
Filesystem file; generated by
mkefs.
efs-sengine.srec
.elf
Suffix for ELF (Executable and
Linking Format) file.
ipl-ifs-mbx800.elf
ifs-
Prefix for QNX Image
Filesystem file; generated by
mkifs.
ifs-800fads.elf
ipl-
Prefix for IPL (Initial Program
Loader) file.
ipl-eagle.srec
.openbios
Suffix for OpenBIOS format
file.
ifs-walnut.openbios
.prepboot
Suffix for Motorola PRePboot
format file.
ifs-prpmc800.prepboot
.srec
Suffix for S-record format file.
ifs-malta.srec
July 30, 2004
Chapter 6 Building OS and Flash Images
141
Overview of images
☞
 2004, QNX Software Systems Ltd.
The System Builder uses a somewhat simplified convention. Only a
file’s three-letter extension, not its prefix or any other part of the
name, determines how the Builder should handle the file.
For example, an OS image file is always a .ifs file in the Builder,
regardless of its format (ELF, binary, SREC, etc.). To determine a
file’s format in the IDE, you’ll need to view the file in an editor.
OS image (.ifs file)
The OS image is a bootable image filesystem that contains the startup
header, startup code, procnto, your boot script, and any drivers
needed to minimally configure the operating system:
Startup header
Startup
procnto
Boot script
Image
filesystem
devf-*
Generally, we recommend that you keep your OS image as small as
possible to realize the following benefits:
Memory conservation — When the system boots, the entire OS
image gets loaded into RAM. This image isn’t unloaded from
RAM, so extra programs and data built into the image require
more memory than if your system loaded and unloaded them
dynamically.
Faster boot time — Loading a large OS image into RAM can take
longer to boot the system, especially if the image must be loaded
via a network or serial connection.
Stability — Having a small OS image provides a more stable boot
process. The fewer components you have in your OS image, the
142
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Overview of images
lower the probability that it will fail to boot. The components that
must go in your image (startup, procnto, a flash driver or network
components, and a few shared objects) change rarely, so they’re
less subject to errors introduced during the development and
maintenance cycles.
If your embedded system has a hard drive or CompactFlash (which
behaves like an IDE hard drive), you can access the data on it by
including a block-oriented filesystem driver (e.g. devb-eide) in
your OS image filesystem and calling the driver from your boot script.
For details on the driver, see devb-eide in the Utilities Reference.
If your system has an onboard flash device, you can use it to store
your OS image and even boot the system directly from flash (if you’re
board allows this — check your hardware documentation). Note that
an OS image is read-only; if you want to use the flash for read/write
storage, you’ll need to create a flash filesystem image (.efs file).
Flash filesystem image (.efs file)
Flash filesystem images are useful for storing your programs, extra
data, and any other utilities (e.g. qconn, ls, dumper, and pidin)
that you want to access on your embedded system.
If your system has a flash filesystem image, you should include a
devf* driver in your OS image and start the driver in your boot
script. While you can mount an image filesystem only at /, you can
specify your own mountpoint (e.g. /myFlashStuff) when you set
up your .efs image in the IDE. The system recognizes both the .ifs
and .efs filesystems simultaneously because the process manager
transparently overlays them. To learn more about filesystems, see the
Filesystem chapter in the QNX Neutrino System Architecture guide.
Combined image
For convenience, the IDE can join together any combination of your
IPL, OS image, and .efs files into a single, larger image that you can
transfer to your target:
July 30, 2004
Chapter 6 Building OS and Flash Images
143
Overview of images
 2004, QNX Software Systems Ltd.
IPL
Alignment
(blocksize
of onboard
flash)
Final IPL size
Padding
IFS
Padding
EFS starts
a new block
EFS
When you create a combined image, you specify the IPL’s path and
filename on your host machine. You can either select a precompiled
IPL from among the many BSPs that come with QNX Momentics PE,
or compile your own IPL from your own assembler and C source.
☞
The Builder expects the source IPL to be in ELF format.
Padding separates the IPL, .ifs, and .efs files in the combined
image.
Padding after the IPL
The IPL can scan the entire combined image for the presence of the
startup header, but this slows the boot process. Instead, you can have
the IPL scan through a range of only two addresses and place the
startup header at the first address.
Specifying a final IPL size that’s larger than the actual IPL lets you
modify the IPL (and change its length) without having to modify the
scanning addresses with each change. This way, the starting address
of the OS image is independent of the IPL size.
☞
144
You must specify a padding size greater than the total size of the IPL
to prevent the rest of the data in the combined image file from
partially overwriting your IPL.
Chapter 6 Building OS and Flash Images
July 30, 2004
Overview of images
 2004, QNX Software Systems Ltd.
Padding before .ifs images
If your combined image includes one or more .efs images, specify
an alignment equal to the block size of your system’s onboard flash.
The optimized design of the flash filesystem driver requires that all
.efs images begin at a block boundary. When you build your
combined image, the IDE adds padding to align the beginning of the
.efs image(s) with the address of the next block boundary.
Project layout
A single System Builder project can contain your .ifs file and
multiple .efs files, as well as your startup code and boot script. You
can import the IPL from another location or you can store it inside the
project directory.
By default, your QNX System Builder project includes the following
parts:
Item
Description
Images directory
The images and generated files that the
IDE creates when you build your project.
Overrides directory
When you build your project, the IDE
first looks in this directory for any files.
You can use the Overrides directory to
easily test a change to your build.
Reductions directory
The IDE lets you reduce your image size
by eliminating unused libraries, and
shrinking the remaining libraries. The
IDE stores the reduced libraries in the
Reductions directory.
.project file
Information about the project, such as its
name and type. All IDE projects have a
.project file.
continued. . .
July 30, 2004
Chapter 6 Building OS and Flash Images
145
Overview of images
 2004, QNX Software Systems Ltd.
Item
Description
.sysbldr meta file
Information about the properties specific
to a QNX System Builder project. This
file describes where the IDE looks for
files (including the Overrides and
Reductions directories), the location of
your IPL file, how the IDE includes
.efs files, and the final format of your
.ifs file.
project.bld file
Information about the structure and
contents of your .ifs and .efs files.
This file also contains your boot script
file.
.bsh file
Contains the boot script for your project.
Overview of workflow
Here are the main steps involved in using the IDE to get Neutrino up
and running on your board:
Creating a QNX System Builder project for an OS or a flash image
for your board. The process is very simple if a BSP exists for your
board. If an exact match isn’t available, you may be able to modify
an existing BSP to meet your needs.
Building your project to create the image.
Transferring the OS image to your board. You might do this
initially to verify that the OS image runs on your hardware, and
then again (and again) as you optimize your system.
Configuring your projects.
Optimizing your system by reducing the size of the libraries.
146
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Creating a project for an OS image
Creating a project for an OS image
To create a new QNX System Builder Project:
☞
1
From the main menu, select File→New→Project.
2
Select QNX in the left column, then QNX System Builder
Project in the right. Click Next.
3
Name your project and click Next.
4
At this point, you need to specify your target hardware. You
can either import an existing buildfile (as shipped with your
QNX BSPs) or select a generic type (e.g. “Generic PPCBE”).
We recommend that you select Import Existing Buildfile, rather than
a generic option. Creating a buildfile requires a working knowledge of
boot script grammar (as described in the entry for mkifs in the
Utility Reference and in the Building Embedded Systems manual).
5
If you chose a generic type, jump to the last step. If you chose
to import an existing buildfile, continue with the next step.
6
Click Next, then Browse to locate an appropriate buildfile.
Refer to your BSP docs for the proper .build file for your
board. You can find buildfiles for all the BSPs installed on your
system in
C:\QNX630\target\qnx6\processor\boot\build\ on your
Windows host. (For Neutrino, Linux, or Solaris hosts, see the
appendix Where Files Are Stored in this guide.)
7
Click Finish. The IDE creates your new project, which
includes all the components that make up the OS image.
Creating a project for a flash filesystem
image
To create a flash filesystem project:
1
July 30, 2004
From the main menu, select File→New→Project.
Chapter 6 Building OS and Flash Images
147
Building an OS image
 2004, QNX Software Systems Ltd.
2
Select QNX in the left column, then QNX System Builder
EFS Project in the right. Click Next.
3
Name your project and click Next.
4
Specify your target hardware (e.g. “Generic ARMLE”).
5
Click Finish. The IDE creates your new EFS project, which
includes a “generic” .efs image – you’ll likely need to specify
the block size, image size, and other properties to suit the flash
on your particular board.
Building an OS image
You build your QNX System Builder projects using the standard
Eclipse build mechanism:
➤ From the main menu, select Project→Build|Rebuild Project.
Depending on whether the auto-build feature is set (open
Window→Preferences→Workbench), you can also build projects
using the context menu:
1
In the Navigator or System Builder Projects view, right-click
the project.
2
Select build.
The System Builder Console view shows the output produced when
you build your images:
Output can come from any of these utilities:
148
Chapter 6 Building OS and Flash Images
July 30, 2004
Downloading an image to your target
 2004, QNX Software Systems Ltd.
mkefs
mkifs
mkimage
mkrec
objcopy
For more information, see their entries in the Utilities Reference.
You can clear the view by clicking the Clear Output button (
).
Downloading an image to your target
Many boards have a ROM monitor, a simple program that runs when
you first power on the board. The ROM monitor lets you
communicate with your board via a command-line interface (over a
serial or Ethernet link), download images to the board’s system
memory, burn images into flash, etc.
The Builder has two facilities you can use to communicate with your
board:
serial terminals (up to four)
TFTP server
☞
If your board doesn’t have a ROM monitor, you probably can’t use the
download services in the IDE; you’ll have to get the image onto the
board some other way (e.g. JTAG). To learn how to connect to your
particular target, consult your hardware and BSP documentation.
Downloading via a serial link
With the Builder’s builtin serial terminals, you don’t need to leave the
IDE and open a serial communications program (e.g. HyperTerminal)
in order to talk to your target, download images, etc.
To open a terminal:
July 30, 2004
Chapter 6 Building OS and Flash Images
149
Downloading an image to your target
 2004, QNX Software Systems Ltd.
➤ From the main menu, select Show View→Other. . . , then select
QNX System Builder→Terminal N (where N is 1 to 4).
The Terminal views lets you set standard communications parameters
(baud rate, parity, data bits, stop bits, and flow control), choose a port
(COM1 or COM2), send a BREAK command, and so on.
To communicate with your target over a serial connection:
1
Connect your target and host machine with a serial cable.
2
Specify the device (e.g. COM 2) and the communications
settings in the view’s menu:
You can now interact with your target by typing in the view.
To transfer a file using the Serial Terminal view:
150
1
Using either the serial terminal view or another method (outside
the IDE), configure your target so that it’s ready to receive an
image. For details, consult your hardware documentation.
2
In the serial terminal view, click the Send File button:
3
In the Select File to Send dialog, enter the name of your file (or
click Browse).
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
4
☞
Select a protocol (e.g. sendnto).
The QNX sendnto protocol sends a sequence of records (including
the start record, data records, and a go record). Each record has a
sequence number and a checksum. Your target must be running an
IPL (or other software) that understands this protocol.
5
☞
Downloading an image to your target
Click OK. The Builder transmits your file over the serial
connection.
You can click the Cancel button to stop the file transfer:
Downloading via TFTP
The Builder’s TFTP server eliminates the need to set up an external
server for downloading images (if your target device supports TFTP
downloads). The TFTP server knows about all Builder projects in the
system and automatically searches them whenever it receives requests
for service.
When you first open the TFTP Server view (in any perspective), the
Builder starts its internal TFTP server. For the remainder of the
current IDE session, the TFTP server will listen for incoming TFTP
transfer requests and automatically fulfill them.
☞
Currently, the Builder’s internal server supports only TFTP read
requests; you can’t use the server to write files from the target to the
host development machine.
The TFTP Server view provides status and feedback for current and
past TFTP transfers. As the internal TFTP server handles requests,
the view provides visual feedback:
July 30, 2004
Chapter 6 Building OS and Flash Images
151
Downloading an image to your target
 2004, QNX Software Systems Ltd.
Each entry in the view shows:
TFTP client IP address/hostname
requested filename
transfer progress bar
transfer status message.
Transferring a file
To transfer a file using the TFTP Server view:
1
Open the TFTP Server view. The internal TFTP server starts.
2
Using either the Builder’s serial terminal or another method,
configure your target to request a file recognized by the TFTP
server. (The TFTP Server view displays your host’s IP address.)
During the transfer, the view shows your target’s IP address, the
requested file, and the transfer status.
You can clear the TFTP server view of all completed transactions by
clicking its clear button (
152
).
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Downloading an image to your target
The internal TFTP server recognizes files in the Images directory of
all open QNX System Builder projects; you don’t need to specify the
full path.
Transferring files that aren’t in Images
!
CAUTION: The IDE deletes the content of the Images directory
during builds — don’t use this directory to transfer files that the
System Builder didn’t generate. Instead, configure a new path, as
described in the following procedure.
To enable the transfer of files that aren’t in the Images directory:
1
From the main menu, select Window→Preferences.
2
In the left pane of the Preferences dialog, select
QNX→Connections→TFTP Server.
3
Check Other Locations.
4
Click Add Path, and then select your directory from the
Browse For Folder dialog.
5
Click Apply.
6
Click OK. The TFTP server is now aware of the contents of
your selected directory.
Downloading using other methods
If your board doesn’t have an integrated ROM monitor, you may not
be able transfer your image over a serial or TFTP connection. You’ll
have to use some other method instead, such as:
CompactFlash — copy the image to a CompactFlash card plugged
into your host, then plug the card into your board to access the
image.
Or:
July 30, 2004
Chapter 6 Building OS and Flash Images
153
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
Flash programmer — manually program your flash with an
external programmer.
Or:
JTAG/ICE/emulator — use such a device to program and
communicate with your board.
For more information, see the documentation that came with your
board.
Configuring your Builder projects
In order to use the Builder to produce your final embedded system,
you’ll likely need to:
add/remove image items
configure the properties of an image and its items
configure the properties of the project itself.
As mentioned earlier, every Builder project has a project.bld file
that contains information about your image’s boot script, all the files
in your image, and the properties of those files:
If you double-click the project.bld, you’ll see your project’s
components in the Images and Filesystem panes in the editor area, as
well as a Properties view:
154
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Configuring your Builder projects
Managing your images
The Images pane shows a tree of all the files in your image, sorted by
type:
binaries
shared libraries
symbolic links
DLLs
other files
directories
Adding files to your image
When you add files, you can either browse your host filesystem or
select a file from a list of search paths:
July 30, 2004
Browse method
If you choose a file by browsing, you’ll probably
want to configure the project to use an absolute
path so that the IDE will always find the exact file
you specified (provided you keep the file in the
same location). Note that other users of your
project would also have to reproduce your setup in
order for the IDE to locate files.
Select method
Select a file from a preconfigured list of search
locations. We recommend that you use this option
because it’s more flexible and lets others easily
Chapter 6 Building OS and Flash Images
155
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
reproduce your project on their hosts. You can add
search paths to the list.
Note that the IDE saves only the filename. When
you build your project, the IDE follows your
search paths and uses the first file that matches
your specified filename. If you specify a file that
isn’t in the search path, the build will be
incomplete. To learn how to configure your search
paths, see the the section “Configuring project
properties” in this chapter.
To add an item to your image:
1
In the Images pane, right-click the image and select Add Item,
followed by the type of item you want to add:
binary
shared library
symbolic link
file
directory
EFS
☞
156
If you select EFS, the Builder immediately adds a flash filesystem to
your image without prompting.
2
Select the item (e.g. a binary) from the list or browse for it.
3
Select either the Search Path or the Absolute Path option.
(We recommend Search Path, because other users would be
able to recreate your project more easily.)
4
Click Next. A dialog appears showing the image you’re adding
the item to, the image’s location on your target, as well as
options (use in place or copy) for the item’s code and data
segments. (For more information on code and data segments,
see mkifs in the Utilities Reference.
Chapter 6 Building OS and Flash Images
July 30, 2004
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
5
Click Finish. The Builder adds the file to your image, as you
can see in the Images pane.
Deleting files
➤ In either the Images or Filesystem pane, right-click your file
and select Delete.
Adding directories
To add a directory to your image:
☞
1
In the Filesystem pane, right-click the parent directory and
select Add Item→Directory.
2
Specify the directory name, path, and image name. Some fields
are filled in automatically.
3
Click Finish. Your directory appears in the Filesystem pane.
You can also add a directory by specifying the path for an item in the
Location In Image field in the Properties view. The IDE includes the
specified directory as long as the item remains in your image.
Deleting directories
➤ In either the Images or Filesystem pane, right-click your
directory and select Delete.
☞
July 30, 2004
A deleted directory persists if it still contains items. To completely
remove the directory, delete the reference to the directory in the
Location In Image field in the Properties view for all the items in the
directory.
Chapter 6 Building OS and Flash Images
157
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
Configuring image properties
The Properties view lets you see and edit the properties of an image or
any of its items:
To change the properties of an image or item:
1
In the Images or Filesystem pane, select an image or one of its
items.
2
In the Properties view, select an entry in the Value column. The
value is highlighted; for some fields (e.g. CPU Type), a
dropdown menu appears.
3
Type a new value or select one from the dropdown menu.
4
Press Enter.
5
Save your changes.
6
Rebuild your project.
Different properties appear for images and for the items in an image:
Image properties
- Directories
158
Chapter 6 Building OS and Flash Images
July 30, 2004
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
- General
- System (.ifs)
- System (.efs)
Item properties
- General
- Memory
- Permissions
Image properties
Directories
These settings control the default permissions for directories that you
add to the image, as well as for any directories that the tools create
when you build your system. For example, if you add
/usr/bin/ksh to your system, the IDE automatically creates the
usr and bin directories. (For more information on permissions,
seethe Managing User Accounts chapter in the Neutrino User’s Guide
and the chmod entry in the Utilities Reference.)
Note that the values for permissions are given in octal (e.g. 777,
which means the read, write, and execute bits are set for the user,
group, and other categories).
General
Boot Script (.ifs only)
Name of the file that contains the boot script
portion of a buildfile. Boot script files have a .bsh
extension (e.g. prpmc800.bsh).
Compressed (.ifs only)
If set to Yes, the Builder compresses the directory
structure (image filesystem) section of the image.
The directory structure includes procnto, the
boot script, and files. You might enable
compression if you want to save on flash space or
July 30, 2004
Chapter 6 Building OS and Flash Images
159
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
if the BIOS/ROM monitor limits the size of your
image.
CPU Type
Your target’s processor (e.g. armle).
Create Image
If Yes, the IDE builds this image when you build
your project.
Image Name
Name of the .ifs file saved in the Images
directory during a build.
System (.ifs)
Boot File
The image filter that the Builder uses (e.g. srec, elf) to
perform further processing on the image file. For
example, srec converts the image to the Motorola
S-Record format. (For more about image filters, see
mkifs in the Utilities Reference.)
Image Address
The base address where the image is copied to at boot
time. For XIP, set this to the same location as your
image file on flash memory and specify the read/write
memory address with the RAM Address value,
described below.
Procnto
Specify which procnto binary to use (e.g.
procnto-600, procnto-600-SMP, etc.).
Procnto $LD LIBRARY PATH
Path(s) where procnto should look for shared
libraries. Separate the paths with a colon (:).
Procnto $PATH
Path(s) where procnto should look for executables.
Separate the paths with a colon (:).
Procnto Arguments
Command-line arguments for procnto.
160
Chapter 6 Building OS and Flash Images
July 30, 2004
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
RAM Address
The location of your read/write memory. For XIP, set
the address; otherwise, set the value to Default. (Note
that RAM Address is the ram attribute in the mkifs
utility.)
Startup
Which startup binary to use (e.g. startup-bios,
startup-rpx-lite, etc.).
Startup Arguments
Command-line arguments for the startup program.
System (.efs)
These settings control the size of your flash filesystem image. Unless
otherwise specified, the values are in bytes, but you can use the
suffixes K, M, or G (e.g. 800, 16K, 2M, 4G). The IDE immediately
rejects invalid entries.
Block Size
The size of the blocks on your flash.
Filter
The filter to use with this image, usually
flashcmp. (The mkefs utility calls flashcmp.
You can use any valid command-line argument
(e.g. flashcmp -t zip).
Image Mount Point
The path where the filesystem is mounted in the
filesystem. By default, the location is /.
Maximum Image Size
The limit for the size of the generated image. If the
image exceeds the maximum size, mkefs fails and
reports an error in the System Builder Console
view. The default setting of 4G accommodates
most images.
July 30, 2004
Chapter 6 Building OS and Flash Images
161
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
Minimum Image Size
Set the minimum size of the embedded filesystem.
If the size of the filesystem is less than this size
after all the specified files have been added, then
the filesystem is padded to the required size. The
default is 0 (i.e. no padding occurs).
Spare Blocks
Set the number of spare blocks to be used by the
embedded filesystem. If you want the embedded
filesystem to be able to reclaim the space taken up
by deleted files, set the number of spare blocks to 1
or more. The default is 1.
Item properties
General
Filename
The name of the file for this item (e.g.
devc-ser8250).
Image Name
The name of the image in which this item resides.
Include In Image
If Yes, the Builder includes this item when it builds
the image.
Location In Image
The directory where the item lives. If you change
this setting, the directory location shown in the
Filesystem pane changes as well.
☞
Symbolic links also have a Linked To field for the source file.
Strip File
162
By default, mkifs strips usage messages,
debugging information, and Photon resources from
executable files that you include in the image.
Doing this helps reduce the size of the image. To
keep this information, select No. See mkifs
Chapter 6 Building OS and Flash Images
July 30, 2004
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
(especially the +raw attribute) and strip in the
Utilities Reference.
☞
Set this field to No if your image includes PhAB applications.
Memory
Use these two settings to specify whether a program’s code and data
segments should be used directly from the image filesystem (Use In
Place) or copied when invoked (Copy). For more information, see the
code attribute in the mkifs documentation.
Permissions
Use these settings to specify the read/write/execute permissions (in
octal) assigned to each item, as well as the item’s group and user ID.
Configuring project properties
The properties dialog for your QNX System Builder project
(right-click the project, then select Properties) lets you view and
change the overall properties of your project. For example, you can
combine images, add dependent projects, and configure search paths.
The dialog includes the following sections:
Info
External Tools Builders
Image Combine
Project Preferences
Search Paths
July 30, 2004
Chapter 6 Building OS and Flash Images
163
Configuring your Builder projects
☞
 2004, QNX Software Systems Ltd.
For information on external tools, follow these links in the Eclipse
Workbench User Guide: Tasks→Building resources→Running
external tools.
Image Combine
As mentioned earlier, the Builder lets you create a combined image.
You use the Image Combine part of the properties dialog to:
add an IPL to the start of your image
append an EFS to your image
set the final format of your image
Adding an IPL to the start of your image
To add an IPL to the start of your image:
!
1
In the Navigator or System Builder Projects view, right-click
your project and select Properties.
2
Select Image Combine.
3
Check Add IPL.
4
Enter the IPL filename (or select it by clicking the browse icon).
5
In the Padding field, select padding equal to or greater than the
size of your IPL.
CAUTION: If the padding is less than the size of the IPL, the image
won’t contain the complete IPL.
6
164
Click OK.
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Configuring your Builder projects
If you get a File Not Found error while building, make sure the Build
with profiling option is unchecked in all of the C/C++ projects in the
BSP working set, then rebuild all of the projects.
Right-click on a project, then choose Properties and select QNX
C/C++ Project to view the Build with profiling setting.
Adding an EFS to your image
To append a flash filesystem to your image:
1
In the Image Combine section of the properties dialog for your
project, check Append EFS.
2
In the Alignment field, select the granularity of the padding.
The padding is a multiple of your selected alignment.
3
Click OK.
Setting the final format of your OS image
You use the Image Combine section of your project’s properties
dialog to set the final format for your image, even if it isn’t a
combined image.
To change the final format of your OS image:
1
In the Image Combine section of the properties dialog for your
project, check the Final Processing box.
2
In the Offset field, enter the board-specific offset. This setting
is generally used for S-Record images.
3
In the Format field, select the format from the dropdown menu
(e.g. SREC, Intel hex records, binary.)
4
Click OK.
For more information of the final processing of an OS image, see
mkrec in the Utilities Reference.
July 30, 2004
Chapter 6 Building OS and Flash Images
165
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
Search Paths
The Search Paths pane lets you configure where the IDE looks for
the files you specified in your project.bld file:
The IDE provides separately configurable search paths for:
binaries
shared libraries
DLLs
other files
system files.
To add a search path:
166
1
In the Navigator or System Builder Projects view, right-click
your project and select Properties.
2
In the left pane, select Search Paths.
3
In the right pane, select one of the following tabs:
Chapter 6 Building OS and Flash Images
July 30, 2004
Configuring your Builder projects
 2004, QNX Software Systems Ltd.
Binaries
Shared Libraries
DLLs
Other Files
System Files.
4
Click one of the following buttons:
Add Absolute Path — a hard-coded path
Add QNX TARGET Path — a path with a
$QNX TARGET prefix
Add CPU Path — a path with a $QNX TARGET/$CPU
prefix
Add Project — a path with a
$WORKSPACE/projectName prefix.
The Browse For Folder or Search Projects dialog appears.
5
Select your path or project and click OK. The IDE adds your
path to the end of the list.
To manage your search paths:
1
In the Search Path section of the properties dialog, select one
of the following tabs:
Binaries
Shared Libraries
DLLs
Other Files
System Files.
2
Select a path, then click one of these buttons:
Move Up
Move Down
Remove Selected.
July 30, 2004
Chapter 6 Building OS and Flash Images
167
Optimizing your system
!
 2004, QNX Software Systems Ltd.
CAUTION: The Overrides directory must be first in the list. The
Reductions directory, which is listed in the Shared Libraries tab,
must be second in the list.
Changing the order of the Overrides or Reductions directories
may cause unexpected behavior.
3
Click OK.
Optimizing your system
Since “less is better” is the rule of thumb for embedded systems, the
Builder’s System Optimizer and the Dietician help you optimize your
final system by:
reducing the size of shared libraries for your image
performing system-wide optimizations to remove unnecessary
shared libraries, add required shared libraries, and reduce the size
of all shared libraries in the system.
168
Chapter 6 Building OS and Flash Images
July 30, 2004
Optimizing your system
 2004, QNX Software Systems Ltd.
!
CAUTION: If you reduce a shared library, and your image
subsequently needs to access binaries on a filesystem (disk, network,
etc.) that isn’t managed by the System Builder, then the functions
required by those unmanaged binaries may not be present. This will
cause those binaries to fail on execution.
In general, shared-library optimizers such as the Dietician are truly
useful only in the case of a finite number of users of the shared
libraries, as you would find in a closed system (i.e. a typical
embedded system).
If you have only a small number of unmanaged binaries, one
workaround is to create a dummy flash filesystem image and add to
this image the binaries you need to access. This dummy image will be
built with the rest of the images, but it can be ignored. This technique
lets the Dietician be aware of the requirements of your runtime
system.
Optimizing all libraries in your image
To optimize all the libraries in an image:
1
In the Navigator or System Builder Projects view, double-click
your project’s project.bld file.
2
In the toolbar, click the Optimize System button (
3
In the System Optimizer, select the optimizations that you want
to make:
).
Remove unused libraries
When you select this option, the Dietician inspects your
entire builder project and ensures that all shared libraries
in the system are required for proper operation. If the
Builder finds libraries that no component in your project
actually needs, you’ll be prompted to remove those
libraries from your project.
July 30, 2004
Chapter 6 Building OS and Flash Images
169
Optimizing your system
 2004, QNX Software Systems Ltd.
Add missing libraries
This option causes the Dietician to inspect your entire
project for missing libraries. If any binaries, DLLs, or
shared libraries haven’t met load-time library
requirements, you’ll be prompted to add these libraries to
your project.
Apply diet(s) system wide
This option runs the Dietician on all the libraries selected.
The diets are applied in the proper order so that runtime
dependencies aren’t broken. If you were to do this by
hand, it’s possible that the dieting of one shared library
could render a previously dieted shared library
non-functional. The order of operations is key!
☞
To ensure that your image works and is as efficient as possible, you
should select all three options.
4
Click Next. You’ll see a list of the libraries scheduled to be
removed, added, or put on a diet. Uncheck the libraries that you
don’t want included in the operation, then move to the next
page.
5
Click Finish. The System Optimizer optimizes your libraries;
the dieted libraries appear in your project’s Reductions
directory.
Optimizing a single library
Optimizing a single library doesn’t reduce the library as effectively as
optimizing all libraries simultaneously, because the System Optimizer
accounts for dependencies.
To reduce a library such as libc using the Dietician, you must
iteratively optimize each individual library in your project between
two and five times (depending on the number of dependency levels).
You can optimize a single library to its optimum size if it has no
dependencies.
170
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Moving files between the host and target
To optimize a single library in an image:
1
In the Navigator or System Builder Projects view, double-click
your project’s project.bld file.
2
In the editor, expand the Shared Libraries item (if it isn’t
already), and select the library you want to optimize.
3
In the toolbar, click the Optimize System button (
4
In the System Optimizer, select the Apply diet(s) system wide
option.
5
Click Next. The pane shows the library you want to reduce.
6
Click Finish. The Dietician generates a new, reduced library
and puts it in your project’s Reductions directory.
).
Restoring a slimmed-down library
If after reducing a library, you notice that your resulting image is too
“slim,” you can manually remove the reduced library from the
Reductions directory, and then rebuild your image using a standard,
“full-weight” shared library.
To restore a library to its undieted state:
1
In the Navigator or System Builder Projects view, open the
Reductions directory in your project. This directory contains
the dieted versions of your libraries.
2
Right-click the library you want to remove and select Delete.
Click OK to confirm your selection. The IDE deletes the
unwanted library; when you rebuild your project, the IDE uses
the undieted version of the library.
Moving files between the host and target
The IDE’s File System Navigator view lets you easily move files
between your host and a filesystem residing on your target.
July 30, 2004
Chapter 6 Building OS and Flash Images
171
Moving files between the host and target
☞
 2004, QNX Software Systems Ltd.
If you haven’t yet created a target system, you can do so right from
within the File System Navigator view:
➤ Right-click anywhere in the view, then select Add New Target.
The view displays the target and directory tree in the left pane, and the
contents of the selected directory in the right pane:
☞
If the File System Navigator view has only one pane, click the
dropdown menu button ( ) in the title bar, then select Show table.
You can also customize the view by selecting Table Parameters or
Show files in tree.
Note that the File System Navigator view isn’t part of the default
QNX System Builder perspective; you must manually bring the view
into your current perspective.
To see the File System Navigator view:
1
From the main menu, select Window→Show View→Other. . . .
2
Select QNX Targets, then double-click File System
Navigator.
Moving files to the target
You can move files from your host machine to your target using
copy-and-paste or drag-and-drop methods.
172
Chapter 6 Building OS and Flash Images
July 30, 2004
 2004, QNX Software Systems Ltd.
Moving files between the host and target
To copy files from your host filesystem and paste them on your
target’s filesystem:
☞
1
In a file-manager utility on your host (e.g. Windows Explorer),
select your files, then select Copy from the context menu.
2
In the left pane of the File System Navigator view, right-click
your destination directory and select Paste.
To convert files from DOS to Neutrino (or Unix) format, use the
textto -l filename command. (For more information, see textto
in the Utilities Reference.)
To drag-and-drop files to your target:
➤ Drag your selected files from any program that supports
drag-and-drop (e.g. Windows Explorer), then drop them in the
File System Navigator view.
Moving files from the target to the host
To copy files from your target machine and paste them to your host’s
filesystem:
1
☞
In the File System Navigator view, right-click a file, then select
Copy to→File System. The Browse For Folder dialog
appears.
To import files directly into your workspace, select Copy
to→Workspace. The Select target folder dialog appears.
2
Select your desired destination directory and click OK.
To move files to the host machine using drag-and-drop:
➤ Drag your selected files from the File System Navigator view
and drop them in the Navigator or System Builder Projects
view.
July 30, 2004
Chapter 6 Building OS and Flash Images
173
Chapter 7
Developing Photon Applications
In this chapter. . .
What is PhAB? 177
Using PhAB 179
Starting Photon applications
July 30, 2004
182
Chapter 7 Developing Photon Applications
175
What is PhAB?
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
Use the PhAB visual design tool to develop Photon apps.
What is PhAB?
The Photon microGUI includes a powerful development tool called
PhAB (Photon Application Builder), a visual design tool that
generates the underlying C/C++ code to implement your program’s
UI.
With PhAB, you can dramatically reduce the amount of programming
required to build a Photon application. You can save time not only in
writing the UI portion of your code, but also in debugging and testing.
PhAB helps you get your applications to market sooner and with
more professional results.
PhAB lets you rapidly prototype your applications. You simply select
widgets, arrange them as you like, specify their behavior, and interact
with them as you design your interface.
PhAB’s opening screen looks like this:
July 30, 2004
Chapter 7 Developing Photon Applications
177
What is PhAB?
 2004, QNX Software Systems Ltd.
PhAB and the IDE
The IDE frequently runs command-line tools such as gdb and mkefs
“behind the scenes,” but PhAB and the IDE are separate applications;
each runs in its own window. You can create files, generate code
snippets, edit callbacks, test your UI components, etc. in PhAB, while
you continue to use the IDE to manage your project as well as debug
your code, run diagnostics, etc.
PhAB was originally designed to run under the Photon microGUI on
a QNX Neutrino host, but the phindows (“Photon in Windows”)
utility lets you run PhAB on a Windows host as well. The IDE lets
you see, debug, and interact with your target Photon application right
from your host machine as if you were sitting in front of your target
machine.
178
Chapter 7 Developing Photon Applications
July 30, 2004
Using PhAB
 2004, QNX Software Systems Ltd.
Using PhAB
In most respects, using PhAB inside the IDE is the same as running
PhAB as a standalone application.
☞
For a full description of PhAB’s functionality, see the Photon
Programmer’s Guide.
Creating a QNX Photon Appbuilder project
In order to use PhAB with the IDE, you must create a QNX Photon
Appbuilder project to contain your code. This type of project
contains tags and other information that let you run PhAB from
within the IDE.
To create a PhAB Project:
☞
July 30, 2004
1
From the workbench menu, select File→New→Project. . . .
2
In the left pane, select QNX.
3
In the right pane, select Photon Appbuilder Project.
4
Click Next.
5
Name your project.
6
Ensure that Use Default Location is checked. Don’t use a
different location.
7
Click Next.
8
Select your target architecture.
If you wish to set any other options for this project, click the
remaining tabs and fill in the fields. For details on the tabs in this
wizard, see “New C/C++ Project wizard tabs” in the Common
Wizards Reference chapter.
Chapter 7 Developing Photon Applications
179
Using PhAB
 2004, QNX Software Systems Ltd.
9
Click Finish.
The IDE creates your project, then launches PhAB. (In
Windows, the IDE also creates a Console for PhAB window.)
Closing PhAB
To end a PhAB session:
➤ From PhAB’s main menu, select File→Exit.
☞
In Windows, don’t end a PhAB session by clicking the Close button
in the top-right corner of the PhAB window; clicking this button
closes the phindows utility session without letting PhAB itself shut
down properly. Subsequent attempts to restart PhAB may fail.
To recover from improperly closing PhAB:
1
Close the Console for PhAB window.
2
Reopen your QNX Photon Appbuilder project.
Reopening PhAB
To reopen your QNX Photon Appbuilder project:
➤ Open the Project menu and click Open Appbuilder:
180
Chapter 7 Developing Photon Applications
July 30, 2004
Using PhAB
 2004, QNX Software Systems Ltd.
Editing code
You can edit the code in your QNX Photon Appbuilder project using
both PhAB and the IDE. Using PhAB, you can control the widgets
and the overall layout of your program; using either PhAB or the IDE,
you can edit the code that PhAB generates and specify the behavior of
your callbacks.
To use PhAB to edit the code in a QNX Photon Appbuilder project:
☞
1
In the C/C++ Projects view, select a QNX Photon Appbuilder
project.
2
Click the Open Appbuilder button in the toolbar (
starts, then opens your project.
). PhAB
If for some reason the Open Appbuilder button isn’t in the C/C++
Perspective’s toolbar:
1
From the main menu, select Window→Customize
Perspective.
2
In the left pane, select Other→Photon Appbuilder Actions.
3
Check Photon Appbuilder Actions.
4
Click OK. The Open Appbuilder button (
toolbar.
) appears in the
To use the IDE to edit the code in a QNX Photon Appbuilder project:
➤ In the C/C++ Projects view, double-click the file you want to
edit. The file opens in an editor.
If a file that you created with PhAB doesn’t appear in the C/C++
Projects view, right-click your project and select Refresh.
July 30, 2004
Chapter 7 Developing Photon Applications
181
Starting Photon applications
☞
 2004, QNX Software Systems Ltd.
Editing files using two applications can increase the risk of
accidentally overwriting your changes. To minimize this risk, close
the file in one application before editing the file in the other.
Building a QNX Photon Appbuilder project
You build a QNX Photon Appbuilder project in exactly the same way
as other projects. (For information on building projects, see the
“Building projects” section in the Developing Programs chapter.)
To build a QNX Photon Appbuilder project:
➤ In the C/C++ Projects view, right-click your QNX Photon
Appbuilder project and select Build. The IDE builds your
project.
Starting Photon applications
You can connect to a Photon session from a Windows or QNX
Neutrino host machine and run your Photon program as if you were
sitting in front of the target machine. Photon appears in a phindows
window on your Windows host or in a phditto window on your
QNX Neutrino host.
The remote Photon session runs independently of your host. For
example, the clipboards don’t interact, and you can’t drag and drop
files between the two machines. The phindows and phditto
utilities transmit your mouse and keyboard input to Photon and
display the resulting state of your Photon session as a bitmap on your
host machine.
Before you run a remote Photon session on a Windows host, you must
first prepare your target machine. (For details, see the “Connecting
with Phindows” section in the Preparing Your Target chapter.)
To start a remote Photon session:
182
Chapter 7 Developing Photon Applications
July 30, 2004
Starting Photon applications
 2004, QNX Software Systems Ltd.
➤ In the Target Navigator view, right-click a target and select
Launch Remote Photon.
Photon appears in a Phindows window.
You can start a Photon application you created in PhAB in exactly the
same way that you launch any other program in the IDE. By default,
the program opens in the target machine’s main Photon session. (For
more on launching, see the Launch Configurations Reference chapter
in this guide.)
To run your Photon program in a remote Photon session window:
1
In the remote Photon session, open a command window (e.g. a
terminal from the shelf).
2
In the command window, enter:
echo $PHOTON
The target returns the session, such as /dev/ph1470499. The
number after ph is the process ID (PID).
☞
July 30, 2004
3
In the IDE, edit the launch configuration for your QNX Photon
Appbuilder project.
4
Select the Arguments tab.
5
In the C/C++ Program Arguments field, enter -s followed by
the value of $PHOTON. For example, enter -s
/dev/ph1470499.
6
Click Apply, then Run or Debug. Your remote Photon
program opens in the phindows or phditto window on your
host machine.
If you close and reopen a remote Photon session, you must update
your launch configuration to reflect the new PID of the new session.
Chapter 7 Developing Photon Applications
183
Chapter 8
Profiling an Application
In this chapter. . .
Introducing the Application Profiler 187
Profiling your programs 189
Controlling your profiling sessions 198
Understanding your profiling data 200
July 30, 2004
Chapter 8 Profiling an Application
185
Introducing the Application Profiler
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter shows you how to use the application profiler.
Introducing the Application Profiler
The QNX Application Profiler lets you examine the overall
performance of programs, no matter how large or complex, without
following the source one line at a time. Whereas a debugger helps you
find errors in your code, the Application Profiler helps you pinpoint
“sluggish” areas of your code that could run more efficiently.
July 30, 2004
Chapter 8 Profiling an Application
187
Introducing the Application Profiler
 2004, QNX Software Systems Ltd.
QNX Application Profiler perspective.
Types of profiling
The Application Profiler lets you perform:
statistical profiling
instrumented profiling
postmortem profiling (on standard gmon.out files).
Statistical profiling
The Application Profiler takes “snapshots” of your program’s
execution position every millisecond and records the current address
being executed. By sampling the execution position at regular
intervals, the tool quickly builds a summary of where the system is
spending its time in your code.
188
Chapter 8 Profiling an Application
July 30, 2004
Profiling your programs
 2004, QNX Software Systems Ltd.
With statistical profiling, you don’t need to use instrumentation,
change your code, or do any special compilation. The tool profiles
your programs nonintrusively, so it doesn’t bias the information it’s
collecting.
Note, however, that the results are subject to statistical inaccuracy
because the tool works by sampling. Therefore, the longer a program
runs, the more accurate the results.
Instrumented profiling
If you build your executables with profiling enabled, the Application
Profiler can provide call-pair information (i.e. which functions called
which). When you build a program with profiling enabled, the
compiler inserts snippets of code into your functions in order to report
the addresses of the called and calling functions. As your program
runs, the tool produces an exact count for every call pair.
Postmortem profiling
The IDE lets you gather profiling information into a gmon.out file
and examine its contents with the Application Profiler. The tool gives
you all the information you’d get from the traditional gprof tool, but
in graphical form. You can examine gmon.out files created by your
programs, whether you built them using the IDE or the qcc -p
command. For more on the gprof utility, go to www.gnu.org; for
qcc, see the Utilities Reference.
Postmortem profiling files give you the same information as
instrumented profiling.
Profiling your programs
Whether you plan to do your profiling in real time or postmortem
(using a gmon.out file), you should build your programs with
profiling enabled before you start a profiling session.
This section includes these topics
Building a program for profiling
July 30, 2004
Chapter 8 Profiling an Application
189
Profiling your programs
 2004, QNX Software Systems Ltd.
Running and profiling a process
Profiling a running process
Postmortem profiling
☞
If you already have a gmon.out file, you’re ready to start a
postmortem profiling session.
Building a program for profiling
Although you can profile any program, you’ll get the most useful
results by profiling executables built for debugging and profiling. The
debug information lets the IDE correlate executable code and
individual lines of source; the profiling information reports call-pair
data.
This tables shows the application profiling features that are possible
with the various build types:
Feature
Release version
Debug version
Release v. &
profiling
Debug v. &
profiling
Call pairs
No
No
Yes
Yes
Statistical
sampling
Limited
Limited
Yes
Yes
Line
profiling
No
Limited
No
Yes
Postmortem
profiling
No
No
Yes
Yes
To build executables with debug information and profiling enabled:
190
1
In the C/C++ Projects view, right-click your project and select
Properties.
2
In the left pane, select QNX C/C++ Project.
Chapter 8 Profiling an Application
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
July 30, 2004
Profiling your programs
3
In the right pane, select the Options tab.
4
Check the Build debug version and Build with Profiling
options:
The Application Profiler uses the information in the debuggable
executables to correlate lines of code in your executable and the
source code. To maximize the information you get while profiling, use
executables with debug information for both running and debugging.
5
Click Apply.
6
Click OK.
7
Rebuild your project.
Chapter 8 Profiling an Application
191
Profiling your programs
☞
 2004, QNX Software Systems Ltd.
To build a non-QNX project for profiling, compile and link using the
-p option. For example, your makefile might have a line like this:
make CCOPTS+=-p LDOPTS+=-p
Running and profiling a process
To run and profile a process:
192
1
Create a QNX Application launch configuration for an
executable with debug information as you normally would, but
don’t click OK. You may choose either a Run or a Debug
session.
2
On the launcher, click the Tools tab.
3
Click Add/Delete Tool. The Select tools to support dialog
appears.
4
Enable the QNX Application Profiler tool.
5
Click OK.
6
On the launcher, click the Profiler tab:
Chapter 8 Profiling an Application
July 30, 2004
Profiling your programs
 2004, QNX Software Systems Ltd.
7
Fill in these fields:
Profiler update interval (ms)
You use this option to control how often the Profiler polls
for data. A low setting causes continuous (but low)
network traffic and fast refresh rates. A high setting
causes larger network data bursts and may cause higher
memory usage on the target because the target must
buffer the data. The default setting of 1000 should
suffice.
Shared library paths
The IDE doesn’t know the location of your shared library
paths, so you must specify the directory containing any
libraries that you wish to profile. For a list of the library
paths that are automatically included in the search path,
see the appendix Where Files Are Stored.
8
July 30, 2004
Click Apply.
Chapter 8 Profiling an Application
193
Profiling your programs
 2004, QNX Software Systems Ltd.
9
If you want the IDE to automatically change to the Application
Profiler perspective when you run or debug, select the
Common tab, and set the Run mode and Debug mode
dropdowns to QNX Application Profiler.
10
Click Run or Debug. The IDE starts your program and profiles
it.
Profiling a running process
To profile a process that’s already running on your target:
194
1
In the Launch Configurations dialog for the program you
want to profile, click the Debugger tab.
2
Enable the Attach to running process setting.
3
Click the Tools tab.
4
Click Add/Delete Tool. . . . The Tools selection dialog appears.
5
Enable the Application Profiler tool.
6
Click OK.
7
On the launcher, click the Application Profiler tab:
Chapter 8 Profiling an Application
July 30, 2004
Profiling your programs
 2004, QNX Software Systems Ltd.
8
Fill in these fields:
Profiler update interval (ms)
You use this option to control how often the Profiler polls
for data. A low setting causes continuous (but low)
network traffic and fast refresh rates. A high setting
causes larger network data bursts and may cause higher
memory usage on the target because the target must
buffer the data. The default setting of 1000 should
suffice.
Shared library paths
The IDE doesn’t know the location of your shared library
paths, so you must specify the directory containing any
libraries that you wish to profile. For a list of the library
paths that are automatically included in the search path,
see the appendix Where Files Are Stored.
July 30, 2004
Chapter 8 Profiling an Application
195
Profiling your programs
 2004, QNX Software Systems Ltd.
Switch to this tool’s perspective on launch.
Check this to automatically switch to the Application
Profiler perspective when using this launcher.
9
Click Apply, then click Run.
10
You’ll now see a list of processes running on your target. Select
the one you want to profile.
Postmortem profiling
The IDE lets you profile your program after it terminates, using the
traditional gmon.out file. Postmortem profiling doesn’t provide as
much information as profiling a running process:
Multithreaded processes aren’t supported. Thus, the Thread
Processor Usage view always shows the totals of all your
program’s threads combined as one thread.
Shared libraries and DLLs aren’t shown.
Profiling a gmon.out file involves three basic steps:
gathering profiling information into a file
importing the file into your workspace
starting the postmortem profiling session.
Gathering profiling information
The IDE lets you store your profiling information in the directory of
your choice using the PROFDIR environment variable.
To gather profiling information:
1
196
Create a launch configuration for a debuggable executable as
you normally would, but don’t click Run or Debug.
Chapter 8 Profiling an Application
July 30, 2004
Profiling your programs
 2004, QNX Software Systems Ltd.
☞
You must have the QNX Application Profiler tool disabled in your
launch configuration.
2
Select the Environment tab.
3
Click New.
4
In the Name field, type PROFDIR.
5
In the Value field, enter a valid path to a directory on your
target machine.
6
Click OK.
7
Run your program. When your program exits successfully, it
creates a new file in the directory you specified. The filename
format is pid.projectName (e.g. 3047466.helloworld g).
This is the gmon.out profiler data file.
Importing a gmon.out file
You can bring into your workspace existing gmon.out files that you
created outside the IDE.
To import a gmon.out file into your workspace:
July 30, 2004
1
Open the File System Navigator view (Window→Show
View→Other. . . →QNX Targets→File System Navigator.
2
In the File System Navigator view, right-click your file and
select Copy to. . . →Workspace. The Select target folder
dialog appears.
3
Select the project related to your program.
4
Click OK.
5
In the C/C++ Projects view, right-click the file you imported
into your workspace and select Rename.
6
Enter gmon.out (or gmon.out.n, where n is any numeric
character). The IDE renames your file.
Chapter 8 Profiling an Application
197
Controlling your profiling sessions
 2004, QNX Software Systems Ltd.
Starting a postmortem profiling session
To start the postmortem profiling session:
1
In the C/C++ Projects view, right-click your gmon.out file
and select Open in QNX Application Profiler. The Program
Selection dialog appears.
2
Select the program that generated the gmon.out file.
3
Click OK. You can now profile your program in the QNX
Application Profiler perspective.
Controlling your profiling sessions
The Application Profiler view (Window→Show
View→Other. . . →QNX Application Profiler→Application
Profiler) lets you control multiple profiling sessions simultaneously.
You can:
terminate applications
choose the executable or library to show profiling information for
in the Sampling Information, Call Information, and Thread
Processor Usage views.
198
Chapter 8 Profiling an Application
July 30, 2004
Controlling your profiling sessions
 2004, QNX Software Systems Ltd.
The Application Profiler view displays the following as a
hierarchical tree for each profiling session:
Session item
Description
Launch instance
Launch configuration name and
launch type (e.g. prof201
[C/C++ QNX QConn (IP)])
Profiled program
Project name and start time
(e.g. prof201 on
Possible icons
localhost pid 4468773
(3/4/03 12:41 PM))
Application Profiler instance
Program name and target
computer URL (e.g.
Application Profiler
Attached to: prof201
<4468773> on
10.12.3.200)
Executable
Shared libraries
DLLs
To choose which executable or library to display information for in
the QNX Application Profiler perspective:
➤ In the Application Profiler view, click one of the following:
the QNX Application Profiler instance
an executable
a shared library
a DLL
To terminate an application running on a target:
1
July 30, 2004
In the Application Profiler view, select a launch configuration.
Chapter 8 Profiling an Application
199
Understanding your profiling data
2
☞
 2004, QNX Software Systems Ltd.
Click the Terminate button (
) in the view’s title bar.
To clear old launch listings from this view, click the Remove All
Terminated Launches button (
).
Understanding your profiling data
For each item you select in the Application Profiler view, other the
views within the QNX Application Profiler perspective display the
profiling information for that item:
This view:
Shows:
Application Profiler Editor
usage by line
Sampling Information
usage by function
Thread Processor Usage
usage by thread
Call Information
Call counts
Usage by line
The Application Profiler Editor lets you see the amount of time your
program spends on each line of code and in each function.
To open the editor:
1
Launch a profile session for a debuggable (i.e. g) executable.
2
In the Application Profiler view, select your program by
selecting an Application Profiler instance (
(
3
200
) or an executable
).
In the Sampling Information or Call Information view,
double-click a function that you have the source for. The IDE
opens the corresponding source file in the Application Profiler
Editor:
Chapter 8 Profiling an Application
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Understanding your profiling data
You may get incorrect profiling information if you change your source
after compiling because the Application Profiler Editor relies on the
line information provided by the debuggable version of your code.
The Application Profiler Editor displays a bar graph on the left side.
The bars are color coded:
Green
CPU time spent within the function as a percentage of the
program’s total CPU time. The green bar appears on the
first line of executable code in the function.
Orange
CPU time spent on a line of code as a percentage of the
program’s total CPU time. Within a function, the lengths
of the orange bars add up to the length of the green bar.
Blue
CPU time spent on a line of code as a percentage of the
function’s total CPU time. Within a function, the sum of
all the blue bars spans the width of the editor’s margin.
To view quantitative profiling values:
July 30, 2004
Chapter 8 Profiling an Application
201
Understanding your profiling data
 2004, QNX Software Systems Ltd.
➤ In the Application Profiler Editor, hover the pointer over a
colored bar. The CPU usage appears, displayed as a percentage
and a time:
Usage by function
The Sampling Information view shows a flat profile of the item that’s
currently selected in the Application Profiler view. You can examine
profiling information for programs, shared libraries, and DLLs:
The view lists all the functions called in the selected item. For each
function, this view displays:
the total CPU time spent in the function
the CPU time spent in the function since you last reset the
counters.
If you select a program compiled for debugging, the view also
displays:
the number of times the function has been called
the average CPU time per call.
202
Chapter 8 Profiling an Application
July 30, 2004
Understanding your profiling data
 2004, QNX Software Systems Ltd.
To see your function usage:
1
Launch a profile session for a debuggable (i.e. g) executable.
2
In the Application Profiler view, select your program by
selecting an Application Profiler instance ( ) or any
subordinate line. The Sampling Information view displays
profiling information for your selection.
To reset the counters in the Time since last reset(s) column:
➤ Click the Reset Sample counts button (
Information view’s title bar.
) in the Sampling
Usage by thread
The Thread Processor Usage view displays the CPU usage (in
seconds and as a percentage of your program’s total time) for each
thread of the item that’s currently selected in the Application Profiler
view:
You can use this information to:
identify which threads are the most and least active
determine the appropriate size of your application’s thread pool.
(If there are idle threads, you might want to reduce the size of the
pool.)
To see your thread usage:
July 30, 2004
Chapter 8 Profiling an Application
203
Understanding your profiling data
 2004, QNX Software Systems Ltd.
1
Launch a profile session for a debuggable (i.e. g) executable.
2
In the Application Profiler view, select your program by
selecting an Application Profiler instance ( ) or any
subordinate line. The Thread Processor Usage view displays
profiling information for your selection.
Call counts
For the item that’s currently selected in the Application Profiler view,
the Call Information view shows your call counts in three panes:
Call Pairs
Call Graph
Call Pair Details.
To display your call counts:
1
Launch a profile session for a debuggable (i.e. g) executable.
2
In the Application Profiler view, select your program by
selecting an Application Profiler instance ( ) or any
subordinate line. The Call Information view displays profiling
information for your selection:
204
Chapter 8 Profiling an Application
July 30, 2004
Understanding your profiling data
 2004, QNX Software Systems Ltd.
Call Pairs pane
The Call Pairs pane shows you where every function was called from
as well as the call-pair count, i.e. the number of times each function
called every other function.
Call Graph pane
The Call Graph pane shows you a graph of the function calls. Your
selected function appears in the middle, in blue. On the left, in yellow,
are all the functions that called your function. On the right, also in
yellow, are all the functions that your function called.
To see the calls to and from a function:
➤ Click a function in:
the Function column in the Call Pairs pane
or:
the Call Graph pane.
July 30, 2004
Chapter 8 Profiling an Application
205
Understanding your profiling data
☞
 2004, QNX Software Systems Ltd.
You can display the call graph only for functions that were compiled
with profiling enabled.
Call Pair Details pane
The Call Pair Details pane shows the information about the function
you’ve selected in the Call Graph pane. The Caller and Call Count
columns show the number of times each function called the function
you’ve selected.
The Called and Called Count columns show the number of times
your selected function called other functions. This pane shows only
the functions that were compiled with profiling. For example, it
doesn’t show calls to functions, such as printf(), in the C library.
206
Chapter 8 Profiling an Application
July 30, 2004
Chapter 9
Using Code Coverage
In this chapter. . .
Code coverage in the IDE 209
Enabling code coverage 212
Controlling your session 216
Examining data line-by-line 218
Examining your coverage report 219
Seeing your coverage at a glance 221
July 30, 2004
Chapter 9 Using Code Coverage
207
Code coverage in the IDE
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
Use the Code Coverage tool to help test your code.
Code coverage in the IDE
Code coverage is a way to measure how much code a particular
process has executed during a test or benchmark. Using
code-coverage analysis, you can then create additional test cases to
increase coverage and determine a quantitative measure of code
coverage, which is an indirect measure of the quality of your software
(or better, a direct measure of the quality of your tests).
Types of code coverage
Several types of metrics are commonly used in commercial
code-coverage tools, ranging from simple line or block coverage (i.e.
“this statement was executed”) to condition-decision coverage (i.e.
“all terms in this Boolean expression are exercised”). A given tool
usually provides a combination of types.
The coverage tool in the IDE is a visual font end to the gcov metrics
produced by the gcc compiler. These coverage metrics are essentially
basic block coverage and branch coverage.
July 30, 2004
Chapter 9 Using Code Coverage
209
Code coverage in the IDE
 2004, QNX Software Systems Ltd.
The IDE presents these metrics as line coverage, showing which lines
are fully covered, partially covered, and not covered at all. The IDE
also presents percentages of coverage in terms of the actual code
covered (i.e. not just lines).
Block coverage
Block coverage, sometimes known as line coverage, describes
whether a block of code, defined as not having any branch point
within (i.e. the path of execution will enter from the beginning and
exit at the end.) is executed or not.
By tracking the number of times the block of code has been executed,
the IDE can determine the total coverage of a particular file or
function. The tool also uses this information to show line coverage by
analyzing the blocks on each line and determining the level of
coverage of each.
Branch coverage
Branch coverage can track the path of execution taken between blocks
of code. Although this metric is produced by the gcc compiler,
currently the IDE doesn’t provide this information.
How the coverage tool works
The IDE’s code coverage tool works in conjunction with the compiler
(gcc), the QNX C library (libc), and optionally the remote target
agent (qconn). When code coverage is enabled for an application, the
compiler will instrument the code so that at run time, each branch
execution to a basic block is counted. During the build, the IDE
produces data files in order to recreate the program’s flow graph and
to provide line locations of each block.
210
Chapter 9 Using Code Coverage
July 30, 2004
 2004, QNX Software Systems Ltd.
Code coverage in the IDE
CAUTION: Since the IDE creates secondary data files at compilation
time, you must be careful when building your programs in a
multi-targeted build environment such as QNX Neutrino.
!
You must either:
ensure that the last compiled binary is the one you’re collecting
coverage data on,
or:
simply enable only one architecture and debug/release variant.
Note also that the compiler’s optimizations could produce unexpected
results, so you should perform coverage tests on a non-optimized,
debug-enabled build.
When you build a program with the Build with Code Coverage build
option enabled and then launch it using a C/C++ QNX Qconn (IP)
launch configuration, the instrumented code linked into the process
will connect to qconn, allowing the coverage data to be read from the
process’s data space.
But if you launch a coverage-built process with coverage disabled in
the launch configuration, this will cause the process to write the
coverage information to a data file (.da) at run time, rather than read
it from the process’s data space.
☞
You should use data files only if you’re running the local launch
configuration on a QNX Neutrino self-hosted development system.
Note that the data will need to be imported into the IDE code
coverage tool.
Once a coverage session has begun, you can immediately view the
data. The QNX Code Coverage perspective contains a Code
Coverage Sessions view that lists previous as well as currently active
sessions. You can explore each session and browse the corresponding
source files that have received coverage data.
July 30, 2004
Chapter 9 Using Code Coverage
211
Enabling code coverage
 2004, QNX Software Systems Ltd.
Enabling code coverage
To build executables with code coverage enabled:
!
1
In the C/C++ Projects view, right-click your project and select
Properties. The properties dialog for your project appears.
2
In the left pane, select QNX C/C++ Project.
3
In the Build Options pane, check Build with Code Coverage.
4
In the Build Type pane, check only one build type.
5
In the Build Variants tab, check only one build variant.
CAUTION: If the IDE is set to build more than one executable, the
code-coverage information may be meaningless.
6
Click OK.
7
In the C/C++ Projects view, right-click your project and select
Rebuild.
Enabling code coverage for non-QNX projects
If you’re using your own custom build environment, rather than QNX
makefiles, you’ll have to manually pass the coverage option to the
compiler.
To enable code coverage for non-QNX projects
1
Compile using these options to gcc:
-fprofile-arcs -ftest-coverage
If your using qcc, compile with:
-Wc,-fprofile-arcs -Wc,-ftest-coverage
2
Link using the -p option.
For example, your makefile might look something like this:
212
Chapter 9 Using Code Coverage
July 30, 2004
Enabling code coverage
 2004, QNX Software Systems Ltd.
objects= Profile.o main.o
CFLAGS= -g -Wc,-ftest-coverage -Wc,-fprofile-arcs -I. -I../proflibCPP-std
all: profileCPP-std
clean:
-rm $(objects) profileCPP-std *.bb *.bbg
$(objects): %.o: %.cpp
QCC -c $(CFLAGS) $< -o [email protected]
profileCPP-std: $(objects)
$(CC) -Vgcc ntox86 $ˆ -g -p -o [email protected] -L../proflibCPP-std -lProfLib -lcpp
Starting a coverage-enabled program
To start a program and measure the code coverage:
July 30, 2004
1
Create a C/C++ QNX QConn (IP) launch configuration as you
normally would, but don’t click OK yet.
2
On the launcher, click the Tools tab.
3
Click Add/Delete Tool. The Tools selection dialog appears.
4
Check the Code Coverage tool:
Chapter 9 Using Code Coverage
213
Enabling code coverage
214
 2004, QNX Software Systems Ltd.
5
Click OK.
6
Click the Code Coverage tab, and fill in these fields:
Chapter 9 Using Code Coverage
July 30, 2004
Enabling code coverage
 2004, QNX Software Systems Ltd.
Enable GCC 3 Coverage metrics collection.
Check this if your application was compiled
with gcc 3.3.1 or later. The default is to
collect code coverage information from
applications compiled with gcc 2.
Scan interval
This option sets how often the Code Coverage
tool polls for data. A low setting causes
continuous (but low) network traffic. A high
setting causes larger network data bursts and
may cause higher memory usage on the target
because the target must buffer the data. The
default setting of 1 s should suffice.
Referenced projects
Check any project in this list you wish to
gather code-coverage data for. Projects must
be built with coverage enabled.
July 30, 2004
Chapter 9 Using Code Coverage
215
Controlling your session
Comments
 2004, QNX Software Systems Ltd.
Your notes about the session, for your own
personal use. The comments appear at the top
of the generated reports.
7
Check Switch to this tool’s perspective on launch if you want
to automatically go to the Code Coverage perspective when you
run or debug.
8
Click Apply.
9
Click Run or Debug.
Controlling your session
The Code Coverage Sessions view lets you control and display
multiple code-coverage sessions:
The view displays the following as a hierarchical tree for each session:
216
Chapter 9 Using Code Coverage
July 30, 2004
Controlling your session
 2004, QNX Software Systems Ltd.
Session item
Description
Possible icons
Code coverage session
Launch configuration name,
coverage tool, and start time
(e.g. ccov102 factor [GCC
Code Coverage] (7/2/03
2:48 PM))
Project
Project name and amount of
coverage (e.g.
ccov102 factor [ 86.67%
])
File
Filename and amount of
coverage (e.g.
ccov102 factor.c [
86.67% ])
Function
Function name and amount of
coverage (e.g. main [ 100%
])
The IDE uses several icons in this view:
Icon
Meaning
No coverage
Partial coverage
Missing or out-of-date source file
The IDE also adds a coverage markup icon ( ) to indicate source
markup in the editor. (See the “Examining data line-by-line” section,
below.)
You can update the list of sessions by clicking the Refresh All
Sessions button (
the Collapse All (
July 30, 2004
). To reduce the size of the hierarchical tree, click
) button.
Chapter 9 Using Code Coverage
217
Examining data line-by-line
 2004, QNX Software Systems Ltd.
To combine several sessions:
1
In the Code Coverage Sessions view, select the sessions you
want to combine.
2
Right-click your selections and select Combine/Copy
Sessions. The IDE prompts you for a session name and creates
a combined session.
Examining data line-by-line
The IDE can display the line-by-line coverage information for your
source code. In the left margin, the editor displays a “covered” icon
( ) beside each line of source. In the right margin, the editor
displays a summary of the sections that haven’t been covered:
To open a file in the QNX Code Coverage perspective:
➤ In the Code Coverage Sessions view, expand a session and
double-click a file or function.
218
Chapter 9 Using Code Coverage
July 30, 2004
Examining your coverage report
 2004, QNX Software Systems Ltd.
To display coverage information from a particular session:
➤ In the Code Coverage Sessions view, right-click a session and
select Coverage Markup, then select one of the following:
Mark source not covered
Mark source covered
The selected icon appears beside the corresponding source in
the C/C++ Editor. In the Code Coverage Sessions view, a
coverage marker ( ) overlays the source file icon.
To automatically show coverage information when opening a file:
1
Open the Preferences dialog (Window→Preferences).
2
In the left pane, select QNX→Code Coverage.
3
In the right pane, check the desired markers in the
Automatically display coverage markers field.
4
Click OK. The next time you open a file, the markers appear
automatically. To add markers from another session, add them
manually, as described above.
To remove all coverage markers:
➤ In the Code Coverage Sessions view’s title bar, click the
Remove All Coverage Markers button (
).
Examining your coverage report
The Code Coverage Report view provides a summary (in XML) of
your session. The view lets you drill down into your project and see
the coverage for individual files and functions:
July 30, 2004
Chapter 9 Using Code Coverage
219
Examining your coverage report
 2004, QNX Software Systems Ltd.
To generate a report, simply right-click a coverage session and select
Generate Report.
By default, the IDE displays reports in the Code Coverage Report
view, but you can also have the IDE display reports in an external
browser. Using an external browser lets you compare several reports
simultaneously.
To toggle between viewing reports in the Code Coverage Report view
and in an external browser:
1
Open the Preferences dialog (Window→Preferences).
2
In the left pane, select QNX→Code Coverage.
3
In the right pane, check/uncheck the View reports in external
browser item.
4
Click OK.
To print or save a report:
220
Chapter 9 Using Code Coverage
July 30, 2004
Seeing your coverage at a glance
 2004, QNX Software Systems Ltd.
➤ In the Code Coverage Report view’s title bar, click one of the
following:
Print button (
)
Save entire report button (
).
Seeing your coverage at a glance
The Properties view displays a summary of the code coverage for a
project, file, or function you’ve selected in the Code Coverage
Sessions view.
The Properties view tells you how many lines were covered, not
covered, and so on:
July 30, 2004
Chapter 9 Using Code Coverage
221
Chapter 10
Finding Memory Errors
In this chapter. . .
Introduction 225
Analyzing your program 236
Manually launching a program for memory tracing
Tracing memory events 240
Controlling your memory analysis session 245
Examining your target’s memory 246
July 30, 2004
238
Chapter 10 Finding Memory Errors
223
Introduction
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
Use the QNX Memory Analysis perspective to solve memory problems.
Introduction
Have you ever had a customer say, “The program was working fine
for days, then it just crashed”? If so, chances are good that your
program had a memory error — somewhere.
Debugging memory errors can be frustrating; by the time a problem
appears, often by crashing your program, the corruption may already
be widespread, making the source of the problem difficult to trace.
The QNX Memory Analysis perspective shows you how your
program uses memory and can help ensure that your program won’t
cause problems. The perspective helps you quickly pinpoint memory
errors in your development and testing environments before your
customers get your product.
July 30, 2004
Chapter 10 Finding Memory Errors
225
Introduction
☞
 2004, QNX Software Systems Ltd.
The QNX Memory Analysis perspective may produce incorrect
results when more than one IDE is communicating with the same
target system. To use this perspective, make sure only one IDE is
connected to the target system.
Memory management in QNX Neutrino
By design, the architecture of the OS helps ensure that faults,
including memory errors, are confined to the program that caused
them. Programs are less likely to cause a cascade of faults because
processes are isolated from each other and from the microkernel.
Even device drivers behave like regular debuggable processes:
User space
File
system
Microkernel
Programs
TCP/IP
stack
Device drivers
This robust architecture ensures that crashing one program has little
or no effect on other programs throughout the system. When a
program faults, you can be sure that the error is restricted to that
process’s operation.
Neutrino’s full memory protection means that almost all the memory
addresses your program encounters are virtual addresses. The process
manager maps your program’s virtual memory addresses to the actual
physical memory; memory that is contiguous in your program may be
transparently split up in your system’s physical memory:
226
Chapter 10 Finding Memory Errors
July 30, 2004
Introduction
 2004, QNX Software Systems Ltd.
Virtual memory
Mapping
Physical memory
1
1
2
2
3
3
The process manager allocates memory in small pages (typically 4K
each). To determine the size for your system, use the
sysconf( SC PAGESIZE) function.
As you’ll see when you use the memory-analysis tools, the IDE
categorizes your program’s virtual address space as follows:
program
stack
shared library
objects
heap
July 30, 2004
Chapter 10 Finding Memory Errors
227
Introduction
 2004, QNX Software Systems Ltd.
0xFFFFFFFF
Reserved
Growth
Shared libraries
Growth
Objects
Growth
Heap
Program
Process base address
Growth
Stack
Stack
Guard page
0
Process memory layout on an x86.
Program memory
Program memory holds the executable contents of your program. The
code section contains the read-only execution instructions (i.e. your
actual compiled code); the data section contains all the values of the
global and static variables used during your program’s lifetime:
228
Chapter 10 Finding Memory Errors
July 30, 2004
Introduction
 2004, QNX Software Systems Ltd.
Program's
virtual memory
MyProgram (executable)
Mapping
Physical memory
int min=10;
int max = 50;
int main () {
Program
code
}
&min
&max
Program
data
Stack memory
Stack memory holds the local variables and parameters your
program’s functions use. Each process in Neutrino contains at least
the main thread; each of the process’s threads has an associated stack.
When the program creates a new thread, the program can either
allocate the stack and pass it into the thread-creation call, or let the
system allocate a default stack size and address:
Program's virtual
memory
Thread 1
stack
Thread 2
stack
Thread 3
stack
Thread 4
stack
Growth
When your program runs, the process manager reserves the full stack
in virtual memory, but not in physical memory. Instead, the process
manager requests additional blocks of physical memory only when
your program actually needs more stack memory. As one function
calls another, the state of the calling function is pushed onto the stack.
July 30, 2004
Chapter 10 Finding Memory Errors
229
Introduction
 2004, QNX Software Systems Ltd.
When the function returns, the local variables and parameters are
popped off the stack.
The used portion of the stack holds your thread’s state information
and takes up physical memory. The unused portion of the stack is
initially allocated in virtual address space, but not physical memory:
Program's virtual
memory
Mapping
Physical memory
Allocated
A typical
thread's
stack
Unallocated
Guard page
(read-only)
Legend:
Used
Unused
At the end of each virtual stack is a guard page that the microkernel
uses to detect stack overflows. If your program writes to an address
within the guard page, the microkernel detects the error and sends the
process a SIGSEGV signal.
As with other types of memory, the stack memory appears to be
contiguous in virtual process memory, but not necessarily so in
physical memory.
Shared-library memory
Shared-library memory stores the libraries you require for your
process. Like program memory, library memory consists of both code
and data sections. In the case of shared libraries, all the processes map
to the same physical location for the code section and to unique
locations for the data section:
230
Chapter 10 Finding Memory Errors
July 30, 2004
Introduction
 2004, QNX Software Systems Ltd.
Program 1's
virtual memory
Mapping
Physical memory
Program 1
library code
Library
code
Program 1
library data
Data
Program 2's
virtual memory
Data
CommonLibrary.so
&loops
int loops = 0;
Counterfunction() {
for (loops= ; ;) {
...
}
}
Program 2
library code
&loops
Program 2
library data
Object memory
Object memory represents the areas that map into a program’s virtual
memory space, but this memory may be associated with a physical
device. For example, the graphics driver may map the video card’s
memory to an area of the program’s address space:
Video
screen
Graphics driver's
virtual memory
Object
memory
Mapping
Physical memory
Video
card
Video
memory
Heap memory
Heap memory represents the dynamic memory used by programs at
runtime. Typically, processes allocate this memory using the malloc(),
realloc(), and free() functions.These calls ultimately rely on the
mmap()function to reserve memory that the malloc library
distributes.
The process manager usually allocates memory in 4K blocks, but
allocations are typically much smaller. Since it would be wasteful to
use 4K of physical memory when your program wants only 17 bytes,
the malloc library manages the heap. The library dispenses the
July 30, 2004
Chapter 10 Finding Memory Errors
231
Introduction
 2004, QNX Software Systems Ltd.
paged memory in smaller chunks and keeps track of the allocated and
unused portions of the page:
Program's virtual
memory
malloc library
Free
blocks: 4, 7, 9
Used
blocks: 1, 2, 3,
5, 6, 8, 7
malloc( ... )
9
8
7
6
Page block
5
4
3
Legend:
2
Used
1
Overhead
Free
Each allocation uses a small amount of fixed overhead to store
internal data structures. Since there’s a fixed overhead with respect to
block size, the ratio of allocator overhead to data payload will be
larger for smaller allocation requests.
When your program uses the malloc() function to request a block of
memory, the malloc library returns the address of an appropriately
sized block. To maintain constant-time allocations, the malloc
library may break some memory into fixed blocks. For example, the
library may return a 20-byte block to fulfill a request for 17 bytes, a
1088-byte block for a 1088-byte request, and so on.
When the malloc library receives an allocation request that it can’t
meet with its existing heap, the library requests additional physical
232
Chapter 10 Finding Memory Errors
July 30, 2004
Introduction
 2004, QNX Software Systems Ltd.
memory from the process manager. As your program frees memory,
the library merges adjacent free blocks to form larger free blocks
wherever possible. If an entire memory page becomes free as a result,
the library returns that page to the system. The heap thus grows and
shrinks in 4K increments:
Program's virtual
memory
Mapping
Physical memory
Growth
What the Memory Analysis perspective can reveal
The main system allocator has been instrumented to keep track of
statistics associated with allocating and freeing memory. This lets the
memory statistics module nonintrusively inspect any process’s
memory usage.
When you launch your program with the Memory Trace tool, your
program uses the debug version of the malloc library
(libmalloc g.so). Besides the normal statistics, this library also
tracks the history of every allocation and deallocation, and provides
cover functions for the string and memory functions (e.g.
strcmp(),memcpy(),memmove()). Each cover function validates the
corresponding function’s arguments before using them. For example,
if you allocate 16 bytes, then forget the terminating null character and
attempt to copy a 16-byte string into the block using the strcpy()
function, the library detects the error.
July 30, 2004
Chapter 10 Finding Memory Errors
233
Introduction
 2004, QNX Software Systems Ltd.
The debug version of the malloc library uses more memory than the
nondebug version. When tracing all calls to malloc() and free(), the
library requires additional CPU overhead to process and store the
memory-trace events.
The Memory Analysis perspective can help you pinpoint and solve
various kinds of problems, including:
memory leaks
memory errors
stack errors
inefficient heap usage
Memory leaks
Memory leaks can occur if your program allocates memory and then
forgets to free it later. Over time, your program consumes more
memory than it actually needs.
In its mildest form, a memory leak means that your program uses
more memory than it should. QNX Neutrino keeps track of the exact
memory your program uses, so once your program terminates, the
system recovers all the memory, including the lost memory.
If your program has a severe leak, or leaks slowly but never
terminates, it could consume all memory, perhaps even causing
certain system services to fail.
These tools in the Memory Analysis perspective can help you find and
fix memory leaks:
Malloc Information view — you can watch your program’s heap
usage and see if it increases over time.
Memory Events view — shows you all the instances where you
program allocates, reallocates, and frees memory. The view lets
you hide allocations that have a matching call to free(); the
remaining allocations are either still in use or forgotten.
234
Chapter 10 Finding Memory Errors
July 30, 2004
 2004, QNX Software Systems Ltd.
Introduction
Memory errors
Memory errors can occur if your program tries to free the same
memory twice or uses a stale or invalid pointer. These “silent” errors
can cause surprising, random application crashes. The source of the
error can be extremely difficult to find, because the incorrect
operation could have happened in a different section of code long
before an innocent operation triggered a crash.
In the event of a such an error, the IDE can stop your program’s
execution and let you see all the allocations that led up to the error.
The Memory Events view displays memory events, together with a
timestamp and the exact line of source code that generated each event.
The view lets you find the prior call that accessed the same memory
address, even if your program made the call days earlier.
Stack errors
Stack errors can occur if your program contains functions that are
deeply recursive or use a significant amount of local data. Errors of
this sort can be difficult to find using conventional testing; although
your program seems to work properly during testing, the system could
fail in the field, likely when your system is busiest and is needed the
most.
The Memory Information view lets you see how much stack memory
your program and its threads use. The view can warn you of potential
stack errors.
Inefficient heap usage
Your program can experience problems if it uses the heap
inefficiently. Memory-allocation operations are expensive, so your
program may run slowly if it repeatedly allocates and frees memory,
or continuously reallocates memory in small chunks.
The Malloc Information view displays a count of your program’s
memory allocations; if your program has an unusually high turnover
rate, this might mean that the program is allocating and freeing more
memory than it should.
July 30, 2004
Chapter 10 Finding Memory Errors
235
Analyzing your program
 2004, QNX Software Systems Ltd.
You may also find that your program uses a surprising amount of
memory, even though you were careful not to allocate more memory
than you required. Programs that make many small allocations can
incur substantial overhead.
The Malloc Information view lets you see the amount of overhead
memory the malloc library uses to manage your program’s heap. If
the overhead is substantial, you can review the data structures and
algorithms used by your program, and then make adjustments so that
your program uses its memory resources more efficiently. The Malloc
Information view lets you track your program’s reduction in overall
memory usage.
☞
To learn more about the common causes of memory problems, see
Heap Analysis: Making Memory Errors a Thing of the Past in the
QNX Neutrino Programmer’s Guide.
Analyzing your program
To extract the most information from your program, you should
launch it with the Memory Trace tool enabled:
236
1
Create a Run or Debug type of QNX Application launch
configuration as you normally would, but don’t click Run or
Debug.
2
In the launch configuration dialog, click the Tools tab.
3
Click Add/Delete Tool.
4
In the Tools Selection dialog, check the Memory Trace tool.
5
Click OK.
6
Click the Memory Trace tab.
7
Configure the Memory Trace settings for your program:
Chapter 10 Finding Memory Errors
July 30, 2004
Analyzing your program
 2004, QNX Software Systems Ltd.
Memory Event Action
The action you wish the IDE to take when it detects a
memory error. The default is to attach to the process with
the debugger, but the IDE can also ignore the error or
cause the program to terminate.
Full memory allocation/deallocation trace
By default, the IDE logs every allocation/deallocation
that the program makes. If you turn this option off, the
IDE records only memory errors. If you want to use the
Allocation Trace tab in the Memory Events view, make
sure this option is on.
Note that full tracing can substantially slow down
programs that allocate and free a lot of memory. It also
generates significant traffic on the communications
medium.
July 30, 2004
Chapter 10 Finding Memory Errors
237
Manually launching a program for memory tracing
 2004, QNX Software Systems Ltd.
Display console debug output
The preloaded library can display diagnostic messages to
the program’s stderr when it encounters an error. If this
option is on, the information appears in the Console view.
Malloc Library
The name of the malloc library used by the Memory
Trace tool on the target. The default of
libmalloc g.so should suffice.
Memory Device
The device on the target to which all memory-event data
is sent. The default of /dev/dbgmem should suffice.
8
If you want the IDE to automatically change to the QNX
Memory Analysis perspective when you run or debug, check
Switch to this tool’s perspective on launch.
9
Click Apply to save your changes.
10
Click Run or Debug. The IDE starts your program and lets you
analyze your program’s memory.
Manually launching a program for memory
tracing
You can manually launch an application on your target without using
the IDE for the launch, yet still have the application convey
memory-trace information back to your host where you can use the
IDE to monitor the target.
To support memory analysis, you preload the debug malloc shared
library (dbgmallog g.so) before the standard C shared library.
There’s no need to recompile your application with any additional
special options.
238
Chapter 10 Finding Memory Errors
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Manually launching a program for memory tracing
To properly map memory trace information to specific lines of code,
you must tell the compiler to produce DWARF format debug
information instead of the default STABS+.
Use the -Wc,-gdwarf-2 and -Wl,-gdwarf-2 options to qcc or the
-gdwarf-2 option to gcc.
For applications that link statically, you’ll have to manually link
against the debug malloc shared library, rather than use the
LD PRELOAD mechanism described below. All other settings
should be equally valid.
Preparing your host and the target agent
1
Ensure that the target agent (qconn) is running on your target
system.
2
Prepare the host and target agent to receive memory
information.
Since the application isn’t being launched from the IDE, you
must manually start the thread that gathers memory
information:
2a
Open the Target Navigator (Window→Show
View→Other. . . →QNX Targets).
2b
Create a new target connection to the embedded system if
required (right-click the Target Navigator and select Add
New Target).
2c
Right-click the target and make sure Watch Memory
Events is checked.
At this point, the IDE has communicated with the target agent
and informed it to expect to receive memory-trace data. You’ll
likely want to switch to the Memory Analysis Perspective to
see the results of the trace.
3
July 30, 2004
Launch the application on the target.
Chapter 10 Finding Memory Errors
239
Tracing memory events
 2004, QNX Software Systems Ltd.
The debug malloc library uses environment variables to drive its
logging behavior. You should launch your application with the
following variables defined in addition to the LD PRELOAD
value (if your application hasn’t been compiled statically):
MALLOC DEBUG
Enables checking of errors and generation of events if set.
MALLOC EVENTFILE
Indicates where to log the memory errors to. This should
be set to /dev/dbgmem (a file managed by qconn).
MALLOC TRACE
Indicates where to log the malloc/realloc/free trace
information. This should be set to /dev/dbgmem as well.
If this isn’t set, the trace information isn’t logged.
For example, assuming you have an application named myapp,
you would set:
LD PRELOAD=/usr/lib/libmalloc g.so MALLOC DEBUG=1 \
MALLOC EVENTFILE=/dev/dbgmem MALLOC TRACE=/dev/dbgmem myapp
Or, if myapp was linked statically against libmalloc g.so
already:
MALLOC DEBUG=1 MALLOC EVENTFILE=/dev/dbgmem MALLOC TRACE=/dev/dbgmem myapp
4
Now you can watch the results being gathered in the IDE. Any
errors and allocation traces captured will be logged into the
Memory Analysis view (assuming you have turned on
MALLOC DEBUGM and MALLOC TRACE and set them
to /dev/dbgmem).
Tracing memory events
The Memory Events view categorizes memory errors by target and
launch configuration:
240
Chapter 10 Finding Memory Errors
July 30, 2004
Tracing memory events
 2004, QNX Software Systems Ltd.
Error events tree
The Error events tree pane displays the following as a hierarchical
tree:
Session item
Description
Icons
Target
The target’s hostname. The value is specified
in the target’s /etc/hosts file; a root user
can set this value manually on the target using
the hostname myNewName command (see the
Utilities Reference).
Process
The process filename and PID (e.g.
mem102 g(5222434))
Memory error category
Description of the error (e.g. Pointer
within malloc region, but outside
of malloc data bounds)
continued. . .
July 30, 2004
Chapter 10 Finding Memory Errors
241
Tracing memory events
 2004, QNX Software Systems Ltd.
Session item
Description
Icons
Memory error source
Origin of the error, including the function name
as well as the source filename and line number,
if available (e.g. main
[C:/QNXsdk/workspace/mem102/mem102.c:13])
Particular memory event
The type of event (e.g. allocation trace). When
you select a particular event, the Event
backtrace pane shows the event’s details. If
you double-click a particular event, the IDE
highlights the event’s corresponding source
code line (if it exists).
To clear the Error events tree pane:
➤ Right-click a target instance, executable, or white space, and
select Clear. The IDE removes your selection. If you click
white space, the IDE clears the entire list.
To jump to a memory error that you have the source for:
➤ Double-click an error in the Error events tree or Allocation
Trace panes.
To toggle between long and short names of the source files:
➤ Click the Show long pathnames/Show short pathnames
button ( ) in the Memory Event view’s toolbar.
Event backtrace pane
The Event backtrace pane displays a call stack trace leading up to
your selected memory error.
To display error information in the Event Backtrace pane:
➤ Click on a memory error
242
Chapter 10 Finding Memory Errors
in the Error events tree pane.
July 30, 2004
 2004, QNX Software Systems Ltd.
Tracing memory events
Allocation Trace tab
The Allocation Trace tab displays a table containing all the allocation
events that are generated by the process you’ve selected in the Error
events tree pane.
Two adjacent tabs — Unmatched allocations and Unmatched
deallocations — show subsets of the information displayed in the
Allocation Trace tab. (See below for details.)
Note that the event information is available only if you enabled Full
memory allocation/deallocation trace when you configured the
Memory Trace tool:
The table in the Allocation Trace tab includes the following columns:
July 30, 2004
Range
The group of events being examined.
Call type
How the memory was changed via malloc(),
realloc(), or free() calls. Remember that a call to
realloc() with a size of 0 is the same as a call to
free().
Call #
The sequential order of the allocations, starting from
0.
Chapter 10 Finding Memory Errors
243
Tracing memory events
 2004, QNX Software Systems Ltd.
Pointer
The pointer to the block of memory that was
allocated, reallocated, or freed.
Length
The size (in bytes) of the memory segment (for
malloc() only).
Calling address
The location in code where the memory change was
called. The entry might show the library (e.g.
libc.so.2
(atexit+0x0000001D)0xB031D34D), the
absolute address (e.g. 0xB0319AA6), or the line of
code (e.g.
(main+0x0000001A)main[mem102:c22]).
Match call #
Call number of the corresponding event (e.g. a
malloc() call is shown for its corresponding free()).
Match call address
The location in the source code where the
matched-call operation happened (if available).
To display error information in the Allocation Trace tab:
➤ Click an executable (
memory error source (
), memory error category (
), or
) in the Error events tree pane.
To exclude memory events that are external to your program, such as
the events associated with system libraries:
➤ In the Memory Events view’s toolbar menu, select
Show→Events with Source Only.
244
Chapter 10 Finding Memory Errors
July 30, 2004
 2004, QNX Software Systems Ltd.
Controlling your memory analysis session
Unmatched allocations tab
This tab shows only the allocations that don’t have a matching
deallocation. You can use this tab to display actual memory leaks.
Unmatched deallocations
This tab shows the list of memory free events that weren’t coupled
with corresponding mallocs/reallocs.
Controlling your memory analysis session
The Target Navigator view lets you control the information
displayed by the following views:
Malloc Information
Memory Information
For more information on the Target Navigator view, see the Getting
System Information chapter.
To control the display in the Malloc Information or Memory
Information view:
➤ In the Target Navigator view, expand a target and select a
process:
July 30, 2004
Chapter 10 Finding Memory Errors
245
Examining your target’s memory
 2004, QNX Software Systems Ltd.
Examining your target’s memory
Two views in the Memory Analysis perspective are especially useful
for examining the memory of your target system:
Malloc Information view (for heap usage and other details)
Memory Information view (for examining virtual address space)
Malloc Information view
The Malloc Information view displays statistical information from the
general-purpose, process-level memory allocator:
When you select a process in the Target Navigator view, the IDE
queries the target system and retrieves the allocator’s statistics. The
IDE gathers statistics for the number of bytes that are allocated, in
use, and overhead.
246
Chapter 10 Finding Memory Errors
July 30, 2004
 2004, QNX Software Systems Ltd.
Examining your target’s memory
The Malloc Information view refreshes its display once per second.
The view includes the following panes:
Total Heap
Calls Made
Core Requests
Distribution
History
Total Heap
The Total Heap pane shows your total heap memory, which is the sum
of the following states of memory:
Used (dark blue)
Overhead (turquoise)
Free (lavender)
The bar chart shows the relative size of each.
Calls Made
The Calls Made pane shows the number of times a process has
allocated, freed, or reallocated memory by calling malloc(), free(),
and realloc() functions. (See the Library Reference.)
Core Requests
The Core Requests pane displays the number of allocations that the
system allocator automatically made to accommodate the needs of the
program you selected in the Target Navigator view. The system
allocator dispenses memory in increments of 4K (one page).
The number of allocations will never equal the number of
deallocations, because when the program starts, it allocates memory
that isn’t released until it terminates.
July 30, 2004
Chapter 10 Finding Memory Errors
247
Examining your target’s memory
 2004, QNX Software Systems Ltd.
Distribution
The Distribution pane shows a distribution of the memory allocation
sizes. The pane includes the following columns:
Byte Range
The size range of the memory blocks.
Total mallocs and frees
The total number of calls that effectively allocate or
free memory. For example, if your program
reallocated memory from 10 bytes to 20 bytes, both
the free count for the 0-16 byte range and the malloc
count for the 17-24 range would increment.
Allocated
The remaining number of allocated blocks. The value
is equal to the number of allocations minus the
number of deallocations.
% Returned
The ratio of freed blocks to allocated blocks,
expressed as a percentage. The value is calculated as
the number of deallocations divided by the number of
allocations.
Usage (min/max)
The calculated minimum and maximum memory
usage for a byte range. The values are calculated by
multiplying the number of allocated blocks by the
minimum and maximum sizes of the range. For
example, if the 65-80 byte range had two blocks
allocated, the usage would be 130/160. You should
use these values for estimated memory usage only;
the actual memory usage will usually lie somewhere
in between.
History
The History pane shows a chronology of the heap usage shown in the
Total Heap pane. The pane automatically rescales as the selected
process increases its total heap.
248
Chapter 10 Finding Memory Errors
July 30, 2004
Examining your target’s memory
 2004, QNX Software Systems Ltd.
The History pane updates the data every second, with a granularity of
1K. Thus, two 512-byte allocations made over several seconds trigger
one update.
☞
You can choose to hide or display the Distribution and History panes:
1
In the Malloc Information view’s title bar, click the dropdown
menu button (
2
), followed by Show.
Click the pane you want displayed.
Virtual address space
The Memory Information view displays the memory used by the
process you select in the Target Navigator view:
The view shows the following major categories of memory usage:
Stack (red)
- guard (light)
- unallocated (medium)
- allocated (dark)
Program (royal blue)
July 30, 2004
Chapter 10 Finding Memory Errors
249
Examining your target’s memory
 2004, QNX Software Systems Ltd.
- data (light)
- code (dark)
Heap (blue violet)
Objects (powder blue)
Shared Library (green)
- data (light)
- code (dark)
Unused (white)
The Process Memory pane shows the overall memory usage. To keep
large sections of memory from visually overwhelming smaller
sections, the view scales the display semilogarithmically and indicates
compressed sections with a split.
Below the Process Memory pane, the Process Memory subpane
shows your selected memory category (e.g. Stack, Library) linearly.
The subpane colors the memory by subcategory (e.g. a stack’s guard
page), and shows unused memory.
The Memory Information view’s table lists all the memory segments
and the associated virtual address, size, permissions, and offset. The
major categories list the total sizes for the subcategories (e.g. Library
lists the sizes for code/data in the Size column). The Process Memory
pane and subpane update their displays as you make selections in the
table.
The Memory Information view’s table includes the following
columns:
250
Name
The name of the category.
V. Addr.
The virtual address of the memory.
Size
The size of the section of memory. For the major
categories, the column lists the totals for the minor
categories. For example, a listing of 312K/16K beside
Chapter 10 Finding Memory Errors
July 30, 2004
 2004, QNX Software Systems Ltd.
Examining your target’s memory
the Library entry indicates that the total was 312K for
data, 16K for code.
Map Flags
The flags and protection bits for the memory block.
See the mmap() function’s flags and prot arguments in
the Library Reference.
Offset
The memory block’s offset into shared memory, which
is equal to the mmap() function’s off argument.
To toggle the Memory Information view’s table arrangement between
a flat list and a categorized list:
➤ Select the dropdown menu ( ) in the Memory Information
view’s title bar and select Categorize.
July 30, 2004
Chapter 10 Finding Memory Errors
251
Chapter 11
Getting System Information
In this chapter. . .
Introduction 255
What the System Information perspective reveals 256
Controlling your system information session 260
Examining your target system’s attributes 263
Watching your processes 264
Tracking thread activity 266
Inspecting virtual address space 269
Tracking heap usage 269
Examining process signals 270
Getting channel information 271
Tracking file descriptors 273
Tracking resource usage 274
July 30, 2004
Chapter 11 Getting System Information
253
Introduction
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter shows you how to work with the System Information perspective.
Introduction
The IDE provides a rich environment not only for developing and
maintaining your software, but also for examining the details of your
running target systems.
Within the IDE, you’ll find several views whose goal is to provide
answers to such questions as: Are my processes running? What state
are they in? What resources are being used, and by which processes?
Which processes/threads are communicating with which other
processes/threads?
Such questions play an important role in your overall system design.
The answers to these questions often lie beyond examining a single
process or thread, as well as beyond the scope of a single tool, which
is why a structured suite of integrated tools can prove so invaluable.
The tools discussed in this chapter are designed to be mixed and
matched with the rest of the IDE’s development components to help
you gain insight into your system and thereby develop better products.
July 30, 2004
Chapter 11 Getting System Information
255
What the System Information perspective reveals
 2004, QNX Software Systems Ltd.
What the System Information perspective
reveals
The System Information perspective provides a complete and detailed
report on your system’s resource allocation and use, along with key
metrics such as CPU usage, program layout, the interaction of
different programs, and more:
The perspective’s metrics may prove useful throughout your
development cycle, from writing and debugging your code through
your quality-control strategy.
Key terms
Before we describe how to work with the System Information
perspective, let’s first briefly discuss the terms used in the perspective
itself. The main items are:
thread
256
The minimum “unit of execution” that can be scheduled
to run.
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
process
What the System Information perspective reveals
A “container” for threads, defining the virtual address
space within which threads will execute. A process will
always contain at least one thread. Each process has its
own set of virtual addresses, typically ranging from 0 to
4G.
Threads within a process share the same virtual memory
space, but have their own stack. This common address
space lets threads within the process easily access shared
code and data, and lets you optimize or group common
functionality, while still providing process-level
protection from the rest of the system.
scheduling priority
Neutrino uses priorities to establish the order in which
threads get to execute when multiple threads are
competing for CPU time.
Each thread can have a scheduling priority ranging from
1 to 255 (the highest priority), independent of the
scheduling policy. The special idle thread (in the process
manager) has priority 0 and is always ready to run. A
thread inherits the priority of its parent thread by default.
You can set a thread’s priority using the
pthread setschedparam() function.
scheduling policy
When two or more threads share the same priority (i.e.
the threads are directly competing with each other for the
CPU), the OS relies on the threads’ scheduling policy to
determine which thread should run next. Three policies
are available:
Round-robin
FIFO
sporadic
You can set a thread’s scheduling policy using the
pthread setschedparam() function or you can start a
July 30, 2004
Chapter 11 Getting System Information
257
What the System Information perspective reveals
 2004, QNX Software Systems Ltd.
process with a specific priority and policy by using the
on -p command (see the Utilities Reference for details).
state
Only one thread can actually run at any one time. If a
thread isn’t in this RUNNING state, it must either be
READY or BLOCKED (or in one of the many “blocked”
variants).
message passing
The most fundamental form of communication in
Neutrino. The OS relays messages from thread to thread
via a send-receive-reply protocol. For example, if a
thread calls MsgSend(), but the server hasn’t yet received
the message, the thread would be SEND-blocked; a
thread waiting for an answer is REPLY-blocked, and so
on.
channel
Message passing is directed towards channels and
connections, rather than targeted directly from thread to
thread. A thread that wishes to receive messages first
creates a channel; another thread that wishes to send a
message to that thread must first make a connection by
“attaching” to that channel.
signal
Asynchronous event notifications that can be sent to your
process. Signals may include:
simple alarms based on a previously set timer
a notification of unauthorized access of memory or
hardware
a request for termination
user-definable alerts.
The OS supports the 32 standard POSIX signals (as in
UNIX) as well as the POSIX realtime signals. The
POSIX signals interface specifies how signals target a
particular process, not a specific thread. To ensure that
signals go to a thread that can handle specific signals,
258
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
What the System Information perspective reveals
many applications mask most signals from all but one
thread.
You can specify the action associated with a signal by
using the sigaction() function, and block signals by using
sigprocmask(). You can send signals by using the raise()
function, or send them manually using the Target
Navigator view (see “Sending a signal” below).
☞
For more information on all these terms and concepts, see the QNX
Neutrino Microkernel chapter in the System Architecture guide.
The views in this perspective
You use the views in the System Information perspective for these
main tasks:
July 30, 2004
To:
Use this view:
Control your system information session.
Target Navigator
Examine your target system’s attributes.
System Summary
Watch your processes.
Process Information
Track thread activity.
Thread Information
Inspect virtual address space.
Memory Information
Track heap usage.
Malloc Information
Examine process signals.
Signal Information
Get channel information.
System Blocking
Graph
Track file descriptors.
Connection
Information
Track resource usage.
System Resources
Chapter 11 Getting System Information
259
Controlling your system information session
 2004, QNX Software Systems Ltd.
Controlling your system information
session
The selections you make in the Target Navigator view control the
information you see in the System Information perspective:
You can customize the Target Navigator view to:
sort processes by PID (process ID) or by name
group processes by PID family
control the refresh rate.
To access the Target Navigator view’s customization menu, click the
menu button (
) in the Target Navigator view’s title bar.
You can reverse the sort order by clicking the Reverse sort button
(
260
) in the view’s title bar.
Chapter 11 Getting System Information
July 30, 2004
Controlling your system information session
 2004, QNX Software Systems Ltd.
Sending a signal
The Target Navigator view lets you send signals to the processes on
your target. For example, you can terminate a process by sending it a
SIGTERM signal.
To send a signal to a process:
!
1
In the Target Navigator view, right-click a process and select
Deliver Signal.
2
Select a signal from the dropdown menu.
3
Click OK. The IDE delivers the signal to your selected process.
CAUTION: Delivering a signal to a process will, in most cases, cause
that process to terminate.
Updating the views
To update the views in the System Information perspective:
➤ In the Target Navigator view, expand a target and select a
process. (You can also select groups of processes by using the
Ctrl or Shift keys.) The views reflect your selection.
By default, the IDE refreshes the views in the System Information
perspective every five seconds, but you can customize the frequency:
1
In the Target Navigator view, click the menu dropdown button
(
July 30, 2004
), then select Refresh.
Chapter 11 Getting System Information
261
Controlling your system information session
2
 2004, QNX Software Systems Ltd.
Select either:
Manual
Note that the views don’t update until you make a
new selection in the Target Navigator view or
click the Refresh button (
some views:
Periodic
) in the title bar of
The views are refreshed at the rate you specify. To
change the rate, select Set Rate and type a new
value in the Refresh rate dialog.
Adding views to the System Information perspective
By default, some views don’t appear in the System Information
perspective. To add a view to the perspective:
262
1
From the main menu, select Window→Show View→Other. . . .
2
Expand the QNX System Information item and select a view.
3
Click OK. The view appears in your perspective.
4
If you want to save a customized set of views as a new
perspective, select Window→Save Perspective As from the
main menu.
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Examining your target system’s attributes
Some of the views associated with the System Information
perspective can add a noticeable processing load to your host CPU.
You can improve its performance by:
Closing the System Information perspective when you’re not using
it.
Closing unneeded views within the perspective. You can instantly
reopen all the closed views by selecting Window→Reset
Perspective from the main menu.
Reducing the refresh rate (as described above).
Examining your target system’s attributes
The System Summary view displays a listing of your target’s system
attributes, including your target’s processor(s), memory, active
servers, and processes:
July 30, 2004
Chapter 11 Getting System Information
263
Watching your processes
 2004, QNX Software Systems Ltd.
The System Summary view includes the following panes:
System Specifications
System Memory
Processes
System Specifications pane
The System Specifications pane displays your system’s hostname,
board type, OS version, boot date, and CPU information. If your
target is an SMP system, the pane lists CPU information for each
processor.
System Memory pane
The System Memory pane displays your system’s total memory and
free memory in numerical and graphical form.
Processes pane
The Processes pane displays the process name, heap usage, CPU
usage time, and start time for the processes running on your selected
target. The pane lets you see application processes, server processes,
or both.
Watching your processes
The Process Information view displays information about the
processes you select in the Target Navigator view. The view shows
the name of the process, its arguments, environment variables, and so
on. The view also shows the threads in the process and the states of
each thread:
264
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
Watching your processes
The Process Information view includes the following panes:
Arguments
Thread Details
Environment Variables
Identification Details
July 30, 2004
Chapter 11 Getting System Information
265
Tracking thread activity
 2004, QNX Software Systems Ltd.
Arguments pane
The Arguments pane shows the arguments that were used to start your
selected process as they were passed to your process, but not
necessarily as you typed them. For example, if you type ws *.c, the
pane might show ws cursor.c io.c my.c phditto.c
swaprelay.c, since the shell expands the *.c before launching the
program.
Thread Details pane
The Thread Details pane shows some fixed information about your
selected process’s threads, including the thread’s ID, priority,
scheduling policy, state, and stack usage. You can get more
information about threads and their attributes by using the Thread
Information view (see “Tracking thread activity” in this chapter).
Environment Variables pane
The Environment Variables pane provides the values of the
environment variables that are set for your selected process. (For
more information, see the Commonly Used Environment Variables
appendix in the Utilities Reference.
Identification Details pane
The Identification Details pane provides the values of the process’s
IDs: real user, effective user, real group, and effective group.
These values determine which permissions are used for your program.
For example, if you start a process as root, but use the seteuid() and
setegid() functions to run the program as the user jsmith, the
program runs with jsmith’s permissions. By default, all programs
launched from the IDE run as root.
Tracking thread activity
The Thread Information view displays the attributes of the threads
that are associated with the process or processes you select in the
Target Navigator view:
266
Chapter 11 Getting System Information
July 30, 2004
Tracking thread activity
 2004, QNX Software Systems Ltd.
The Thread Information view lets you display a substantial amount of
information about your threads, but some of the column entries aren’t
shown by default.
To configure the information displayed in the Thread Information
view:
1
In the Thread Information view, click the menu dropdown
button (
2
July 30, 2004
).
Select Configure. The Configure dialog appears:
Chapter 11 Getting System Information
267
Tracking thread activity
3
 2004, QNX Software Systems Ltd.
You can:
Add entries to the view by selecting items from the
Available Items list and clicking Add.
Remove entries from the view by selecting items in the New
Items list and clicking Remove.
Adjust the order of the entries by selecting items in the New
Items list and clicking Shift Up or Shift Down.
4
Click OK. The view displays the entries that you specified in
the New Items list.
To see a listing that combines the Process and Thread entries in a tree:
1
In the Thread Information view, click the menu dropdown
button (
2
268
).
Select Tree View.
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
Inspecting virtual address space
Inspecting virtual address space
The Memory Information view displays the memory used by the
process you select in the Target Navigator view:
For details on the Memory Information view, see the “Virtual address
space (Memory Information view)” section in the Finding Memory
Errors chapter in this guide.
Tracking heap usage
The Malloc Information view displays statistical information from
the general-purpose, process-level memory allocator:
July 30, 2004
Chapter 11 Getting System Information
269
Examining process signals
 2004, QNX Software Systems Ltd.
For details on the Malloc Information view, see the “Heap (Malloc
Information view)” section in the Finding Memory Errors chapter in
this guide.
Examining process signals
The Signal Information view shows the signal maps for the
processes selected in the Target Navigator view. If you hover over a
signal, you’ll see information about specific signals for a specific
thread or process:
270
Chapter 11 Getting System Information
July 30, 2004
Getting channel information
 2004, QNX Software Systems Ltd.
The view includes a color-coded map showing signals that are:
ignored (blue) — applies to the entire process
blocked (red) — applies to individual threads
pending (green)
enabled (white).
You can send a signal to any process by using the Target Navigator
view (see the section “Sending a signal” in this chapter.)
Getting channel information
The System Blocking Graph view presents a color-coded display of
all the active channels in the system and illustrates the interaction of
threads with those channels.
Interaction with resource objects are such that a thread can be blocked
waiting for access to the resource or waiting for servicing (i.e. the
thread is SEND-blocked on a channel).
July 30, 2004
Chapter 11 Getting System Information
271
Getting channel information
 2004, QNX Software Systems Ltd.
The thread could also be blocked waiting for a resource to be released
back to the thread or waiting for servicing to terminate (i.e. the thread
is REPLY-blocked).
Clients in such conditions are shown on the left side of the graph, and
the resource under examination is in the middle. Threads that are
waiting to service a request or are active owners of a resource, or are
actively servicing a request, are displayed on the right side of the
graph:
In terms of “classical” QNX terminology, you can think of the items
in the legend at the top of the graph like this:
Legend item
Thread state
Servicing request
Not RECEIVE-blocked (e.g. RUNNING,
blocked on a mutex, etc.)
Waiting for request
RECEIVE-blocked
continued. . .
272
Chapter 11 Getting System Information
July 30, 2004
Tracking file descriptors
 2004, QNX Software Systems Ltd.
Legend item
Thread state
Waiting for reply
REPLY-blocked
Waiting for service
SEND-blocked
Tracking file descriptors
The Connection Information view displays the file descriptors,
server, and connection flags related to your selected process’s
connections. The view also shows (where applicable) the pathname of
the resource that the process accesses through the connection:
The information in this view comes from the individual resource
manager servers that are providing the connection. Certain resource
managers may not have the ability to return all the requested
information, so some fields will be left blank.
July 30, 2004
Chapter 11 Getting System Information
273
Tracking resource usage
 2004, QNX Software Systems Ltd.
The IOFlags column describes the read (r) and write (w) status of the
file. A double dash (--) indicates no read or write permission; a blank
indicates that the information isn’t available.
The Seek Offset column indicates the connector’s offset from the start
of the file.
Note that for some FDs, an “s” appears beside the number. This
means that the FD in question was created via a side channel — the
connection ID is returned from a different space than file descriptors,
so the ID is actually greater than any valid file descriptor.
For more information on side channels, see ConnectAttach() in the
Library Reference.
To see the full side channel number:
1
In the Connection Information view, click the menu dropdown
button (
2
).
Select Full Side Channels.
Tracking resource usage
The System Resources view shows various pieces of information
about your system’s processes. You can choose one of the following
displays:
System Uptime
General Resources
Memory Resources
To select which display you want to see, click the menu dropdown
button (
) in the System Resources view.
System Uptime display
The System Uptime display provides information about the start time,
CPU usage time, and the usage as a percent of the total uptime, for all
the processes running on your selected target:
274
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
Tracking resource usage
General Resources display
The General Resources display provides information about CPU
usage, heap size, and the number of open file descriptors, for all the
processes running on your selected target.
July 30, 2004
Chapter 11 Getting System Information
275
Tracking resource usage
 2004, QNX Software Systems Ltd.
Memory Resources display
The Memory Resources display provides information about the heap,
program, library, and stack usage for each process running on your
selected target:
276
Chapter 11 Getting System Information
July 30, 2004
 2004, QNX Software Systems Ltd.
Tracking resource usage
To learn more about the meaning of the values shown in the Memory
Resources display, see the Finding Memory Errors chapter in this
guide.
July 30, 2004
Chapter 11 Getting System Information
277
Chapter 12
Analyzing Your System with Kernel
Tracing
In this chapter. . .
Introducing the QNX System Profiler 281
Configuring a target for system profiling 285
Capturing instrumentation data in event log files 289
Viewing and interpreting the captured data 291
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
279
Introducing the QNX System Profiler
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
Use the System Profiler to analyze your system via instrumentation.
Introducing the QNX System Profiler
The System Profiler is a tool that works in concert with the Neutrino
instrumented kernel (procnto-instr) to provide insight into the
operating system’s events and activities. Think of the System Profiler
as a system-level software logic analyzer. Like the Application
Profiler, the System Profiler can help pinpoint areas that need
improvement, but at a system-wide level.
The instrumented kernel can gather a variety of events, including:
kernel calls
process manager activities
interrupts
scheduler changes
context switches
user-defined trace data
You might use the System Profiler to solve such problems as:
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
281
Introducing the QNX System Profiler
 2004, QNX Software Systems Ltd.
IPC bottlenecks (by observing the flow of messages among
threads)
resource contention (by watching threads as they change states)
cache coherency in an SMP machine (by watching threads as they
migrate from one CPU to another).
☞
Details on kernel instrumentation (such as types and classes of events)
are more fully covered in the System Analysis Toolkit (SAT) User’s
Guide.
The QNX System Profiler perspective includes several components
that are relevant to system profiling:
Navigator view
Events are stored in log files (with the extension .kev) within
projects in your workspace. These log files are associated with
the System Profiler editor.
Target Navigator view
When you right-click a target machine in the Target Navigator,
you can select Kernel event tracing, which initiates the Trace
Logging wizard. You use this wizard to specify which events to
capture, the duration of the capture period, as well as specific
details about where the generated event log file (.kev file) will
be stored.
System Profiler editor
This editor provides the graphical representation of the
instrumentation events in the captured log file. Like all other
Eclipse editors, the System Profiler editor shows up in the editor
area and can be brought into any perspective. This editor is
automatically associated with .kev files, but if you have other
file types that contain instrumentation data, you could associate
the editor with those files as well.
282
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Introducing the QNX System Profiler
 2004, QNX Software Systems Ltd.
Trace Event Log view
This view lists instrumentation events, as well as their details
(time, owner, etc.), surrounding the selected position in the
currently active System Profiler editor.
Trace Search panel
Unlike the other search panels in the IDE, the Trace Search
panel can search for events only in the currently active System
Profiler editor. You use this search panel to build conditions and
then combine them into an expression. A search will iterate
through the events from the active log file and be applied
against the expression; “hits” appear in the Search Results view
and are highlighted in the System Profiler’s editor.
Condition Statistics view
A tabular statistical representation of the conditions used in the
search panel.
Event Owner Statistics view
A tabular statistical representation of events broken down per
owner.
General Statistics view
A tabular statistical representation of events.
☞
Statistics can be gathered for the entire log file or for a selected range.
Bookmarks view
Just as you can bookmark lines in a text file, here you can
bookmark particular locations and event ranges displayed in the
System Profiler editor, then see your bookmarked events in the
Bookmarks view.
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
283
Introducing the QNX System Profiler
☞
 2004, QNX Software Systems Ltd.
The System Profiler perspective may produce incorrect results when
more than one IDE is communicating with the same target system. To
use this perspective, make sure only one IDE is connected to the
target system.
Before you begin
As mentioned earlier, in order to capture instrumentation data for
analysis, the instrumented kernel (procnto-instr) must be
running. This kernel is a drop-in replacement for the standard kernel
(though the instrumented kernel is slightly larger).
☞
To know if the instrumented kernel is running, enter this command:
ls /proc/boot
If procnto-instr appears in the output, then the OS image is
running the instrumented kernel.
To substitute the procnto-instr module in the OS image on your
board, you can either manually edit your buildfile, then run mkifs to
generate a new image, or use the System Builder to configure the
image’s properties.
Replacing the kernel using the System Builder
1
In the System Builder Projects view, double-click the
project.bld file for the image you want to change.
284
2
In the Images pane of the Builder’s editor, select the image.
3
In the Properties view, click the Procnto field (under System).
A dropdown-menu button appears in the field:
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
 2004, QNX Software Systems Ltd.
Configuring a target for system profiling
4
Select procnto-instr, press Enter, then save your change.
5
Rebuild your project, then transfer your new OS image to your
board.
Assuming you’re running the instrumented kernel on your board,
you’re ready to use the System Profiler. A profiling session usually
involves these three steps:
Configuring a target for system profiling.
Capturing instrumentation data in event log files.
Viewing and interpreting the captured data.
☞
In order to get timing information from the kernel, you need to be a
root user.
Configuring a target for system profiling
You can gather trace events from the instrumented kernel in two
different ways. You run a command-line utility (e.g. tracelogger)
on your target to generate a log file, and then transfer that log file back
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
285
Configuring a target for system profiling
 2004, QNX Software Systems Ltd.
to your development environment for analysis. Or, you can capture
events directly from the IDE using the Trace Events Configuration
wizard.
Using the command-line server currently offers more flexibility as to
when the data is captured, but requires that you set up and configure
filters yourself using the TraceEvent() API. The Trace Events
Configuration wizard lets you set a variety of different static filters
and configure the duration of time that the events will be logged for.
For more information on the tracelogger utility, see its entry in the
Utilities Reference. For TraceEvent(), see the Library Reference.
Launching the System Profiler Configuration wizard
➤ In the Target Navigator, right-click a target, then select Kernel
Events Tracing.
☞
If you don’t already have a target project, you’ll have to create one:
➤ In the Target Navigator, right-click and select Add New Target.
You can use this target project for a number of different tasks
(debugging, memory analysis, profiling), so once you create it, you
won’t have to worry about connecting to your target again. Note also
that the qconn target agent must be running on your target machine.
Selecting options in the wizard
The wizard takes you through the process of selecting:
the location of the captured log file (both on the target temporarily
and on the host in your workspace)
the duration of the event capture
the size of the kernel buffers
the event-capture filters (to control which events will be captured).
286
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Configuring a target for system profiling
 2004, QNX Software Systems Ltd.
Here are the main fields in this wizard:
July 30, 2004
Log filename
Name you want to use for the kernel events log file
(.kev) in your workspace.
Info filename
Name for the file containing information about the
events log file.
Chapter 12 Analyzing Your System with Kernel Tracing
287
Configuring a target for system profiling
 2004, QNX Software Systems Ltd.
Tracing method, Type (Period of time)
The duration of the capture of events as defined by
a time.
Tracing method, Period length
Floating-point value in seconds representing the
length of time to capture kernel events on the target.
Tracing method, Type (Iterations)
The duration of the capture of events as defined by
the number of kernel event buffers.
Tracing method, Number of Iterations
Total number of full kernel event buffers to log on
the target.
Trace file, Mode (Stream)
In this mode, no file is saved on the target. Kernel
event buffers are directly sent from qconn to the
IDE.
Trace file, Mode (Save on target then upload)
In this mode, kernel event buffers are first saved in a
file on the target, then uploaded to your workspace.
Trace file, Filename on target
Name of the file used to save the kernel event
buffers on the target.
Trace statistics file, Mode (Do not generate)
No file will be generated.
Trace statistics File, Mode (Generate only on the target)
The information file will be generated only on the
target.
Trace statistics File, Mode (Save on target then upload)
The statistical information is first saved in a file on
the target, then uploaded to your workspace.
288
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
 2004, QNX Software Systems Ltd.
Capturing instrumentation data in event log files
Trace statistics File, Filename on target
Name of the file used to save the statistical
information on the target.
Buffers, Number of kernel buffers
Size of the static ring of buffers allocated in the
kernel.
Buffers, Number of qconn buffers
Maximum size of the dynamic ring of buffers
allocated in the qconn target agent.
Capturing instrumentation data in event log
files
Regardless of how your log file is captured, you have a number of
different options for how to regulate the amount of information
actually captured:
On/Off toggling of tracing
Static per-class Off/Fast/Wide mode filters
Static per-event Off/Fast/Wide mode filters
User event-handler filters
(For more information, see the SAT User’s Guide.)
The IDE lets you access the first three of the above filters. You can
enable tracing (currently done by activating the tracing wizard), and
then select what kind of data is logged for various events in the
system.
The events in the system are organized into different classes (kernel
calls, communication, thread states, interrupts, etc). You can toggle
each of these classes in order to indicate whether or not you want to
generate such events for logging.
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
289
Capturing instrumentation data in event log files
 2004, QNX Software Systems Ltd.
The data logged with events comes in two modes:
Fast mode
290
A small-payload data packet that conveys only the
most important aspects of the particular event. Better
for performance.
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
 2004, QNX Software Systems Ltd.
Wide mode
Viewing and interpreting the captured data
A larger-payload data packet that contains a more
complete event definition, with more context. Better
for understanding the data.
Depending on the purpose of the trace, you’ll want to selectively
enable different tracing modes for different types of events so as to
minimize the impact on the overall system. For its part in the analysis
of these events, the IDE will do its best to work with whatever data is
present. (But note that some functionality may not be available for
post-capture analysis if it isn’t present in the raw event log. ;-))
Viewing and interpreting the captured data
Once an event file is generated and transferred back to the
development host for analysis (whether it was done automatically by
the IDE or generated by using tracelogger and manually extracted
back to the IDE), you can then invoke the System Profiler editor.
The IDE includes a custom perspective for working with the System
Profiler. This perspective sets up some of the more relevant views for
easy access.
The System Profiler editor
In order to start examining an event file, the easiest way is to name it
with a .kev (kernel event) extension. Files with this extension are
automatically bound to the System Profiler editor.
The System Profiler editor is the center of all of the analysis activity.
It provides different visualization options for the event data in the log
files:
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
291
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
Timeline presentation (the default)
Displays events associated with their particular owners (i.e.
processes, threads, and interrupts) along with the state of those
particular owners (where it makes sense to do so).
CPU Activity presentation
Displays the CPU activity associated with a particular thread of
process. For a thread, CPU activity is defined as the amount of
runtime for that thread. For a process, CPU activity is the
amount of runtime for all the process’s threads combined.
CPU Usage presentation
Displays the percent of CPU usage associated with all event
owners. CPU usage is the amount of runtime that event owners
get.
Process Activity presentation
Displays CPU usage for an individual selected process or
thread.
The timeline presentation is the default. To choose one of the other
three types, right-click in the editor, then select Display→Type.
Each of these visualizations is available as a “pane” in a stack of
“panes.” Additionally, the visualization panes can be split — you can
292
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
look at the different sections of the same log file and do comparative
analysis.
All panes of the same stack share the same display information. A
new pane inherits the display information of the previous pane, but
becomes independent after it’s created.
To split the display, right-click in the editor, then select
Display→Split. Note that you can lock two panes to each other.
☞
You can have a maximum of four panes.
A number of different features are available from within the editor:
Event owner selection
Clicking on event owners will select them in the IDE.
These selected event owners can then be used by other
components of the IDE (such as Filters and Find).
If an owner has children (e.g. a parent process with
threads), you’ll see an arrow beside the parent’s name.
To see a parent’s children, click the arrow (or press E to
expand, C to collapse).
Filters
Event owners and specific events can be filtered out
using the Event Owner Filters and Event Filters items
in the right-click (context) menu. You can use this
filtering feature to significantly cut down on the
unwanted event “noise” in the display. Once filtered, the
log file can be saved as a new log file (using Save As) to
produce a smaller, more succinct log file for further
examination.
For example, to view only processes that are sending
pulses, right-click in the timeline, then select Event
Owner Filters→Show Only→MsgSend Family.
Find
July 30, 2004
Selecting Ctrl – F (or Edit→Find/Replace) will open up
a dialog that lets you quickly move from event to event.
This is particularly useful when following the flow of
Chapter 12 Analyzing Your System with Kernel Tracing
293
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
activity for a particular event owner or when looking for
particular events.
Markers
You can place markers in the timeline editor just as you
would to annotate text files. Press the B key to add a
marker.
These markers show up in the Bookmarks view and can
represent a range of time or a single particular event
instance.
Cursor tracking
The information from the System Profiler editor is also
made available to other components in the IDE such as
the Trace Event Log and the Trace Event Statistics
views. These views can synchronize with the cursor,
event owner selections, and time ranges, and can adjust
their content accordingly.
IPC representation
The flow of interprocess communication (e.g. messages,
pulses) is represented by a vertical arrow between the
two elements.
You can toggle IPC tracing on/off by pressing I or
clicking this button in the toolbar:
Types of selection
Within the editor, you can select either of the following:
an element (e.g. a thread)
a point in time.
294
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
Elements
To select a single element, simply click the element’s name. To
unselect an element, press and hold the Ctrl key, then click each
selected element’s name.
To select multiple elements, press and hold the Ctrl key, then click
each element’s name.
Time
To select a point in time, click an element on the timeline.
To select a range, click the start point on the timeline, then drag and
release at the end point.
Or, select the start point, then hold down the Shift key and select the
end point.
Zooming
When zooming in, the display will center the selection. If a
time-range selection is smaller than the current display, the display
will adjust to the range selection (or by a factor of two).
When zooming out, the display will center the selection and adjust by
a factor of two.
When using a prefix zoom factor (100% to 0.01%), the display will
center the current selection and adjust to the new factor.
There are various ways to zoom:
right-click menu (Display→Zoom)
toolbar icons
hotkeys (zoom in: + or Space; zoom out: - or Ctrl – Space)
Scrolling
You use these keys to scroll through time:
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
295
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
To move:
Use this key:
The selection to the left by one event.
←
The selection to the right by one event.
→
The display to the right by one page
(horizontal scrollbar thumb size).
Ctrl – Page Up
The display to the left by one page (horizontal
scrollbar thumb size).
Ctrl – Page Down
The display to the beginning of the timeline.
Ctrl – Home
The display to the end of the timeline.
Ctrl – End
You use these keys to scroll through elements:
To move the display:
Use this key:
Up by one element.
↑
Down by one element.
↓
Up by one page (horizontal scrollbar thumb size).
Page Up
Down by one page (horizontal scrollbar thumb
size).
Page Down
To the top of the element list.
Home
To the bottom of the element list.
End
Hovering
When you pause your mouse pointer over an element or an event,
you’ll see relevant information (e.g. PID, timestamps, etc.).
☞
296
Hovering works only on childless elements (i.e. interrupts and
threads).
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
Other views in the System Profiler
There are a number of additional components outside of the editor
that you can use to examine the event data in more detail:
Trace Event Log view
This view can display additional details for the events
surrounding the cursor in the editor. The additional detail
includes the event number, time, class, type as well as decoding
the data associated with a particular event.
Trace Search panel
Invoked by Ctrl – H (or via Search→Search option, this panel
lets you execute more complex event queries than are possible
with the Find dialog.
You can define conditions, which may include regular
expressions for matching particular event data content (e.g. all
MsgSend events whose calling function corresponds to
mmap()). You can then evaluate these conditions and place
annotation directly into the System Profiler editor. The results
are shown in the Search view.
Condition, Event Owner, General Statistics views
These views provide a tabular statistical representation of
particular events. The statistics can be gathered for the entire
log file or for a selected range.
Here’s an example of the General Statistics view:
July 30, 2004
Chapter 12 Analyzing Your System with Kernel Tracing
297
Viewing and interpreting the captured data
 2004, QNX Software Systems Ltd.
Properties view
Shows information about the log file that was captured, such as
the date and time as well as the machine the log file was
captured on.
298
Chapter 12 Analyzing Your System with Kernel Tracing
July 30, 2004
Chapter 13
Common Wizards Reference
In this chapter. . .
Introduction 301
Creating a C/C++ project 303
Creating a target 316
Converting projects 318
July 30, 2004
Chapter 13 Common Wizards Reference
299
Introduction
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This chapter describes the IDE’s wizards.
Introduction
Wizards guide you through a sequence of tasks, such as creating a
new project or converting an existing non-IDE project to a QNX
C/C++ application or library project.
Wizards aren’t directly connected to any perspective. You can access
all the wizards from the main menu by selecting
File→New→Other. . . .
In the New Project dialog, the wizards are categorized according to
the nature of the project. If you select C in the left pane, you’ll see all
projects that have a C nature listed in the right pane; select QNX, and
you’ll see all the projects with a QNX nature:
July 30, 2004
Chapter 13 Common Wizards Reference
301
Introduction
 2004, QNX Software Systems Ltd.
Notice the overlap: the QNX C Project wizard appears in the right
pane for both C and QNX.
Besides the nature-specific wizards, the IDE also has “simple”
wizards that deal with the very basic elements of projects: Project,
Folder, and File. These elements have no natures associated with
them. You can access these wizards by selecting
File→New→Other. . . →Simple.
302
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
☞
Although a project may seem to be nothing other than a directory in
your workspace, the IDE attaches special meaning to a project — it
won’t automatically recognize as a project any directory you happen
to create in your workspace.
But once you’ve created a project in the IDE, you can bring new
folders and files into your project folder, even if they were created
outside the IDE (e.g. using Windows Explorer). To have the IDE
recognize such folders and files:
➤ In the Navigator view, right-click the navigator pane and select
Refresh.
Creating a C/C++ project
You use the New Project wizard to create a C or C++ project, which
can be one of these varieties:
QNX C Project (application)
QNX C++ Project (application)
A C or C++ application for multiple target platforms. It
supports the QNX-specific project structure using common.mk
files to perform a QNX recursive make.
☞
July 30, 2004
If you open a common.mk file in the editor, you can toggle the display
to reveal hidden internal code by clicking this icon in the toolbar:
Chapter 13 Common Wizards Reference
303
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
QNX C Project (library)
QNX C++ Project (library)
A library that other projects can reference. In most other
respects, library projects resemble QNX C/C++ application
Projects.
Standard Make C Project
Standard Make C++ Project
A basic C or C++ project that uses a standard makefile and
GNU make to build the source files. You don’t get the added
functionality of the QNX build organization and the
common.mk file, but these standard projects adapt well to your
existing code that you wish to bring into the IDE. (For more
about makefiles and the make utility, see the Conventions for
Makefiles and Directories appendix in the Programmer’s
Guide.)
As a rule, the IDE provides UI elements to control most of the build
properties of QNX projects, but not of Standard Make projects (unless
you consider a makefile a “UI element”).
How to create a C/C++ project
To create a C/C++ project :
1
From the menu, select File→New→Project. . . .
2
In the left pane, select the project’s nature according to this
table:
If you want to build:
Select:
Standard Make C project
C
QNX C application project
C or QNX
continued. . .
304
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
July 30, 2004
If you want to build:
Select:
QNX C library project
C or QNX
Standard Make C++ application project
C++
QNX C++ application project
C++ or QNX
QNX C++ library project
C++ or QNX
3
In the right pane, select the type of project that you want (e.g.
QNX C Project).
4
Click Next.
5
Give your project a name.
6
Ensure that Use Default Location is checked.
7
Select the type (application or library):
Chapter 13 Common Wizards Reference
305
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
If you’re building a library, see below.
306
8
Click Next. The wizard displays the appropriate tabs.
9
Select each tab and fill in the required information. The fields
for each tab are described in the “Tabs in the New C/C++
Project wizard” section, below.
10
Click Finish. The IDE creates your new project in your
workspace.
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
☞
In the C/C++ Development perspective, you can also access the QNX
C/C++ Projects wizards via these buttons:
If you’re building a library project
You’ll need to choose the type of library you wish to build:
Static library (libxx.a)
Combine binary object files (i.e. *.o) into an archive that will
later be directly linked into an executable.
July 30, 2004
Chapter 13 Common Wizards Reference
307
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
Shared library (libxx.so)
Combine binary objects together and join them so they’re
relocatable and can be shared by many processes. Shared
libraries are named using the format libxx.so.version, where
version is a number with a default of 1. The libxx.so file will
be a symbolic link to the latest version.
Static library for shared objects (libxxS.a)
Same as static library, but using position-independent code
(PIC). Use this if you want a library that will later be linked into
a shared object. The System Builder uses these types of libraries
to create new shared libraries that contain only the symbols that
are absolutely required by a specific set of programs.
Shared library without export (xx.so)
A shared library without versioning. Generally, you manually
open the library with the dlopen() function and look up specific
functions with the dlsym() function.
If you’re building a Standard Make C/C++ project
Since this type of project doesn’t use the QNX recursive multivariant
makefile structure, you’ll have to set up your own makefile.
Here’s how to create a simple “Hello World” non-QNX project:
308
1
Open the New Project wizard.
2
Select Standard Make C (or C++) Project, then click Next.
3
Name your project, then click Finish. The IDE has now created
a project structure.
4
Now you’ll create a makefile for your project. In the Navigator,
highlight your project, then click the Create a File button on the
toolbar:
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
5
Name your file “Makefile” and click Finish. The editor
should now open, ready for you to create your Makefile.
Here’s a sample Makefile you can use:
CC:=qcc
hello: hello.c
all: hello
clean:
rm -f hello.o hello
☞
Use Tab characters to indent commands inside of make rules, not
spaces.
6
When you’re finished editing, save your file (right-click, then
select Save, or click the Save button in the tool bar).
7
Finally, you’ll create your “hello world” C (or C++) source file.
Again, open a new file, which might look something like this
when you’re done:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello, world!\n");
return EXIT SUCCESS;
}
July 30, 2004
Chapter 13 Common Wizards Reference
309
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
Tabs in the New C/C++ Project wizard
Depending on the type of project you choose, the New Project wizard
displays different tabs:
QNX C or C++ application or library project
Tabs:
Build Variants
Projects
Make Builder
Error Parsers
Options
Standard Make C or C++ project
Tabs:
Projects
Make Builder
Error Parsers
Binary Parser
Paths and Symbols
Build Variants tab
The Build Variants tab lets you choose the platforms to compile
executables for:
310
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
☞
By default, all platforms are enabled. You might want to set your
preferences for QNX projects to build only for the specific target
platforms you want. To do this, open:
Window→Preferences→QNX→New Project→Build Variants.
If you’ve already created a QNX Target System Project, you’ll also
see entries such as My test [localhost - x86]. These let you
build specifically for a configured target.
You must choose at least one platform.
July 30, 2004
Chapter 13 Common Wizards Reference
311
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
Projects tab
The Projects tab lets you specify your preferred order of building:
For example, if you associate myProject with mySubProject, the IDE
builds mySubProject first when you rebuild all your projects. If you
change mySubProject, the IDE doesn’t automatically rebuild
myProject.
Make Builder tab
The Make Builder tab lets you configure how the IDE handles make
errors, what command to use to build your project, and when to do a
build:
312
Chapter 13 Common Wizards Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Build Setting
Creating a C/C++ project
If you want the IDE to stop building when it
encounters a make or compile error, check Stop on
Error. Otherwise, check Keep Going On Error.
Build Command
If you want the IDE to use the default make
command, check Use Default. If you want to use a
different utility, uncheck Use Default and enter
your own command in the Build Command field
(e.g. C:\myCustomMakeProgram).
July 30, 2004
Chapter 13 Common Wizards Reference
313
Creating a C/C++ project
 2004, QNX Software Systems Ltd.
Workbench Build Behavior
You can specify how you want the IDE to build
your project:
whenever you save any file in your project
incremental build (make all)
full rebuild (make clean all)
Error Parsers
The Error Parsers tab lets you specify which build output parsers (e.g.
Intel C/C++ Compiler Error Parser, CDT GNU Assembler Error
Parser, etc.) apply to this project and in which order. To change the
order, simply select an item, then use the Up or Down buttons to
position the item where you want in the list.
Options tab
The Options tab lets you specify several attributes for the project
you’re building:
314
Chapter 13 Common Wizards Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
July 30, 2004
Creating a C/C++ project
General options
By default, some project properties (e.g. active
targets) are local — they’re stored in the
.metadata folder in your own workspace. If you
want other developers to share all of your project’s
properties, then set Share all project properties
on. The IDE then stores the properties in a
.cdtproject file, which you can save in your
version control system so that others may share the
project file.
Build Options
If you want to profile your application and take full
advantage of the QNX Application Profiler, then
Chapter 13 Common Wizards Reference
315
Creating a target
 2004, QNX Software Systems Ltd.
check Build with Profiling (see the Profiling an
Application chapter in this guide).
If you want use the QNX Code Coverage tool, then
check Build with Code Coverage (see the Using
Code Coverage chapter in this guide).
If you want the IDE to do more dependency
checking than it normally would, then set the
Enhanced dependency checking option on. Note
that this will mean slower builds, so you may want
to turn this off in order to improve build times.
Binary Parser tab
If you’re building a Standard Make C/C++ project, then this tab lets
you define which binary parser (e.g. ELF Parser) should be used to
deal with the project’s binary objects.
Paths and Symbols tab
If you’re building a Standard Make C/C++ project, then this tab lets
you specify the include paths and C/C++ macro definitions for this
particular project. Certain features of the IDE (e.g. syntax
highlighting, code assistance, etc.) rely on this information, as do
source-code parsers.
☞
At a later time, you can supply this data using the Set QNX Build
Environment. . . item in the context menu of the C/C++ Projects
view.
Creating a target
You must create a Target System Project for every target you want to
use with the IDE.
To create a new target:
316
1
From the menu, select File→New→Project. . . .
2
In the left pane, select QNX.
Chapter 13 Common Wizards Reference
July 30, 2004
Creating a target
 2004, QNX Software Systems Ltd.
3
In the right pane, select QNX Target System Project.
4
Click Next. The New QNX Target System Project wizard
appears:
5
Complete the fields described below:
Target Name
Type a descriptive name for your QNX Target
System Project.
Project contents
Check Use default to store it in your
workspace, or turn this option off and select
another location in the Directory field.
July 30, 2004
Chapter 13 Common Wizards Reference
317
Converting projects
 2004, QNX Software Systems Ltd.
QNX Connector Selection
Type the target connection in the Hostname or
IP and Port fields. If you’re running the IDE
on a QNX Neutrino machine running qconn,
then check Use local QNX Connector; the
IDE automatically fills in the connection
information. (If you wish to connect to a
different target, you may turn Use local QNX
Connector off, and then fill in the fields
manually.)
Target Configuration
This section is for a future feature.
6
☞
Click Finish. Your new QNX Target System Project appears in
the Navigator view. When you create a launch configuration,
the target is listed under the Main tab in the Target Options
pane. Note that you can use the Add New Target button in the
Target Options pane to open the New Target System Project
wizard.
You can also reach the New Target System Project wizard from within
the Target Navigator (right-click, then select Add New Target).
Converting projects
At various times, you may need to convert non-QNX projects to QNX
projects (i.e. give them a QNX nature). For example, suppose another
developer committed a project to CVS without the .project and
.cdtproject files. The IDE won’t recognize that project as a QNX
project when you check it out from CVS, so you’d have to convert it.
Or, you may wish to turn a Standard Make C/C++ project into a QNX
C/C++ project in order to take advantage of the QNX recursive
makefile hierarchy (a project with a QNX nature causes the IDE to
use the QNX make tools and structure when building that project).
The IDE lets you convert many projects at once, provided you’re
converting all those projects into projects of the same type.
318
Chapter 13 Common Wizards Reference
July 30, 2004
Converting projects
 2004, QNX Software Systems Ltd.
☞
If you wish to convert a QNX project back into a Standard Make
C/C++ project, you can use the Convert C/C++ Projects wizard. From
the main menu, select File→New→Other. . . . In the left pane, select
C. In the right pane, select Convert to a C or C++ Project.
Converting to a QNX project
To convert a non-QNX project to a QNX Project:
☞
July 30, 2004
1
From the menu, select File→New→Project. . . .
2
In the left pane, select QNX.
3
In the right pane, select Convert to a QNX Project. The
Convert C/C++ Projects wizard appears.
You can also use the Convert to a QNX Project button to bring up the
conversion wizard:
4
Click Next.
5
Select the project(s) you want to convert in the Candidates for
conversion field.
6
Specify the language (C or C++).
7
Specify the type of project (application or library).
8
Click Finish. Your converted project appears in the C/C++
Projects view and the Navigator view.
Chapter 13 Common Wizards Reference
319
Converting projects
☞
 2004, QNX Software Systems Ltd.
You now have a project with a QNX nature, but you’ll need to make
further adjustments (e.g. specify a target platform) via the Properties
dialog if you want it to be a working QNX Project.
Completing the conversion
The conversion wizard gave your Standard Make project a QNX
nature; you now need to use the Properties dialog to fully convert
your project to a working QNX Project.
To bring up the Properties dialog of a project:
320
1
In the C/C++ Projects view (or the Navigator), right-click your
project.
2
Select Properties from the context menu. The Properties dialog
appears:
3
In the left pane, select QNX C/C++ Project.
4
Specify the properties you want using the available tabs:
Chapter 13 Common Wizards Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
5
July 30, 2004
Converting projects
Options
See the section “Tabs in the New C/C++
Project wizard” above.
Build Variants
See the section “Tabs in the New C/C++
Project wizard” above.
General
In the Installation directory field, you can
specify the destination directory (e.g. bin)
for the output binary you’re building. (For
more information, see the Conventions for
Makefiles and Directories appendix in the
Programmer’s Guide.)
In the Target base name field, you can
specify your binary’s base name, i.e. the
name without any prefixes or suffixes. By
default, the IDE uses your project name as
the executable’s base name. For example, if
your project is called “Test 1,” then a debug
version of your executable would be called
“Test 1 g” by default.
In the Use file name, enter the name of the
file containing the usage message for your
executable. (For more on usage messages,
see the entry for usemsg in the Utilities
Reference.
Compiler
See the section Compiler tab below.
Linker
See the section Linker tab below.
Make Builder
See the section “Tabs in the New C/C++
Project wizard” above.
Error Parsers
See the section “Tabs in the New C/C++
Project wizard” above.
When you’ve finished specifying the options you want, click
Apply, then OK. The conversion process is complete.
Chapter 13 Common Wizards Reference
321
Converting projects
 2004, QNX Software Systems Ltd.
Compiler tab
The Compiler tab changes depending on which of the three categories
you select:
General options
Extra source paths
Extra include paths
Compiler type
If you’ve selected General options, the first item
you specify is the type of compiler. Currently, the
choices are:
GCC 2.95.3
GCC 3.3.1
Intel (icc)
Output options
Here you can specify the warning level (0 to 9), i.e.
the threshold level of warning messages that the
compiler outputs. You can also choose to have the
preprocessor output intermediate code to a file; the
IDE will name the output file your source file.i (C)
or your source file.ii (C++), using the name of
your source file as the base name.
Code generation For the Optimization level, you can specify four
levels: from 0 (no optimization) to 3 (most
optimization). In the Stack size field, you can
specify the stack size, in bytes or kilobytes.
Definitions field
Here you can specify the list of compiler defines to
be passed to the compiler on the command line in
the form -D name[=value], but you don’t have to
bother with the -D part; the IDE adds it
automatically.
Other options field
Here you can specify any other command-line
options that aren’t already covered in the Compiler
322
Chapter 13 Common Wizards Reference
July 30, 2004
Converting projects
 2004, QNX Software Systems Ltd.
tab. For more information on the compiler’s
command-line options, see qcc in the Utilities
Reference.
Extra source paths
If you want to specify source locations other than
your project’s root directory, select this category.
Then click the appropriate button to specify the
location:
Project. . . — You can add source from another
project in your current workspace. Note that the
IDE uses relocatable notation, so even if other
team members have different workspace
locations, they can all work successfully
without having to make any additional project
adjustments.
QNX target. . . — You can add source from
anywhere in or below your ${QNX TARGET}
directory on your host.
Disk. . . — You can choose to add source from
anywhere in your host’s filesystem.
Extra include paths
You can specify a list of directories where the
compiler should look for include files. The options
here are the same as for Extra source paths,
except that here you can change the order of
directories in the list, which can be important if
you happen to have more than one header file with
the same name.
Linker tab
The Linker tab changes depending on which of the four categories
you select:
General options
July 30, 2004
Chapter 13 Common Wizards Reference
323
Converting projects
 2004, QNX Software Systems Ltd.
Extra library paths
Extra libs
Post-build actions
Export symbol options
This field lets you define the level of final stripping
of your binary, ranging from exporting all symbols
to removing just the debugger symbols to
removing them all.
Generate map file
If you set this option on, the IDE will print a link
map to the build console.
Build goal name Specify the output filename for an application or
library project. Note that the name you enter in this
field will force the library’s shared-object name to
match.
By default, a generated application will have the
same name as the project it’s built from. A library
will have prefix of “lib” and a suffix of “.a” or
“.so” after the project name. In addition, debug
variants of applications and libraries have a suffix
of “ g.”
Link against C++ library (valid for C++ projects only)
Select the particular C++ library you want to use.
Library shared object name
You can use this field to override the shared-object
name used in C/C++ library projects. Note that this
will not affect the actual filename.
324
Chapter 13 Common Wizards Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Converting projects
If you specify a filename in the Build goal name field, don’t use the
Library shared object name field.
Library version
This dropdown list lets you select a version
number for both the library’s shared-object name
and filename. If this is a library that doesn’t have a
version number (e.g. “platform.so”), then
select “No.”
Note that you can still set the library version even
if Build goal name is specified.
Other options field
Here you can specify any other command-line
options that aren’t already covered in the Linker
tab. For more information on the linker’s options,
see the entry for ld in the Utilities Reference.
Extra library paths
Select this category if you want to specify
locations where the linker should look for import
libraries (.so or .a files). Then click the
appropriate button to specify the location. (These
buttons work the same as those in the Compiler tab
when you select Extra source paths.)
Extra libraries
Here you can add a list of libraries (.so or .a
files) to search for unsatisfied references. For each
item in this list, you can define:
Stripped name, the base name without the lib
prefix (which ld adds automatically) and
without the suffix (.so or .a).
Library type (static or dynamic)
Debug/Release mode. A “No” or “Yes” in this
field indicates whether or not the builder will
match the debug or release version of the
July 30, 2004
Chapter 13 Common Wizards Reference
325
Converting projects
 2004, QNX Software Systems Ltd.
library with the final binary’s type. For
example, if you select “Yes” and you want to
link against a debug version of the library, the
IDE will append “ g” to the library’s base
name. If you select “No,” then the builder
passes (to ld) this name exactly as you entered
it. So, if you wanted to use a release version of
your binary and link against a debug version of
the library, you’d specify MyLibraryName g
as the name.
☞
Adding a new element to the extra library list automatically adds the
directory where this library resides to the Extra library paths list
(see above), if it’s not already there. But if you remove an item from
the list, its parent directory is not automatically removed.
You can add a library in two ways:
Add button — lets you create an empty element
and define it manually
Add from project — lets you browse your
workspace for the library. Note that when you
add a library from your workspace, the IDE
uses relocatable notation so other members with
different workspace locations can all work
successfully without having to make any project
adjustments.
Extra object files This lets you link a project against any object file
or library, regardless of the filename.
326
Chapter 13 Common Wizards Reference
July 30, 2004
Converting projects
 2004, QNX Software Systems Ltd.
☞
The file-selection dialog may seem slow when adding new files. This
is because the system can’t make assumptions about naming
conventions and instead must use a binary parser to determine if a file
is an object file or a library.
Note also that the Extra object files option is available for an
individual platform only. If a project has more than one active
platform, you can’t use this feature. In that case, you can still specify
extra object files using the Advanced mode for each platform
separately.
Post-build actions
When you select this category and click the Add
button, you’ll see a dialog that lets you select one
of four predefined post-build actions for your
project:
Copy result to other location
Move result to other location
Rename result
Run other shell command
In the What field, you specify the item (e.g.
application) you want to copy or move; in the
Where field, you specify the destination. You can
use the To Workspace or To Filesystem buttons to
locate the place.
If you select Rename result, a New Name field
appears for you to enter the name. If you select
Other command, enter the shell command in the
field.
Note that you can set up more than one post-build
action; each will be processed sequentially.
July 30, 2004
Chapter 13 Common Wizards Reference
327
Converting projects
 2004, QNX Software Systems Ltd.
Advanced/regular modes
The Properties dialog can appear in two different modes: regular
(default) and advanced.
To activate the advanced mode, press the Advanced button at the
bottom of the dialog:
To return to regular mode, press the Regular button:
In advanced mode, you can override various options that were set at
the project level for the particular build variant you’ve selected:
platform (the one specified or all supported platforms)
build mode (e.g. debug, release, user-defined)
compiler options
linker options
For example, you can change the optimization level for a particular C
file, specify which set of import libraries to use for a specific
architecture, and so on.
328
Chapter 13 Common Wizards Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Converting projects
During the final build, the IDE will merge the options you’ve set for
the project’s general configuration with the advanced options, giving
priority to the advanced settings.
July 30, 2004
Chapter 13 Common Wizards Reference
329
Chapter 14
Launch Configurations Reference
In this chapter. . .
What is a launch configuration? 333
Types of launch configurations 333
Running and debugging the first time 335
Running and debugging subsequent times 339
Setting execution options 341
July 30, 2004
Chapter 14 Launch Configurations Reference
331
What is a launch configuration?
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
You must set up a Launch Configuration before you can run or debug a program.
What is a launch configuration?
To run or debug programs with the IDE, you must set up a launch
configuration to define which programs to launch, the command-line
options to use, and what values to use for environment variables. The
configurations also define which special tools to run with your
program (e.g. Code Coverage tool).
The IDE saves your launch configurations so you can quickly
reproduce the particular execution conditions of a setup you’ve done
before, no matter how complicated.
Each launch configuration specifies a single program running on a
single target. If you want to run your program on a different target,
you can copy and modify an existing launch configuration. And you
can use the same configuration for both running and debugging your
program, provided that your options are the same.
Types of launch configurations
The IDE supports these types of launch configurations:
July 30, 2004
Chapter 14 Launch Configurations Reference
333
Types of launch configurations
 2004, QNX Software Systems Ltd.
C/C++ QNX QConn (IP)
If you’re connecting to your target machine by IP,
select this configuration (even if your host machine
is also your target). You’ll have full debugger
control and can use the Application Profiler,
Memory Trace, and Code Coverage tools. Your
target must be running qconn.
C/C++ QNX PDebug (Serial)
If you can access your target only via a serial
connection, select this configuration. Rather than
use qconn, the IDE uses the serial capabilities of
gdb and pdebug directly. This option is available
only when you select Debug.
C/C++ Local
If you’re developing on a self-hosted system, you
may create a C/C++ Local launch configuration.
You don’t need to use qconn; the IDE launches
your program through gdb.
C/C++ Postmortem debugger
If your program produced a dump file (via the
dumper utility) when it faulted, you can examine
the state of your program by loading it into the
postmortem debugger. This option is available only
when you select Debug. When you debug, you’re
prompted to select a dump file.
PhAB Application
If you wish to run a PhAB application, follow the
steps for creating a C/C++ QNX QConn (IP) launch
configuration.
The main difference between the C/C++ QNX QConn (IP) launch
configurations and the other types is that the C/C++ QNX QConn (IP)
type supports the runtime analysis tools (Profiler and Memory
Trace).
334
Chapter 14 Launch Configurations Reference
July 30, 2004
Running and debugging the first time
 2004, QNX Software Systems Ltd.
Running and debugging the first time
You can use the same launch configuration to run or debug a program.
Your choices in the Launch Configurations dialog may cause subtle
changes in the dialog but greatly affect such things as:
options in the dialog
how the IDE connects to the target
what tools are available for the IDE to use.
☞
The Run and Debug menu items appear in the C/C++ Development
perspective by default, but they may not appear in all perspectives.
You’ll need the Run→Run. . . menu item in order to set up a launch
configuration. To bring the menu item into your current perspective:
1
From the main menu, select Window→Customize
Perspective.
2
In the left pane, select Other→Launch.
3
Check the Launch box.
4
Click OK.
Debugging a program the first time
To create a launch configuration in order to debug a program for the
first time:
July 30, 2004
1
In the C/C++ Projects view (or the Navigator view), select your
project.
2
From the main menu, select Run→Debug. . . (or, click the
Debug icon and select Debug. . . from the dropdown menu):
Chapter 14 Launch Configurations Reference
335
Running and debugging the first time
3
336
 2004, QNX Software Systems Ltd.
Select a launch configuration type:
Chapter 14 Launch Configurations Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Running and debugging the first time
If you’re connecting to your target via IP, select C/C++ QNX
QConn (IP). If not, see the “Types of launch configurations”
section in this chapter before deciding.
☞
4
Click New. The dialog displays the appropriate tabs.
5
Give this configuration a name.
6
Fill in the details in the various tabs. See the “Setting execution
options” section in this chapter for details about each tab.
7
Click Debug. You can now launch and debug your program.
You can also use the Debug As menu item to conveniently select a
particular launch configuration:
Running a program the first time
When you configure a program to run, you should also configure it to
debug as well.
☞
There are fewer options for running programs than for debugging.
Some configurations aren’t available.
To run a program the first time:
➤ Repeat the procedure for debugging a program (see “Debugging
a program the first time”), with the following changes:
Instead of selecting Run→Debug from the main menu,
select Run→Run. . . (or, click the Run icon and select
Run. . . from the dropdown menu):
July 30, 2004
Chapter 14 Launch Configurations Reference
337
Running and debugging the first time
 2004, QNX Software Systems Ltd.
Instead of clicking Debug when you’re done, click Run.
Instead of running under the control of a debugger, your
program simply runs.
☞
You can also use the Run As menu item to conveniently select a
particular launch configuration:
The IDE also lets you run a program without creating a launch
configuration, but the program’s output doesn’t appear in the Console
view.
To run a program without using the launcher:
338
Chapter 14 Launch Configurations Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Running and debugging subsequent times
1
After building the program, drag the executable from the
C/C++ Projects view to a target listed in the File System
Navigator view. (To learn more about the view, see the
“Moving files between the host and target” in the Building OS
and Flash Images chapter.)
2
In the File System Navigator view, right-click your file and
select Run. When the dialog appears, click OK. Your program
runs.
Running and debugging subsequent times
Once you’ve created a launch configuration, running or debugging a
program is as easy as selecting that configuration. You can do this in
several ways:
fast way: see “Launching a selected program”
faster way: see “Launching from a list of favorites”
fastest way: see “Launching the last-launched program”
Launching a selected program
To debug or run a program that you’ve created a launch configuration
for:
1
From the main menu, select Run→Debug. . . or Run→Run. . . .
2
In the left pane, select the launch configuration you created
when you first ran or debugged your program.
3
Click Debug or Run.
Launching from a list of favorites
If you have a program that you launch frequently, you can add it to
the Debug or Run dropdown menu so you can launch it quickly.
July 30, 2004
Chapter 14 Launch Configurations Reference
339
Running and debugging subsequent times
☞
 2004, QNX Software Systems Ltd.
To use this method, you must have selected Display in favorites
when you first created your launch configuration. If you didn’t, edit
the Display in favorites menu option under the Common tab. See
“Setting execution options” in this chapter.
To debug or run a program using your favorites list:
1
Do one of the following:
Run: From the main menu, select Run→Run History.
Run: Click the dropdown menu
part of the run menu
.
button set
Debug: From the main menu, select Run→Debug History.
Debug: Click the dropdown menu
menu button set
part of the debug
.
You’ll see a list of all the launch configurations you specified in
the Display in favorites menu:
340
Chapter 14 Launch Configurations Reference
July 30, 2004
Setting execution options
 2004, QNX Software Systems Ltd.
2
Select your launch configuration.
Launching the last-launched program
To relaunch the last program you ran or debugged:
➤ Press F11 or click the Debug or Run dropdown button (
then select your launch configuration.
),
Setting execution options
The Launch Configurations dialog has several tabs:
Main
Arguments
Environment
Download
Debugger
Source
Common
Tools
☞
All of these tabs appear when you select the C/C++ QNX QConn
(IP) type of launch configuration; only some tabs appear when you
select the other types.
Main tab
This tab lets you specify the project and the executable that you want
to run or debug. The IDE might fill in some of the fields for you:
July 30, 2004
Chapter 14 Launch Configurations Reference
341
Setting execution options
 2004, QNX Software Systems Ltd.
Different fields appear in the Main tab, depending on the type of
configuration you’re creating. Here are descriptions of all the fields:
Project
Enter the name of the project that contains the executable
you want to launch. You may also locate a project by
clicking Browse. . . . You can create or edit launch
configurations only for open projects.
C/C++ Application
Enter the relative path of the executable’s project directory
(e.g. x86/o/Test1 x86). For QNX projects, an
executable with a suffix of g indicates it was compiled
for debugging. You may also locate an available
executable by clicking Search. . . .
342
Chapter 14 Launch Configurations Reference
July 30, 2004
Setting execution options
 2004, QNX Software Systems Ltd.
Target Options
1
If you don’t want the IDE to create a “pseudo
terminal” on the target that sends terminal output to
the Console view on a line-by-line basis, then check
the Don’t use terminal emulation on target option.
To use terminal emulation, your target must be
running the devc-pty utility.
2
If you want to filter-out platforms that don’t match
your selected executable, then set the Filter targets
based on C/C++ Application selection on. For
example, if you’ve chosen a program compiled for
PPC, you’ll see only PPC targets and offline targets.
3
Select a target from the available list. If you haven’t
created a target, click the Add New Target button.
For more information about creating a target, see the
Common Wizards Reference chapter.
General Options
If you’re creating a C/C++ QNX PDebug (Serial) launch
configuration, then you’ll see the Stop in main option,
which is set on by default. This means that after you start
the debugger, it stops in main() and waits for your input.
☞
For serial debugging, make sure that the pseudo-terminal
communications manager (devc-pty) is running.
Serial Port Options
Here you can specify the serial port (e.g. COM1 for
Windows hosts; /dev/ser1 for Neutrino) and the baud
rate, which you select from the dropdown list.
Arguments tab
This tab lets you specify the arguments your program uses and the
directory where it runs.
July 30, 2004
Chapter 14 Launch Configurations Reference
343
Setting execution options
 2004, QNX Software Systems Ltd.
C/C++ Program Arguments
Enter the arguments that you want to pass on the command line.
For example, if you want to send the equivalent of myProgram
-v -L 7, type -v -L 7 in this field. You can put -v and -L 7
on separate lines because the IDE automatically strings the
entire contents together.
Working directory on target
The option Use default working directory is set on by default.
This means the executable will run in the /tmp directory on
your target. If you turn off this option, you can click Browse. . .
to locate a different directory.
Environment tab
The Environment tab lets you set the environment variables and
values to use when the program launches. For example, if you want to
set the environment variable named PHOTON to the value
/dev/photon 2 when you run your program, use this tab. Click
New to add an environment variable.
Download tab
The Download tab lets you tell the IDE whether to transfer an
executable from the host machine to the target, or to select one that
already resides on the target.
Executable field
If you select Download executable to target, the
IDE sends a fresh copy of the executable every
time you run or debug.
The Download directory on target field shows
the default directory of /tmp on your target. If you
select the Use executable on target option, you’ll
need to specify a directory here. You can also use
the Browse. . . button to locate a directory.
The Strip debug information before
downloading option is set on by default. Turn it
344
Chapter 14 Launch Configurations Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Setting execution options
off if you don’t want the IDE to strip the
executable you’re downloading to your target.
The Use unique name option is set on by default.
This means the IDE will make your executable’s
filename unique (e.g. append a number) during
each download session.
Extra libraries
The Extra libraries pane lets you select the shared
libraries your program needs. If you click the Auto
button, the IDE tries to automatically find the
libraries needed. If you click From project, the
IDE will look in your workspace for libraries.
You also have the option of not downloading any
shared libraries to your target.
By default, the IDE removes the files it has downloaded after each
session. If you don’t want the IDE to “clean up” after itself, then turn
off the Remove downloaded components after session option.
Debugger tab
The Debugger tab lets you configure how your debugger works. The
content in the Debugger Options pane changes depending on the type
of debugger you select:
July 30, 2004
Chapter 14 Launch Configurations Reference
345
Setting execution options
☞
 2004, QNX Software Systems Ltd.
The settings in the Debugger tab affect your executable only when
you debug it, not when you run it.
Generic debugger settings
Debugger
The debugger dropdown list includes the available
debuggers for the selected launch-configuration type.
The list also varies depending on whether you’re
debugging a remote or a local target.
Run program in debugger/Attach to running process
Most of the time, you’ll want to choose Run program
in debugger. If you click Attach to running process,
you’re prompted to select a process from a list at run
time. Note the following limitations:
You can’t use the Memory Trace tool.
346
Chapter 14 Launch Configurations Reference
July 30, 2004
Setting execution options
 2004, QNX Software Systems Ltd.
The console output isn’t available in the Console
view.
Stop at main() on startup
This option is set on by default. If you turn it off, the
program runs until you interrupt it manually, or until it
hits a breakpoint.
Automatically track the values of variables.
Enable this option if you want the system to track every
variable as you step through your program. Disable the
option if you want to manually select individual
variables to work with in the Variables view in the
debugger (see the Debugging Your Programs chapter).
Debugger Options
GDB command file
This field lets you specify a file for running gdb using the
-command option (see the Utilities Reference).
Load shared library symbols automatically
This option (on by default) lets you watch line-by-line stepping
of library functions in the C/C++ Editor. You may wish to turn
this option off if your target doesn’t have much memory; the
library symbols take up RAM on the target.
You can use the pane to select specific libraries or use the Auto
button to have the IDE attempt to select your libraries.
Stop on shared library events
Choose this option if you want the debugger to break
automatically when a shared library or DLL is loaded or
unloaded.
July 30, 2004
Chapter 14 Launch Configurations Reference
347
Setting execution options
 2004, QNX Software Systems Ltd.
Source tab
The Source tab lets you specify where the debugger should look for
source files. By default, the debugger uses the source from your
project in your workspace, but you can specify source from other
locations (e.g. from a central repository).
To specify a new source location:
1
2
On the Source tab, click Add. . . . The Add Source Location
dialog appears. You may choose to add the source either from
your workspace or elsewhere:
1a
If you wish to add source from your workspace, select
Existing Project Into Workspace, click Next, select
your project, then click Finish.
1b
If you wish to add source from outside your workspace,
select File System Directory, then click Next.
Type the path to your source in the Select location directory
field or use the Browse button to locate your source.
If you want to specify a mapping between directories, choose
the Associate with option and enter the directory in the
available field. For example, if your program was built in the
C:/source1 directory and the source is available in the
C:/source2 directory, enter C:/source2 in the first field and
associate it with C:/source1 using the second field.
If you want the IDE to recurse down the directories you pointed
it at to find the source, then choose the Search subfolders
option.
3
Click Finish. The IDE adds the new source location.
Common tab
The Common tab lets you define where the launch configuration is
stored, how you access it, and what perspective you change to when
you launch.
348
Chapter 14 Launch Configurations Reference
July 30, 2004
Setting execution options
 2004, QNX Software Systems Ltd.
Type of launch configuration
When you create a launch configuration, the IDE saves it as a
.launch file. If you select Local, the IDE stores the
configuration in one of its own plugin directories. If you select
Shared, you can save it in a location you specify (such as in
your project). Saving as Shared lets you commit the .launch
file to CVS, which allows other to run the program using the
same configuration.
Perspective to switch to or open when launched in
You can tell the IDE which perspectives to change to when you
run or debug. You can specify the perspectives, or simply set
them to Default. To determine the default perspectives for both
running and debugging, select Window→Preferences from the
main menu and select Debug from the left pane.
Display in favorites
You can have your launch configuration displayed when you
click the Run or Debug dropdown menus in the toolbar. To do
so, check the Run or Debug options under the Display in
favorites menu heading.
Tools tab
The Tools tab lets you add runtime analysis tools to the launch. To do
this, click the Add/Delete Tool button at the bottom of the tab:
July 30, 2004
Chapter 14 Launch Configurations Reference
349
Setting execution options
 2004, QNX Software Systems Ltd.
You can add the following tools (some launch options affect which
tools are available):
Application Profiler
Lets you count how many times functions are called, who called
which functions, and so on. For more on this tool, see the
Profiling Your Application chapter.
Memory Trace
Lets you track memory errors. For more on this tool, see the
Finding Memory Errors chapter.
Code Coverage
Lets you measure what parts of your program have run, and
what parts still need to be tested. For more on this tool, see the
Code Coverage chapter.
350
Chapter 14 Launch Configurations Reference
July 30, 2004
 2004, QNX Software Systems Ltd.
Setting execution options
If you want the IDE to open the appropriate perspective for the
tool during the launch, then check Switch to this tool’s
perspective on launch.
July 30, 2004
Chapter 14 Launch Configurations Reference
351
Appendix A
Tutorials
In this appendix. . .
Before you start. . .
355
Tutorial 1 — creating a standard make C/C++ project 355
Tutorial 2 — creating a QNX C/C++ project 358
Tutorial 3 — importing an existing project into the IDE 360
Tutorial 4 — importing a QNX BSP into the IDE 361
July 30, 2004
Appendix: A Tutorials
353
Before you start. . .
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Common
Wizards
Tutorials
Where Files
Are Stored
Here are several tutorials to help you get going with the IDE.
Before you start. . .
Before you begin the tutorials, we recommend that you first
familiarize yourself with the IDE’s components and interface by
reading the IDE Concepts chapter.
You might also want to look at the core Eclipse basic tutorial on using
the workbench in the Workbench User Guide (Getting
started→Basic tutorial).
Tutorial 1 — creating a standard make
C/C++ project
In this tutorial, you’ll create a simple, standard make project (i.e. a
project that doesn’t involve the QNX multivariant makefile structure).
You use the New Project wizard whenever you create a new project in
the IDE. Follow these steps to create a simple “hello world” project:
1
July 30, 2004
To open the New Project wizard, select File→New→Project. . .
from the main menu of the workbench.
Appendix: A Tutorials
355
Tutorial 1 — creating a standard make C/C++ project
356
 2004, QNX Software Systems Ltd.
2
In the wizard’s left pane, select C (or C++). In the right pane,
select Standard Make C (or C++) Project, then click Next:
3
Name your project (e.g. “MyFirstProject”), then click
Finish. The IDE has now created a project structure.
4
Now you’ll create a makefile for your project. In the Navigator
view (or the C/C++ Projects view — it doesn’t matter which),
highlight your project:
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
Tutorial 1 — creating a standard make C/C++ project
5
Click the Create a File button on the toolbar:
6
Name your file “Makefile” and click Finish. The editor
should now open, ready for you to create your Makefile.
Here’s a sample Makefile you can use:
CC:=qcc
all: hello
hello: hello.c
clean:
rm -f hello.o hello
☞
Use Tab characters to indent commands inside of make rules, not
spaces.
7
July 30, 2004
When you’re finished editing, save your file (right-click, then
select Save, or click the Save button in the tool bar).
Appendix: A Tutorials
357
Tutorial 2 — creating a QNX C/C++ project
8
 2004, QNX Software Systems Ltd.
Finally, you’ll create your “hello world” C (or C++) source file.
Again, open a new file called hello.c, which might look
something like this when you’re done:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello, world!\n");
return EXIT SUCCESS;
}
Congratulations! You’ve just created your first standard make project
in the IDE.
For instructions on building your program, see the section “Building
projects” in the Developing C/C++ Programs chapter.
☞
In order to run your program, you must first set up a Neutrino target
system. For details, see:
the Preparing Your Target chapter
the section “Running projects” in the Developing C/C++ Programs
chapter.
Tutorial 2 — creating a QNX C/C++ project
Unlike standard make projects, a QNX project relies on the QNX
recursive makefile hierarchy to support multiple CPU targets. (For
more on the QNX recursive makefile hierarchy, see the Conventions
for Makefiles and Directories appendix in the Programmer’s Guide.)
Follow these steps to create a simple QNX C (or C++) “hello world”
project:
1
358
In the C/C++ Development perspective, click the New QNX C
Project (or New QNX C++ Project) button in the toolbar:
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
Tutorial 2 — creating a QNX C/C++ project
The New Project wizard appears.
2
Name your project, then select the type (e.g. Application):
3
Click Next – but don’t press Enter! (Pressing Enter at this point
amounts to clicking the Finish button, which will cause the IDE
to create the project for all CPU variants, which you may not
want.)
4
In the Build Variants tab, check the build variant that matches
your target type, such as X86 (Little Endian), PPC (Big
Endian), etc.
5
In the Options tab, make sure the Build debug version and
Build release version options are set.
6
Click Finish. The IDE creates your QNX project and displays
the source file in the editor.
Congratulations! You’ve just created your first QNX project.
For instructions on building your program, see the section “Building
projects” in the Developing C/C++ Programs chapter.
July 30, 2004
Appendix: A Tutorials
359
Tutorial 3 — importing an existing project into the IDE
☞
 2004, QNX Software Systems Ltd.
In order to run your program, you must first set up a Neutrino target
system. For details, see:
the Preparing Your Target chapter
the section “Running projects” in the Developing C/C++ Programs
chapter.
Tutorial 3 — importing an existing project
into the IDE
In this tutorial, you’ll use the IDE’s Import wizard, which lets you
import existing projects, files, even files from ZIP archives into your
workspace.
☞
You can use various methods to import source into the IDE. For
details, see the chapter Managing Source Code.
Follow these steps to bring one of your existing C or C++ projects
into the IDE:
360
1
First you need to create an IDE project for your existing source.
Select File→New→Project. . . .
2
Select the type of project (e.g. Standard Make C project).
3
Name your project (e.g. “MyOldProject”).
4
Unselect Use Default Location, because we need to tell the
IDE where your resources reside in the filesystem (since they
don’t yet reside in your workspace).
5
In the Location: field, type in the path to your source (or click
Browse. . . ).
6
Click Finish.
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
Tutorial 4 — importing a QNX BSP into the IDE
Congratulations! You’ve just imported one of your existing projects
into the IDE.
Tutorial 4 — importing a QNX BSP into the
IDE
QNX BSPs and other source packages are distributed as .zip
archives. The IDE lets you import both kinds of packages into the
IDE:
When you import:
The IDE creates:
QNX BSP source package
A System Builder project.
QNX C/C++ source package
A C or C++ application or library
project.
For more information on System Builder projects, see the chapter
Building OS and Flash Images.
Step 1: Use File→Import. . .
You import a QNX source archive using the standard Eclipse import
dialog:
July 30, 2004
Appendix: A Tutorials
361
Tutorial 4 — importing a QNX BSP into the IDE
 2004, QNX Software Systems Ltd.
As you can see, you can choose to import either a QNX BSP or a
“source package.” Although a BSP is, in fact, a package that contains
source code, the two types are structured differently and will generate
different types of projects. If you try to import a BSP archive as a
QNX Source Package, the IDE won’t create a System Builder project.
362
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
Tutorial 4 — importing a QNX BSP into the IDE
Step 2: Select the package
After you choose the type of package you’re importing, the wizard
then presents you with a list of the packages found in
$QNX TARGET/usr/src/archives on your host:
Notice that as you highlight a package in the list, a description for that
package is displayed.
To add more packages to the list:
1
July 30, 2004
Click the Select Package. . . button.
Appendix: A Tutorials
363
Tutorial 4 — importing a QNX BSP into the IDE
2
 2004, QNX Software Systems Ltd.
Select the .zip source archive you want to add.
Step 3: Select the source projects
Each source package contains several components (or projects to use
the IDE term). For the package you selected, the wizard then gives
you a list of each source project contained in the archive:
You can decide to import only certain parts of the source package —
simply uncheck the entries you don’t want (they’re all selected by
364
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
Tutorial 4 — importing a QNX BSP into the IDE
default). Again, as you highlight a component, you’ll see its
description in the bottom pane.
Step 4: Select a working set
The last page of the import wizard lets you name your source
projects. You can specify:
Working Set Name — to group all related imported projects
together as a set
Project Name Prefix — for BSPs, this becomes the name of the
System Builder project; for other source projects, this prefix allows
the same source to be imported several times without any conflicts.
July 30, 2004
Appendix: A Tutorials
365
Tutorial 4 — importing a QNX BSP into the IDE
☞
 2004, QNX Software Systems Ltd.
If you plan to import a source BSP and a binary BSP into the IDE,
remember to give each project a different name.
Step 5: Build
When you finish with the wizard, it creates all the projects and brings
in the sources from the archive. It will then ask if you want to build
all the projects you’ve just imported.
366
Appendix: A Tutorials
July 30, 2004
 2004, QNX Software Systems Ltd.
☞
Tutorial 4 — importing a QNX BSP into the IDE
If you answer Yes, the IDE will begin the build process, which may
take several minutes (depending on how much source you’ve
imported).
If you decide not to build now, you can always do a Rebuild All from
the main toolbar’s Project menu at a later time.
If you didn’t import all the components from a BSP package, you can
bring in the rest of them by selecting the System Builder project and
opening the import wizard (right-click the project, then select
Import. . . ). The IDE detects your selection and then extends the
existing BSP (rather than making a new one).
QNX BSP Perspective
When you import a QNX Board Support Package, the IDE opens the
QNX BSP Perspective. This perspective combines the minimum
elements from both the C/C++ Development Perspective and the
System Builder Perspective:
July 30, 2004
Appendix: A Tutorials
367
Tutorial 4 — importing a QNX BSP into the IDE
 2004, QNX Software Systems Ltd.
Congratulations! You’ve just imported a QNX BSP into the IDE.
368
Appendix: A Tutorials
July 30, 2004
Appendix B
Where Files Are Stored
July 30, 2004
Appendix: B Where Files Are Stored
369
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Common
Wizards
Tutorials
Where Files
Are Stored
This appendix shows you where to find key files used by the IDE.
Here are some of the more important files used by the IDE:
Type of file
Sample location (Windows)
Workspace folder
C:\QNX630\workspace
.metadata folder (for personal settings)
C:\QNX630\workspace\.metadata
Error log
C:\QNX630\workspace\.metadata\.log
☞
July 30, 2004
You can specify where you want your workspace folder to reside.
For details, see the section “Running Eclipse” in the Tasks chapter of
the Workbench User Guide. (To access the guide, open Help→Help
Contents, then select Workbench User Guide from the list.)
Appendix: B Where Files Are Stored
371
Appendix C
Utilities Used by the IDE
July 30, 2004
Appendix: C Utilities Used by the IDE
373
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
This appendix lists the utilities used by the IDE.
Here are the utilities used by the IDE:
dumper — Dump the postmortem state of a program (QNX)
flashcmp — Compress files for a flash filesystem
gcc — Compile and link a program (GNU)
gcov — Gather code coverage data (GNU)
gdb — Debugger (GNU)
gprof — Code profiler (GNU)
icc — Intel C and C++ compiler
ld — Linker command (POSIX)
make — Maintain, update, and regenerate groups of programs
(POSIX)
mkefs — Build an embedded filesystem (QNX)
mkifs — Build an OS image filesystem (QNX)
mkimage — Build a socket image from individual files (QNX)
July 30, 2004
Appendix: C Utilities Used by the IDE
375
 2004, QNX Software Systems Ltd.
mkrec — Convert a binary image into ROM format (QNX)
mksbp — Build a QNX System Builder project
objcopy — Copy the contents of one object file to another (GNU)
pdebug — Process-level debugger
pidin — Display system statistics (QNX Neutrino)
procnto — QNX Neutrino microkernel and process manager
(QNX Neutrino)
qcc — Compile command (QNX Neutrino, QNX 4)
qconfig — Query and display QNX installations and
configurations
qconn — Provide service support to remote IDE components
QWinCfg — Query and display QNX installations and
configurations
sendnto — Send an OS image to a target over a serial or parallel
port (QNX4)
strip — Remove unnecessary information from executable files
(POSIX)
tracelogger — Log tracing information
usemsg — Change the usage message for a command (QNX
Neutrino)
376
Appendix: C Utilities Used by the IDE
July 30, 2004
Appendix D
Migrating to the 6.3 Release
In this appendix. . .
Introduction 379
From 6.2.1 to 6.3.0
From 6.2.0 to 6.3.0
July 30, 2004
380
383
Appendix: D Migrating to the 6.3 Release
377
Introduction
 2004, QNX Software Systems Ltd.
Getting
Started
Development
Running &
Debugging
Program
Analysis
Target System
Analysis
About This
Guide
Developing
C/C++
Programs
Launch
Configurations
Finding
Memory Errors
Building
OS and Flash
Images
IDE Concepts
Developing
Photon
Applications
Debugging
Programs
Profiling an
Application
Getting
System
Information
Preparing
Your Target
Managing
Source Code
Using Code
Coverage
Analyzing
Your System
Migrating to
6.3
Utilities Used
by the IDE
Reference material
Tutorials
Common
Wizards
Where Files
Are Stored
You can easily migrate your old workspace and projects to this release.
Introduction
Upgrading from a previous version of the IDE involves two basic
steps:
Step 1 — converting your development workspace to be compliant
with the latest version of the IDE framework. The IDE performs this
process automatically at startup when it detects an older workspace
version.
☞
You can redirect the IDE to point at different workspaces simply by
running this command:
qde -data path to workspace
Step 2 — converting your individual projects. Depending on which
version of the IDE framework you’re migrating from (6.2.0 or 6.2.1),
you’ll have to take different steps to convert your projects.
July 30, 2004
Appendix: D Migrating to the 6.3 Release
379
From 6.2.1 to 6.3.0
 2004, QNX Software Systems Ltd.
From 6.2.1 to 6.3.0
Migrating your workspace
☞ This conversion is a one-way process. Although your data files will
remain intact, you won’t be able to use this workspace with earlier
versions of the IDE.
1
Start the IDE pointing at your 6.2.1 workspace. You’ll see a
splash page (“Please wait — Completing the install”), followed
by the Different Workspace Version dialog:
2
Click OK to convert your workspace.
3
Next the Workbench Layout dialog tells you that the layout of
some of the views and editors can’t be restored:
This is to be expected, because we’re upgrading the minor
version of installed components, so there may be some UI
adjustments. Click OK.
Now you’re ready to migrate your existing projects to 6.3.0.
380
Appendix: D Migrating to the 6.3 Release
July 30, 2004
 2004, QNX Software Systems Ltd.
From 6.2.1 to 6.3.0
Migrating your projects
If the 6.3.0 IDE detects any 6.2.1 C/C++ standard make projects at
startup, you’ll be prompted to convert these projects to the new
format:
You must run this conversion process over each 6.2.1 project so it can
take full advantage of the new features of the C/C++ Development
Tools.
☞
QNX C/C++ projects are automatically converted to the new project
format.
Running the conversion wizard
At startup, the conversion wizard automatically checks for projects to
convert. Note that you can convert older projects that were never in
the workspace (e.g. projects you’ve brought in via a revision control
system).
You can access the Make Project Migration wizard at any time:
➤ Open Window→Customize Perspective. . . →Other→Update
Make Projects
The IDE will then add an icon (Update Old Make Project) to the
toolbar so you can launch the conversion wizard. The icon is activated
whenever you select projects that are candidates for conversion.
July 30, 2004
Appendix: D Migrating to the 6.3 Release
381
From 6.2.1 to 6.3.0
 2004, QNX Software Systems Ltd.
The conversion wizard looks like this:
382
Appendix: D Migrating to the 6.3 Release
July 30, 2004
 2004, QNX Software Systems Ltd.
From 6.2.0 to 6.3.0
From 6.2.0 to 6.3.0
1
July 30, 2004
Start the IDE pointing at your 6.2.0 workspace. You’ll see a
splash page (“Please wait — Completing the install”), followed
by the Different Workspace Version dialog:
Appendix: D Migrating to the 6.3 Release
383
From 6.2.0 to 6.3.0
 2004, QNX Software Systems Ltd.
2
Click OK to convert your workspace.
3
Next the Cannot Preserve Layout dialog tells you that the
saved interface layout can’t be preserved:
This is to be expected, because we’re upgrading the major,
incompatible versions of installed components and of the
workspace itself. Click OK.
Now you’re ready to migrate your existing projects to 6.3.0.
Migrating your projects
The format of 6.2.0 C/C++ projects (include QNX projects) is
incompatible with the 6.3.0 format — you must follow these steps to
convert your old projects:
1
The initial projects will appear in the workspace as non-C/C++
projects. First you must convert each project based on the type
of project it was originally stored as:
Standard C/C++ projects (which are based on an external
build configuration such as a Makefile)
384
Appendix: D Migrating to the 6.3 Release
July 30, 2004
From 6.2.0 to 6.3.0
 2004, QNX Software Systems Ltd.
QNX C/C++ projects (which are based specifically on the
QNX multiplatform Makefile macros).
Use the appropriate conversion wizard:
For this type of project:
Open this wizard:
Standard C/C++
File→New→Other. . . →C→Convert to a C/C++
Make Project
QNX C/C++
File→New→Other. . . →QNX→Migrate QNX 6.2.0
Projects
2
☞
July 30, 2004
Go through this conversion process for each 6.2.0 project so it
can take full advantage of the new features of the C/C++
Development Tools. You must also do this for any projects that
are stored outside your workspace (e.g. in a revision control
system).
Many project options have changed from QNX 6.2.0 to QNX 6.3.0.
Although the conversion process will attempt to maintain
configuration options, you should verify your individual project files
to make sure any new settings have been initialized to the values you
want.
Appendix: D Migrating to the 6.3 Release
385
Glossary
July 30, 2004
Glossary
387
 2004, QNX Software Systems Ltd.
console
Name for a general view that displays output from a running program.
Some perspectives have their own consoles (e.g. C-Build Console,
Builder Console).
drop cursors
When you move a “floating” view over the workspace, the normal
pointer changes into a different image to indicate where you can dock
the view.
Eclipse
Name of a tools project and platform developed by an open
consortium of vendors (Eclipse.org), including QNX Software
Systems.
The QNX Developer Tools Suite consists of a set of special plugins
integrated into the standard Eclipse framework.
editors
Visual components within the workbench that let you edit or browse
a resource such as a file.
navigator
One of the main views in the workbench, the Navigator shows you a
hierarchical view of your available resources.
outline
A view that shows a hierarchy of items, as the functions and header
files used in a C-language source file.
perspectives
Visual “containers” that define which views and editors appear in the
workspace.
July 30, 2004
Glossary
389
 2004, QNX Software Systems Ltd.
plugins
In the context of the Eclipse Project, plugins are individual tools that
seamlessly integrate into the Eclipse framework. QNX Software
Systems and other vendors provide such plugins as part of their IDE
offerings.
profiler
A QNX perspective that lets you gather sample “snapshots” of a
running process in order to examine areas where its performance can
be improved. This perspective includes a Profiler view to see the
processes selected for profiling.
project
A collection of related resources (i.e. folders and files) for managing
your work.
resources
In the context of the workbench, resources are the various projects,
folders, and files that you work with.
In the context of the QNX System Information Perspective, resources
are the memory, CPU, and other system components available for a
running process to use.
script
A special section within a QNX buildfile containing the command
lines to be executed by the OS image being generated.
stream
Eclipse term for the head branch in a CVS repository.
target
Has two meanings:
As a software term, refers to the file that the make command examines
and updates during a build process. Sometimes called a “make target.”
390
Glossary
July 30, 2004
 2004, QNX Software Systems Ltd.
As a hardware term, refers to the Neutrino-based PC or embedded
system that’s connected to the host PC during cross-development.
tasks
A view showing the resources or the specific lines within a file that
you’ve marked for later attention.
UI
User interface.
views
Alternate ways of presenting the information in your workbench. For
example, in the QNX System Information perspective, you have
several views available: Memory Information, Malloc Information,
etc.
workbench
The Eclipse UI consisting of perspectives, views, and editors for
working with your resources.
July 30, 2004
Glossary
391
Index
!
.bsh file (System Builder)
.efs file (System Builder)
.ifs file (System Builder)
.kev files (System Profiler)
.launch file 349
.project file 145
.sysbldr meta file 145
.zip archives 83
/dev/dbgmem 240
135
143
142
282
A
Add New Target 172
advanced mode (Properties
dialog) 328
using to override regular
options 328
Allocation Trace tab (Memory
Events view) 237, 243
analysis tools
specifying for launch 350
Application Profiler 187–206
July 30, 2004
specifying for launch 350
Application Profiler Editor 201
colors used in 201
Application Profiler perspective
configuring the IDE to
automatically change to
194
Arguments pane (Process
Information view) 266
Arguments tab (launch
configurations dialog)
341, 343
assumptions in this guide xxi
autobuild
turning off 40
B
binaries
seeing usage messages for 134
Binary Inspector view 132, 134
Binary Parser tab (New Project
wizard) 316
block coverage 209
Index
393
Index
 2004, QNX Software Systems Ltd.
defined 210
bookmarks
for Help documents 8
Bookmarks view 283
boot order 137
boot script 140
boot scripts 135
branch coverage 209
currently not provided in the
IDE 210
defined 210
breakpoints 111–118
removing 118
BSP
importing source into the
IDE 83
perspective 89
BSPs
buildfiles ship with 135
filename conventions in 141
build
all projects 41
automatic feature 40
configurations 75
executables with code coverage
enabled 212
options 43
order of projects 42
saving resources before 42
single projects 41
terminology 40
turning off the autobuild
feature 40
variants 39
Build Command field (New Project
wizard) 313
394
Index
Build Setting field (New Project
wizard) 313
Build Variants tab (New Project
wizard) 310
buildfile
defined 135
importing a 147
C
C project
standard make, as distinct from a
QNX multivariant project
13
C++ library
selecting a 324
C-Build view 40
C/C++ Development
perspective 33–60
C/C++ Local launch
configuration 334
C/C++ Postmortem debugger launch
configuration 334
C/C++ Projects view 33, 34
adding standard includes and
defines 61
compared with Navigator
view 35
C/C++ QNX PDebug (Serial) launch
configuration 334
C/C++ QNX QConn (IP) launch
configuration 334
C/C++ Editor 47–54
adding comments to code in 51
color 52
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
debugging from 106
font 52
line numbers 52
preferences 52
C/C++ Editor view 33
call counts See also call pairs
call pairs 205
Calls Made pane (Malloc
Information view) 247
case
don’t use to distinguish a project
or file 12
channels
shown in the System Blocking
Graph view 271
clean (build term) 40
code coverage 209–221
block coverage 209
branch coverage 209
combining sessions 218
defined 209
enabling 212
for non-QNX projects 212
icons 217
IDE tool is a visual font end to
gcov 209
line-by-line information 218
markers 219
measures quality of tests 209
scan interval 215
should be set for only one build
variant at a time 212
summary report 221
viewing reports in a
browser 220
Code Coverage Report view 219
Code Coverage Sessions view 216
July 30, 2004
code coverage tool
specifying for launch 350
coexistence of OS versions 17
color
in the C/C++ Editor 52
colors
for signals 271
combined image 140, 143
comments
adding to code in
C/C++ Editor 51
Common tab (launch configurations
dialog) 341, 348
common.mk file
toggle to reveal hidden internal
code 303
communications
IP 23
serial 23
compiler
optimization levels 322
selecting type of 322
specifying command-line
options 323
specifying defines to be passed
to 322
warning levels 322
Compiler tab (Properties
dialog) 322
Condition Statistics view 283
Connection Information view 259,
273
Console view (Debugger) 125
containers
build configurations
creating 78
editing 79
Index
395
Index
 2004, QNX Software Systems Ltd.
build configurations for 78
building 82
creating 75
defined 75
editing configurations for 79
seeing tree-view of 79
Content Assist 48
conventions
for filenames in QNX
BSPs 141
for filenames in the System
Builder 142
POSIX/UNIX filesystem xxii
conversion wizard 319
Core Requests pane (Malloc
Information view) 247
CVS
default source-management
system in the IDE 67
CVS Repositories view 70
CVS Repository Exploring
perspective 68
D
dbgmallog g.so
238
DDK
importing source into the
IDE 84
debug
agent 25
Debug perspective
views in 108
Debug view 101
396
Index
selections in drive other
views 101
Debug/Release mode
for adding extra libraries (Linker
tab in Properties dialog)
326
debugger 97–127
options in launch
configuration 347
specifying source locations
for 348
Debugger tab (launch configurations
dialog) 341, 345
debugging
assembly-language
functions 107
building an executable for 98
controls for 102
session
controlling a 106
several programs
simultaneously 97
via C/C++ editor 106
via hotkeys 104
without the Debug view 104
devc-pty 343
Dietician (System Builder) 168
disassembly mode (Debugger) 107
Distribution pane (Malloc
Information view) 248
Download tab (launch configurations
dialog) 341, 344
drag-and-drop 70, 90
dumper command 375
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
E
Eclipse
consortium 3
documentation on using CVS in
the IDE 68
Platform 3
editor
C/C++ 47, 60
Content Assist feature 48
defined 11
enhanced source navigation 60
jumping to function source
(F3) 60
opening headers (Ctrl – Shift –
o) 60
System Builder 132
editor (System Profiler) 282
editors
alternate
aren’t integrated with rest of
IDE 11
inside the IDE 11, 53
outside the IDE 11, 53
Element Statistics view 283
Environment tab (launch
configurations dialog)
341, 344
environment variables
MAKEFLAGS 19
QNX CONFIGURATION 17,
19
QNX HOST 19
QNX TARGET 19
setting in launch configurations
dialog 344
TMPDIR 19
July 30, 2004
Environment Variables pane (Process
Information view) 266
Error events tree 241
error log file 371
Error Parsers tab (New Project
wizard) 314
errors
markers used to indicate 55
Event backtrace pane 242
executable
sending fresh copy of whenever
you run or debug 344
stripping debug information
before downloading 345
unique name of for each
download session 345
executables
building for debugging 98
Export wizard 90
expressions
evaluating/examining in the
debugger 118
Expressions view 118
extra libraries
adding to launch
configuration 345
F
F3 (jump to function source)
60
FDs
side channels shown for 274
file
locations in workspace 371
File System Navigator view 171
Index
397
Index
 2004, QNX Software Systems Ltd.
Add New Target option 172
filename conventions
in QNX BSPs 141
in the System Builder 142
files
associations with editors 53
bringing into a project
folder 303
created outside the IDE 303
creating from scratch 54
exporting 90
filtering 36
host-specific 19
IDE removes from target after
downloading 345
importing 70
moving between host and target
machines 171
opening 35
opening headers 60
target-specific 19
Filesystem pane (System
Builder) 132
flash filesystem
appending to an OS image 165
flashcmp command 375
font
in the C/C++ Editor 52
functions
finishing names of in the
editor 48
jumping to source for 60
398
Index
G
gcc command 375
gcov command 375
GDB
using directly from the
IDE 127
gdb command 375
General Resources display (System
Resources view) 275
General Statistics view 283
gmon.out file 190
importing a 197
gprof command 375
H
heap usage 235
hello world 38
running 45
Help
creating bookmarks in 8
HTML server within the IDE 7
navigating 7
tips and tricks 9
help
hover for function synopsis 50
History pane (Malloc Information
view) 248
hosts
host-specific files, location
of 19
hovering (in System Profiler
editor) 296
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
I
icc command
375
icons
in Code Coverage Sessions
view 217
IDE
convenience of 3
help system 7
migrating to the current
version 379
starting via icon or menu
item 4
starting via the qde
command 4
IDE User’s Guide
how to use xix
Identification Details pane (Process
Information view) 266
image
adding files to 155
booting 137
combined 140
combines 143
downloading a 149
final format of 165
flash filesystem 140, 143
OS 140, 142
properties of 158
types of in System Builder 140
Image Combine (System
Builder) 164
Images directory 145
Images pane (System Builder) 132
Import wizard 70
include paths
July 30, 2004
adding standard includes and
defines 61
specifying 323
instrumented kernel 284
IOFlags column (Connection
Information view) 274
IP communications 23
IPL 138
adding to an image 164
K
kernel
instrumented 284
keyboard shortcuts 15
L
launch configurations 44, 333–351
creating for debugging 335
creating for running 337
dialog 341
tabs in 341
for a debuggable
executable 100
list of favorites 339, 349
not automatically deleted when
you delete associated
projects 47
types of 333
launcher 15
running a program without 338
launches
old
Index
399
Index
 2004, QNX Software Systems Ltd.
removing 200
ld command 375
LD PRELOAD 239
libraries
buttons for adding (Linker tab in
Properties dialog) 326
how to build 307
optimizing in System
Builder 168
shared 308
shared without export 308
specifying locations of for the
linker 325
static 307
static for shared objects 308
line numbers
how to show them in the
C/C++ Editor 52
link map
generating a 324
linked resources 70
linker
command-line options 325
Linker tab (Properties dialog) 323
log files (System Profiler) 282
M
Main tab (launch configurations
dialog) 341
make
targets
adding 43
removing 44
400
Index
Make Builder tab (New Project
wizard) 312
make command 375
Make Project Migration wizard 381
makefile
recursive hierarchy 38
MAKEFLAGS 19
Malloc Information view 234, 235,
245, 246, 259
MALLOC DEBUG 240
MALLOC EVENTFILE 240
MALLOC TRACE 240
markers
for errors 55
memory
changing a process’s 121
errors 225–251
events 235
filtering 244
leaks 234
management 226
Memory Event Action 237
Memory Events view 234, 235, 240
Memory Information view 235,
245, 249, 259
Memory Resources display (System
Resources view) 276
Memory Trace 233
Memory Trace tool
launching a program to
use 236
manually launching a program
to use 238
specifying for launch 350
Memory view
customizing 123
Memory view (Debugger) 120
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
migrating
involves two steps 379
to the current version of the
IDE 379–385
mkefs 132
mkefs command 375
mkifs 132
mkifs command 375
mkimage command 375
mkrec command 375
mksbp 132
mksbp command 375
multivariant project
as distinct from a standard make
C project 13
N
natures 13
Navigator view 33
compared with C/C++ Projects
view 35
New Project wizard 38, 303
tabs in 310
New QNX Target System Project
wizard 317
O
objcopy command
375
opening headers 60
Options tab (New Project
wizard) 314
OS image
July 30, 2004
components of 137
OS versions
coexistence of 17
specifying which to build
for 18
Outline view 37
Overrides directory 145
must be first in the list of search
paths 168
P
padding (System Builder) 144
pathname delimiter in QNX
docs xxi
Paths and Symbols tab (New Project
wizard) 316
pdebug 25, 334
pdebug command 375
perspective
C/C++ Development 33–60
defined 9
perspectives
govern which views appear 10
specifying which to switch to
during launch 349, 351
PhAB
editing code in 181
how to close 180
reopening 180
PhAB (Photon Application
Builder) 177
Phindows 29
Photon Application Builder
(PhAB) 177
Index
401
Index
 2004, QNX Software Systems Ltd.
pidin command
375
platforms
all are enabled by default 311
how to specify which to build
for 311
position-independent code
(PIC) 308
post-build actions (Linker tab in
Properties dialog) 327
preferences 16
C/C++ Editor 52
Process Information view 259, 264
Processes pane (System Summary
view) 264
procnto 138, 139, 160
variants 139
procnto command 375
procnto-instr 284
PROFDIR 196
profiling
a running process 194
building a program for 190
instrumented 189
non-QNX projects 192
per-function 202
per-line 200
per-thread 203
postmortem 189, 196
running and profiling a
process 192
sessions
how to control 198
statistical 188
types of 188
program
debugging for the first
time 335
402
Index
relaunching a 341
running for the first time 337
running/debugging once you’ve
created a launch
configuration 339
programs
creating 34
running 34, 44
project
defined 11
names
don’t use case alone to
distinguish 12
don’t use spaces in 12
Project Name Prefix (BSP import
wizard) 87
project.bld file (System
Builder) 136, 145
projects
building 148
container 75
converting to QNX type 318
creating 38
creating in the System
Builder 147
deleting 46
does not also delete launch
configuration 47
different types of 304
exporting 90
flash filesystem 147
how to create 304
importing 70
migrating from 6.2.0 to
6.3.0 384
migrating from 6.2.1 to
6.3.0 381
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
nesting
not yet supported in
Eclipse 71
non-QNX
how to create 308
opening 35
properties of
setting 328
System Builder 145
configuring 154, 163
target system 316
Projects tab (New Project
wizard) 312
properties
image (System Builder) 159
item (System Builder) 162
Properties dialog
advanced mode 328
used when converting a
project 320
Properties view
in System Builder 154
Q
qcc command 375
qconfig 17
qconfig command 375
qconn 239, 334
qconn command 375
qde command 4
location of executable file 4
QNX
recursive makefile
hierarchy 38
July 30, 2004
QNX BSP Perspective 89
QNX C/C++ Application Project
relies on QNX recursive
makefile hierarchy 38
QNX C/C++ project
as distinct from a standard make
C/C++ project 13
QNX Code Coverage
perspective 218
QNX GDB Console view
enabling 126
QNX Memory Analysis
perspective 225
switching to automatically 238
QNX Momentics
version of on host must match
OS version on target 24
QNX Neutrino
memory management in 226
robust architecture of 226
QNX System Builder
perspective 131
QNX Target System Project
creating a 45
QNX tools
overview 4
QNX CONFIGURATION 17, 19
QNX HOST 19
QNX TARGET 19
qwincfg command 375
R
rebuild 40
Reductions directory
145, 171
Index
403
Index
 2004, QNX Software Systems Ltd.
must be second in the list of
search paths 168
Registers view 119
regular mode (Properties
dialog) 328
resources
defined 15
linked 70
ROM monitor 131, 149, 153
root
all programs launched from the
IDE run as 266
Run→Run. . . menu item 335
S
scan interval (code coverage) 215
scrolling (in System Profiler
editor) 295
search paths (System Builder) 166
Seek Offset column (Connection
Information view) 274
selection
types of in the System Profiler
editor 294
sendnto 131, 151
sendnto command 375
serial communications 24
serial terminal 149
Set QNX Build Environment
wizard 61
shared libraries
deleting reduced versions
of 171
404
Index
Shared Libraries view
(Debugger) 123
shortcuts, keyboard 15
side channels 274
signal
sending to a running
process 261
Signal Information view 259, 270
signals
color-coding for 271
sending to a suspended
program 125
Signals view (Debugger) 124
source
specifying locations of 323
source (from QNX)
importing into the IDE 83
source code
exporting
to a .zip file 90
to the filesystem 90
importing into the IDE 70
Source tab (launch configurations
dialog) 341, 348
spaces
don’t use when naming a project
or file 12
stack errors 235
startup code 138, 139
strip command 375
stripped name (Linker tab in
Properties dialog) 325
symbols
loading 123
stripping from a binary 324
System Blocking Graph view 259,
271
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
System Builder
editor 132
Filesystem pane 132
Images pane 132
toolbar 133
System Builder Console view 148
System Builder project
creating a 147
System Builder Projects view 135
System Information
perspective 255
CPU processing load and 263
key terms used in 256
updating views in 261
views in 259
System Memory pane (System
Summary view) 264
System Resources view 259, 274
selecting which display to
see 274
System Specifications pane (System
Summary view) 264
System Summary view 259, 263
System Uptime display (System
Resources view) 274
target system project
creating a 316
target-specific files, location of 19
targets (make) 43
adding 43
removing 44
Tasks view 55
terminal emulation 343
TFTP server 149, 151
TFTP server view 131
Thread Details pane (Process
Information view) 266
Thread Information view 259, 266
configuring 267
tips and tricks (item in Help
menu) 9
TMPDIR 19
toolbar
System Builder 133
Tools tab (launch configurations
dialog) 341, 349
Total Heap pane (Malloc Information
view) 247
Trace Event Log view 283
Trace Search 283
tracelogger command 375
T
U
target (machine) 23
Target Navigator view 259
customizing 260
sending a signal using 261
using to control Malloc
Information and Memory
Information views 245
July 30, 2004
Unmatched allocations tab (Memory
Events view) 245
Unmatched deallocations (Memory
Events view) 245
update interval (QNX Application
Profiler) 193, 195
Index
405
Index
 2004, QNX Software Systems Ltd.
Update Old Make Project icon 381
usage message
for binaries in System
Builder 134
usage message, displayed for each
item in System Builder
132
usemsg command 375
user’s guide
how to use this xix
utilities
used by the System
Builder 148
V
variables
preventing the debugger from
reading 110
Variables view 111
view
Application Profiler 199
Binary Inspector 132, 134
Bookmarks 283
C-Build 40
C/C++ Projects 33, 34
C/C++ Editor 33
Code Coverage Report 219
Code Coverage Sessions 216
Condition Statistics 283
Debug 101
Element Statistics 283
File System Navigator 171
General Statistics 283
Navigator 33
406
Index
Outline 37
System Builder Console 148
System Builder Projects 135
Trace Event Log 283
views
defined 10
W
watchpoints 111–118
removing 118
wizard
conversion 381
Make Project Migration 381
wizards 301–321
are categorized according to
natures 301
creating “nature-free” files,
folders, or projects 302
creating a new project 303
how to access 301
New Project 38, 310
New QNX Target System
Project 317
Set QNX Build
Environment 61
simple 302
workbench 5
menus 6
Workbench Build Behavior field
(New Project wizard) 314
Workbench User Guide 33
references to CVS in 68
working directory
on target machine 344
July 30, 2004
Index
 2004, QNX Software Systems Ltd.
Working Set Name (BSP import
wizard) 87
workspace
defined 12
migrating from 6.2.0 to
6.3.0 383
migrating from 6.2.1 to
6.3.0 380
specifying where the IDE should
look for a 12
X
XIP
160
Z
zooming (in System Profiler
editor) 295
July 30, 2004
Index
407
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement