INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE...

466
INTEGRATED DEVELOPMENT ENVIRONMENT USER’S GUIDE QNX ® MOMENTICS ® DEVELOPMENT SUITE V6.3

Transcript of INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE...

Page 1: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

INTEGRATED DEVELOPMENT ENVIRONMENTUSER’S GUIDE

Q N X ® M O M E N T I C S ® D E V E L O P M E N T S U I T E V 6 .3

Page 2: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

QNX Momentics PE 6.3

IDE User’s Guide

For Windows , Linux , Solaris , and QNX Neutrino hosts

2005, QNX Software Systems Ltd.

Page 3: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

QNX Software Systems Ltd.175 Terence Matthews CrescentKanata, OntarioK2M 1W8CanadaVoice: +1 613 591-0931Fax: +1 613 591-3579Email: [email protected]:http://www.qnx.com/

2002 – 2005, QNX Software Systems Ltd. All rights reserved.

Publishing history

May 2004 First edition

Electronic edition published January 2005.

Technical support options

To obtain technical support for any QNX product, visit theTechnical Support section in theServices area on our website(www.qnx.com). You’ll find a wide range of support options, including our free web-basedDeveloper 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

Page 4: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Contents

About This Guide xviiTypographical conventions xix

How to use this guide xxi

Assumptions xxiii

Note to Windows users xxiii

IDE Concepts 11What is an IDE? 3

An IDE for building embedded systems 3

Starting the IDE 4

Starting the IDE from the command line 4

Workbench 5

Workbench menus 6

Help system 7

Opening the IDE Help 7

Navigating the Help 7

Help bookmarks 9

Tips and tricks 9

Perspectives 9

Views and editors 10

Views 10

Editors 11

Projects and workspace 12

Specifying a workspace location 12

How the IDE looks at projects 13

January 31, 2005 Contents iii

Page 5: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Host and target machines 14

Target agent (theqconn daemon) 14

Launcher 15

Resources 15

Wizards 15

Keyboard shortcuts 15

Preferences 16

Version coexistence 17

Specifying which OS version to build for 18

Environment variables 19

Preparing Your Target 212Host-target communications 23

IP communications 23

Serial communications 24

Example: Serial debugging via PPP 25

Connecting with Phindows 29

Developing C/C++ Programs 313The 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 43

Creating personal build options 44

Running projects 45

iv Contents January 31, 2005

Page 6: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Deleting projects 47

Writing code 48

C/C++ Editor layout 48

Finishing function names 49

Inserting code snippets 50

Adding#include directives 51

Hover help 51

Commenting-out code 52

Customizing the C/C++ Editor 53

Using other editors 53

Creating files from scratch 55

More development features 55

Tracking remaining work 56

Code synopsis 59

Checking your build 60

Accessing source files for functions 61

Opening headers 61

Managing Source Code 654CVS and the IDE 67

Local history feature 68

Project files (.project and.cdtproject) 68

Core Eclipse documentation on using CVS in the IDE 68

Importing existing source code into the IDE 70

Projects within projects? 71

Filesystem drag-and-drop 75

CVS repository 76

Import wizard 81

Linked resources 81

Using container projects 82

Creating a container project 82

Setting up a build configuration 85

Editing existing configurations 86

January 31, 2005 Contents v

Page 7: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Importing a BSP or other QNX source packages 90

Step 1: UseFile→Import. . . 90

Step 2: Select the package 92

Step 3: Select the source projects 93

Step 4: Select a working set 94

Step 5: Build 95

Exporting projects 97

Using theExport. . . command 97

Debugging Programs 1035Introduction 105

Debugging your program 106

Building an executable for debugging 106

Starting your debugging session 108

Controlling your debug session 109

Using the controls 110

Debug launch controls 114

Disassembly mode 115

More debugging features 116

Inspecting variables 116

Using breakpoints and watchpoints 119

Evaluating your expressions 126

Inspecting your registers 127

Inspecting a process’s memory 128

Inspecting shared-library usage 131

Monitoring signal handling 132

Viewing your output 133

Debugging with GDB 134

Building OS and Flash Images 1376Introducing the QNX System Builder 139

Toolbar buttons 141

Binary Inspector 142

vi Contents January 31, 2005

Page 8: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Boot script files 143

Builder projects 144

The scope of the Builder 144

Overview of images 145

The components of an image, in order of booting 145

Types of images you can create 148

Project layout 153

Overview of workflow 154

Creating a project for an OS image 155

Creating a project for a flash filesystem image 155

Building an OS image 156

Downloading an image to your target 157

Downloading via a serial link 157

Downloading via TFTP 159

Downloading using other methods 161

Configuring your Builder projects 162

Managing your images 163

Configuring image properties 166

Configuring project properties 171

Optimizing your system 176

Optimizing all libraries in your image 177

Optimizing a single library 178

Restoring a slimmed-down library 179

Moving files between the host and target 179

Moving files to the target 180

Moving files from the target to the host 181

Developing Photon Applications 1837What is PhAB? 185

PhAB and the IDE 186

Using PhAB 187

Creating a QNX Photon Appbuilder project 187

Closing PhAB 188

January 31, 2005 Contents vii

Page 9: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Reopening PhAB 188

Editing code 189

Building a QNX Photon Appbuilder project 190

Starting Photon applications 190

Profiling an Application 1938Introducing the Application Profiler 195

Types of profiling 196

Profiling your programs 197

Building a program for profiling 198

Running and profiling a process 200

Profiling a running process 202

Postmortem profiling 204

Controlling your profiling sessions 206

Understanding your profiling data 208

Usage by line 208

Usage by function 210

Usage by thread 211

Call counts 212

Using Code Coverage 2159Code coverage in the IDE 217

Types of code coverage 217

How the coverage tool works 218

Enabling code coverage 220

Enabling code coverage for non-QNX projects 220

Starting a coverage-enabled program 221

Controlling your session 224

Examining data line-by-line 226

Examining your coverage report 227

Seeing your coverage at a glance 229

Finding Memory Errors 23110

viii Contents January 31, 2005

Page 10: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Introduction 233

Memory management in QNX Neutrino 234

What the Memory Analysis perspective can reveal 241

Analyzing your program 244

Manually launching a program for memory tracing 246

Preparing your host and the target agent 247

Tracing memory events 249

Error events tree 249

Event backtrace pane 251

Allocation Trace tab 251

Unmatched allocations tab 253

Unmatched deallocations 253

Controlling your memory analysis session 253

Examining your target’s memory 254

Malloc Information view 254

Virtual address space 258

Getting System Information 26111Introduction 263

What the System Information perspective reveals 264

Key terms 264

The views in this perspective 267

Controlling your system information session 268

Sending a signal 269

Updating the views 269

Adding views to the System Information perspective 270

Examining your target system’s attributes 271

System Specifications pane 272

System Memory pane 272

Processes pane 272

Watching your processes 272

Arguments pane 274

Thread Details pane 274

January 31, 2005 Contents ix

Page 11: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Environment Variables pane 274

Identification Details pane 274

Tracking thread activity 274

Inspecting virtual address space 277

Tracking heap usage 277

Examining process signals 278

Getting channel information 279

Tracking file descriptors 281

Tracking resource usage 282

System Uptime display 282

General Resources display 283

Memory Resources display 284

Analyzing Your System with Kernel12Tracing 287

Introducing the QNX System Profiler 289

Before you begin 292

Configuring a target for system profiling 293

Launching the System Profiler Configuration wizard 294

Selecting options in the wizard 294

Capturing instrumentation data in event log files 297

Viewing and interpreting the captured data 299

The System Profiler editor 299

Other views in the System Profiler 304

Common Wizards Reference 30713Introduction 309

Creating a C/C++ project 311

How to create a C/C++ project 312

Tabs in the New C/C++ Project wizard 318

Creating a target 324

Converting projects 326

Converting to a QNX project 327

x Contents January 31, 2005

Page 12: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Completing the conversion 328

Importing projects 337

Existing Container Project into Workspace 339

Existing Project into Workspace 342

External Features 343

External Plug-ins and Fragments 343

File System 343

GCC Coverage Data from Project 347

QNX Board Support Package 350

QNX mkifs Buildfile 353

QNX Source Package 356

Team Project Set 359

Zip file 361

Launch Configurations Reference 36514What is a launch configuration? 367

Types of launch configurations 367

Running and debugging the first time 369

Debugging a program the first time 369

Running a program the first time 371

Running and debugging subsequent times 373

Launching a selected program 373

Launching from a list of favorites 373

Launching the last-launched program 375

Setting execution options 375

Main tab 375

Arguments tab 377

Environment tab 378

Download tab 378

Debugger tab 379

Source tab 382

Common tab 382

Tools tab 383

January 31, 2005 Contents xi

Page 13: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Tutorials 387ABefore you start. . . 389

Tutorial 1 — creating a standard make C/C++ project 389

Tutorial 2 — creating a QNX C/C++ project 392

Tutorial 3 — importing an existing project into the IDE 394

Tutorial 4 — importing a QNX BSP into the IDE 395

Step 1: UseFile→Import. . . 395

Step 2: Select the package 397

Step 3: Select the source projects 398

Step 4: Select a working set 399

Step 5: Build 400

Where Files Are Stored 403B

Utilities Used by the IDE 407C

Migrating to the 6.3 Release 411DIntroduction 413

From 6.2.1 to 6.3.0 414

Migrating your workspace 414

Migrating your projects 415

From 6.2.0 to 6.3.0 417

Migrating your projects 418

Glossary 421

Index 427

xii Contents January 31, 2005

Page 14: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

List of Figures

The IDE User’s Guide at a glance. xxi

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 theIDE. 67

CVS project warning 77

The New Project wizard 78

The Confirm Overwrite dialog 79

CVS project warning 79

The Checkout Into dialog 80

This chapter shows you how to work with the debugger. 105

Use the System Builder to create OS and flash images for yourtarget. 139

Typical boot order. 146

Use the PhAB visual design tool to develop Photon apps. 185

This chapter shows you how to use the application profiler. 195

QNX Application Profiler perspective. 196

Use the Code Coverage tool to help test your code. 217

Use the QNX Memory Analysis perspective to solve memoryproblems. 233

Process memory layout on an x86. 236

This chapter shows you how to work with the System Informationperspective. 263

January 31, 2005 List of Figures xiii

Page 15: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

Use the System Profiler to analyze your system viainstrumentation. 289

This chapter describes the IDE’s wizards. 309

TheImport wizard 338

Importing a container project 340

Selecting container components to import 341

Importing an existing project 342

Importing code from the filesystem 344

TheSelect Types dialog lets you filter imported files by selectingone or more extensions. 345

Browsing for a project or folder 346

Importing GCC coverage data 348

Referenced projects and comments 349

Importing a BSP 350

Selecting source projects from a BSP archive 351

Selecting a working set from a BSP archive 352

Building BSP projects 353

Importing a mkifs .build file 354

Selecting a destination System Builder project 355

Importing a QNX Source Package 356

Selecting source projects from a source package 357

Selecting a working set from a BSP archive 358

Building package projects 359

Importing a Team Project Set 360

Importing code from a ZIP archive 361

TheSelect Types dialog lets you filter imported files by selectingone or more extensions. 362

Browsing for a project or folder 363

You must set up a Launch Configuration before you can run ordebug a program. 367

Here are several tutorials to help you get going with the IDE.389

xiv List of Figures January 31, 2005

Page 16: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

This appendix shows you where to find key files used by the IDE.405

This appendix lists the utilities used by the IDE. 409

You can easily migrate your old workspace and projects to thisrelease. 413

January 31, 2005 List of Figures xv

Page 17: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 18: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

About This Guide

January 31, 2005 About This Guide xvii

Page 19: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 20: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Typographical conventions

Typographical conventionsThroughout this manual, we use certain typographical conventions todistinguish technical terms. In general, the conventions we useconform to those found in IEEE POSIX publications. The followingtable 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 componentsCancel

We format single-step instructions like this:

➤ To reload the current page, pressCtrl – R.

We use an arrow (→) in directions for accessing menu items, like this:

January 31, 2005 About This Guide xix

Page 21: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Typographical conventions 2005, QNX Software Systems Ltd.

You’ll find the Other... menu item underPerspective→Show View.

We use notes, cautions, and warnings to highlight importantmessages:

Notes point out something important or useful.☞

CAUTION: Cautions tell you about commands or procedures thatmay have unwanted or undesirable side effects.!

WARNING: Warnings tell you about commands or proceduresthat could be dangerous to your files, your hardware, or evenyourself.

xx About This Guide January 31, 2005

Page 22: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. How to use this guide

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

The IDE User’s Guide at a glance.

How to use this guideThisUser’s Guidedescribes the Integrated Development Environment(IDE), which is part of the QNX Momentics development suite. Theguide introduces you to the IDE and shows you how to use iteffectively to build your QNX Neutrino-based systems.

The workflow diagram above shows how the guide is structured andsuggests how you might use the IDE. Once you understand the basicconcepts, you’re ready to begin the typical cycle of setting up yourprojects, writing code, debugging, testing, and finally fine-tuning yourtarget system.

Each chapter begins with the workflow diagram, but with thechapter’s bubble highlighted to show where you are in the book. Notethat in the online version each bubble is a link.

January 31, 2005 About This Guide xxi

Page 23: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

How to use this guide 2005, QNX Software Systems Ltd.

CAUTION: This release of the IDE is based on Eclipse 2.1. If youhave an older version of the IDE, see Appendix C: Migrating to the6.3 Release in this guide.

!

The following table may help you find information quickly:

To: Go to:

Learn about theworkspace,perspectives, views,and editors

IDE Concepts

Use the IDE’s helpsystem

IDE Concepts

Connect your hostand target

Preparing Your Target

Import existingcode into the IDE

Managing Source Code

Import a QNX BSPsource package

Managing Source Code

Set executionoptions for yourprograms

Launch Configurations Reference

Check code intoCVS

Managing Source Code

Run QNX Neutrinoon your target

Building OS and Flash Images

Examine executionstats (e.g. callcounts) in yourprograms

Profiling an Application

continued. . .

xxii About This Guide January 31, 2005

Page 24: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Assumptions

To: Go to:

Exercise a test suite Using Code Coverage

Find and fix amemory leak in aprogram

Finding Memory Errors

See process orthread states,memory allocation.etc.

Getting System Information

Examine yoursystem’sperformance,kernel events, etc.

Analyzing Your System with Kernel Tracing

Look up a keyboardshortcut

IDE Concepts

Find the meaningof a special termused in the IDE

Glossary

AssumptionsThis guide assumes the following:

� On your host you’ve already installed the QNX Momentics suite,which includes a complete QNX Neutrino developmentenvironment.

� You’re familiar with the architecture of the QNX Neutrino RTOS.

� You can write code in C or C++.

Note to Windows usersIn our documentation, we use a forward slash (/) as a delimiter inallpathnames, including those pointing to Windows files.

January 31, 2005 About This Guide xxiii

Page 25: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Note to Windows users 2005, QNX Software Systems Ltd.

We also generally follow POSIX/UNIX filesystem conventions.

xxiv About This Guide January 31, 2005

Page 26: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 1

IDE Concepts

In this chapter. . .What is an IDE? 3Starting the IDE 4Workbench 5Help system 7Perspectives 9Views and editors 10Projects and workspace 12Host and target machines 14Target agent (theqconn daemon) 14Launcher 15Resources 15Wizards 15Keyboard shortcuts 15Preferences 16Version coexistence 17

January 31, 2005 Chapter 1 � IDE Concepts 1

Page 27: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 28: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. What is an IDE?

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter introduces key concepts used in the IDE.

What is an IDE?Welcome to the Integrated Development Environment (IDE), apowerful set of tools in the QNX Momentics Professional Editiondevelopment suite. The IDE is based on the Eclipse Platformdeveloped by Eclipse.org, an open consortium of tools vendors(including QNX Software Systems).

The IDE incorporates into the Eclipse framework severalQNX-specific plugins designed for building projects for targetsystems running the QNX Neutrino RTOS. The tools suite provides asingle, consistent, integrated environment, regardless of the hostplatform you’re using (Windows, Linux, Solaris, or QNX Neutrino).Note that all plugins from any vendor work within the Eclipseframework in the same way.

An IDE for building embedded systemsThe IDE provides a coherent, easy-to-use work environment forbuilding your applications. If you’ve used an IDE before, then youalready have a good idea of the convenience and power this kind oftoolset can offer.

January 31, 2005 Chapter 1 � IDE Concepts 3

Page 29: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Starting the IDE 2005, QNX Software Systems Ltd.

Through a set of related windows, the IDE presents various ways ofviewing and working with all the pieces that comprise your system. Interms 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 andmakefile structure. On the contrary, it relies on those tools. And evenif you continue to build your programs at the command line, you canalso benefit from the IDE’s unique and powerful tools, such as theQNX System Analysis tool and theQNX System Profiler, whichcan literallyshowyou, in dynamic, graphical ways, exactly what yoursystem is up to.

Starting the IDEAfter you install QNX Momentics, you’ll see — depending on whichhost 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 lineYou can also start the IDE by running theqde command:

1 Go to the directory where theqde.exe executable (Windows)or theqde script (all other hosts) resides. For example,C:/QNX630/host/win32/x86/usr/qde/eclipse.

2 Run this command:

4 Chapter 1 � IDE Concepts January 31, 2005

Page 30: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Workbench

qde

Don’t run theeclipse command, even thought it may seem to work.Always useqde instead, because it sets up the proper QNX-specificenvironment.

You can also direct the IDE at a particularworkspacelocation. Fordetails, see the section “Specifying a workspace location” in thischapter.

For more information on starting the IDE, including advancedexecution options for developing or debugging parts of Eclipse itself,seeTasks→Running Eclipse in theWorkbench User Guide.

WorkbenchWhen you first run the IDE, you should see theworkbench, whichlooks like this:

January 31, 2005 Chapter 1 � IDE Concepts 5

Page 31: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Workbench 2005, QNX Software Systems Ltd.

The first thing you see.

Workbench menusAt the top of the workbench you’ll see a menu bar that containsseveral menus:

For details on each menu, seeReference→User InterfaceInformation→Workbench menus in theWorkbench User Guide.For a basic tutorial on using the workbench UI, seeGettingStarted→Basic tutorial→The Workbench in theWorkbench UserGuide.

6 Chapter 1 � IDE Concepts January 31, 2005

Page 32: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Help system

Help systemThe IDE contains its own Help system, which is an HTML server thatruns in its own window “above” the workbench (i.e. the Help isn’t aperspective or a view).

Opening the IDE HelpFrom the main menu, selectHelp→Help Contents:

The Help Contents menu item is enabled by default. If for somereason you don’t see the menu item:

1 From the main menu, selectWindow→CustomizePerspective.

2 In the left pane of the Customize Perspective dialog, selectOther→Help.

3 In the left pane, click theHelp box.

4 Click OK. The Help Contents menu item is now available.

Navigating the HelpThe left pane of the Help window is thebookshelf, which has links tothe various documentation sets. Click one of the links to view adocument. Note that you can return to the bookshelf at any time by

clicking theTable of Contents button ( ).

The Contents pane includes at least the following titles:

January 31, 2005 Chapter 1 � IDE Concepts 7

Page 33: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Help system 2005, QNX Software Systems Ltd.

Workbench User Guide

Written by Eclipse.org, the book explains Eclipse concepts andcore IDE functionality, and includes tutorials on using theworkbench. Although some of the workbench topics arecovered lightly here in this IDEUser’s Guide, you can find fulldocumentation on using the workbench in the EclipseWorkbench User Guide.

QNX Momentics Professional Edition

The QNX documentation set, which includes several titles:

� A Roadmap to the QNX Momentics Professional Edition

� Dinkum library documentation

� High Availability Toolkit

� Getting Started with Neutrino 2

� Integrated Development Environment (featuring thisUser’sGuide)

� Phindows for QNX Neutrino

� Photon Multilingual Input

� Photon microGUI for QNX Neutrino

� Power Management

� QNX Neutrino RTOS 6.3 (featuring theUser’s Guide,Utilities Reference, andLibrary Reference

� System Analysis Toolkit

� Documentation for DDKs, and much, much more (over11,000 pages in all!).

Some title pages have content on them, some don’t. If you click atitle, and the right side of the window remains blank, you’ve hit a“placeholder” title page. Simply expand the title entry to see itscontents.

8 Chapter 1 � IDE Concepts January 31, 2005

Page 34: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Perspectives

Help bookmarksYou can create a bookmark for any help page:

1 On the Help browser’s toolbar, click theBookmark Document

button ( ).

2 To see your bookmarks, click theBookmarks ( ) tab at thebottom of the contents pane.

To learn more about the IDE’s Help system, follow these links in theEclipseWorkbench User Guide: Concepts→Help system.

Tips and tricksThe Help menu contains aTips 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.).

PerspectivesA perspectiveis a task-oriented arrangement of the workbenchwindow.

For example, if you’re debugging, you can use the preconfiguredDebug perspective, which sets up the IDE to show all the tools relatedto debugging. If you wanted to work with the elements and toolsrelated to profiling, you’d open the Application Profiler perspective.

January 31, 2005 Chapter 1 � IDE Concepts 9

Page 35: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Views and editors 2005, QNX Software Systems Ltd.

You can customize a perspective by adding or removing elements. Forexample, if you wanted to have certain profiling tools availablewhenever you’re debugging, you could add those elements to theDebug perspective.

Perspectives generally consist of these components:

� toolbars

� views

� editors.

Perspectives govern whichviewsappear on your workbench. Forexample, when you’re in the Debug perspective, the following mainviews are available (in the default configuration):

� Debug

� Breakpoints

� Variables

� Console

� Tasks.

Views and editorsViews

Viewsorganize information in various convenient ways. For example,the Outline view shows you a list of all the function names whenyou’re editing a C file in the C/C++ Editor. The Outline view isdynamic; if you declare a function calledmynewfunc(), the Outlineview immediately lists it.

Views give you different presentations of your resources. Forexample, 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:

10 Chapter 1 � IDE Concepts January 31, 2005

Page 36: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Views and editors

� insight into editor contents (e.g. Outline view)

� navigation (e.g. Navigator view)

� information (e.g. Tasks view)

� control (e.g. Debug view).

EditorsYou useeditorsto browse or change the content of your files. Eacheditor 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.

Theeditor areais a section of the workbench window reserved foreditors. Note that views can be anywhere on the workbench except inthe editor area.

The IDE lets you rearrange views and editors so they’re beside eachother (tiled) or stacked on top of each other (tabbed).

If you wish to use a different text editor than the one that’s built intothe IDE, you can do so, but you’ll lose theintegrationof the variousviews and perspectives. For example, within the IDE’s text editor, youcan 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, orget context-sensitive help as you pause your cursor over a functionname 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 theRefresh command (right-clickmenu in theNavigator view or theC/C++ Projects view).

January 31, 2005 Chapter 1 � IDE Concepts 11

Page 37: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Projects and workspace 2005, QNX Software Systems Ltd.

Projects and workspaceProjectsare generic containers for your source code, makefiles, andbinaries. Before you do any work in the IDE, you must first createprojects to store your work. One of the more common projects is aQNX C/C++ Project.

Throughout this guide, we use the term “C/C++” as shorthand tocover both C and C++ projects. The titles of elements within the IDEitself are often explicit (e.g. “QNX C Project,” “QNX C++ 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 youchanged it.

Your workspaceis a folder where you keep your projects. For theexact location of your workspace folder on your particular host, seethe appendix Where Files Are Stored in this guide.

Specifying a workspace locationYou can redirect the IDE to point at different workspaces:

➤ From the directory where theqde.exe executable (Windows)or theqde script (all other hosts) resides, run this command:

qde -data path to workspace

This command launches the IDE and specifies where you want theIDE to create (or look for) theworkspace folder.

12 Chapter 1 � IDE Concepts January 31, 2005

Page 38: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Projects and workspace

Don’t use spaces when naming a project or file — they can causeproblems with some tools, such as themake utility.

Also, don’t use case alone to distinguish files and projects. OnUnix-style hosts (i.e. Solaris, Linux, QNX Neutrino), filenames arecase-sensitive, but in Windows they’re not. For example,Hello.c

andhello.c would refer to the same file in Windows, but would beseparate filenames in Unix-style systems.

How the IDE looks at projectsThe IDE associates projects withnaturesthat define thecharacteristics of a given project. For example, a Standard Make CProject will have a “C nature,” whereas a QNX C Project will have aC nature as well as a QNX C nature, and so on. Note that QNX C orC++ projects assume the QNX recursive makefile hierarchy tosupport multiple target architectures; standard make projects don’t.

For more on the QNX recursive makefile hierarchy, see theConventions for Makefiles and Directories appendix in theProgrammer’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 beirrelevant in certain contexts (e.g. a list of QNX System Builderprojects won’t contain any C++ library projects).

Here are the most common projects and their associated natures:

January 31, 2005 Chapter 1 � IDE Concepts 13

Page 39: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Host and target machines 2005, QNX Software Systems Ltd.

Project Associated natures

Simple Project n/a

Standard Make C Project C

Standard Make C++ Project C, C++

QNX C Project C, QNX C

QNX C Library Project C, QNX C

QNX C++ 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 naturespersist in CVS, include these files when you commit your project.

The IDE doesn’t directly support nested projects; each project mustbe organized as a discrete entity. However, the IDE does supportproject dependencies by allowing a project to reference other projectsthat reside in your workspace. Container projects also let youlogically nest projects by collecting several projects together.

Host and target machinesThehostis the machine where the IDE resides (e.g. Windows). Thetarget is the machine where QNX Neutrino and your program actuallyrun.

Target agent (the qconn daemon)Theqconn daemon is the target agent written specifically to supportthe IDE. It facilitates communication between the host and targetmachines.

14 Chapter 1 � IDE Concepts January 31, 2005

Page 40: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Launcher

If you’re running the IDE on a QNX Neutrino PC (self-hosted), yourtarget machine may also be the host machine. In this case, you muststill run qconn, even though your host machine is “connecting toitself.”

For more information about connection methods, see the LaunchConfigurations Reference chapter in this guide.

LauncherBefore you can run a program, you must tell the IDE’s launcher whatprogram to run, what target to run it on, what arguments to pass to theprogram, and so on.

If you want to run the program on another target or run with differentoptions (e.g. with profiling enabled), you must create a newlaunchconfigurationor copy a previous one and modify it.

ResourcesResourcesis a collective term for your projects, folders, and files.

WizardsWizardsguide you through a sequence of tasks. For example, tocreate a QNX C Project, you run a wizard that takes you through allthe steps and gathers all the necessary information before creating theproject. For more information, see the Common Wizards Referencechapter in this guide.

Keyboard shortcutsYou’ll find many keyboard shortcuts for various UI tasks throughoutthe IDE. TheWindow menu includes an item for the main shortcuts:

January 31, 2005 Chapter 1 � IDE Concepts 15

Page 41: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Preferences 2005, QNX Software Systems Ltd.

You can easily create your own shortcuts. For instructions, followthese links in theWorkbench User Guide:

Reference→Preferences→Keys

Some existing shortcuts and some commands that can be assigned toshortcuts only apply to Java code and projects. For example, the“Search for Declaration in Workspace” command, which is bound toCtrl – G only works with Java code.

PreferencesThePreferences dialog (under the Window menu) lets you customizethe behavior of your environment — when to build your projects, howto open new perspectives, which target processors to build for, etc.

16 Chapter 1 � IDE Concepts January 31, 2005

Page 42: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Version coexistence

Besides global preferences, you can also set preferences on aper-projectbasis via theProperties item in right-click menus.

Version coexistenceThe QNX Momentics 6.3.0 development suite lets you install andwork with multiple versions of Neutrino (from 6.2.1 and later) — youcan choose which version of the OS to build programs for.

When you install QNX Momentics, you get a set of configuration filesthat indicate where you’ve installed the software. TheQNX CONFIGURATION environment variable stores the locationof the configuration files for the installed versions of Neutrino; on aself-hosted Neutrino machine, the default is/etc/qnx.

QWinCfg for Windows hosts

On Windows hosts, you’ll find a configuration program (QWinCfg)for switching between versions of QNX Momentics.

You launchQWinCfg via the start menu (e.g.All Programs→QNXMomentics 6.3.0→Configuration).

January 31, 2005 Chapter 1 � IDE Concepts 17

Page 43: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Version coexistence 2005, QNX Software Systems Ltd.

For details on usingQWinCfg, see its entry in theUtilities Reference.

qconfig utility for non-Windows hosts

Theqconfig utility lets you configure your machine to use a specificversion of Neutrino:

� If you run it without any options,qconfig lists the versions thatare installed on your machine.

� If you specify the-e option, you can set up the environment forbuilding software for a specific version of the OS. For example, ifyou’re using the Korn shell (ksh), you can configure your machinelike 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 currentqconfig choice as thedefault version of the OS; if you haven’t chosen a version, the IDEchooses an entry from the directory identified byQNX CONFIGURATION. If you want to override the IDE’s choice,you can choose the appropriate build target.

Specifying which OS version to build forTo specify which version of Neutrino you want the IDE to build for:

1 Open the Preferences dialog (Window→Preferences).

2 SelectQNX.

3 Using the dropdown list in theSelect Install field, choose theOS version you want to build for.

4 Click Apply, thenOK.

18 Chapter 1 � IDE Concepts January 31, 2005

Page 44: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Version coexistence

Environment variablesNeutrino uses these environment variables to locate files on thehostmachine:

QNX HOST The location of host-specific files.

QNX TARGET

The location of target back ends on the hostmachine.

QNX CONFIGURATION

The location of theqconfig configuration files.

MAKEFLAGS The location of included*.mk files.

TMPDIR The directory to use for temporary files.gcc usestemporary files to hold the output of one stage ofcompilation used as input to the next stage: forexample, the output of the preprocessor, which isthe input to the compiler proper.

Theqconfig utility sets these variables according to the version ofQNX Momentics that you specified.

January 31, 2005 Chapter 1 � IDE Concepts 19

Page 45: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 46: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 2

Preparing Your Target

In this chapter. . .Host-target communications 23Connecting with Phindows 29

January 31, 2005 Chapter 2 � Preparing Your Target 21

Page 47: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 48: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Host-target communications

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter explains how to set up host-target communications.

Host-target communicationsRegardless of whether you’re connecting to a remote or a local target,you have to prepare your target machine so that the IDE can interactwith the QNX Neutrino image running on the target.

The IDE supports host-target communications using either an IP or aserial connection. We recommend both. If you have only a serial linkyou’ll be able to debug a program, but you’ll need an IP link in orderto use any of the advanced diagnostic tools in the IDE.

IP communicationsBefore you can configure your target for IP communications, youmust connect the target and host machines to the same network.

To configure your target for IP communications:

1 Open a terminal window on your target.

2 Log in asroot.

3 Start the target agent by entering this command:

January 31, 2005 Chapter 2 � Preparing Your Target 23

Page 49: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Host-target communications 2005, QNX Software Systems Ltd.

qconn

The version of QNX Momentics on your host must be the same ornewer than the version of QNX Neutrino on your target, orunexpected behavior may occur. Newer features won’t be supportedby an older target.

4 You’ll need the target machine’s IP address (e.g.10.12.3.200) when you connect to your target. To get theaddress, enter:netstat -in

When you set up a launch configuration, selectC/C++ QNX QConn(IP). (See the Launch Configurations Reference chapter in this guidefor more information.)

pdebug must be present on the target system in/usr/bin for alldebugging sessions.qconn will launch it as needed.

Serial communicationsBefore you can configure your target for serial communications, youmust establish a working serial connection between your host andtarget machines.

To configure your target for serial communications:

1 Open a terminal window on your target.

2 Log in asroot.

3 If it’s not already running, start the serial device driver that’sappropriate for your target. Intel x86-based machines usuallyuse thedevc-ser8250 driver.

4 Once the serial driver is running, you’ll see a serial device listedin the/dev directory. To confirm it’s running, enter:ls /dev/ser*

24 Chapter 2 � Preparing Your Target January 31, 2005

Page 50: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Host-target communications

You’ll see an entry such as/dev/ser1 or /dev/ser2.

5 Start the pseudo-terminal communications manager(devc-pty):devc-pty &

6 Start the debug agent by entering this command (assumingyou’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 thebaud=baudrateentry; you’ll need this information to properlyconfigure the host side of the connection.

When you set up a launch configuration, selectC/C++ QNX PDebug(Serial). (See the Launch Configurations Reference chapter in thisguide for more information.)

Example: Serial debugging via PPPThis example shows you how to prepare your target and host for serialdebugging using a PPP connection.

Before you begin, make sure the serial ports on both the host andtarget systems are configured properly and can talk to each otherthrough 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:debug57600

January 31, 2005 Chapter 2 � Preparing Your Target 25

Page 51: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Host-target communications 2005, QNX Software Systems Ltd.

/dev/ser111.0.0.1:11.0.0.0

You may need to try a slower baud rate if you have any problems at57600.

2 If it’s not already running, startio-net with this command:io-net -ptcpip -ppppmgr

3 Now start the PPP daemon:pppd

4 Finally, start theqconn target agent:qconn

QNX Neutrino host

To configure your QNX Neutrino host for serial communication usingPPP:

1 Create a/etc/ppp/options file containing the following:debug57600/dev/ser111.0.0.1:11.0.0.0

You may need to try a slower baud rate if you have any problems at57600.

2 If it’s not already running, startio-net with this command:io-net -ptcpip -ppppmgr

3 Start the PPP daemon with thepassive option:pppd passive

26 Chapter 2 � Preparing Your Target January 31, 2005

Page 52: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Host-target communications

Windows host

To configure your Windows XP host for serial communication usingPPP:

The names of menu items and other details differ slightly on othersupported versions of Windows.

1 In the Control Panel, selectNetwork Connections.

2 In the New Connection Wizard dialog, clickSet up anadvanced connection, then clickNext:

3 SelectConnect directly to another computer, then clickNext.

4 When prompted for the role of your target, chooseGuest:

January 31, 2005 Chapter 2 � Preparing Your Target 27

Page 53: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Host-target communications 2005, QNX Software Systems Ltd.

5 Name your connection (e.g. “pppbiscayne”).

6 When prompted to select a device, chooseCommunicationsPort (COM1), then clickNext.

7 When prompted to specify whether you want this connection tobe for your use only, or for anyone’s, selectAnyone’s use.

8 If you want Windows to create a desktop shortcut, click theoption on the last page of the wizard. If not, simply clickFinish.

9 In theConnect nameof targetdialog, enter your user ID andpassword, the selectProperties.

10 Select theOptions tab.

11 Turn off the optionPrompt for name and password,certificate, etc., then clickOK.

28 Chapter 2 � Preparing Your Target January 31, 2005

Page 54: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Connecting with Phindows

Connecting with PhindowsThe IDE lets you connect to a Photon session on a target from aWindows host machine and interact with the remote Photon system asif 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 asroot.

2 Edit the/etc/inetd.conf file and add the following line (oruncomment 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 theinetd daemon:slay inetd

5 Now restartinetd:inetd

Theinetd daemon starts and you can connect to your targetusing Phindows.

For details on using Phindows, see the Phindows ConnectivityUser’sGuidein your QNX Momentics documentation set.

January 31, 2005 Chapter 2 � Preparing Your Target 29

Page 55: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 56: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 3

Developing C/C++ Programs

In this chapter. . .The C/C++ Development perspective 33Controlling your projects 34Creating projects 38Building projects 39Running projects 45Deleting projects 47Writing code 48More development features 55

January 31, 2005 Chapter 3 � Developing C/C++ Programs 31

Page 57: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 58: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. The C/C++ Development perspective

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter shows you how to create and manage your C or C++ projects.

The C/C++ Development perspectiveThe C/C++ Development perspective is where you develop and buildyourprojects. As mentioned in the Concepts chapter, a project is acontainer for organizing and storing your files.

Besides writing code and building your projects, you may also debugand analyze your programs from the C/C++ Development perspective.

You’ll find complete documentation on the C/C++ Developmentperspective, including several tutorials to help you get started, in thecore Eclipse platform docset:Help→Help Contents→C/C++Development User Guide.

The views in the C/C++ Development perspective are drivenprimarily 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’llfind full documentation on the Navigator in theWorkbench UserGuide:

January 31, 2005 Chapter 3 � Developing C/C++ Programs 33

Page 59: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your projects 2005, QNX Software Systems Ltd.

For information on the Navigator’s: See these sections in the WorkbenchUser Guide:

toolbar and icons Concepts→Views→Navigator view

right-click context menu Reference→User interfaceinformation→Views andEditors→Navigator View

Wizards and Launch ConfigurationsTo create and run your first program, you’ll use two major facilitieswithin the IDE:

� wizards — for quickly creating a new project

� launch configurations — for setting up how your program shouldrun.

Once you’ve used these parts of the IDE for the first time, you’ll beable to create, build, and run your programs very quickly. For details,see the Common Wizards Reference and Launch ConfigurationsReference chapters in this guide.

Controlling your projectsThe C/C++ Development perspective’sC/C++ Projects view isperhaps the most important view in the IDE because you can controlyour projects with it. The selections you make in the C/C++ Projectsview greatly affect what information the other views display.

The C/C++ Projects view gives a “virtual” or filtered presentation ofall the executables, source, and shared objects that comprise yourproject. You can set filters for the types of files you want shown inthis view.

The C/C++ Projects view has many of the same features as theNavigator view, but is configured specifically for C and C++

34 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 60: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your projects

development. At first glance, the two may seem identical, but theC/C++ Projects view:

� shows only open C/C++ projects

� presents the project’s executables as if they reside in a subdirectorycalledbin

� for a library project, presents the project’s libraries as if they residein subdirectory calledlib

� hides certain files

� includesBuild Project and related commands in its right-clickmenu

� gives an outline of*.c, *.cc, *.cpp, *.h, and binary files.

Opening filesTo open files and display them in the editor area:

➤ In the C/C++ Projects view, double-click the file to be opened.

The file opens in the editor area.

Opening projectsSince the C/C++ Projects view hidesclosedprojects, you must usethe Navigator view to open them.

➤ In the Navigator view, right-click your project, then selectOpen Project.

The project opens — you can see it in the C/C++ Projects view.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 35

Page 61: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your projects 2005, QNX Software Systems Ltd.

Filtering filesTo hide certain files from the C/C++ Projects view:

1 In the C/C++ Projects view, click the menu dropdown button

( ).

2 SelectFilter. The File Filter dialog appears:

3 In the filter pane, select the types of files you wish to hide. Forexample, if you select.*, then all files that start with a period(e.g..cdtproject, .project, etc.) won’t appear in theC/C++ Projects view.

36 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 62: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your projects

4 Click OK. The C/C++ Projects view automatically refreshesand shows only the files you haven’t filtered.

Outlines of source and executable filesThe 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 ofyour 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 aswell. You can examine the structure of executables to see thefunctions that you declared and used in the file, as well as theelements that were called indirectly, such asmalloc(), init(), anderrno:

January 31, 2005 Chapter 3 � Developing C/C++ Programs 37

Page 63: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating projects 2005, QNX Software Systems Ltd.

Creating projectsIf you’re creating an application from scratch, you’ll probably want tocreate a QNX C/C++ Application Project, which relies on the QNXrecursive makefile hierarchy to support multiple CPU targets. Formore on the QNX recursive makefile hierarchy, see the Conventionsfor Makefiles and Directories appendix in theProgrammer’s Guide.

If you want to import an existing project, see the section “Importingexisting source code into the IDE” in the Managing Source Codechapter in this guide.

You use the New Project wizard whenever you create a new project inthe IDE. Here are the steps to create a simple “hello world” type ofprogram:

38 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 64: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Building projects

1 In the C/C++ Development perspective, click theNew QNX CProject button in the toolbar:

The New Project wizard appears.

There are actually several ways to open the New Project wizard. Seethe Common Wizards Reference chapter in this guide for details.

2 Name your project, then select thetype:

3 Click Next – but don’t pressEnter! (PressingEnter at this pointamounts to clicking the Finish button, which will cause the IDEto create the project forall CPU variants, which you may notwant.)

4 In the Build Variants tab, check the build variant that matchesyour target type, such as X86 (Little Endian), PPC (BigEndian), etc.

Also, checkBuild debug version andBuild release version.

5 Click Finish. The IDE creates your project and displays thesource file in the editor.

Building projectsOnce you’ve created your project, you’ll want tobuild it. Note thatthe IDE uses the samemake utility and makefiles that are used on thecommand line.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 39

Page 65: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Building projects 2005, QNX Software Systems Ltd.

The IDE can build projects automatically (i.e. whenever you changeyour source) or let you build them manually. When you do manualbuilds, you can also decide on the scope of the build.

You can watch a build’s progress and see output from the buildcommand in the C-Build view. If a build generates any errors orwarnings, you can see them in the Tasks view.

Build terminologyThe IDE uses a number of terms to describe the scope of the build:

Build Build only the components affected by modified files inthat particular project (i.e.make all).

Clean Delete all the built components (i.e..o, .so, .exe, andso on) without building anything (i.e.make clean).

Rebuild Delete all the built components, then build each onefrom scratch. A Rebuild is really a Clean followed by aBuild (i.e. make clean; make all).

Turning off the autobuild featureBy default, the IDE automatically rebuilds your project every timeyou 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 ifthey’re small. But for large projects, you might want to turn thisfeature off.

To turn off autobuilding:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectWorkbench.

3 In the right pane, disable thePerform build automatically onresource modification option. The IDE now builds yourprojects only when you ask it to.

40 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 66: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Building projects

Existing C/C++ projects (not QNX C/C++ projects) have their ownautobuild setting. To turn this off:

1 Right-click the C/C++ project, then chooseProperties from themenu.

2 SelectC/C++ Make Project in the list on the left.

3 Select theMake Builder tab.

4 Disable theBuild on resource save (Auto Build) option in theWorkbench Build Behavior section.

5 Click OK to close the project properties dialog and return to theworkbench.

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

January 31, 2005 Chapter 3 � Developing C/C++ Programs 41

Page 67: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Building projects 2005, QNX Software Systems Ltd.

number of target platforms, this could take a significant amount oftime.

To rebuild all your open projects:

➤ From the main menu, selectProject→Rebuild All.

Building selected projects

To rebuild a single project:

➤ In the C/C++ Projects view, right-click a project and select oneof:

� Build Project

� Rebuild Project

Autosave before building

To have the IDE automatically save all your changed resources beforeyou do a manual build:

1 From the main menu, selectWindow→Preferences.

42 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 68: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Building projects

2 In the left pane, selectWorkbench.

3 In the right pane, check theSave all modified resourcesautomatically prior to manual build option. The IDE savesyour resources before it builds your project.

Configuring project build orderYou can tell the IDE to build certain projects before others. And if agiven project refers to another project, the IDE builds that projectfirst.

Setting the build order doesn’t necessarily cause the IDE to rebuild allprojects that depend on a given project. You must rebuild all projectsto ensure that all dependencies are resolved.

To manually configure the project build order:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectBuild Order.

3 Disable theUse default build order option.

4 Select a project in the list, then use theUp or Down buttons toposition the project where you want in the list.

5 When you’re done, clickApply, thenOK.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 43

Page 69: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Building projects 2005, QNX Software Systems Ltd.

Creating personal build options

In this section, the term “targets” refers to operations that themake

command executes during a build, not to target machines.

A make target is an action called by themake utility to perform abuild-related task. For example, QNX makefiles support a targetnamedclean, which gets called asmake clean. The IDE lets youset up your ownmake targets (e.g.myMakeStuff). You can also use amake target to pass options such asCPULIST=x86, which causes themake utility to build only for x86. Of course, such an option wouldwork only if it’s already defined in the makefile.

To add your own custommake target to the C/C++ Project view’sright-click menu:

1 In the C/C++ Projects view, right-click a project and selectCreate Make Target. . . .

2 Type the name of yourmake target (e.g.myMakeStuff).

3 Click Create.

You’ll see your target option listed in the Build Targets dialog, whichappears when you select theBuild Make Target. . . item of theright-click menu of the C/C++ Projects view. Your targets also appearin the Make Targets view.

To build your project with a custommake target:

1 In the C/C++ Projects view, right-click a project.

2 In the context menu, selectBuild Make Target. . . item. TheBuild Targets dialog appears.

3 Select your custom target, then clickBuild.

44 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 70: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Running projects

To remove amake target:

1 Open the Make Targets view (Window→Show View→MakeTargets). Expand your project to see your make targets.

2 Right-click the target you want to remove, then selectDeleteBuild Target.

Running projectsBefore running an application, you must prepare your target. If it isn’talready 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 letsyou run or debug your executables on either a local or a remote QNXNeutrino target machine. (For a description of local and remotetargets, 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 IDEcommunicates with your target; once you’ve created a QNX TargetSystem Project, you can reuse it for every program that runs onthat particular target.

� a Launch Configuration, which describes how the program runson your target; you’ll need to set this up only once for thatparticular program.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 45

Page 71: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Running projects 2005, QNX Software Systems Ltd.

For a complete description of how to create a QNX Target SystemProject, see the Common Wizards Reference chapter in this guide.

For a complete description of the Launch Configurations dialog andits available options, see the Launch Configurations Referencechapter in this guide.

To create a QNX Target System Project:

1 From the menu, selectFile→New→Other. . . .

2 In the left pane, selectQNX.

3 In the right pane, selectQNX 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 Navigatorview.

To create a launch configuration so you can run your “hello world”QNX C Application Project:

Make sure you build your project first before you create a launchconfiguration for it. See “Building projects” above.

1 In the C/C++ Projects view, select your project.

2 From theRun workbench menu, click theRun. . . menu item:

46 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 72: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Deleting projects

3 In the Launch Configurations dialog, selectC/C++ QNXQConn (IP) in the left pane.

4 Click New.

5 In the Name field, give your launch configuration a name.

6 Click theSearch button beside the C/C++ Application field.The Program Selection dialog appears.

7 Select a program to run; theg indicates it was compiled fordebugging.

8 Click OK.

9 In theTarget Options pane, select your target.

10 Click theRun button.

Your program runs — you should see its output in the Console view.

Deleting projectsTo delete a project:

January 31, 2005 Chapter 3 � Developing C/C++ Programs 47

Page 73: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Writing code 2005, QNX Software Systems Ltd.

1 In the C/C++ Projects view, right-click a project and selectDelete from the context menu. The IDE then prompts you toconfirm, 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 forthat project arenot deleted. This feature lets you delete and recreate aproject without also having to repeat that operation for anycorresponding launch configurations you may have created.

For more on launch configurations, see the Launch ConfigurationsReference chapter in this guide.

Writing codeThe C/C++ Editor is where you write and modify your code. As youwork in the editor, the IDE dynamically updates many of the otherviews (even if you haven’t saved your file).

C/C++ Editor layoutThe C/C++ Editor has a gray border on each side. The border on theleft margin might contain icons that indicate errors or other problemsdetected by the IDE, as well as icons for any bookmarks, breakpoints,or tasks (from the Tasks view). The icons in the left margincorrespond to the line of code.

48 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 74: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Writing code

The border on the right margin displays red and yellow bars thatcorrespond to the errors and warnings from the Tasks view. Unlike theleft margin, the right margin displays the iconsfor the entire length ofthe file.

Finishing function namesThe Content Assist feature can help you finish the names of functionsif 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’sname.

2 PressCtrl – Space. (Or, right-click near the cursor and selectContent Assist.) A menu with the available functions appears:

3 You may do one of the following:

� Continue typing. The list shortens.

� Scroll with the up and down arrows. PressEnter to select thefunction.

� Scroll with your mouse. Double-click a function to insert it.

� To close the Content Assist window, pressEsc.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 49

Page 75: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Writing code 2005, QNX Software Systems Ltd.

Inserting code snippetsThe IDE has another code-completion feature that can insert cannedsnippets of code such as an emptydo-while structure. If you’vealready used the Content Assist feature, you may have already noticedthe Code Templates feature; you access it the same way.

To use Code Templates:

1 As with Content Assist, start typing, then pressCtrl – Space.(Or, right-click near the cursor and selectContent Assist).

2 Any code templates that match the letters you’ve typed willappear first in the list:

The IDE lets you enable as many of these templates as you like, editthem as you see fit, create your own templates, and so on.

To edit a template or add one of your own:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectC/C++→Code Templates.

3 To edit a template, select it, then clickEdit.

50 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 76: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Writing code

4 To add you own template, clickNew. A dialog for adding newtemplates appears:

Adding #include directivesTo insert the appropriate#include directive for any documentedQNX Neutrino function:

1 In the C/C++ Editor, double-click the function name, but don’thighlight the parentheses or any leading tabs or spaces.

2 Right-click and selectAdd Include. The IDE automaticallyadds the#include statement to the top of the file, if it isn’talready there.

Hover helpThe IDE’s hover help feature gives you the synopsis for a functionwhile you’re coding. To use hover help:

➤ In the C/C++ Editor, pause your pointer over a function. You’llsee a text box showing the function’s summary and synopsis:

January 31, 2005 Chapter 3 � Developing C/C++ Programs 51

Page 77: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Writing code 2005, QNX Software Systems Ltd.

Commenting-out codeYou can easily add comments using either the C or C++ style, even tolarge sections of code. You can add// characters to the beginning oflines, 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 toaccidentally uncomment sections. Also, the editor can comment oruncomment selectedlines— if you highlight a partial line, the editorcomments out the entire line, not just the highlighted section.

To comment or uncomment a block of code:

1 In the C/C++ Editor, highlight a section of code to becommented or uncommented. For one line, place your cursoron that line.

2 Right-click and selectComment or Uncomment.

52 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 78: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Writing code

Customizing the C/C++ EditorYou can change the font, set the background color, show linenumbers, and control many other visual aspects of the C/C++ Editor.You can also configure context highlighting and change how the CodeAssist feature works. You do all this in the C/C++ Editor preferencesdialog:

To access the C/C++ Editor preferences dialog:

1 SelectWindow→Preferences.

2 In the left pane, selectC/C++→C/C++ Editor.

Using other editorsIf you wish to use a different text editor than the one that’s built intothe IDE, you can do so, but you’ll lose theintegrationof the variousviews and perspectives. For example, within the C/C++ Editor, you

January 31, 2005 Chapter 3 � Developing C/C++ Programs 53

Page 79: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Writing code 2005, QNX Software Systems Ltd.

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, orget hover help as you pause your cursor over a function name in yourcode, and so on.

If you want to use other editors, you can do so either outside or insidethe 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 tosynchronize the IDE with the changes.

To synchronize the IDE with changes you’ve made using an editoroutside of the IDE:

➤ In the C/C++ Projects view, right-click the tree pane and selectRefresh. The IDE updates the display to reflect any changesyou’ve made (such as creating new files).

Within the IDE

You can specify file associations that determine the editor you want touse for each file type. For example, you can tell the IDE to use anexternal program such as WordPad to edit all.h files. Once thatpreference is set, you can double-click a file in the C/C++ Projectsview, and the IDE automatically opens the file in your selectedprogram.

If the IDE doesn’t have an association set for a certain file type, it usesthe host OS defaults. For example, on a Windows host, if youdouble-click a.DOC file, Word or WordPad automatically launchesand opens the file.

54 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 80: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More development features

For more information about file associations, follow these links in theEclipseWorkbench User Guide: Reference→Preferences→FileAssociations.

Creating files from scratchBy default, the IDE creates a simple “hello world” C/C++ source filefor you, which you may or may not want to use as a template for yourown code.

To create a new C/C++ file:

1 Highlight the project that will contain the new file you’recreating.

2 Click theCreate a File button on the toolbar:

3 Enter (or select) the name of the folder where the file willreside.

4 Name your file, then click Finish.

You should now see an empty text editor window, ready for you tobegin working on your new file. Notice your filename highlighted inblue in the title bar above the editor.

More development featuresBesides the features already described above, the IDE has severalother helpful facilities worth exploring.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 55

Page 81: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More development features 2005, QNX Software Systems Ltd.

Tracking remaining workThe Tasks view gives you a list of errors and warnings related to yourprojects. These are typically syntax errors, typos, and otherprogramming errors found by the compiler:

The Tasks view is part of the core Eclipse platform. For moreinformation about this view, follow these links in theWorkbench UserGuide: Reference→User interface information→View andEditors→Tasks view.

Error markers

The IDE also shows corresponding markers in several other locations:

� C/C++ Projects view — on both the file that contained compileerrors 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 determinewhere it is):

➤ In the Tasks view, double-click the error marker () or

warning marker ( ). The file opens in the editor area, withthe cursor on the offending line.

To jump to errors sequentially:

56 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 82: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More development features

➤ Click theJump to next error marker button ( ) or the

Jump to previous error marker button ( ).

Filtering errors

Depending on the complexity and stage of your program, the IDE cangenerate an overwhelming number of errors. But you can customizethe Tasks view so you’ll see only the errors you want to see.

To access the error-filtering dialog:

➤ In the Tasks view, click theFilter icon ( ).

The Filter Tasks dialog lets you adjust the scope of the errors shown inthe Tasks view. The more boxes checked, the more errors you’ll see.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 57

Page 83: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More development features 2005, QNX Software Systems Ltd.

Setting reminders

The Tasks view lets you create your own tasks. Besides automaticallylisting build errors, the view lets you set personal reminders for theunfinished function you’re writing, the error-handling routine youwant to check, or whatever.

You use the New Tasks dialog to add a personal task:

58 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 84: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More development features

1 In the Tasks view, right-click the tasks pane and selectNewTask.

2 Complete the dialog for your task:

To remove a personal task:

➤ In the Tasks view, right-click the task and select eitherDelete orMark Completed.

Code synopsisThe Outline view gives you a structural view of your C/C++ sourcecode:

January 31, 2005 Chapter 3 � Developing C/C++ Programs 59

Page 85: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More development features 2005, QNX Software Systems Ltd.

The view shows the elements in the source file in the order they occur,including functions, libraries, and variables. You may also sort the listalphabetically, or hide certain items (fields, static members, andnonpublic members).

If you click an entry in the Outline view, the editor’s cursor moves tothe start of the item selected.

Checking your buildThe C-Build view displays the output from themake utility:

Customizing the C-Build view

You can choose to clear the C-Build view before each new build or letthe output of each subsequent build grow in the display. You can alsohave the C-Build view appear on top of the other stacked viewswhenever you build.

60 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 86: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More development features

To set the preferences for the C-Build view:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectC/C++→Build Console:

Accessing source files for functionsWhile editing source code in the editor, you can select a functionname, pressF3, and the editor immediately jumps to the source filefor 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 headersYou can select a header (such asstdio.h) in the C/C++ editor andpressCtrl – Shift – o to open the header file in the editor. You can alsoright-click the header file’s name in the Outline view, then chooseOpen.

Many of the enhanced source navigation and code developmentaccelerators available in the C/C++ editor are extracted from thesource code. To provide the most accurate data representation, theproject must be properly configured with the include paths anddefines used to compile the source.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 61

Page 87: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More development features 2005, QNX Software Systems Ltd.

For QNX projects the standard include paths and defines are setautomatically based on the compiler and architecture. Additionalvalues can be set using the project’s properties.

For Standard C/C++ Make projects, you must define the valuesyourself. These values can be set manually using the Paths andSymbols tab of the project’s properties, or they can bet setautomatically using theSet QNX Build Environment. . . item in theproject’s context menu.

Set the include paths and defines for a Standard C/C++ Make project:

1 In the C/C++ Projects view, right-click your project and selectSet QNX Build Environment. . . .

The Set QNX Build Environment wizard appears.

62 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 88: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More development features

2 Select one or more Standard C/C++ Make projects to updateand clickNext.

The Compiler/Architecture Selection panel appears.

January 31, 2005 Chapter 3 � Developing C/C++ Programs 63

Page 89: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More development features 2005, QNX Software Systems Ltd.

3 Select the appropriate Compiler, Language, and Architecturefor your project, and clickFinish.

64 Chapter 3 � Developing C/C++ Programs January 31, 2005

Page 90: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 4

Managing Source Code

In this chapter. . .CVS and the IDE 67Importing existing source code into the IDE 70Using container projects 82Importing a BSP or other QNX source packages90Exporting projects 97

January 31, 2005 Chapter 4 � Managing Source Code 65

Page 91: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 92: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. CVS and the IDE

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter describes managing source code from within the IDE.

CVS and the IDECVS is the default source-management system in the IDE. Othersystems (e.g. ClearCase) are also supported.

The CVS Repository Exploring perspective lets you bring code fromCVS into your workspace. If another developer changes the source inCVS while you’re working on it, the IDE helps you synchronize withCVS and resolve any conflicts. You can also choose to automaticallynotify the CVS server whenever you start working on a file. The CVSserver will then notify other developers who work on that file as well.Finally, the CVS Repository Exploring perspective lets you checkyour modified code back into CVS.

The IDE connects to CVS repositories that reside only on remoteservers— you can’t have a local CVS repository (i.e. one that resideson your host computer).

January 31, 2005 Chapter 4 � Managing Source Code 67

Page 93: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

CVS and the IDE 2005, QNX Software Systems Ltd.

Local history featureThe IDE has a builtin “undo” file-management facility calledlocalhistory. While you’re working on your code, the IDE automaticallykeeps track of the changes you make to your file; it lets you roll backto 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 theWorkbench User Guide: Reference→User interfaceinformation→Development environment→Local history.

Project files (.project and .cdtproject)For each project, the IDE stores important information in these twofiles:

� .project

� .cdtproject

You mustinclude both files with your project when you commit it toCVS.

Core Eclipse documentation on using CVS in the IDESince the CVS Repository Exploring perspective is a core Eclipsefeature, you’ll find complete documentation in the EclipseWorkbenchUser Guide. Follow these links:

� Tips and Ticks→Team - CVS

� Tasks→Working in the team environment

This table may help you find information quickly in theWorkbenchUser Guide:

68 Chapter 4 � Managing Source Code January 31, 2005

Page 94: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. CVS and the IDE

If you want to: Go to:

Connect to a CVS repository Tasks→Working in the teamenvironment→Working witha CVS repository→Creating aCVS repository location

Check code out of CVS Tasks→Working in the teamenvironment→Working withprojects shared withCVS→Checking out a projectfrom a CVS repository

Synchronize with a CVSrepository

Tasks→Working in the teamenvironment→Synchronizingwith the repository, especiallytheUpdating section

See who’s also working on a fileTasks→Working in the teamenvironment→Finding outwho’s working on what:watch/edit

Resolve CVS conflicts Tasks→Working in the teamenvironment→Synchronizingwith therepository→Resolvingconflicts

Prevent certain files from beingcommitted to CVS

Tasks→Working in the teamenvironment→Synchronizingwith the repository→Versioncontrol life cycle: adding andignoring resources

Create and apply a patch Tasks→Working in the teamenvironment→Working withpatches

continued. . .

January 31, 2005 Chapter 4 � Managing Source Code 69

Page 95: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

If you want to: Go to:

Track code changes that haven’tbeen committed to CVS

Tasks→Working with localhistory, especially theComparing resources with thelocal history section

View an online FAQ about theCVS Repository Exploringperspective

Reference→TeamSupport→CVS

Importing existing source code into the IDEAs with many tasks within the IDE, there’s more than one way tobring existing source files into your workspace:

� filesystem drag-and-drop— from a Windows host you can dragand drop (or copy and paste) individual files from the filesysteminto your project in your workspace.

� CVS repository— you can use theCVS Repositories view toconnect to a CVS repository and check out projects, folders, orfiles 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 andfolders that reside in the filesystemoutsideyour project’s locationin the workspace. You might use linked resources, for example, ifyou have a source tree that’s handled by some othersource-management tool outside of the IDE. (For more on linkedresources, follow these links in theWorkbench User Guide:Concepts→Workbench→Linked resources.)

Whatever method you use, you always need to set up an IDEprojectin your workspace in order to work with the resources you’reimporting.

70 Chapter 4 � Managing Source Code January 31, 2005

Page 96: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

If you’re importing code that uses an existing build system, you mayneed to provide aMakefile with all: andclean: targets that callyour existing build system.

For example, if you’re using thejam tool to build your application,your IDE projectMakefile might look like this:

all:jam -fbuild.jam

clean:jam -fbuild.jam clean

Projects within projects?Suppose you have an existing source hierarchy that looks somethinglike this:

In order to work efficiently with this source in the IDE, eachcomponent and subcomponent should be a “subproject” within theone main project. (You could keep an entire hierarchy as a singleproject if you wish, but you’d probably find it cumbersome to buildand work with such a monolith.)

January 31, 2005 Chapter 4 � Managing Source Code 71

Page 97: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

Unfortunately, the current version of Eclipse (2.1) in QNXMomentics 6.3 doesn’t support nesting projects as such. So howwould you import such a source tree into Eclipse 2.1?

Step 1

First, in your workspace create a single project that reflects all thecomponents that reside in your existing source tree:

1 SelectFile→New→Project. . . .

2 Select the type of project (e.g. Standard Make C project).

3 Name your project (e.g. “EntireSourceProjectA”).

4 UnselectUse Default Location, because we need to tell theIDE where the resources reside in the filesystem (since theydon’t reside in your workspace).

5 In theLocation: field, type in the path to your source (or clickBrowse. . . ).

6 Click Finish. You should now have a project that lookssomething like this in the C/C++ Projects view:

72 Chapter 4 � Managing Source Code January 31, 2005

Page 98: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

Step 2

Now we’ll create an individual project (viaFile→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 thefollowing source components:

� ComponentA

� ComponentB

� SubcomponentC

� SubcomponentD

1 SelectFile→New→Project. . . .

2 Select the type of project (e.g. Standard Make C project).

January 31, 2005 Chapter 4 � Managing Source Code 73

Page 99: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

3 Name your project (e.g. “ProjectComponentA”).

4 CheckUse default location, because we want the IDE to createaproject in your workspace for this and all the othercomponents that comprise your EntireSourceProjectA. In thenext step, we’ll be linking each project to the actual location ofthe directories in your source tree.

5 Click Finish, and you’ll see ProjectComponentA in the C/C++Projects view.

Step 3

Next we’ll link each individual project in the IDE to its correspondingdirectory in the source tree:

1 SelectFile→New→Folder.

2 Make sure your new project (ProjectComponentA) is selectedas the parent folder.

3 Name the folder (e.g. “ComponentA”).

4 Click theAdvanced>> button.

5 CheckLink to folder in the file system.

6 Enter the path to that folder in your source tree (or useBrowse. . . ).

7 Click Finish. Your ProjectComponentA project should nowshow a folder calledComponentA, the contents of whichactually reside in your source tree:

Link

74 Chapter 4 � Managing Source Code January 31, 2005

Page 100: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

Step 4

Now we’ll need to tell the IDE to build ProjectComponentA in theComponentA linked folder that you just created in your workspace:

1 In the C/C++ Projects view, right-clickProject ComponentA, then selectProperties from thecontext menu.

2 SelectC/C++ Make Project.

3 In theMake Builder tab, set the Build Directory toComponentA in your workspace.

Now when you go to buildProject ComponentA, the IDE willbuild it in theComponentA folder in your workspace (even thoughthe source actually resides in a folder outside your workspace).

CAUTION: The linked resources facility lets youoverlapfiles inyour workspace, so files from one project can appear in anotherproject. But keep in mind that if you change a file or other resource inone place, theduplicate resource will also be affected. If you delete aduplicate resource, its original will also be deleted!

Special rules apply when working with linked resources. Since alinked resource must reside directly below a project, you can’t copy ormove a linked resource into other folders. If you delete a linkedresource from your project, this willnot cause the correspondingresource in the filesystem to also be deleted. But if you deletechildresources of linked folders, thiswill delete those child resources fromthe filesystem!

!

Filesystem drag-and-dropOn Windows hosts, you can select files or folders and drop them intoprojects in theNavigator view:

1 Create a new project. If your existing code has an existing buildprocedure, use aStandard Make C/C++ Project. If not, you

January 31, 2005 Chapter 4 � Managing Source Code 75

Page 101: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

can use aQNX C/C++ Project or aStandard Make C/C++Project.

2 Switch to theNavigator view.

3 Select one or more source files or folders in the WindowsExplorer, then drag them into the project. The files will becopied into your project workspace.

You can also use Cut, Copy and Paste to move or copy files into aproject from Windows Explorer.

CVS repositoryUsing theCVS Repository Exploring perspective, you can check outmodules or directories into existing projects, or to create new projects.

Bringing code into the IDE from CVS differs slightly depending onwhat you’re importing:

� an existing C/C++ project

� existing C/C++ code that isn’t part of a project

� existing C/C++ code that needs to be added to an existing project

Importing a C/C++ project from CVS

To check out an existing C/C++ project (either a QNX project or aStandard Make project) from the CVS repository into yourworkspace:

1 Right-click the project in theCVS Repositories view andchooseCheck Out As Project from the menu.

The IDE creates a project with the same name as the CVSmodule in your workspace. The project is automaticallyrecognized as a Standard Make or QNX project (if the projecthas.project and.cdtproject files).

2 If the project is a QNX project:

76 Chapter 4 � Managing Source Code January 31, 2005

Page 102: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

2a Right-click the new project in theNavigator or C/C++Projects view and chooseProperties.

2b Click theBuild Variants tab, which displays a warning:

CVS project warning

2c Select one or more of the build variants, then clickOK.

Importing C/C++ code from CVS

To check out existing C/C++ code that isn’t part of a project:

1 Right-click the module or directory in theCVS Repositoriesview and chooseCheck Out As. . . from the menu.

The IDE displays theNew Project wizard.

January 31, 2005 Chapter 4 � Managing Source Code 77

Page 103: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

The New Project wizard

2 Choose an appropriate project type:

� QNX C/C++ Project – Use a QNX project if you don’t needto integrate your new project with an existing build system.

� Standard Make C/C++ Project – Use a Standard Makeproject if you need to create your ownMakefile tointegrate with an existing build process.

Click Next to continue.

3 Enter a name for the new project in theName field.

4 Click Finish to close theNew Project wizard and check out thecode as a new project.

78 Chapter 4 � Managing Source Code January 31, 2005

Page 104: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

The IDE displays theConfirm Overwrite dialog box.

The Confirm Overwrite dialog

5 Click OK to continue. If you were actually overwriting anexisting project, theNew Project wizard would have stoppedyou.

6 If you’re creating a QNX project:

6a Right-click the new project in theNavigator or C/C++Projects view and chooseProperties.

6b Click theBuild Variants tab, which displays a warning:

CVS project warning

6c Select one or more of the build variants, then clickOK.

7 If you’re creating a Standard Make project, create a newMakefile with appropriateall: andclean: targets.

Importing C/C++ code into an existing project

To import a directory full of C/C++ code into an existing project:

1 Right-click the module or directory in theCVS Repositoriesview and chooseCheck Out Into. . . from the menu.

The IDE displays theCheckout Into dialog.

January 31, 2005 Chapter 4 � Managing Source Code 79

Page 105: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing existing source code into the IDE 2005, QNX Software Systems Ltd.

The Checkout Into dialog

2 If you want to check out the contents of the CVS module ordirectory into a folder, enter a folder name in theTarget foldername field.

3 Select a project to add this code to in theParent of targetfolder list. You can filter this list by choosing one of theFilterproject list options:

� Show all valid target projects – no filtering

� Show unshared projects – limits the list to projects thatarenot in CVS

� Show projects shared with the same repository – limitsthe list to projects that exist in the same CVS repository

80 Chapter 4 � Managing Source Code January 31, 2005

Page 106: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing existing source code into the IDE

4 To check out any subdirectories as well, check theCheckoutsubfolders box.

5 Click Finish to add the code from CVS to the selected project.

Import wizardUse theImport wizard to bring files or folders into an existing projectfrom a variety of different sources, such as:

� an existing container project

� an existing project

� another directory

� a QNX Board Support Package

� a QNX mkifs Buildfile

� a QNX Source Package

� a Team Project Set

� a Zip file

For details, see “Importing projects” in the Common WizardsReference chapter.

Linked resourcesAs an alternative to dragging-and-dropping, you can link files andfolders into a project. This lets you include files in your project, evenif they need to reside in a specific place on your filesystem (becauseof a restrictive source control system, for example).

To add a linked resource to a project in theC/C++ Project orNavigator view:

1 Right-click on a project, then chooseFile or Folder from theNew menu.

TheNew File or New Folder dialog appears.

January 31, 2005 Chapter 4 � Managing Source Code 81

Page 107: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Using container projects 2005, QNX Software Systems Ltd.

2 Click theAdvanced >> button, and check theLink to file inthe file system or Link to folder in the file system check box.

3 Enter the full path to the file or folder, or click theBrowse. . .button to select a file or folder.

4 Click Finish to link the file or folder into your project.

SeeConcepts→Workbench→Linked resources in theWorkbenchUser Guidefor more information about linked resources.

Using container projectsA containeris a project that creates a logical grouping of subprojects.Containers can ease the building of large multiproject systems. Youcan have containers practically anywhere you want on the filesystem,with one exception: containers can’t appear in the parent folders ofother projects (because this would create a projects-in-projectsproblem).

Containers let you specify just about any number ofbuildconfigurations(which are analogous tobuild variantsin C/C++projects). Each build configuration contains a list of subprojects andspecifies which variant to be built for each of those projects. Note thateach build configuration may contain a different list and mix ofsubprojects (e.g. QNX C/C++ projects, standard make projects, orother container projects.)

Creating a container project

In order to create a container, you must have at least one subprojectthat you want to contain.

To create a container project:

1 SelectFile→New→Project. . . , thenQNX→C/C++ ContainerProject:

82 Chapter 4 � Managing Source Code January 31, 2005

Page 108: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using container projects

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:

January 31, 2005 Chapter 4 � Managing Source Code 83

Page 109: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Using container projects 2005, QNX Software Systems Ltd.

Each subproject has a make-targets entry under the Target field.The “Default” entry means don’t pass any targets to themake

command. QNX C/C++ projects will interpret this as “rebuild”.If a subproject is also a container project, this field representsbuild configuration for that container.

You can set the default for QNX C/C++ projects by opening thePreferences dialog box, then choosingQNX→Containerproperties.

6 Select the build variant for each project you wish to build. Youcan chooseAll (for everyvariant that has already been createdin the project’s folder) orAll Enabled (for just the variantsyou’ve selected). Note that the concept of variants makes senseonly for QNX C/C++ projects.

84 Chapter 4 � Managing Source Code January 31, 2005

Page 110: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using container projects

TheStop on error column controls whether the build process for thecontainer will stop at the first subproject to have an error or willcontinue to build all the remaining subprojects.

7 If you want to reduce clutter in the C/C++ Projects view, thencreate aworking setfor your container. The working set willcontain all the projects initially added to the container.

To select a working set, click the down-arrow at the top of theC/C++ Projects view pane and select the working set you want.Note that the working set created when the container wascreated will have the same name as the container.

If you add or remove elements to a container project later, theworking set isnot updated automatically.

8 Click Finish. The IDE creates your container project.

Setting up a build configurationJust as QNX C/C++ projects have build variants, container projectshavebuild configurations. Each configuration can be entirely distinctfrom other configurations in the same container. For example, youcould have two separate configurations, say “Development” and“Released,”, in your top-level container. The “Development”configuration would build the “Development” configuration of anysubcontainers, as well as the appropriate build variant for anysubprojects. The “Released” configuration would be identical, exceptthat it would build the “Released” variants of subprojects.

Note that the default configuration is the first configuration that wascreated when the container project was created.

To create a build configuration for a container:

1 In the C/C++ Projects view, right-click the container.

2 SelectCreate Container Configuration. . . .

January 31, 2005 Chapter 4 � Managing Source Code 85

Page 111: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Using container projects 2005, QNX Software Systems Ltd.

3 In the Container Build Configuration dialog, name theconfiguration.

4 Click Add Project, then select all the projects to be included inthis configuration.

5 Change theVariant andStop on error entries for eachincluded project as appropriate.

If you want to change the build order, use theShift Up or Shift Downbuttons.

6 Click OK.

Editing existing configurationsThere are two ways to change existing configurations for a containerproject, both of which appear in the right-click menu:

� Properties

� Build Container Configuration

Although you can use either method to edit a configuration, youmight find the Properties facility easier because it shows you atree-viewof your entire container project.

Note also that you can edit only those configurations that areimmediate 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:

86 Chapter 4 � Managing Source Code January 31, 2005

Page 112: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using container projects

1 Right-click the container project and selectProperties.

2 In the left pane, selectContainer Build Configurations.

3 Expand the project in the tree-view on the right.

4 Select the configuration you want to edit. Configurations arelisted as children of the container.

5 Click theEdit button at the right of the dialog. This opens thefamiliar Container Build Configuration dialog (from the NewContainer wizard), which you used when you created thecontainer.

6 Make any necessary changes — add, delete, reorder projects, orchange which make target or variant you want built for anygiven project.

While editing a configuration, you can include or exclude acomponent from the build just by checking or unchecking thecomponent. Note that if you exclude a component from being built,it’s not removed from your container.

7 Click OK, then clickOK again (to close the Properties dialog).

Editing via the Build Container Configuration. . . item

You can access theContainer Build Configuration dialog from thecontainer project’s right-click menu:

January 31, 2005 Chapter 4 � Managing Source Code 87

Page 113: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Using container projects 2005, QNX Software Systems Ltd.

88 Chapter 4 � Managing Source Code January 31, 2005

Page 114: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using container projects

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 selectBuild ContainerConfiguration. . . .

2 Select the configuration you want to edit from the list.

3 Click theEdit button. This opens the familiar Container BuildConfiguration dialog (from the New Container wizard), whichyou used when you created the container.

4 Make any necessary changes — add, delete, reorder projects, orchange which make target or variant you want built for anygiven project.

5 Click OK, then clickOK again (to save your changes and closethe dialog).

Building a container project

Once you’ve finished setting up your container project and itsconfigurations, it’s very simple to build your container:

1 In the C/C++ Projects view, right-click your container project.

2 SelectBuild Container Configuration. . . .

3 Choose the appropriate configuration from the dialog.

4 Click Build.

January 31, 2005 Chapter 4 � Managing Source Code 89

Page 115: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing a BSP or other QNX source packages 2005, QNX Software Systems Ltd.

A project’s build variant selected in the container configuration willbe built, regardless of whether the variant is selected in the C/C++project’s properties. In other words, the container project overridesthe individual project’s build-variant setting during the build.

The one exception to this is theAll Enabled variant in the containerconfiguration. If the container configuration is set to build all enabledvariants of a project, then only those variants that you’ve selected inthe project’s build-variant properties will be built.

To build the default container configuration, you can also use theBuild item in the right-click menu.

Importing a BSP or other QNX sourcepackagesQNX BSPs and other source packages (e.g. DDKs) are distributed as.zip archives. The IDE lets you import both kinds of packages intothe 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 libraryproject.

Step 1: Use File→Import. . .You import a QNX source archive using the standard Eclipse importdialog:

90 Chapter 4 � Managing Source Code January 31, 2005

Page 116: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing a BSP or other QNX source packages

If you’re importing a BSP, selectQNX Board Support Package. Ifyou’re importing a DDK, selectQNX 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 containssource code, the two types are structured differently and will generatedifferent types of projects. If you try to import a BSP archive as aQNX Source Package, the IDE won’t create a System Builder project.

January 31, 2005 Chapter 4 � Managing Source Code 91

Page 117: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing a BSP or other QNX source packages 2005, QNX Software Systems Ltd.

Step 2: Select the packageAfter you choose the type of package you’re importing, the wizardthen 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 thatpackage is displayed.

To add more packages to the list:

1 Click theSelect Package. . . button.

92 Chapter 4 � Managing Source Code January 31, 2005

Page 118: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing a BSP or other QNX source packages

2 Select the.zip source archive you want to add.

Step 3: Select the source projectsEach source package contains several components (orprojects, in IDEterms). For the package you selected, the wizard then gives you a listof 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

January 31, 2005 Chapter 4 � Managing Source Code 93

Page 119: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing a BSP or other QNX source packages 2005, QNX Software Systems Ltd.

default). Again, as you highlight a component, you’ll see itsdescription in the bottom pane.

Step 4: Select a working setThe last page of the import wizard lets you name your sourceprojects. You can specify:

� Working Set Name — to group all related imported projectstogether as a set

� Project Name Prefix — for BSPs, this becomes the name of theSystem Builder project; for other source projects, this prefix allowsthe same source to be imported several times without any conflicts.

94 Chapter 4 � Managing Source Code January 31, 2005

Page 120: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing a BSP or other QNX source packages

If you plan to import a source BSPanda binary BSP into the IDE,remember to give each project a different name.

Step 5: BuildWhen you finish with the wizard, it creates all the projects and bringsin the sources from the archive. It will then ask if you want to buildall the projects you’ve just imported.

January 31, 2005 Chapter 4 � Managing Source Code 95

Page 121: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing a BSP or other QNX source packages 2005, QNX Software Systems Ltd.

If you answerYes, the IDE will begin the build process, which maytake several minutes (depending on how much source you’veimported).

If you decide not to build now, you can always do aRebuild All fromthe main toolbar’sProject menu at a later time.

If you didn’t import all the components from a BSP package, you canbring in the rest of them by selecting the System Builder project andopening the import wizard (right-click the project, then selectImport. . . ). The IDE detects your selection and then extends theexisting BSP (rather than making a new one).

QNX BSP Perspective

When you import a QNX Board Support Package, the IDE opens theQNX BSP Perspective. This perspective combines the minimumelements from both the C/C++ Development Perspective and theSystem Builder Perspective:

96 Chapter 4 � Managing Source Code January 31, 2005

Page 122: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Exporting projects

Exporting projectsYou can export projects to your filesystem or to.zip files:

� drag a file or folder from a project to your filesystem

pressAlt while dragging tocopythe file or folder instead ofmovingitout of the project.

� use theCopy (to copy) orCut (to move) context menu items, thenPaste the file into your filesystem

� export to the filesystem using theExport. . . command

� export to a.zip file using theExport. . . command.

Using the Export. . . commandThe Export wizard helps you export entire projects to your filesystemor a.zip file.

To export one or more projects:

1 ChooseFile→Export. . . (or Export. . . from the Navigatorcontext menu).

The Export wizard appears.

January 31, 2005 Chapter 4 � Managing Source Code 97

Page 123: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Exporting projects 2005, QNX Software Systems Ltd.

2 To export your project to the filesystem, chooseFile system. Toexport your project to a.zip file, chooseZip file. Click Next.

The Export wizard’s next panel appears.

98 Chapter 4 � Managing Source Code January 31, 2005

Page 124: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Exporting projects

3 Select the projects you want to export. You can also select ordeselect specific files in each project.

To select files based on their extensions, click theSelectTypes. . . button. The Select Types dialog box appears.

January 31, 2005 Chapter 4 � Managing Source Code 99

Page 125: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Exporting projects 2005, QNX Software Systems Ltd.

Click one or more extensions, then clickOK to filter theselected files in the Export wizard.

4 When you’re done selecting projects and files, clickFinish.

100 Chapter 4 � Managing Source Code January 31, 2005

Page 126: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Exporting projects

If you export more than one project, and someone imports from theresulting filesystem or.zip file, they’ll get one project containing allof the projects you exported.

January 31, 2005 Chapter 4 � Managing Source Code 101

Page 127: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 128: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 5

Debugging Programs

In this chapter. . .Introduction 105Debugging your program 106Controlling your debug session 109More debugging features 116

January 31, 2005 Chapter 5 � Debugging Programs 103

Page 129: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 130: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter shows you how to work with the debugger.

IntroductionOne of the most frequently used tools in the traditionaldesign-develop-debug cycle is the source-level debugger. In the IDE,this powerful tool provides an intuitive debugging environment that’scompletely integrated with the other workbench tools, giving you theflexibility you need to best address the problems at hand.

Have you ever had to debug several programs simultaneously? Didyou have to use separate tools when the programs were written indifferent languages or for different processors? The IDE’s sourcedebugger provides a unified environment for multiprocess andmultithreaded debugging of programs written in C, C++, EmbeddedC++, or Java. You can debug such programs concurrently on one ormultiple remote target systems, or locally if you’re doing Neutrinoself-hosted development.

In order to use the full power of the Debug perspective, you must useexecutables compiled for debugging. These executables containadditional debug information that lets the debugger make directassociations between the source code and the binaries generated from

January 31, 2005 Chapter 5 � Debugging Programs 105

Page 131: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Debugging your program 2005, 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. Ittranslates each GUI action into a sequence of GDB commands, thenprocesses the output from GDB to display the current state of theprogram being debugged.

The IDE updates the views in the Debug perspective only when theprogram is suspended.

Editing your source after compiling causes the line numbering to beout of step because the debug information is tied directly to thesource. Similarly, debugging an optimized binary can also causeunexpected jumps in the execution trace.

Debugging your programBuilding an executable for debugging

Although you can debug a regular executable, you’ll get far morecontrol by building debug variants of the executables. When youcreated your project, you may have already set the option to cause theIDE to build an executable that’s ready for debugging. If so, youshould have executables withg appended to the filename. If not, youmust tell the IDE to build debug variants:

1 In the C/C++ Projects view (or the Navigator view), right-clickthe project and selectProperties.

2 In the left pane, selectQNX C/C++ Project.

3 In the right pane, select theBuild Variants tab.

4 Under your selected build variants, make sureDebug isenabled:

106 Chapter 5 � Debugging Programs January 31, 2005

Page 132: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Debugging your program

5 Click Apply.

6 Click OK.

7 Rebuild your project (unless you’re using the IDE’s autobuildfeature).

For more information about setting project options, see the CommonWizards Reference chapter.

January 31, 2005 Chapter 5 � Debugging Programs 107

Page 133: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Debugging your program 2005, QNX Software Systems Ltd.

Starting your debugging session

For a full description of starting your programs and the launchconfiguration options, see the Launch Configurations Referencechapter.

After building a debug-enabled executable, your next step is to createa launch configuration for that executable so you can run and debug it:

1 From the main menu, selectRun→Debug. . . . The launchconfigurations dialog appears.

2 Create a launch configuration as you normally would, but don’tclick OK.

3 Select theDebugger 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 perspectivewhen you debug a program. If the default is no longer set, or if youwish to change to a different perspective when you debug, see the“Setting execution options” section in the Launch ConfigurationsReference chapter.

If launching a debugging session doesn’t work when connected to thetarget withqconn, make surepdebug is on the target in/usr/bin.

108 Chapter 5 � Debugging Programs January 31, 2005

Page 134: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your debug session

Controlling your debug sessionThe contents ofall views in the Debug perspective are driven by theselections you make in theDebug view.

The Debug view lets you manage the debugging or running of aprogram in the workbench. This view displays the stack frame for thesuspended threads for each target you’re debugging. Each thread inyour program appears as a node in the tree. The view displays theprocess for each program you’re running.

The Debug view shows the target information in a tree hierarchy asfollows (shown here with a sample of the possible icons):

Session item Description Possible icons

Launch instance Launch configurationname and type (e.g.Stack Builder[C/C++ QNX QConn(IP)])

Debugger instance Debugger name and state(e.g.QNX GDBDebugger(Breakpoint hit))

continued. . .

January 31, 2005 Chapter 5 � Debugging Programs 109

Page 135: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your debug session 2005, QNX Software Systems Ltd.

Session item Description Possible icons

Thread instance Thread number and state(e.g.Thread[1](Suspended))

Stack frame instance Stack frame number,function, filename, andline number

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 reasonfor the suspension (e.g. end of stepping range, breakpoint hit, signalreceived, and so on). When a program exits, the IDE displays the exitcode.

The label includes the thread’s state. In the example above, the threadwas suspended because the program hit a breakpoint. You can’tsuspend only one thread in a process; suspension affectsall threads.

The Debug view also drives the C/C++ Editor; as you step throughyour program, the C/C++ Editor highlights the location of theexecution pointer.

Using the controlsAfter you start the debugger, it stops (by default) inmain()and waitsfor your input. (For information about changing this setting, see the“Debugger tab” section in the Launch Configurations Referencechapter.)

The debugging controls appear in the following places (but not alltogether in any one place):

� at the top of the Debug view as buttons

� in the Debug view’s right-click context menu

110 Chapter 5 � Debugging Programs January 31, 2005

Page 136: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your debug session

� in the main menu underRun (with hotkeys)

� in the C/C++ Editor.

The controls are superseded by breakpoints. For example, if you askthe program to step over a function (i.e. run until it finishes thatfunction) and the program hits a breakpoint, the program pauses onthat breakpoint, even though it hasn’t finished the function.

The icons and menu items are context-sensitive. For example, you canuse theTerminate action to kill a process, but not a stack frame.

Action Icon Hotkey Description

Resume F8 Run the processfreely from currentpoint

Suspend Regain control of therunning process

Terminate Kill the process

Restart Rerun the processfrom the beginning

Resume without signal Resume theexecution of aprocess withoutdelivering a pendingsignal

Step Into F5 Step forward oneline, going intofunction calls

Step Over F6 Step forward oneline without goinginto function calls

Run to return F7 Finish this function

continued. . .

January 31, 2005 Chapter 5 � Debugging Programs 111

Page 137: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your debug session 2005, QNX Software Systems Ltd.

Action Icon Hotkey Description

Resume at line Resume theexecution of theprocess at thespecified line. Usingthis action to changeinto a differentfunction may causeunpredictableresults.

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 yourprogram 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 Debugview’s toolbar. Repeat as desired.

3 Finish the debug session by choosing one of the debug launchcontrols (e.g.Disconnect). For details, see the section “Debuglaunch controls” in this chapter.

Using hotkeys

Even if you’re running your debug session without the Debug viewshowing, you can use the hotkeys or (theRun menu) to step throughyour program. You can enable the debug hotkeys in any perspective.

112 Chapter 5 � Debugging Programs January 31, 2005

Page 138: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your debug session

You can easily customize these keys (viaWindow→Preferences→Workbench→Keys):

To customize the debug hotkeys:

1 ChooseWindow→Preferences from the menu. ThePreferences dialog is displayed.

2 ChooseWorkbench→Keys in the list on the left.

3 ExpandRun in theCommands tree. The commands forrunning and stepping through a program are displayed.

4 Select a command. Its scope, configuration, and current keysequence (if any) are listed in theAssigned key sequences box.

January 31, 2005 Chapter 5 � Debugging Programs 113

Page 139: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your debug session 2005, QNX Software Systems Ltd.

5 To assign this command to a new hot key, select the keysequence from theKey sequence box.

6 Click OK to activate your new hot keys.

From the C/C++ Editor

You can control your debug session using the C/C++ Editor by havingthe program run until it hits the line your cursor is sitting on (i.e. thegdb until command). If the program never hits that line, theprogram runs until it finishes.

To use the C/C++ Editor to debug a program:

1 In the editor, select a file associated with the process beingdebugged.

2 Left-click to insert the cursor where you want to interrupt theexecution.

3 Right-click near the cursor and selectRun To Line

Debug launch controlsIn addition to controlling the individual stepping of your programs,you can also control the debug session itself (e.g. terminate thesession, stop the program, and so on) using the debug launch controlsavailable in the Debug view (or in the view’s right-click menu).

As with the other debug controls, these are context-sensitive; someare disabled depending on whether you’ve selected a thread, aprocess, and so on, in the Debug view.

Action Icon Description

Terminate Kill the selectedprocess.

continued. . .

114 Chapter 5 � Debugging Programs January 31, 2005

Page 140: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your debug session

Action Icon Description

Terminate & Remove Kill the selectedprocess and removeit from the Debugview.

Terminate All Kill all activeprocesses in theDebug view.

Disconnect Detach the debugger(i.e. gdb) from theselected process(useful fordebugging attachedprocesses).

Remove All Terminated Launches Clear all the killedprocesses from theDebug view.

Relaunch Restart the process.

Disassembly modeYou can also examine your program as it steps into functions that youdon’t have source code for, such asprintf(). Normally, the debuggersteps over these functions, even when you clickStep Into. When theinstruction pointer enters functions for which it doesn’t have thesource, the IDE shows the function in the Assembly Editor.

To step into assembly-language functions during debugging:

➤ In the Debug view, click theDisassembly Mode On/Off toggle

button ( ). As youStep Into assembler functions, the IDEshows the execution trace in the Assembly Editor.

January 31, 2005 Chapter 5 � Debugging Programs 115

Page 141: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

More debugging featuresBesides the Debug view, you’ll find several other useful views in theDebug 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 variablesThe Variables view displays information about the variables in thecurrently selected stack frame:

At the bottom of the view, the Detail pane displays the value of theselected variable (as evaluated bygdb).

116 Chapter 5 � Debugging Programs January 31, 2005

Page 142: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

If you happen to have multiple variables of the same name, the onemost 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 viewdoesn’t try to keep up with the execution of a running program; itupdates the display only when execution stops.

You can decide whether or not to display the variable type (e.g.int)

by clicking theShow Type Names toggle button ( ).

You can also control whether or not the IDE tracks your program’svariables. See the “Debugger tab” section in the LaunchConfigurations Reference chapter.

Customizing the Variables view

You can customize the look of the Variables view and set the color ofchanged variables (red by default).

To access the Variables view preferences:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectDebug→Variable Views:

January 31, 2005 Chapter 5 � Debugging Programs 117

Page 143: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

Changing variable values

While debugging a program, you may wish to manually change thevalue of a variable to test how your program handles the setting or tospeed through a loop.

To change a variable value while debugging:

1 In the Variables view, right-click the variable and selectChange 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 variablesfrom the target. You might use this feature for variables that are eithervery sensitive or specified as volatile.

118 Chapter 5 � Debugging Programs January 31, 2005

Page 144: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

To enable or disable a variable:

➤ In the Variables view, right-click the variable and select eitherEnable or Disable. (You can disableall the variables in yourlaunch configuration. See the “Debugger tab” section in theLaunch 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 inthe field (e.g.int).

Restore Original Type

Cancels yourCast 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 alength and start index that you specify. Thisoption is available only for pointers.

Using breakpoints and watchpointsThe Breakpoints view lists all the breakpoints and watchpoints you’veset in your open projects:

January 31, 2005 Chapter 5 � Debugging Programs 119

Page 145: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

A breakpointmakes your program stop whenever a certain point inthe program is reached. For each breakpoint, you can add conditionsto better control whether or not your program stops.

A watchpointis a special breakpoint that stops the program’sexecution whenever the value of an expression changes, withoutspecifying where this may happen. Unlike breakpoints, which areline-specific, watchpoints are event-specific and take effect whenevera 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 IDEplaces 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 youdebug the program, the execution suspendsbeforethat line of codeexecutes.

To add a breakpoint:

1 In the editor area, open the file that you want to add thebreakpoint to.

120 Chapter 5 � Debugging Programs January 31, 2005

Page 146: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

2 Notice that the left edge of the C/C++ Editor has a blank spacecalled amarker bar.

3 Hover your pointer over the marker bar beside the exact line ofcode where you want to add a breakpoint. Right-click themarker bar and selectAdd Breakpoint:

A dot appears, indicating the breakpoint:

January 31, 2005 Chapter 5 � Debugging Programs 121

Page 147: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, 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 afunction and selectAdd/Remove Breakpoint.

To add a breakpoint at a specific address:

1 In the Debug view’s title bar, click theDisassembly Mode

On/Off button ( ). The code in the C/C++ Editor appears asassembler.

2 You can now add a breakpoint as you normally would.

The debugger disables all address breakpoints when you relaunchyour debugger session. You can enable a breakpoint by right-clickingit and selectingEnable Breakpoint.

Adding watchpoints

To add a watchpoint:

1 From the main menu, selectRun→Add C/C++ Watchpoint.(If this option isn’t available, selectWindow→CustomizePerspective. In the left pane, selectOther, then checkC/C++Debug. Click OK.)

122 Chapter 5 � Debugging Programs January 31, 2005

Page 148: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

2 Enter an expression in the field. The expression may beanything that can be evaluated inside anif statement. (e.g.y==1)

3 If you want the program to stop when it reads the watchexpression, checkRead; to have the program stop when itwrites the expression, checkWrite.

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 IDEunconditionally 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 In the Breakpoints view, right-click the breakpoint orwatchpoint and selectProperties. (For breakpoints only, in theC/C++ Editor, right-click the breakpoint and selectBreakpointProperties.) You need to fill in at least one field:

January 31, 2005 Chapter 5 � Debugging Programs 123

Page 149: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

2 In theCondition field, enter the Boolean expression toevaluate. The expression may be anything that can be evaluatedinside anif statement (e.g.x > y ). The default isTRUE.

3 In theIgnore Count field, enter the number of times thebreakpoint or watchpoint may be hit before it begins to takeeffect (not the number of times the condition is true). Thedefault is 0.

4 Click OK. When in debug mode, your program stops when itmeets the conditions you’ve set for the breakpoint orwatchpoint.

Disabling/enabling breakpoints and watchpoints

You may wish to temporarily deactivate a breakpoint or watchpointwithout losing the information it contains.

To disable or enable a breakpoint or watchpoint:

124 Chapter 5 � Debugging Programs January 31, 2005

Page 150: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

➤ In the Breakpoints view, right-click the breakpoint orwatchpoint and selectDisable or Enable (For breakpoints only,right-click the breakpoint in the editor area and selectDisableBreakpoint or Enable Breakpoint):

To disable or enable multiple breakpoints or watchpoints:

1 In the Breakpoints view, use any of the following methods toselect the breakpoints:

� Select breakpoints and watchpoints while holding down theCtrl key.

� Select a range of breakpoints and watchpoints while holdingdown theShift key.

� From the main menu, selectEdit→Select All.

� Right-click in the Breakpoints view and selectSelect All.

2 Right-click the highlighted breakpoints/watchpoints and selectDisable or Enable.

January 31, 2005 Chapter 5 � Debugging Programs 125

Page 151: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

To remove one or more breakpoints/watchpoints:

➤ Select the breakpoint or watchpoint, right-click, then selectRemove or Remove All.

Evaluating your expressionsThe Expressions view lets you evaluate and examine the value ofexpressions:

The behavior of the Detail pane and many of the options in theright-click menu are the same as that of the Variables view. (See the“Inspecting variables” section in this chapter.)

To evaluate an expression:

1 From the menu, selectRun→Add Expression (C/C++). (Orright-click in the C/C++ Editor and selectAdd Expression.)

126 Chapter 5 � Debugging Programs January 31, 2005

Page 152: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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 theExpressions view. When the debugger suspends the program’sexecution, it reevaluates all expressions and highlights thechanged values.

Inspecting your registersThe Registers view displays information about the registers in thecurrently selected stack frame. When the execution stops, the changedvalues are highlighted.

The functionality of the Registers view is very similar to that of theVariables view; for more information, see the “Inspecting variables”section in this chapter.

January 31, 2005 Chapter 5 � Debugging Programs 127

Page 153: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

You can also customize the colors in the Registers view and changethe default value of theShow Type Names option.

To access the Registers view customization dialog:

1 From the main menu, selectWindow→Preferences.

2 In the left pane, selectDebug→Registers View.

Inspecting a process’s memoryThe Memory view lets you inspect and change your process’smemory. The view consists of four tabs that let you inspect multiplesections of memory:

128 Chapter 5 � Debugging Programs January 31, 2005

Page 154: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

QNX Neutrino uses a virtual-addressing model wherein each processhas its own range of valid virtual addresses. This means that theaddress you enter into the Memory view must be a virtual addressthat’s valid for the process you’re debugging (e.g. the address of anyvariable). For more on QNX Neutrino’s memory management, see theProcess Manager chapter in theSystem Architectureguide.

Inspecting memory

The Memory view supports the same addressing as the C language.You can address memory using expressions such as0x0847d3c,(&y)+1024, and*ptr.

To inspect the memory of a process:

1 In the Debug view, select a process. Selecting a threadautomatically selects its associated process.

2 In the Memory view, select one of the four tabs (labeledMemory 1, Memory 2, etc.).

3 In theAddress field, type the address, then pressEnter.

Changing memory

CAUTION: Changing a process’s memory can make your programcrash.!To change the memory of a process:

1 Follow the procedure for inspecting a process’s memory.

2 In the memory pane, type the new value for the memory. TheMemory view works in “typeover” mode; use the arrow keys tojump from byte to byte:

January 31, 2005 Chapter 5 � Debugging Programs 129

Page 155: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, 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 unitsize. You can configure each memory tab independently.

To configure the output format:

1 In the Memory view, select one of the four tabs labeledMemory 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:

130 Chapter 5 � Debugging Programs January 31, 2005

Page 156: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

Note that some output formats look best in a nonproportionalfont such as Courier.

Customizing the Memory view

You can customize the Memory view’s colors and fonts. You can alsocustomize some of its behavior.

To access the view’s customization dialog:

1 From the menu, selectWindow→Preferences.

2 In the left pane, selectDebug→Memory View.

3 You can now change the colors, font, and behavior of theMemory view. When you’re done, clickApply, thenOK.

Inspecting shared-library usageThe Shared Libraries view shows you information about the sharedlibraries for the session you select in the Debug view. The view showsthe name, start address, and end address of each library.

To load a library’s symbols:

➤ Right-click a library and selectLoad Symbols (or LoadSymbols for All for all your libraries).

To control how the IDE polls for new libraries, do one of thefollowing:

January 31, 2005 Chapter 5 � Debugging Programs 131

Page 157: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

� Manually refresh the display using theRefresh button.

� To refresh the display every time your program is suspended, clicktheAuto-Refresh button.

� To auto-refresh by default:

1 From the main menu, selectWindow→Preferences.

2 In the left pane of the Preferences dialog, selectDebug→Shared-Libraries View.

3 In the right pane, enableAuto-refresh by default.

Monitoring signal handlingThe Signals view provides a summary of how your debugger handlessignals 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 yourprogram.

Suspend Upon receipt of a signal, the debugger can suspend yourprogram as if it reached a breakpoint. Thus, you canstep through your code and watch how your programhandles the signal.

132 Chapter 5 � Debugging Programs January 31, 2005

Page 158: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

To change how the debugger handles a signal:

1 In the Signals view, select a signal (e.g.SIGINT) in theNamecolumn.

2 Click the signal’s setting in either thePass or Suspend columnand 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 theSuspend button ( ).

3 In the Signals view, right-click your desired signal and selectResume With Signal. Your program resumes and the debuggerimmediately sends the signal.

You can see a thread-by-thread summary of how yourprogramhandles signals using the Signal Information view. To learn more, seethe “Mapping process signals” section in the Getting SystemInformation chapter.

Viewing your outputThe Console view shows you the output of the execution of yourprogram and lets you supply input to your program:

The console shows three different kinds of text, each in a differentdefault color:

January 31, 2005 Chapter 5 � Debugging Programs 133

Page 159: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

More debugging features 2005, QNX Software Systems Ltd.

� standard output (blue)

� standard error (red)

� standard input (green)

You can choose different colors for these kinds of text on thepreferences pages.

To access the Console view customization dialog:

1 From the menu, selectWindow→Preferences.

2 In the left pane, selectDebug→Console.

Debugging with GDBThe IDE lets you use a subset of the commands that thegdb utilityoffers:

To learn more about thegdb utility, see its entry in theUtilitiesReference

Enabling the QNX GDB Console view

The QNX GDB Console view is part of the regular Console view butisn’t accessible until you toggle to it. Once you do, GDB outputappears in place of the regular Console view output.

To enable the QNX GDB Console view:

1 In the Debug view, select a debug session.

134 Chapter 5 � Debugging Programs January 31, 2005

Page 160: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. More debugging features

2 Click theShow Debugger Console on Target Selection button

( ). The Console view changes to the QNX GDB Consoleview.

Using the QNX GDB Console view

The QNX GDB Console view lets you bypass the IDE and talkdirectly to GDB; the IDE is unaware of anything done in the QNXGDB Console view. Items such as breakpoints that you set from theQNX GDB Console view don’t appear in the C/C++ Editor.

You can’t use theTab key for line completion because the commandsare sent to GDB only when you pressEnter.

To use the QNX GDB Console view:

➤ In the QNX GDB Console view, enter a command (e.g.nexti

to step one instruction):

January 31, 2005 Chapter 5 � Debugging Programs 135

Page 161: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 162: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 6

Building OS and Flash Images

In this chapter. . .Introducing the QNX System Builder 139Overview of images 145Creating a project for an OS image155Creating a project for a flash filesystem image155Building an OS image 156Downloading an image to your target 157Configuring your Builder projects 162Optimizing your system 176Moving files between the host and target179

January 31, 2005 Chapter 6 � Building OS and Flash Images 137

Page 163: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 164: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the QNX System Builder

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Use the System Builder to create OS and flash images for your target.

Introducing the QNX System BuilderOne of the more distinctive tools within the IDE is the QNX SystemBuilder, which simplifies the job of building OS images for yourembedded systems. Besides generating images intended for yourtarget board’s RAM or flash, the QNX System Builder can also helpreduce the size of your images (e.g. by reducing the size of sharedlibraries). The Builder also takes care of tracking librarydependencies for you, prompting you for any missing components.

The Builder contains a Serial Terminal for interacting with yourboard’s ROM monitor or QNX Initial Program Loader (IPL) and fortransferring images (using the QNXsendnto protocol). The Builderalso has an integrated TFTP Server that lets you transfer your imagesto network-aware targets that can boot via the TFTP protocol.

When you open the Builder to create a project, you have the choice ofimporting/customizing an existing buildfile to generate an image or ofcreating one from scratch. The Builder’s editor lets you select whichcomponents (binaries, DLLs, libs) you want to incorporate into yoursystem image. As you add a component, the Builder automaticallyadds any shared libraries required for runtime loading. For example,

January 31, 2005 Chapter 6 � Building OS and Flash Images 139

Page 165: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the QNX System Builder 2005, QNX Software Systems Ltd.

if you add thetelnet application to a project, then the Builderknows to addlibsocket.so in order to ensure thattelnet can run.And when you select a binary, a you’ll see relevant information forthat item, including its usage message, in the Binary Inspector view.

Using standard QNX embedding utilities (mkifs, mkefs), theBuilder can generate configuration files for these tools that can beused outside of the IDE for scripted/automated system building. Asyou do a build, a Console view displays the output from theunderlying build command. Themksbp utility can be used to build aSystem Builderproject.bld from the command-line.mksbpautomatically callsmkifs or mkefs depending on the kind of imagebeing built.

Here’s what the QNX System Builder perspective looks like:

One of the main areas in the Builder is the editor, which presents twopanes side by side:

140 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 166: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the QNX System Builder

Images Shows all the images you’re building. You can add orremove binaries and other components, view theirproperties, etc.

Filesystem Shows the components of your image arranged in ahierarchy, as they would appear in a filesystem onyour target.

Toolbar buttonsAbove the Images and Filesystem panes in the editor you’ll findseveral 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.

January 31, 2005 Chapter 6 � Building OS and Flash Images 141

Page 167: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the QNX System Builder 2005, QNX Software Systems Ltd.

Run the System Optimizer.

Rebuild the current project.

Binary InspectorBelow the Images and Filesystem panes is theQNX BinaryInspector view, which shows the usage message for any binary youselect:

The Binary Inspector also has aUse Info tab that gives the selectedbinary’s name, a brief description, the date it was built, and so on.

142 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 168: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the QNX System Builder

Boot script filesAll QNX BSPs ship with abuildfile, which is a type of “control” filethat gives instructions to themkifs command-line utility to generatean OS image. The buildfile specifies the particular startup program,environment variables, drivers, etc. to use for creating the image. Theboot scriptportion of a buildfile contains the sequence of commandsthat the Process Manager will execute when your completed imagestarts up on the target.

For details on the components and grammar of buildfiles, see thesection “Configuring an OS image” in the chapter Making an OSImage inBuilding Embedded Systemsas well as the entry formkifsin theUtilities Reference.

The QNX System Builder provides a convenient graphical alternativeto the text-based buildfile method. While it hides most of the“gruesome” details from you, the Builder also lets you see and workwith 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 BuilderProjects view, you’ll see its contents in the editor.

January 31, 2005 Chapter 6 � Building OS and Flash Images 143

Page 169: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the QNX System Builder 2005, QNX Software Systems Ltd.

Builder projectsLike other tools within the IDE, the System Builder isproject-oriented— it organizes your resources into a project ofrelated items. Whenever you create a project in the Builder, you’ll seeaproject.bld file in the Navigator or System Builder Projectsview:

Theproject.bld file drives the Builder’s editor area — if youselect theproject.bld, you’ll see your project’s components in theImages and Filesystem panes, where you can add/remove items forthe image you’ll be building.

As with most other tools in the IDE, you build your QNX SystemBuilder projects using the standard Eclipse build mechanism viaProject→Rebuild Project.

The scope of the BuilderYou can use the QNX System Builder throughout yourproduct-development cycle:

� At the outset — to import a QNX BSP, generate a minimal OSimage, and transfer the image to your board, just to make sureeverything works.

� During development — to create an image along with your suite ofprograms and download everything to your eval board.

144 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 170: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Overview of images

� For your final product — to strip out the extra utilities you neededduring 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 orother QNX source packages” in the chapter Managing Source Code inthis guide.

Overview of imagesBefore you use the QNX System Builder to create OS and flashimages for your hardware, let’s briefly describe the concepts involvedin building images so you can better understand the Builder incontext.

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 bootingNeutrino supports a wide variety of CPUs and hardwareconfigurations. Some boards require more effort than others to embedthe OS. For example, x86-based machines usually have a BIOS,which greatly simplifies your job, while other platforms require thatyou create a complete IPL. Embedded systems can range from a tinymemory-constrained handheld computer that boots from flash to anindustrial robot that boots through a network to an SMP system withlots of memory that boots from a hard disk.

Whatever your particular platform or configuration, the SystemBuilder helps simplify the process of building images and transferringthem from your host to your target.

January 31, 2005 Chapter 6 � Building OS and Flash Images 145

Page 171: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Overview of images 2005, QNX Software Systems Ltd.

For a complete description of OS and flash images, see theBuildingEmbedded Systemsguide.

The goal of the boot process is to get the system into a state that letsyour program run. Initially, the system might not recognize disks,memory, or other hardware, so each section of code needs to performwhatever setup is needed in order to run the subsequent section:

1 The IPL initializes the hardware, makes the OS imageaccessible, and then jumps into it.

2 The startup code performs further initializations, then loads andtransfers control to the microkernel/process manager(procnto), the core runtime component of the QNX NeutrinoOS.

3 Theprocnto module then runs the boot script, which performsany final setup required and runs your programs.

procnto Driversand yourprogram

IPL (atreset vector)

Boot scriptStartup

Typical boot order.

At reset, a typical processor has only a minimal configuration that letscode be executed from a known linearly addressable device (e.g.flash, ROM). When your system first powers on, it automatically runsthe IPL code at a specific address called thereset 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 methoddepends on the hardware — some boards need more initializationthan others.

146 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 172: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Overview of images

When the memory is accessible, the IPL scans the flash memory forthe image filesystem, which contains the startup code (described inthe next section). The IPL loads the startup header and startup codeinto 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 interruptcontrollers, cache controllers, and base timers. The code detectssystem resources such as the processor(s), and puts information aboutthese resources into a centrally accessible area called thesystem page.The code can also copy and decompress the image filesystemcomponents, if necessary. Finally, the startup code passes control, invirtual memory mode, to theprocnto module.

The startup code is board-specific and is generally much larger thanthe IPL. Although a largerprocnto module could do the setup, weseparate the startup code so thatprocnto can be board-independent.Once the startup code sets up the hardware, the system can reuse apart of the memory used by startup because the code won’t be neededagain.

The procnto module

Theprocnto module is the core runtime component of the QNXNeutrino OS. It consists of the microkernel, the process manager, andsome initialization code that sets up the microkernel and creates theprocess-manager threads. Theprocnto module is a requiredcomponent of all bootable images.

The process manager handles (among other things) processes,memory, and the image filesystem. The process manager lets otherprocesses see the image filesystem’s contents. Once theprocnto

module is running, the operating system is essentially up and running.One of the process manager’s threads runs the boot script.

Several variants ofprocnto are available (e.g.procnto-400 forPowerPC 400 series,procnto-smp for x86 SMP machines, etc.).

January 31, 2005 Chapter 6 � Building OS and Flash Images 147

Page 173: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Overview of images 2005, QNX Software Systems Ltd.

Boot script

If you want your system to load any drivers or to run your programautomatically after power up, you should run those utilities andprograms from the boot script. For example, you might have the bootscript run adevf driver to access a flash filesystem image and thenrun your program from that flash filesystem.

When you build your image, the boot script is converted from text to atokenized form and saved as/proc/boot/.script. The processmanager runs this tokenized script.

Types of images you can createThe IDE lets you create the following images:

OS image (.ifs file)

An image filesystem. A bootable image filesystem holds theprocnto module, your boot script, and possibly othercomponents such as drivers and shared objects.

Flash image (.efs file)

A flash filesystem. (The “e” stands for “embedded.”) You canuse your flash memory like a hard disk to store programs anddata.

Combined image

An image created by joining together any combination ofcomponents (IPL, OS image, embedded filesystem image) intoa single image. You might want to combine an IPL with an OSimage, for example, and then download that single image to theboard’s memory via a ROM monitor, which you could use toburn the image into flash. A combined image’s filenameextension indicates the file’s format (e.g. (.elf, .srec, etc.).

If you plan on debugging applications on the target, you must includepdebug in /usr/bin. If the target has no other forms of storage,include it in the OS image or Flash image.

148 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 174: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Overview of images

BSP filename conventions

In our BSP docs, buildfiles, and scripts, we use a certain filenameconvention that relies on a name’s prefixes and suffixes to distinguishtypes:

Part of filename Description Example

.bin Suffix for binary format file. ifs-artesyn.bin

.build Suffix for buildfile. sandpoint.build

efs- Prefix for QNX EmbeddedFilesystem file; generated bymkefs.

efs-sengine.srec

.elf Suffix for ELF (Executable andLinking Format) file.

ipl-ifs-mbx800.elf

ifs- Prefix for QNX ImageFilesystem file; generated bymkifs.

ifs-800fads.elf

ipl- Prefix for IPL (Initial ProgramLoader) file.

ipl-eagle.srec

.openbios Suffix for OpenBIOS formatfile.

ifs-walnut.openbios

.prepboot Suffix for Motorola PRePbootformat file.

ifs-prpmc800.prepboot

.srec Suffix for S-record format file. ifs-malta.srec

January 31, 2005 Chapter 6 � Building OS and Flash Images 149

Page 175: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Overview of images 2005, QNX Software Systems Ltd.

The System Builder uses a somewhat simplified convention. Only afile’s three-letter extension,not its prefix or any other part of thename, 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 afile’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 startupheader, startup code,procnto, your boot script, and any driversneeded to minimally configure the operating system:

Startup header

Startup

procnto

Boot script

devf-*Image

filesystem

Generally, we recommend that you keep your OS image as small aspossible to realize the following benefits:

� Memory conservation — When the system boots, the entire OSimage gets loaded into RAM. This image isn’t unloaded fromRAM, so extra programs and data built into the image requiremore memory than if your system loaded and unloaded themdynamically.

� Faster boot time — Loading a large OS image into RAM can takelonger to boot the system, especially if the image must be loadedvia a network or serial connection.

� Stability — Having a small OS image provides a more stable bootprocess. The fewer components you have in your OS image, the

150 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 176: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Overview of images

lower the probability that it will fail to boot. The components thatmust go in your image (startup,procnto, a flash driver or networkcomponents, and a few shared objects) change rarely, so they’reless subject to errors introduced during the development andmaintenance cycles.

If your embedded system has a hard drive or CompactFlash (whichbehaves like an IDE hard drive), you can access the data on it byincluding a block-oriented filesystem driver (e.g.devb-eide) inyour OS image filesystem and calling the driver from your boot script.For details on the driver, seedevb-eide in theUtilities Reference.

If your system has an onboard flash device, you can use it to storeyour OS image and even boot the system directly from flash (if you’reboard allows this — check your hardware documentation). Note thatan OS image is read-only; if you want to use the flash for read/writestorage, 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, extradata, and any other utilities (e.g.qconn, ls, dumper, andpidin)that you want to access on your embedded system.

If your system has a flash filesystem image, you should include adevf* driver in your OS image and start the driver in your bootscript. While you can mount an image filesystem only at/, you canspecify your own mountpoint (e.g./myFlashStuff) when you setup your.efs image in the IDE. The system recognizes both the.ifs

and.efs filesystems simultaneously because the process managertransparently overlays them. To learn more about filesystems, see theFilesystem chapter in the QNX NeutrinoSystem Architectureguide.

Combined image

For convenience, the IDE can join together any combination of yourIPL, OS image, and.efs files into a single, larger image that you cantransfer to your target:

January 31, 2005 Chapter 6 � Building OS and Flash Images 151

Page 177: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Overview of images 2005, QNX Software Systems Ltd.

IPL

Padding

IFS

Alignment(blocksizeof onboardflash)

PaddingEFS startsa new block

Final IPL size

EFS

When you create a combined image, you specify the IPL’s path andfilename on your host machine. You can either select a precompiledIPL 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 combinedimage.

Padding after the IPL

The IPL can scan the entire combined image for the presence of thestartup header, but this slows the boot process. Instead, you can havethe IPL scan through a range of only two addresses and place thestartup header at the first address.

Specifying a final IPL size that’s larger than the actual IPL lets youmodify the IPL (and change its length) without having to modify thescanning addresses with each change. This way, the starting addressof the OS image is independent of the IPL size.

You must specify a padding size greater than the total size of the IPLto prevent the rest of the data in the combined image file frompartially overwriting your IPL.

152 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 178: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Overview of images

Padding before .ifs images

If your combined image includes one or more.efs images, specifyan 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 yourcombined image, the IDE adds padding to align the beginning of the.efs image(s) with the address of the next block boundary.

Project layoutA single System Builder project can contain your.ifs file andmultiple.efs files, as well as your startup code and boot script. Youcan import the IPL from another location or you can store it inside theproject directory.

By default, your QNX System Builder project includes the followingparts:

Item Description

Images directory The images and generated files that theIDE creates when you build your project.

Overrides directory When you build your project, the IDEfirst looks in this directory for any files.You can use theOverrides directory toeasily test a change to your build.

Reductions directory The IDE lets you reduce your image sizeby eliminating unused libraries, andshrinking the remaining libraries. TheIDE stores the reduced libraries in theReductions directory.

.project file Information about the project, such as itsname and type. All IDE projects have a.project file.

continued. . .

January 31, 2005 Chapter 6 � Building OS and Flash Images 153

Page 179: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Overview of images 2005, QNX Software Systems Ltd.

Item Description

.sysbldr meta file Information about the properties specificto a QNX System Builder project. Thisfile describes where the IDE looks forfiles (including theOverrides andReductions directories), the location ofyour IPL file, how the IDE includes.efs files, and the final format of your.ifs file.

project.bld file Information about the structure andcontents of your.ifs and.efs files.This file also contains your boot scriptfile.

.bsh file Contains the boot script for your project.

Overview of workflowHere are the main steps involved in using the IDE to get Neutrino upand running on your board:

� Creating a QNX System Builder project for an OS or a flash imagefor your board. The process is very simple if a BSP exists for yourboard. If an exact match isn’t available, you may be able to modifyan existing BSP to meet your needs.

� Building your project to create the image.

� Transferring the OS image to your board. You might do thisinitially to verify that the OS image runs on your hardware, andthen again (and again) as you optimize your system.

� Configuring your projects.

� Optimizing your system by reducing the size of the libraries.

154 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 180: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a project for an OS image

Creating a project for an OS imageTo create a new QNX System Builder Project:

1 From the main menu, selectFile→New→Project.

2 SelectQNX in the left column, thenQNX System BuilderProject in the right. ClickNext.

3 Name your project and clickNext.

4 At this point, you need to specify your target hardware. Youcan either import an existing buildfile (as shipped with yourQNX BSPs) or select a generic type (e.g. “Generic PPCBE”).

We recommend that you selectImport Existing Buildfile, rather thana generic option. Creating a buildfile requires a working knowledge ofboot script grammar(as described in the entry formkifs in theUtility Referenceand in theBuilding Embedded Systemsmanual).

5 If you chose a generic type, jump to the last step. If you choseto import an existing buildfile, continue with the next step.

6 Click Next, thenBrowse to locate an appropriate buildfile.Refer to your BSP docs for the proper.build file for yourboard. You can find buildfiles for all the BSPs installed on yoursystem inC:/QNX630/target/qnx6/processor/boot/build/ on yourWindows host. (For Neutrino, Linux, or Solaris hosts, see theappendix Where Files Are Stored in this guide.)

7 Click Finish. The IDE creates your new project, whichincludes all the components that make up the OS image.

Creating a project for a flash filesystemimageTo create a flash filesystem project:

1 From the main menu, selectFile→New→Project.

January 31, 2005 Chapter 6 � Building OS and Flash Images 155

Page 181: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Building an OS image 2005, QNX Software Systems Ltd.

2 SelectQNX in the left column, thenQNX System BuilderEFS Project in the right. ClickNext.

3 Name your project and clickNext.

4 Specify your target hardware (e.g. “Generic ARMLE”).

5 Click Finish. The IDE creates your new EFS project, whichincludes a “generic”.efs image – you’ll likely need to specifythe block size, image size, and other properties to suit the flashon your particular board.

Building an OS imageYou build your QNX System Builder projects using the standardEclipse build mechanism:

➤ From the main menu, selectProject→Build|Rebuild Project.

Depending on whether the auto-build feature is set (openWindow→Preferences→Workbench), you can also build projectsusing the context menu:

1 In the Navigator or System Builder Projects view, right-clickthe project.

2 Select build.

The System Builder Console view shows the output produced whenyou build your images:

Output can come from any of these utilities:

156 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 182: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Downloading an image to your target

� mkefs

� mkifs

� mkimage

� mkrec

� objcopy

For more information, see their entries in theUtilities Reference.

You can clear the view by clicking theClear Output button ( ).

Downloading an image to your targetMany boards have aROM monitor, a simple program that runs whenyou first power on the board. The ROM monitor lets youcommunicate with your board via a command-line interface (over aserial or Ethernet link), download images to the board’s systemmemory, burn images into flash, etc.

The Builder has two facilities you can use to communicate with yourboard:

� serial terminals (up to four)

� TFTP server

If your board doesn’t have a ROM monitor, you probably can’t use thedownload services in the IDE; you’ll have to get the image onto theboard some other way (e.g. JTAG). To learn how to connect to yourparticular target, consult your hardware and BSP documentation.

Downloading via a serial linkWith the Builder’s builtin serial terminals, you don’t need to leave theIDE and open a serial communications program (e.g. HyperTerminal)in order to talk to your target, download images, etc.

To open a terminal:

January 31, 2005 Chapter 6 � Building OS and Flash Images 157

Page 183: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Downloading an image to your target 2005, QNX Software Systems Ltd.

➤ From the main menu, selectShow View→Other. . . , then selectQNX System Builder→Terminal N (whereN 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 communicationssettings in the view’s menu:

You can now interact with your target by typing in the view.

To transfer a file using theSerial Terminal view:

1 Using either the serial terminal view or another method (outsidethe IDE), configure your target so that it’s ready to receive animage. For details, consult your hardware documentation.

2 In the serial terminal view, click theSend File button:

3 In theSelect File to Send dialog, enter the name of your file (orclick Browse).

158 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 184: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Downloading an image to your target

4 Select a protocol (e.g.sendnto).

The QNXsendnto protocol sends a sequence of records (includingthe start record, data records, and a go record). Each record has asequence number and a checksum. Your target must be running anIPL (or other software) that understands this protocol.

5 Click OK. The Builder transmits your file over the serialconnection.

You can click theCancel button to stop the file transfer:☞

Downloading via TFTPThe Builder’s TFTP server eliminates the need to set up an externalserver for downloading images (if your target device supports TFTPdownloads). The TFTP server knows about all Builder projects in thesystem and automatically searches them whenever it receives requestsfor service.

When you first open the TFTP Server view (in any perspective), theBuilder starts its internal TFTP server. For the remainder of thecurrent IDE session, the TFTP server will listen for incoming TFTPtransfer requests and automatically fulfill them.

Currently, the Builder’s internal server supports only TFTPreadrequests; you can’t use the server to write files from the target to thehost development machine.

The TFTP Server view provides status and feedback for current andpast TFTP transfers. As the internal TFTP server handles requests,the view provides visual feedback:

January 31, 2005 Chapter 6 � Building OS and Flash Images 159

Page 185: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Downloading an image to your target 2005, 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 TFTPserver. (The TFTP Server view displays your host’s IP address.)During the transfer, the view shows your target’s IP address, therequested file, and the transfer status.

You can clear the TFTP server view of all completed transactions by

clicking its clear button ( ).

160 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 186: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Downloading an image to your target

The internal TFTP server recognizes files in theImages directory ofall open QNX System Builder projects; you don’t need to specify thefull path.

Transferring files that aren’t in Images

CAUTION: The IDE deletes the content of theImages directoryduring builds — don’t use this directory to transfer files that theSystem Builder didn’t generate. Instead, configure a new path, asdescribed in the following procedure.

!

To enable the transfer of files that aren’t in theImages directory:

1 From the main menu, selectWindow→Preferences.

2 In the left pane of the Preferences dialog, selectQNX→Connections→TFTP Server.

3 CheckOther Locations.

4 Click Add Path, and then select your directory from theBrowse For Folder dialog.

5 Click Apply.

6 Click OK. The TFTP server is now aware of the contents ofyour selected directory.

Downloading using other methodsIf your board doesn’t have an integrated ROM monitor, you may notbe able transfer your image over a serial or TFTP connection. You’llhave to use some other method instead, such as:

� CompactFlash — copy the image to a CompactFlash card pluggedinto your host, then plug the card into your board to access theimage.

Or:

January 31, 2005 Chapter 6 � Building OS and Flash Images 161

Page 187: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

� Flash programmer — manually program your flash with anexternal programmer.

Or:

� JTAG/ICE/emulator — use such a device to program andcommunicate with your board.

For more information, see the documentation that came with yourboard.

Configuring your Builder projectsIn 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 aproject.bld filethat contains information about your image’s boot script, all the filesin your image, and the properties of those files:

If you double-click theproject.bld, you’ll see your project’scomponents in the Images and Filesystem panes in the editor area, aswell as a Properties view:

162 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 188: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

Managing your imagesThe Images pane shows a tree of all the files in your image, sorted bytype:

� 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 orselect a file from a list of search paths:

Browse method If you choose a file by browsing, you’ll probablywant to configure the project to use anabsolutepathso that the IDE will always find the exact fileyou specified (provided you keep the file in thesame location). Note that other users of yourproject would also have to reproduce your setup inorder for the IDE to locate files.

Select method Select a file from a preconfigured list of searchlocations. We recommend that you use this optionbecause it’s more flexible and lets others easily

January 31, 2005 Chapter 6 � Building OS and Flash Images 163

Page 189: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

reproduce your project on their hosts. You can addsearch paths to the list.

Note that the IDE saves only the filename. Whenyou build your project, the IDE follows yoursearch paths and uses the first file that matchesyour specified filename. If you specify a file thatisn’t in the search path, the build will beincomplete. To learn how to configure your searchpaths, see the the section “Configuring projectproperties” in this chapter.

To add an item to your image:

1 In the Images pane, right-click the image and selectAdd Item,followed by the type of item you want to add:

� binary

� shared library

� symbolic link

� file

� directory

� EFS

If you select EFS, the Builder immediately adds a flash filesystem toyour image without prompting.

2 Select the item (e.g. a binary) from the list or browse for it.

3 Select either theSearch Path or theAbsolute Path option.(We recommend Search Path, because other users would beable to recreate your project more easily.)

4 Click Next. A dialog appears showing the image you’re addingthe item to, the image’s location on your target, as well asoptions (use in place or copy) for the item’s code and datasegments. (For more information on code and data segments,seemkifs in theUtilities Reference.

164 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 190: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

5 Click Finish. The Builder adds the file to your image, as youcan see in the Images pane.

Deleting files

➤ In either the Images or Filesystem pane, right-click your fileand selectDelete.

Adding directories

To add a directory to your image:

1 In the Filesystem pane, right-click the parent directory andselectAdd Item→Directory.

2 Specify the directory name, path, and image name. Some fieldsare 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 theLocation In Image field in the Properties view. The IDE includes thespecified directory as long as the item remains in your image.

Deleting directories

➤ In either the Images or Filesystem pane, right-click yourdirectory and selectDelete.

A deleted directory persists if it still contains items. To completelyremove the directory, delete the reference to the directory in theLocation In Image field in the Properties view for all the items in thedirectory.

January 31, 2005 Chapter 6 � Building OS and Flash Images 165

Page 191: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

Configuring image propertiesThe Properties view lets you see and edit the properties of an image orany 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 itsitems.

2 In the Properties view, select an entry in theValue column. Thevalue is highlighted; for some fields (e.g. CPU Type), adropdown menu appears.

3 Type a new value or select one from the dropdown menu.

4 PressEnter.

5 Save your changes.

6 Rebuild your project.

Different properties appear for images and for the items in an image:

� Image properties

- Directories

166 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 192: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

- General

- System (.ifs)

- System (.efs)

� Item properties

- General

- Memory

- Permissions

Image properties

Directories

These settings control the default permissions for directories that youadd to the image, as well as for any directories that the tools createwhen you build your system. For example, if you add/usr/bin/ksh to your system, the IDE automatically creates theusr andbin directories. (For more information on permissions,seethe Managing User Accounts chapter in the NeutrinoUser’s Guideand the chmod entry in theUtilities Reference.)

Note that the values for permissions are given inoctal (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 scriptportion of a buildfile. Boot script files have a.bshextension (e.g.prpmc800.bsh).

Compressed (.ifs only)

If set toYes, the Builder compresses the directorystructure (image filesystem) section of the image.The directory structure includesprocnto, theboot script, and files. You might enablecompression if you want to save on flash space or

January 31, 2005 Chapter 6 � Building OS and Flash Images 167

Page 193: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

if the BIOS/ROM monitor limits the size of yourimage.

CPU Type Your target’s processor (e.g.armle).

Create Image If Yes, the IDE builds this image when you buildyour project.

Image Name Name of the.ifs file saved in theImagesdirectory during a build.

System (.ifs)

Boot File The image filter that the Builder uses (e.g.srec, elf) toperform further processing on the image file. Forexample,srec converts the image to the MotorolaS-Record format. (For more about image filters, seemkifs in theUtilities Reference.)

Image Address

The base address where the image is copied to at boottime. For XIP, set this to the same location as yourimage file on flash memory and specify the read/writememory address with theRAM Address value,described below.

Procnto Specify whichprocnto binary to use (e.g.procnto-600, procnto-600-SMP, etc.).

Procnto $LD LIBRARY PATH

Path(s) whereprocnto should look for sharedlibraries. Separate the paths with a colon (:).

Procnto $PATH

Path(s) whereprocnto should look for executables.Separate the paths with a colon (:).

Procnto Arguments

Command-line arguments forprocnto.

168 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 194: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

RAM Address

The location of your read/write memory. For XIP, setthe address; otherwise, set the value toDefault. (NotethatRAM Address is theram attribute in themkifsutility.)

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. Unlessotherwise specified, the values are in bytes, but you can use thesuffixesK, M, orG (e.g.800, 16K, 2M, 4G). The IDE immediatelyrejects invalid entries.

Block Size The size of the blocks on your flash.

Filter The filter to use with this image, usuallyflashcmp. (Themkefs 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 thefilesystem. By default, the location is/.

Maximum Image Size

The limit for the size of the generated image. If theimage exceeds the maximum size,mkefs fails andreports an error in the System Builder Consoleview. The default setting of 4G accommodatesmost images.

January 31, 2005 Chapter 6 � Building OS and Flash Images 169

Page 195: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, 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 sizeafter all the specified files have been added, thenthe filesystem is padded to the required size. Thedefault is 0 (i.e. no padding occurs).

Spare Blocks Set the number of spare blocks to be used by theembedded filesystem. If you want the embeddedfilesystem to be able to reclaim the space taken upby deleted files, set the number of spare blocks to 1or 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 buildsthe image.

Location In Image

The directory where the item lives. If you changethis setting, the directory location shown in theFilesystem pane changes as well.

Symbolic links also have aLinked To field for the source file.☞

Strip File By default,mkifs strips usage messages,debugging information, and Photon resources fromexecutable files that you include in the image.Doing this helps reduce the size of the image. Tokeep this information, selectNo. Seemkifs

170 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 196: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

(especially the+raw attribute) andstrip in theUtilities Reference.

Set this field toNo if your image includes PhAB applications.☞

Memory

Use these two settings to specify whether a program’s code and datasegments should be used directly from the image filesystem (Use InPlace) or copied when invoked (Copy). For more information, see thecode attribute in themkifs documentation.

Permissions

Use these settings to specify the read/write/execute permissions (inoctal) assigned to each item, as well as the item’s group and user ID.

Configuring project propertiesThe properties dialog for your QNX System Builder project(right-click the project, then selectProperties) lets you view andchange the overall properties of your project. For example, you cancombine images, add dependent projects, and configure search paths.

The dialog includes the following sections:

� Info

� External Tools Builders

� Image Combine

� Project Preferences

� Search Paths

January 31, 2005 Chapter 6 � Building OS and Flash Images 171

Page 197: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

For information on external tools, follow these links in the EclipseWorkbench User Guide: Tasks→Building resources→Runningexternal tools.

Image Combine

As mentioned earlier, the Builder lets you create a combined image.You use theImage 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-clickyour project and selectProperties.

2 SelectImage Combine.

3 CheckAdd IPL.

4 Enter the IPL filename (or select it by clicking the browse icon).

5 In thePadding field, select padding equal to or greater than thesize of your IPL.

CAUTION: If the padding is less than the size of the IPL, the imagewon’t contain the complete IPL.!6 Click OK.

172 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 198: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

If you get a File Not Found error while building, make sure theBuildwith profiling option is unchecked in all of the C/C++ projects in theBSP working set, then rebuild all of the projects.

Right-click on a project, then chooseProperties and selectQNXC/C++ Project to view theBuild with profiling setting.

Adding an EFS to your image

To append a flash filesystem to your image:

1 In theImage Combine section of the properties dialog for yourproject, checkAppend EFS.

2 In theAlignment 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 theImage Combine section of your project’s propertiesdialog to set the final format for your image, even if it isn’t acombined image.

To change the final format of your OS image:

1 In theImage Combine section of the properties dialog for yourproject, check theFinal Processing box.

2 In theOffset field, enter the board-specific offset. This settingis generally used for S-Record images.

3 In theFormat 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, seemkrec in theUtilities Reference.

January 31, 2005 Chapter 6 � Building OS and Flash Images 173

Page 199: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring your Builder projects 2005, QNX Software Systems Ltd.

Search Paths

TheSearch Paths pane lets you configure where the IDE looks forthe files you specified in yourproject.bld file:

The IDE provides separately configurable search paths for:

� binaries

� shared libraries

� DLLs

� other files

� system files.

To add a search path:

1 In the Navigator or System Builder Projects view, right-clickyour project and selectProperties.

2 In the left pane, selectSearch Paths.

3 In the right pane, select one of the following tabs:

174 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 200: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring your Builder projects

� 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 Workspace Path — a path with a $WORKSPACEprefix

� Add Project — a path with a$WORKSPACE/projectNameprefix.

TheBrowse For Folder or Search Projects dialog appears.

5 Select your path or project and clickOK. The IDE adds yourpath to the end of the list.

To manage your search paths:

1 In theSearch Path section of the properties dialog, select oneof 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.

January 31, 2005 Chapter 6 � Building OS and Flash Images 175

Page 201: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Optimizing your system 2005, QNX Software Systems Ltd.

CAUTION: TheOverrides directory must be first in the list. TheReductions directory, which is listed in theShared Libraries tab,must be second in the list.

Changing the order of theOverrides or Reductions directoriesmay cause unexpected behavior.

!

3 Click OK.

Optimizing your systemSince “less is better” is the rule of thumb for embedded systems, theBuilder’s System Optimizer and the Dietician help you optimize yourfinal system by:

� reducing the size of shared libraries for your image

� performing system-wide optimizations to remove unnecessaryshared libraries, add required shared libraries, and reduce the sizeof all shared libraries in the system.

176 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 202: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Optimizing your system

CAUTION: If you reduce a shared library, and your imagesubsequently needs to access binaries on a filesystem (disk, network,etc.) that isn’t managed by the System Builder, then the functionsrequired by those unmanaged binaries may not be present. This willcause those binaries to fail on execution.

In general, shared-library optimizers such as the Dietician are trulyuseful only in the case of a finite number of users of the sharedlibraries, as you would find in a closed system (i.e. a typicalembedded system).

If you have only a small number of unmanaged binaries, oneworkaround is to create adummy flash filesystem imageand add tothis image the binaries you need to access. This dummy image will bebuilt with the rest of the images, but it can be ignored. This techniquelets the Dietician be aware of the requirements of your runtimesystem.

!

Optimizing all libraries in your imageTo optimize all the libraries in an image:

1 In the Navigator or System Builder Projects view, double-clickyour project’sproject.bld file.

2 In the toolbar, click theOptimize System button ( ).

3 In the System Optimizer, select the optimizations that you wantto make:

Remove unused libraries

When you select this option, the Dietician inspects yourentire builder project and ensures that all shared librariesin the system are required for proper operation. If theBuilder finds libraries that no component in your projectactually needs, you’ll be prompted to remove thoselibraries from your project.

January 31, 2005 Chapter 6 � Building OS and Flash Images 177

Page 203: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Optimizing your system 2005, QNX Software Systems Ltd.

Add missing libraries

This option causes the Dietician to inspect your entireproject for missing libraries. If any binaries, DLLs, orshared libraries haven’t met load-time libraryrequirements, you’ll be prompted to add these libraries toyour project.

Apply diet(s) system wide

This option runs the Dietician on all the libraries selected.The diets are appliedin the proper orderso that runtimedependencies aren’t broken. If you were to do this byhand, it’s possible that the dieting of one shared librarycould render a previously dieted shared librarynon-functional. The order of operations is key!

To ensure that your image works and is as efficient as possible, youshould select all three options.

4 Click Next. You’ll see a list of the libraries scheduled to beremoved, added, or put on a diet. Uncheck the libraries that youdon’t want included in the operation, then move to the nextpage.

5 Click Finish. The System Optimizer optimizes your libraries;the dieted libraries appear in your project’sReductionsdirectory.

Optimizing a single libraryOptimizing a single library doesn’t reduce the library as effectively asoptimizingall libraries simultaneously, because the System Optimizeraccounts for dependencies.

To reduce a library such aslibc using the Dietician, you mustiteratively optimize each individual library in your project betweentwo and five times (depending on the number of dependency levels).

You can optimize a single library to its optimum size if it has nodependencies.

178 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 204: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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-clickyour project’sproject.bld file.

2 In the editor, expand the Shared Libraries item (if it isn’talready), and select the library you want to optimize.

3 In the toolbar, click theOptimize System button ( ).

4 In the System Optimizer, select theApply diet(s) system wideoption.

5 Click Next. The pane shows the library you want to reduce.

6 Click Finish. The Dietician generates a new, reduced libraryand puts it in your project’sReductions directory.

Restoring a slimmed-down libraryIf after reducing a library, you notice that your resulting image is too“slim,” you can manually remove the reduced library from theReductions 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 theReductions directory in your project. This directory containsthe dieted versions of your libraries.

2 Right-click the library you want to remove and selectDelete.Click OK to confirm your selection. The IDE deletes theunwanted library; when you rebuild your project, the IDE usesthe undieted version of the library.

Moving files between the host and targetThe IDE’sFile System Navigator view lets you easily move filesbetween your host and a filesystem residing on your target.

January 31, 2005 Chapter 6 � Building OS and Flash Images 179

Page 205: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Moving files between the host and target 2005, QNX Software Systems Ltd.

If you haven’t yet created a target system, you can do so right fromwithin the File System Navigator view:

➤ Right-click anywhere in the view, then selectAdd New Target.

The view displays the target and directory tree in the left pane, and thecontents 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 selectShow table.You can also customize the view by selectingTable Parameters orShow files in tree.

Note that the File System Navigator view isn’t part of the defaultQNX System Builder perspective; you must manually bring the viewinto your current perspective.

To see the File System Navigator view:

1 From the main menu, selectWindow→Show View→Other. . . .

2 SelectQNX Targets, then double-clickFile SystemNavigator.

Moving files to the targetYou can move files from your host machine to your target usingcopy-and-paste or drag-and-drop methods.

180 Chapter 6 � Building OS and Flash Images January 31, 2005

Page 206: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Moving files between the host and target

To copy files from your host filesystem and paste them on yourtarget’s filesystem:

1 In a file-manager utility on your host (e.g. Windows Explorer),select your files, then selectCopy from the context menu.

2 In the left pane of the File System Navigator view, right-clickyour destination directory and selectPaste.

To convert files from DOS to Neutrino (or Unix) format, use thetextto -l filenamecommand. (For more information, seetexttoin theUtilities Reference.)

To drag-and-drop files to your target:

➤ Drag your selected files from any program that supportsdrag-and-drop (e.g. Windows Explorer), then drop them in theFile System Navigator view.

Moving files from the target to the hostTo copy files from your target machine and paste them to your host’sfilesystem:

1 In the File System Navigator view, right-click a file, then selectCopy to→File System. TheBrowse For Folder dialogappears.

To import files directly into your workspace, selectCopyto→Workspace. TheSelect target folder dialog appears.

2 Select your desired destination directory and clickOK.

To move files to the host machine using drag-and-drop:

➤ Drag your selected files from theFile System Navigator viewand drop them in the Navigator or System Builder Projectsview.

January 31, 2005 Chapter 6 � Building OS and Flash Images 181

Page 207: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 208: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 7

Developing Photon Applications

In this chapter. . .What is PhAB? 185Using PhAB 187Starting Photon applications 190

January 31, 2005 Chapter 7 � Developing Photon Applications 183

Page 209: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 210: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. What is PhAB?

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Use the PhAB visual design tool to develop Photon apps.

What is PhAB?The Photon microGUI includes a powerful development tool calledPhAB(Photon Application Builder), a visual design tool thatgenerates the underlying C/C++ code to implement your program’sUI.

With PhAB, you can dramatically reduce the amount of programmingrequired to build a Photon application. You can save time not only inwriting the UI portion of your code, but also in debugging and testing.PhAB helps you get your applications to market sooner and withmore professional results.

PhAB lets you rapidly prototype your applications. You simply selectwidgets, arrange them as you like, specify their behavior, and interactwith them as you design your interface.

PhAB’s opening screen looks like this:

January 31, 2005 Chapter 7 � Developing Photon Applications 185

Page 211: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

What is PhAB? 2005, QNX Software Systems Ltd.

PhAB and the IDEThe IDE frequently runs command-line tools such asgdb andmkefs“behind the scenes,” but PhAB and the IDE are separate applications;each runs in its own window. You can create files, generate codesnippets, edit callbacks, test your UI components, etc. in PhAB, whileyou continue to use the IDE to manage your project as well as debugyour code, run diagnostics, etc.

PhAB was originally designed to run under the Photon microGUI ona QNX Neutrino host, but thephindows (“Photon in Windows”)utility lets you run PhAB on a Windows host as well. The IDE letsyou see, debug, and interact with your target Photon application rightfrom your host machine as if you were sitting in front of your targetmachine.

186 Chapter 7 � Developing Photon Applications January 31, 2005

Page 212: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using PhAB

Using PhABIn most respects, using PhAB inside the IDE is the same as runningPhAB as a standalone application.

For a full description of PhAB’s functionality, see the PhotonProgrammer’s Guide.

Creating a QNX Photon Appbuilder projectIn order to use PhAB with the IDE, you must create aQNX PhotonAppbuilder project to contain your code. This type of projectcontains tags and other information that let you run PhAB fromwithin the IDE.

To create a PhAB Project:

1 From the workbench menu, selectFile→New→Project. . . .

2 In the left pane, selectQNX.

3 In the right pane, selectPhoton Appbuilder Project.

4 Click Next.

5 Name your project.

6 Ensure thatUse Default Location is checked. Don’t use adifferent location.

7 Click Next.

8 Select your target architecture.

If you wish to set any other options for this project, click theremaining tabs and fill in the fields. For details on the tabs in thiswizard, see “New C/C++ Project wizard tabs” in the CommonWizards Reference chapter.

January 31, 2005 Chapter 7 � Developing Photon Applications 187

Page 213: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Using PhAB 2005, QNX Software Systems Ltd.

9 Click Finish.

The IDE creates your project, then launches PhAB. (InWindows, the IDE also creates aConsole for PhAB window.)

Closing PhABTo end a PhAB session:

➤ From PhAB’s main menu, selectFile→Exit.

In Windows, don’t end a PhAB session by clicking theClose buttonin the top-right corner of the PhAB window; clicking this buttoncloses thephindows utility session without letting PhAB itself shutdown properly. Subsequent attempts to restart PhAB may fail.

To recover from improperly closing PhAB:

1 Close theConsole for PhAB window.

2 Reopen your QNX Photon Appbuilder project.

Reopening PhABTo reopen your QNX Photon Appbuilder project:

➤ Open theProject menu and clickOpen Appbuilder:

188 Chapter 7 � Developing Photon Applications January 31, 2005

Page 214: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Using PhAB

Editing codeYou can edit the code in your QNX Photon Appbuilder project usingboth PhAB and the IDE. Using PhAB, you can control the widgetsand the overall layout of your program; using either PhAB or the IDE,you can edit the code that PhAB generates and specify the behavior ofyour 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 Appbuilderproject.

2 Click theOpen Appbuilder button in the toolbar ( ). PhABstarts, then opens your project.

If for some reason theOpen Appbuilder button isn’t in the C/C++Perspective’s toolbar:

1 From the main menu, selectWindow→CustomizePerspective.

2 In the left pane, selectOther→Photon Appbuilder Actions.

3 CheckPhoton Appbuilder Actions.

4 Click OK. TheOpen Appbuilder button ( ) appears in thetoolbar.

To use the IDE to edit the code in a QNX Photon Appbuilder project:

➤ In theC/C++ Projects view, double-click the file you want toedit. 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 selectRefresh.

January 31, 2005 Chapter 7 � Developing Photon Applications 189

Page 215: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Starting Photon applications 2005, QNX Software Systems Ltd.

Editing files using two applications can increase the risk ofaccidentally overwriting your changes. To minimize this risk, closethe file in one application before editing the file in the other.

Building a QNX Photon Appbuilder projectYou build a QNX Photon Appbuilder project in exactly the same wayas 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 PhotonAppbuilder project and selectBuild. The IDE builds yourproject.

Starting Photon applicationsYou can connect to a Photon session from a Windows or QNXNeutrino host machine and run your Photon program as if you weresitting in front of the target machine. Photon appears in aphindows

window on your Windows host or in aphditto window on yourQNX Neutrino host.

The remote Photon session runs independently of your host. Forexample, the clipboards don’t interact, and you can’t drag and dropfiles between the two machines. Thephindows andphdittoutilities transmit your mouse and keyboard input to Photon anddisplay the resulting state of your Photon session as a bitmap on yourhost machine.

Before you run a remote Photon session on a Windows host, you mustfirst prepare your target machine. (For details, see the “Connectingwith Phindows” section in the Preparing Your Target chapter.)

To start a remote Photon session:

190 Chapter 7 � Developing Photon Applications January 31, 2005

Page 216: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Starting Photon applications

➤ In the Target Navigator view, right-click a target and selectLaunch Remote Photon.

Photon appears in a Phindows window.

You can start a Photon application you created in PhAB in exactly thesame way that you launch any other program in the IDE. By default,the program opens in the target machine’s main Photon session. (Formore on launching, see the Launch Configurations Reference chapterin 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. aterminal from the shelf).

2 In the command window, enter:echo $PHOTON

The target returns the session, such as/dev/ph1470499. Thenumber afterph is the process ID (PID).

3 In the IDE, edit the launch configuration for your QNX PhotonAppbuilder project.

4 Select theArguments tab.

5 In theC/C++ Program Arguments field, enter-s followed bythe value of$PHOTON. For example, enter-s/dev/ph1470499.

6 Click Apply, thenRun or Debug. Your remote Photonprogram opens in thephindows or phditto window on yourhost machine.

If you close and reopen a remote Photon session, you must updateyour launch configuration to reflect the new PID of the new session.

January 31, 2005 Chapter 7 � Developing Photon Applications 191

Page 217: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 218: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 8

Profiling an Application

In this chapter. . .Introducing the Application Profiler 195Profiling your programs 197Controlling your profiling sessions 206Understanding your profiling data 208

January 31, 2005 Chapter 8 � Profiling an Application 193

Page 219: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 220: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the Application Profiler

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter shows you how to use the application profiler.

Introducing the Application ProfilerThe QNX Application Profiler lets you examine the overallperformance of programs, no matter how large or complex, withoutfollowing the source one line at a time. Whereas a debugger helps youfind errors in your code, the Application Profiler helps you pinpoint“sluggish” areas of your code that could run more efficiently.

January 31, 2005 Chapter 8 � Profiling an Application 195

Page 221: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the Application Profiler 2005, QNX Software Systems Ltd.

QNX Application Profiler perspective.

Types of profilingThe Application Profiler lets you perform:

� statistical profiling

� instrumented profiling

� postmortem profiling (on standardgmon.out files).

Statistical profiling

The Application Profiler takes “snapshots” of your program’sexecution position every millisecond and records the current addressbeing executed. By sampling the execution position at regularintervals, the tool quickly builds a summary of where the system isspending its time in your code.

196 Chapter 8 � Profiling an Application January 31, 2005

Page 222: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Profiling your programs

With statistical profiling, you don’t need to use instrumentation,change your code, or do any special compilation. The tool profilesyour programs nonintrusively, so it doesn’t bias the information it’scollecting.

Note, however, that the results are subject to statistical inaccuracybecause the tool works by sampling. Therefore, thelongera programruns, the more accurate the results.

Instrumented profiling

If you build your executables with profiling enabled, the ApplicationProfiler can providecall-pair information (i.e. which functions calledwhich). When you build a program with profiling enabled, thecompiler inserts snippets of code into your functions in order to reportthe addresses of the called and calling functions. As your programruns, the tool produces an exact count for every call pair.

Postmortem profiling

The IDE lets you gather profiling information into agmon.out fileand examine its contents with the Application Profiler. The tool givesyou all the information you’d get from the traditionalgprof tool, butin graphical form. You can examinegmon.out files created by yourprograms, whether you built them using the IDE or theqcc -p

command. For more on thegprof utility, go towww.gnu.org; forqcc, see theUtilities Reference.

Postmortem profiling files give you the same information asinstrumented profiling.

Profiling your programsWhether you plan to do your profiling in real time or postmortem(using agmon.out file), you should build your programs withprofiling enabled before you start a profiling session.

This section includes these topics

� Building a program for profiling

January 31, 2005 Chapter 8 � Profiling an Application 197

Page 223: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Profiling your programs 2005, QNX Software Systems Ltd.

� Running and profiling a process

� Profiling a running process

� Postmortem profiling

If you already have agmon.out file, you’re ready to start apostmortem profiling session.

Building a program for profilingAlthough you can profile any program, you’ll get the most usefulresults by profiling executables built for debugging and profiling. Thedebug information lets the IDE correlate executable code andindividual lines of source; the profiling information reports call-pairdata.

This tables shows the application profiling features that are possiblewith the various build variants:

Feature Release version Debug version Release v. &profiling

Debug v. &profiling

Call pairs No No Yes Yes

Statisticalsampling

Limited Limited Yes Yes

Lineprofiling

No Limited No Yes

Postmortemprofiling

No No Yes Yes

To build executables with debug information and profiling enabled:

1 In the C/C++ Projects view, right-click your project and selectProperties.

2 In the left pane, selectQNX C/C++ Project.

198 Chapter 8 � Profiling an Application January 31, 2005

Page 224: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Profiling your programs

3 In the right pane, select theOptions tab.

4 Check theBuild with Profiling option:

5 Select theBuild Variants tab and check theDebug variant foryour targets.

The Application Profiler uses the information in the debuggableexecutables to correlate lines of code in your executable and thesource code. To maximize the information you get while profiling, useexecutables with debug information for both running and debugging.

6 Click Apply.

7 Click OK.

8 Rebuild your project.

January 31, 2005 Chapter 8 � Profiling an Application 199

Page 225: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Profiling your programs 2005, 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 processTo run and profile a process:

1 Create aQNX Application launch configuration for anexecutable with debug information as you normally would, butdon’t click OK. You may choose either aRun or aDebugsession.

2 On the launcher, click theTools tab.

3 Click Add/Delete Tool. TheSelect tools to support dialogappears.

4 Enable theQNX Application Profiler tool.

5 Click OK.

6 On the launcher, click theApplication Profiler tab:

200 Chapter 8 � Profiling an Application January 31, 2005

Page 226: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Profiling your programs

7 Fill in these fields:

Profiler update interval (ms)

You use this option to control how often the Profiler pollsfor data. A low setting causes continuous (but low)network traffic and fast refresh rates. A high settingcauses larger network data bursts and may cause highermemory usage on the target because the target mustbuffer the data. The default setting of 1000 shouldsuffice.

Shared library paths

The IDE doesn’t know the location of your shared librarypaths, so you must specify the directory containing anylibraries that you wish to profile. For a list of the librarypaths that are automatically included in the search path,see the appendix Where Files Are Stored.

January 31, 2005 Chapter 8 � Profiling an Application 201

Page 227: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Profiling your programs 2005, QNX Software Systems Ltd.

Switch to this tool’s perspective on launch.

Check this option to automatically switch to theApplication Profiler perspective when this launchconfiguration is used.

8 Click Apply.

9 If you want the IDE to automatically change to the ApplicationProfiler perspective when you run or debug, select theCommon tab, and set theRun mode andDebug modedropdowns toQNX Application Profiler.

10 Click Run or Debug. The IDE starts your program and profilesit.

Profiling a running processTo profile a process that’s already running on your target:

1 In theLaunch Configurations dialog for the program youwant to profile, click theDebugger tab.

2 Enable theAttach to running process setting.

3 Click theTools tab.

4 Click Add/Delete Tool. . . . TheTools selection dialog appears.

5 Enable theApplication Profiler tool.

6 Click OK.

7 On the launcher, click theApplication Profiler tab:

202 Chapter 8 � Profiling an Application January 31, 2005

Page 228: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Profiling your programs

8 Fill in these fields:

Profiler update interval (ms)

You use this option to control how often the Profiler pollsfor data. A low setting causes continuous (but low)network traffic and fast refresh rates. A high settingcauses larger network data bursts and may cause highermemory usage on the target because the target mustbuffer the data. The default setting of 1000 shouldsuffice.

Shared library paths

The IDE doesn’t know the location of your shared librarypaths, so you must specify the directory containing anylibraries that you wish to profile. For a list of the librarypaths that are automatically included in the search path,see the appendix Where Files Are Stored.

January 31, 2005 Chapter 8 � Profiling an Application 203

Page 229: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Profiling your programs 2005, QNX Software Systems Ltd.

Switch to this tool’s perspective on launch.

Check this to automatically switch to the ApplicationProfiler perspective when using this launcher.

9 Click Apply, then clickRun.

10 You’ll now see a list of processes running on your target. Selectthe one you want to profile.

Postmortem profilingThe IDE lets you profile your program after it terminates, using thetraditionalgmon.out file. Postmortem profiling doesn’t provide asmuch information as profiling a running process:

� Multithreaded processes aren’t supported. Thus, the ThreadProcessor Usage view always shows the totals of all yourprogram’s threads combined as one thread.

� Call pair information, shared libraries and DLLs aren’t shown.

Profiling agmon.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 ofyour choice using thePROFDIR environment variable.

To gather profiling information:

1 Create a launch configuration for adebuggableexecutable asyou normally would, but don’t clickRun or Debug.

204 Chapter 8 � Profiling an Application January 31, 2005

Page 230: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Profiling your programs

You must have the QNX Application Profiler tooldisabledin yourlaunch configuration.

2 Select theEnvironment tab.

3 Click New.

4 In theName field, typePROFDIR.

5 In theValue field, enter a valid path to a directory on yourtarget machine.

6 Click OK.

7 Run your program. When your program exits successfully, itcreates a new file in the directory you specified. The filenameformat ispid.projectName(e.g.3047466.helloworld g).This is thegmon.out profiler data file.

Importing a gmon.out file

You can bring into your workspace existinggmon.out files that youcreated outside the IDE.

To import agmon.out file into your workspace:

1 Open the File System Navigator view (Window→ShowView→Other. . . →QNX Targets→File System Navigator.

2 In the File System Navigator view, right-click your file andselectCopy to. . . →Workspace. TheSelect target folderdialog appears.

3 Select the project related to your program.

4 Click OK.

5 In the C/C++ Projects view, right-click the file you importedinto your workspace and selectRename.

6 Entergmon.out (or gmon.out.n, wheren is any numericcharacter). The IDE renames your file.

January 31, 2005 Chapter 8 � Profiling an Application 205

Page 231: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your profiling sessions 2005, QNX Software Systems Ltd.

Starting a postmortem profiling session

To start the postmortem profiling session:

1 In theC/C++ Projects view, right-click yourgmon.out fileand selectOpen in QNX Application Profiler. TheProgramSelection dialog appears.

2 Select the program that generated thegmon.out file.

3 Click OK. You can now profile your program in the QNXApplication Profiler perspective.

Controlling your profiling sessionsTheApplication Profiler view (Window→ShowView→Other. . . →QNX Application Profiler→ApplicationProfiler) lets you control multiple profiling sessions simultaneously.You can:

� terminate applications

� choose the executable or library to show profiling information forin theSampling Information, Call Information, andThreadProcessor Usage views.

206 Chapter 8 � Profiling an Application January 31, 2005

Page 232: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your profiling sessions

TheApplication Profiler view displays the following as ahierarchical tree for each profiling session:

Session item Description Possible icons

Launch instance Launch configuration name andlaunch type (e.g.prof201[C/C++ QNX QConn (IP)])

Profiled program Project name and start time(e.g.prof201 onlocalhost pid 4468773(3/4/03 12:41 PM))

Application Profiler instance Program name and targetcomputer URL (e.g.Application ProfilerAttached to: prof201<4468773> on10.12.3.200)

Executable

Shared libraries

DLLs

Unknown

To choose which executable or library to display information for inthe QNX Application Profiler perspective:

➤ In theApplication 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:

January 31, 2005 Chapter 8 � Profiling an Application 207

Page 233: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Understanding your profiling data 2005, QNX Software Systems Ltd.

1 In theApplication Profiler view, select a launch configuration.

2 Click theTerminate button ( ) in the view’s title bar.

To clear old launch listings from this view, click theRemove All

Terminated Launches button ( ).

Understanding your profiling dataFor each item you select in theApplication Profiler view, other theviews within the QNX Application Profiler perspective display theprofiling 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 lineThe Application Profiler Editor lets you see the amount of time yourprogram 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 theApplication Profiler view, select your program by

selecting an Application Profiler instance ( ) or an executable

( ).

3 In theSampling Information or Call Information view,double-click a function that you have the source for. The IDE

208 Chapter 8 � Profiling an Application January 31, 2005

Page 234: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Understanding your profiling data

opens the corresponding source file in the Application ProfilerEditor:

You may get incorrect profiling information if you change your sourceafter compiling because the Application Profiler Editor relies on theline 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 theprogram’s total CPU time. The green bar appears on thefirst line of executable code in the function.

Orange CPU time spent on a line of code as a percentage of theprogram’s total CPU time. Within a function, the lengthsof 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 thefunction’s total CPU time. Within a function, the sum ofall the blue bars spans the width of the editor’s margin.

January 31, 2005 Chapter 8 � Profiling an Application 209

Page 235: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Understanding your profiling data 2005, QNX Software Systems Ltd.

To view quantitative profiling values:

➤ In the Application Profiler Editor, hover the pointer over acolored bar. The CPU usage appears, displayed as a percentageand a time:

Usage by functionThe Sampling Information view shows a flat profile of the item that’scurrently selected in the Application Profiler view. You can examineprofiling information for programs, shared libraries, and DLLs:

The view lists all the functions called in the selected item. For eachfunction, this view displays:

� the total CPU time spent in the function

� the CPU time spent in the function since you last reset thecounters.

If you select a program compiled for debugging, the view alsodisplays:

210 Chapter 8 � Profiling an Application January 31, 2005

Page 236: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Understanding your profiling data

� the number of times the function has been called

� the average CPU time per call.

To see your function usage:

1 Launch a profile session for a debuggable (i.e.g) executable.

2 In theApplication Profiler view, select your program by

selecting an Application Profiler instance ( ) or anysubordinate line. The Sampling Information view displaysprofiling information for your selection.

To reset the counters in theTime since last reset(s) column:

➤ Click theReset Sample counts button ( ) in the SamplingInformation view’s title bar.

Usage by threadTheThread Processor Usage view displays the CPU usage (inseconds and as a percentage of your program’s total time) for eachthread of the item that’s currently selected in the Application Profilerview:

You can use this information to:

� identify which threads are the most and least active

January 31, 2005 Chapter 8 � Profiling an Application 211

Page 237: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Understanding your profiling data 2005, QNX Software Systems Ltd.

� determine the appropriate size of your application’s thread pool.(If there are idle threads, you might want to reduce the size of thepool.)

To see your thread usage:

1 Launch a profile session for a debuggable (i.e.g) executable.

2 In theApplication Profiler view, select your program by

selecting an Application Profiler instance ( ) or anysubordinate line. TheThread Processor Usage view displaysprofiling information for your selection.

Call countsFor the item that’s currently selected in the Application Profiler view,theCall 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 theApplication Profiler view, select your program by

selecting an Application Profiler instance ( ) or anysubordinate line. TheCall Information view displays profilinginformation for your selection:

212 Chapter 8 � Profiling an Application January 31, 2005

Page 238: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Understanding your profiling data

Call Pairs pane

The Call Pairs pane shows you where every function was called fromas well as the call-pair count, i.e. the number of times each functioncalled every other function.

Call Graph pane

TheCall Graph pane shows you a graph of the function calls. Yourselected function appears in the middle, in blue. On the left, in yellow,are all the functions that called your function. On the right, also inyellow, are all the functions that your function called.

To see the calls to and from a function:

➤ Click a function in:

� theFunction column in theCall Pairs pane

or:

� theCall Graph pane.

January 31, 2005 Chapter 8 � Profiling an Application 213

Page 239: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Understanding your profiling data 2005, QNX Software Systems Ltd.

You can display the call graph only for functions that were compiledwith profiling enabled.

Call Pair Details pane

TheCall Pair Details pane shows the information about the functionyou’ve selected in the Call Graph pane. TheCaller andCall Countcolumns show the number of times each function called the functionyou’ve selected.

TheCalled andCalled Count columns show the number of timesyour selected function called other functions. This pane shows onlythe functions that were compiled with profiling. For example, itdoesn’t show calls to functions, such asprintf(), in the C library.

214 Chapter 8 � Profiling an Application January 31, 2005

Page 240: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 9

Using Code Coverage

In this chapter. . .Code coverage in the IDE 217Enabling code coverage 220Controlling your session 224Examining data line-by-line 226Examining your coverage report 227Seeing your coverage at a glance229

January 31, 2005 Chapter 9 � Using Code Coverage 215

Page 241: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 242: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Code coverage in the IDE

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Use the Code Coverage tool to help test your code.

Code coverage in the IDECode coverage is a way to measure how much code a particularprocess has executed during a test or benchmark. Usingcode-coverage analysis, you can then create additional test cases toincrease coverage and determine a quantitative measure of codecoverage, which is anindirect measure of the quality of your software(or better, a direct measure of the quality of your tests).

Types of code coverageSeveral types of metrics are commonly used in commercialcode-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 toolusually provides a combination of types.

The coverage tool in the IDE is a visual font end to thegcov metricsproduced by thegcc compiler. These coverage metrics are essentiallybasicblock coverageandbranch coverage.

January 31, 2005 Chapter 9 � Using Code Coverage 217

Page 243: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Code coverage in the IDE 2005, QNX Software Systems Ltd.

The IDE presents these metrics as line coverage, showing which linesare fully covered, partially covered, and not covered at all. The IDEalso presents percentages of coverage in terms of the actual codecovered (i.e. not just lines).

Block coverage

Block coverage, sometimes known as line coverage, describeswhether a block of code, defined as not having any branch pointwithin (i.e. the path of execution will enter from the beginning andexit 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 orfunction. The tool also uses this information to show line coverage byanalyzing the blocks on each line and determining the level ofcoverage of each.

Branch coverage

Branch coverage can track the path of execution taken between blocksof code. Although this metric is produced by thegcc compiler,currently the IDE doesn’t provide this information.

How the coverage tool worksThe IDE’s code coverage tool works in conjunction with the compiler(gcc), the QNX C library (libc), and optionally the remote targetagent (qconn). When code coverage is enabled for an application, thecompiler will instrument the code so that at run time, each branchexecution to a basic block is counted. During the build, the IDEproduces data files in order to recreate the program’s flow graph andto provide line locations of each block.

218 Chapter 9 � Using Code Coverage January 31, 2005

Page 244: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Code coverage in the IDE

CAUTION: Since the IDE creates secondary data files at compilationtime, you must be careful when building your programs in amulti-targeted build environment such as QNX Neutrino.

You must either:

� ensure that the last compiled binary is the one you’re collectingcoverage data on,

or:

� simply enable onlyonearchitecture and debug/release variant.

Note also that the compiler’s optimizations could produce unexpectedresults, so you should perform coverage tests on a non-optimized,debug-enabled build.

!

When you build a program with theBuild with Code Coverage buildoption enabled and then launch it using aC/C++ QNX Qconn (IP)launch configuration, the instrumented code linked into the processwill connect toqconn, allowing the coverage data to be read from theprocess’s data space.

But if you launch a coverage-built process with coveragedisabledinthe launch configuration, this will cause the process to write thecoverage information to a data file (.da) at run time, rather than readit from the process’s data space.

You should use data files only if you’re running the local launchconfiguration on a QNX Neutrino self-hosted development system.Note that the data will need to be imported into the IDE codecoverage tool.

Once a coverage session has begun, you can immediately view thedata. The QNX Code Coverage perspective contains aCodeCoverage Sessions view that lists previous as well as currently activesessions. You can explore each session and browse the correspondingsource files that have received coverage data.

January 31, 2005 Chapter 9 � Using Code Coverage 219

Page 245: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Enabling code coverage 2005, QNX Software Systems Ltd.

Enabling code coverageTo build executables with code coverage enabled:

1 In the C/C++ Projects view, right-click your project and selectProperties. The properties dialog for your project appears.

2 In the left pane, selectQNX C/C++ Project.

3 In theBuild Options pane, checkBuild with Code Coverage.

4 In theBuild Variants tab, check only one build variant.

If the IDE is set to build more than one variant, an error is displayedand theOK button is disabled.

5 Click OK.

6 In the C/C++ Projects view, right-click your project and selectRebuild.

Enabling code coverage for non-QNX projectsIf you’re using your own custom build environment, rather than QNXmakefiles, you’ll have to manually pass the coverage option to thecompiler.

To enable code coverage for non-QNX projects

1 Compile using these options togcc:-fprofile-arcs -ftest-coverage

If your usingqcc, compile with:-Wc,-fprofile-arcs -Wc,-ftest-coverage

2 Link using the-p option.

For example, your makefile might look something like this:

objects= Profile.o main.o

CFLAGS= -g -Wc,-ftest-coverage -Wc,-fprofile-arcs -I. -I../proflibCPP-std

220 Chapter 9 � Using Code Coverage January 31, 2005

Page 246: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Enabling code coverage

all: profileCPP-std

clean:-rm $(objects) profileCPP-std *.bb *.bbg

$(objects): %.o: %.cppQCC -c $(CFLAGS) $< -o $@

profileCPP-std: $(objects)

$(CC) -Vgcc ntox86 $ˆ -g -p -o $@ -L../proflibCPP-std -lProfLib -lcpp

Starting a coverage-enabled programTo start a program and measure the code coverage:

1 Create a C/C++ QNX QConn (IP) launch configuration as younormally would, but don’t clickOK yet.

2 On the launcher, click theTools tab.

3 Click Add/Delete Tool. The Tools selection dialog appears.

4 Check the Code Coverage tool:

January 31, 2005 Chapter 9 � Using Code Coverage 221

Page 247: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Enabling code coverage 2005, QNX Software Systems Ltd.

5 Click OK.

6 Click the Code Coverage tab, and fill in these fields:

222 Chapter 9 � Using Code Coverage January 31, 2005

Page 248: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Enabling code coverage

Enable GCC 3 Coverage metrics collection.

Check this if your application was compiledwith gcc 3.3.1 or later. The default is tocollect code coverage information fromapplications compiled withgcc 2.95.3.

Scan interval This option sets how often the Code Coveragetool polls for data. A low setting causescontinuous (but low) network traffic. A highsetting causes larger network data bursts andmay cause higher memory usage on the targetbecause the target must buffer the data. Thedefault setting of5 s should suffice.

Referenced projects

Check any project in this list you wish togather code-coverage data for. Projects mustbe built with coverage enabled.

January 31, 2005 Chapter 9 � Using Code Coverage 223

Page 249: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your session 2005, QNX Software Systems Ltd.

Comments Your notes about the session, for your ownpersonal use. The comments appear at the topof the generated reports.

7 CheckSwitch to this tool’s perspective on launch if you wantto automatically go to the Code Coverage perspective when yourun or debug.

8 Click Apply.

9 Click Run or Debug.

Controlling your sessionThe Code Coverage Sessions view lets you control and displaymultiple code-coverage sessions:

The view displays the following as a hierarchical tree for each session:

Session item Description Possible icons

Code coverage session Launch configuration name,coverage tool, and start time(e.g.ccov102 factor [GCCCode Coverage] (7/2/032:48 PM))

continued. . .

224 Chapter 9 � Using Code Coverage January 31, 2005

Page 250: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your session

Session item Description Possible icons

Project Project name and amount ofcoverage (e.g.ccov102 factor [ 86.67%])

File Filename and amount ofcoverage (e.g.ccov102 factor.c [86.67% ])

Function Function name and amount ofcoverage (e.g.main [ 100%])

The IDE uses several icons in this view:

Icon Meaning

No coverage

Partial coverage

Full (100%) coverage

Missing or out-of-date source file

The IDE also adds a coverage markup icon () to indicate sourcemarkup in the editor. (See the “Examining data line-by-line” section,below.)

To reduce the size of the hierarchical tree, click theCollapse All () button.

To combine several sessions:

1 In the Code Coverage Sessions view, select the sessions youwant to combine.

January 31, 2005 Chapter 9 � Using Code Coverage 225

Page 251: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining data line-by-line 2005, QNX Software Systems Ltd.

2 Right-click your selections and selectCombine/CopySessions. The IDE prompts you for a session name and createsa combined session.

Examining data line-by-lineThe IDE can display the line-by-line coverage information for yoursource code. In the left margin, the editor displays a “covered” icon

( ) beside each line of source. In the right margin, the editordisplays a summary of the coverage by showing green sections forfully-covered code, yellow for partial coverage, and red for nocoverage:

To open a file in the QNX Code Coverage perspective:

➤ In the Code Coverage Sessions view, expand a session anddouble-click a file or function.

To display coverage information from a particular session:

226 Chapter 9 � Using Code Coverage January 31, 2005

Page 252: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Examining your coverage report

➤ In the Code Coverage Sessions view, right-click a session andselectCoverage Markup, then select one of the following:

� Mark lines not covered

� Mark lines partially covered

� Mark lines fully covered

The selected icon appears beside the corresponding source inthe C/C++ Editor. In the Code Coverage Sessions view, acoverage 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, selectQNX→Code Coverage.

3 In the right pane, check the desired markers in theCoveragemarkup when file is opened field.

4 Click OK. The next time you open a file, the markers appearautomatically. To add markers from another session, add themmanually, 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 reportThe Code Coverage Report view provides a summary (in XML) ofyour session. The view lets you drill down into your project and seethe coverage for individual files and functions:

January 31, 2005 Chapter 9 � Using Code Coverage 227

Page 253: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining your coverage report 2005, QNX Software Systems Ltd.

To generate a report, simply right-click a coverage session and selectGenerate Report.

By default, the IDE displays reports in the Code Coverage Reportview, but you can also have the IDE display reports in an external

228 Chapter 9 � Using Code Coverage January 31, 2005

Page 254: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Seeing your coverage at a glance

browser. Using an external browser lets you compare several reportssimultaneously.

To toggle between viewing reports in the Code Coverage Report viewand in an external browser:

1 Open the Preferences dialog (Window→Preferences).

2 In the left pane, selectQNX→Code Coverage.

3 In the right pane, check/uncheck theView reports in externalbrowser item.

4 Click OK.

To print or save a report:

➤ In the Code Coverage Report view’s title bar, click one of thefollowing:

� Print button ( )

� Save entire report button ( ).

You can also refresh the report:

➤ In the Code Coverage Report view’s title bar, click theRefresh

button ( ).

Seeing your coverage at a glanceThe Properties view displays a summary of the code coverage for aproject, file, or function you’ve selected in the Code CoverageSessions view.

The Properties view tells you how many lines were covered, notcovered, and so on:

January 31, 2005 Chapter 9 � Using Code Coverage 229

Page 255: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Seeing your coverage at a glance 2005, QNX Software Systems Ltd.

230 Chapter 9 � Using Code Coverage January 31, 2005

Page 256: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 10

Finding Memory Errors

In this chapter. . .Introduction 233Analyzing your program 244Manually launching a program for memory tracing246Tracing memory events 249Controlling your memory analysis session253Examining your target’s memory 254

January 31, 2005 Chapter 10 � Finding Memory Errors 231

Page 257: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 258: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Use the QNX Memory Analysis perspective to solve memory problems.

IntroductionHave you ever had a customer say, “The program was working finefor days, then it just crashed”? If so, chances are good that yourprogram had a memory error — somewhere.

Debugging memory errors can be frustrating; by the time a problemappears, often by crashing your program, the corruption may alreadybe widespread, making the source of the problem difficult to trace.

The QNX Memory Analysis perspective shows you how yourprogram uses memory and can help ensure that your program won’tcause problems. The perspective helps you quickly pinpoint memoryerrors in your development and testing environments before yourcustomers get your product.

January 31, 2005 Chapter 10 � Finding Memory Errors 233

Page 259: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

The QNX Memory Analysis perspective may produce incorrectresults when more than one IDE is communicating with the sametarget system. To use this perspective, make sure only one IDE isconnected to the target system.

Memory management in QNX NeutrinoBy design, the architecture of the OS helps ensure that faults,including memory errors, are confined to the program that causedthem. Programs are less likely to cause a cascade of faults becauseprocesses are isolated from each other and from the microkernel.Even device drivers behave like regular debuggable processes:

User space

Programs

Device drivers

Filesystem

TCP/IPstack

Microkernel

This robust architecture ensures that crashing one program has littleor no effect on other programs throughout the system. When aprogram faults, you can be sure that the error is restricted to thatprocess’s operation.

Neutrino’s full memory protection means that almost all the memoryaddresses your program encounters arevirtual addresses. The processmanager maps your program’s virtual memory addresses to the actualphysical memory; memory that is contiguous in your program may betransparently split up in your system’s physical memory:

234 Chapter 10 � Finding Memory Errors January 31, 2005

Page 260: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

Virtual memory

1

2

3

Physical memory

1

2

3

Mapping

The process manager allocates memory in small pages (typically 4Keach). To determine the size for your system, use thesysconf( SC PAGESIZE) function.

As you’ll see when you use the memory-analysis tools, the IDEcategorizes your program’s virtual address space as follows:

� program

� stack

� shared library

� objects

� heap

January 31, 2005 Chapter 10 � Finding Memory Errors 235

Page 261: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

Reserved

Shared libraries

Objects

Heap

Program

Stack

Stack

Process base address

0xFFFFFFFF

0

Guard page

Growth

Growth

Growth

Growth

Process memory layout on an x86.

Program memory

Program memory holds the executable contents of your program. Thecode section contains the read-only execution instructions (i.e. youractual compiled code); the data section contains all the values of theglobal and static variables used during your program’s lifetime:

236 Chapter 10 � Finding Memory Errors January 31, 2005

Page 262: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

Program'svirtual memory

Programcode

Physical memoryMappingMyProgram (executable)

int min=10;

int max = 50;

int main () {

}

Programdata

&min

&max

Stack memory

Stack memory holds the local variables and parameters yourprogram’s functions use. Each process in Neutrino contains at leastthe main thread; each of the process’s threads has an associated stack.When the program creates a new thread, the program can eitherallocate the stack and pass it into the thread-creation call, or let thesystem allocate a default stack size and address:

Thread 1stack

Thread 2stack

Thread 3stack

Thread 4stack

Growth

Program's virtualmemory

When your program runs, the process manager reserves the full stackin virtual memory, but not in physical memory. Instead, the processmanager requests additional blocks of physical memory only whenyour program actually needs more stack memory. As one functioncalls another, the state of the calling function is pushed onto the stack.

January 31, 2005 Chapter 10 � Finding Memory Errors 237

Page 263: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

When the function returns, the local variables and parameters arepopped off the stack.

The used portion of the stack holds your thread’s state informationand takes up physical memory. The unused portion of the stack isinitially allocated in virtual address space, but not physical memory:

Program's virtualmemory Physical memoryMapping

Allocated

Guard page(read-only)

A typicalthread's

stack

Used

Unused

Legend:

Unallocated

At the end of each virtual stack is aguard pagethat the microkerneluses to detect stack overflows. If your program writes to an addresswithin the guard page, the microkernel detects the error and sends theprocess aSIGSEGVsignal.

As with other types of memory, the stack memory appears to becontiguous in virtual process memory, but not necessarily so inphysical memory.

Shared-library memory

Shared-library memory stores the libraries you require for yourprocess. Like program memory, library memory consists of both codeand data sections. In the case of shared libraries, all the processes mapto the same physical location for the code section and to uniquelocations for the data section:

238 Chapter 10 � Finding Memory Errors January 31, 2005

Page 264: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

Physical memoryMapping

CommonLibrary.so

int loops = 0;

Counterfunction() {

for (loops= ; ;) {

...

}

}

Program 1'svirtual memory

Program 1library code

Program 1library data

&loops

Program 2'svirtual memory

Program 2library code

Program 2library data

&loops

Librarycode

Data

Data

Object memory

Object memory represents the areas that map into a program’s virtualmemory space, but this memory may be associated with a physicaldevice. For example, the graphics driver may map the video card’smemory to an area of the program’s address space:

Graphics driver'svirtual memory

Objectmemory

Physical memoryMapping

Videomemory

Videoscreen

Videocard

Heap memory

Heap memory represents the dynamic memory used by programs atruntime. Typically, processes allocate this memory using themalloc(),realloc(), andfree()functions.These calls ultimately rely on themmap()function to reserve memory that themalloc librarydistributes.

The process manager usually allocates memory in 4K blocks, butallocations are typically much smaller. Since it would be wasteful touse 4K of physical memory when your program wants only 17 bytes,themalloc library manages the heap. The library dispenses the

January 31, 2005 Chapter 10 � Finding Memory Errors 239

Page 265: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

paged memory in smaller chunks and keeps track of the allocated andunused portions of the page:

1

2

3

4

5

6

7

8

9malloc( ... )

malloc library

Program's virtualmemory

Page block

Usedblocks: 1, 2, 3,

Freeblocks: 4, 7, 9

5, 6, 8, 7

Legend:

Used

Overhead

Free

Each allocation uses a small amount of fixed overhead to storeinternal data structures. Since there’s a fixed overhead with respect toblock size, the ratio of allocator overhead to data payload will belarger for smaller allocation requests.

When your program uses themalloc()function to request a block ofmemory, themalloc library returns the address of an appropriatelysized block. To maintain constant-time allocations, themalloc

library may break some memory into fixed blocks. For example, thelibrary may return a 20-byte block to fulfill a request for 17 bytes, a1088-byte block for a 1088-byte request, and so on.

When themalloc library receives an allocation request that it can’tmeet with its existing heap, the library requests additional physical

240 Chapter 10 � Finding Memory Errors January 31, 2005

Page 266: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

memory from the process manager. As your program frees memory,the library merges adjacent free blocks to form larger free blockswherever possible. If an entire memory page becomes free as a result,the library returns that page to the system. The heap thus grows andshrinks in 4K increments:

Program's virtualmemory Physical memoryMapping

Growth

What the Memory Analysis perspective can revealThe main system allocator has been instrumented to keep track ofstatistics associated with allocating and freeing memory. This lets thememory statistics module nonintrusively inspect any process’smemory usage.

When you launch your program with the Memory Trace tool, yourprogram uses the debug version of themalloc library(libmalloc g.so). Besides the normal statistics, this library alsotracks the history of every allocation and deallocation, and providescover functions for the string and memory functions (e.g.strcmp(),memcpy(),memmove()). Each cover function validates thecorresponding function’s arguments before using them. For example,if you allocate 16 bytes, then forget the terminating null character andattempt to copy a 16-byte string into the block using thestrcpy()function, the library detects the error.

January 31, 2005 Chapter 10 � Finding Memory Errors 241

Page 267: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

The debug version of themalloc library uses more memory than thenondebug version. When tracing all calls tomalloc()andfree(), thelibrary requires additional CPU overhead to process and store thememory-trace events.

The Memory Analysis perspective can help you pinpoint and solvevarious 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 thenforgets to free it later. Over time, your program consumes morememory than it actually needs.

In its mildest form, a memory leak means that your program usesmore memory than it should. QNX Neutrino keeps track of the exactmemory your program uses, so once your program terminates, thesystem recovers all the memory, including the lost memory.

If your program has a severe leak, or leaks slowly but neverterminates, it could consume all memory, perhaps even causingcertain system services to fail.

These tools in the Memory Analysis perspective can help you find andfix memory leaks:

� Malloc Information view — you can watch your program’s heapusage and see if it increases over time.

� Memory Events view — shows you all the instances where youprogram allocates, reallocates, and frees memory. The view letsyou hide allocations that have a matching call tofree(); theremaining allocations are either still in use or forgotten.

242 Chapter 10 � Finding Memory Errors January 31, 2005

Page 268: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

Memory errors

Memory errors can occur if your program tries to free the samememory twice or uses a stale or invalid pointer. These “silent” errorscan cause surprising, random application crashes. The source of theerror can be extremely difficult to find, because the incorrectoperation could have happened in a different section of code longbefore an innocent operation triggered a crash.

In the event of a such an error, the IDE can stop your program’sexecution and let you see all the allocations that led up to the error.The Memory Events view displays memory events, together with atimestamp and the exact line of source code that generated each event.The view lets you find the prior call that accessed the same memoryaddress, even if your program made the call days earlier.

Stack errors

Stack errors can occur if your program contains functions that aredeeply recursive or use a significant amount of local data. Errors ofthis sort can be difficult to find using conventional testing; althoughyour program seems to work properly during testing, the system couldfail in the field, likely when your system is busiest and is needed themost.

The Memory Information view lets you see how much stack memoryyour program and its threads use. The view can warn you of potentialstack errors.

Inefficient heap usage

Your program can experience problems if it uses the heapinefficiently. Memory-allocation operations are expensive, so yourprogram 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’smemory allocations; if your program has an unusually high turnoverrate, this might mean that the program is allocating and freeing morememory than it should.

January 31, 2005 Chapter 10 � Finding Memory Errors 243

Page 269: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Analyzing your program 2005, QNX Software Systems Ltd.

You may also find that your program uses a surprising amount ofmemory, even though you were careful not to allocate more memorythan you required. Programs that make many small allocations canincur substantial overhead.

The Malloc Information view lets you see the amount of overheadmemory themalloc library uses to manage your program’s heap. Ifthe overhead is substantial, you can review the data structures andalgorithms used by your program, and then make adjustments so thatyour program uses its memory resources more efficiently. The MallocInformation view lets you track your program’s reduction in overallmemory usage.

To learn more about the common causes of memory problems, seeHeap Analysis: Making Memory Errors a Thing of the Past in theQNX NeutrinoProgrammer’s Guide.

Analyzing your programTo extract the most information from your program, you shouldlaunch it with the Memory Trace tool enabled:

1 Create a Run or Debug type of QNX Application launchconfiguration as you normally would, but don’t clickRun orDebug.

2 In the Create, manage, and run configurations dialog, click theTools tab.

3 Click Add/Delete Tool.

4 In theTools Selection dialog, check theMemory Trace tool.

5 Click OK.

6 Click theMemory Trace tab.

7 Configure the Memory Trace settings for your program:

244 Chapter 10 � Finding Memory Errors January 31, 2005

Page 270: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Analyzing your program

Memory Event Action

The action you wish the IDE to take when it detects amemory error. The default is to attach to the process withthe debugger, but the IDE can also ignore the error orcause the program to terminate.

Full memory allocation/deallocation trace

By default, the IDE logs every allocation/deallocationthat the program makes. If you turn this option off, theIDE records only memory errors. If you want to use theAllocation Trace tab in the Memory Events view, makesure this option is on.

Note that full tracing can substantially slow downprograms that allocate and free a lot of memory. It alsogenerates significant traffic on the communicationsmedium.

January 31, 2005 Chapter 10 � Finding Memory Errors 245

Page 271: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Manually launching a program for memory tracing 2005, QNX Software Systems Ltd.

Display console debug output

The preloaded library can display diagnostic messages tothe program’sstderrwhen it encounters an error. If thisoption is on, the information appears in the Console view.

Malloc Library

The name of themalloc library used by the MemoryTrace tool on the target. The default oflibmalloc g.so should suffice.

Memory Device

The device on the target to which all memory-event datais sent. The default of/dev/dbgmem should suffice.

8 If you want the IDE to automatically change to the QNXMemory Analysis perspective when you run or debug, checkSwitch 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 youanalyze your program’s memory.

Manually launching a program for memorytracingYou can manually launch an application on your target without usingthe IDE for the launch, yet still have the application conveymemory-trace information back to your host where you can use theIDE to monitor the target.

To support memory analysis, you preload the debug malloc sharedlibrary (dbgmallog g.so) before the standard C shared library.There’s no need to recompile your application with any additionalspecial options.

246 Chapter 10 � Finding Memory Errors January 31, 2005

Page 272: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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 debuginformation instead of the default STABS+.

Use the-Wc,-gdwarf-2 option toqcc or the-gdwarf-2 option togcc.

To do this in the IDE:

1 Right click a project and selectProperties from the menu.

2 SelectQNX C/C++ Project in the left column.

3 Select theCompiler tab.

4 Add -Wc,-gdwarf-2 to theOther options field.

5 Click OK.

6 Rebuild the project.

The DWARF format is not supported on MIPS targets.

For applications that link statically, you’ll have to manually linkagainst the debug malloc shared library, rather than use theLD PRELOAD mechanism described below. All other settingsshould be equally valid.

Preparing your host and the target agent1 Ensure that the target agent (qconn) is running on your target

system.

2 Prepare the host and target agent to receive memoryinformation.

Since the application isn’t being launched from the IDE, youmust manually start the thread that gathers memoryinformation:

2a Open the Target Navigator (Window→ShowView→Other. . . →QNX Targets).

January 31, 2005 Chapter 10 � Finding Memory Errors 247

Page 273: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Manually launching a program for memory tracing 2005, QNX Software Systems Ltd.

2b Create a new target connection to the embedded system ifrequired (right-click the Target Navigator and selectAddNew Target).

2c Right-click the target and make sureWatch MemoryEvents is checked.

At this point, the IDE has communicated with the target agentand informed it to expect to receive memory-trace data. You’lllikely want to switch to the Memory Analysis Perspective tosee the results of the trace.

3 Launch the application on the target.

The debug malloc library uses environment variables to drive itslogging behavior. You should launch your application with thefollowing variables defined in addition to theLD PRELOADvalue (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 shouldbe set to/dev/dbgmem (a file managed byqconn).

MALLOC TRACE

Indicates where to log the malloc/realloc/free traceinformation. 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 namedmyapp,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 againstlibmalloc g.so

already:MALLOC DEBUG=1 MALLOC EVENTFILE=/dev/dbgmem MALLOC TRACE=/dev/dbgmem myapp

248 Chapter 10 � Finding Memory Errors January 31, 2005

Page 274: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracing memory events

4 Now you can watch the results being gathered in the IDE. Anyerrors and allocation traces captured will be logged into theMemory Analysis view (assuming you have turned onMALLOC DEBUGM andMALLOC TRACE and set themto /dev/dbgmem).

Tracing memory eventsTheMemory Events view categorizes memory errors by target andlaunch configuration:

Error events treeTheError events tree pane displays the following as a hierarchicaltree:

January 31, 2005 Chapter 10 � Finding Memory Errors 249

Page 275: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracing memory events 2005, QNX Software Systems Ltd.

Session item Description Icons

Target The target’s hostname. The value is specifiedin the target’s/etc/hosts file; aroot usercan set this value manually on the target usingthehostname myNewNamecommand (see theUtilities Reference).

Process The process filename and PID (e.g.mem102 g(5222434))

Memory error category Description of the error (e.g.Pointerwithin malloc region, but outsideof malloc data bounds)

Memory error source Origin of the error, including the function nameas 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). Whenyou select a particular event, theEventbacktrace pane shows the event’s details. Ifyou double-click a particular event, the IDEhighlights the event’s corresponding sourcecode line (if it exists).

To clear theError events tree pane:

➤ Right-click a target instance, executable, or white space, andselectClear. The IDE removes your selection. If you clickwhite space, the IDE clears the entire list.

To jump to a memory error that you have the source for:

➤ Double-click an error in theError events tree or AllocationTrace panes.

To toggle between long and short names of the source files:

250 Chapter 10 � Finding Memory Errors January 31, 2005

Page 276: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracing memory events

➤ Click theShow long pathnames/Show short pathnames

button ( ) in the Memory Event view’s toolbar.

Event backtrace paneThe Event backtrace pane displays a call stack trace leading up toyour selected memory error.

To display error information in the Event Backtrace pane:

➤ Click on a memory error in theError events tree pane.

Allocation Trace tabThe Allocation Trace tab displays a table containing all the allocationevents that are generated by the process you’ve selected in theErrorevents tree pane.

Two adjacent tabs —Unmatched allocations andUnmatcheddeallocations — show subsets of the information displayed in theAllocation Trace tab. (See below for details.)

Note that the event information is available only if you enabledFullmemory allocation/deallocation trace when you configured theMemory Trace tool:

January 31, 2005 Chapter 10 � Finding Memory Errors 251

Page 277: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracing memory events 2005, QNX Software Systems Ltd.

The table in the Allocation Trace tab includes the following columns:

Range The group of events being examined.

Call type How the memory was changed viamalloc(),realloc(), or free()calls. Remember that a call torealloc()with a size of 0 is the same as a call tofree().

Call # The sequential order of the allocations, starting from0.

Pointer The pointer to the block of memory that wasallocated, reallocated, or freed.

Length The size (in bytes) of the memory segment (formalloc()only).

Calling address

The location in code where the memory change wascalled. The entry might show the library (e.g.libc.so.2 (atexit+0x0000001D)), the absoluteaddress, or the line of code (e.g.(copy string[MemoryError.c:8]).

252 Chapter 10 � Finding Memory Errors January 31, 2005

Page 278: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your memory analysis session

Match call # Call number of the corresponding event (e.g. amalloc()call is shown for its correspondingfree()).

Match call address

The location in the source code where thematched-call operation happened (if available).

To display error information in the Allocation Trace tab:

➤ Click an executable ( ), memory error category ( ), or

memory error source ( ) in theError events tree pane.

To exclude memory events that are external to your program, such asthe events associated with system libraries:

➤ In the Memory Events view’s toolbar menu, selectShow→Events with Source Only.

Unmatched allocations tabThis tab shows only the allocations that don’t have a matchingdeallocation. You can use this tab to display actual memory leaks.

Unmatched deallocationsThis tab shows the list of memory free events that weren’t coupledwith corresponding mallocs/reallocs.

Controlling your memory analysis sessionTheTarget Navigator view lets you control the informationdisplayed by the following views:

� Malloc Information

� Memory Information

January 31, 2005 Chapter 10 � Finding Memory Errors 253

Page 279: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining your target’s memory 2005, QNX Software Systems Ltd.

For more information on the Target Navigator view, see the GettingSystem Information chapter.

To control the display in the Malloc Information or MemoryInformation view:

➤ In the Target Navigator view, expand a target and select aprocess:

Examining your target’s memoryTwo views in the Memory Analysis perspective are especially usefulfor 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 viewThe Malloc Information view displays statistical information from thegeneral-purpose, process-level memory allocator:

254 Chapter 10 � Finding Memory Errors January 31, 2005

Page 280: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Examining your target’s memory

When you select a process in the Target Navigator view, the IDEqueries the target system and retrieves the allocator’s statistics. TheIDE gathers statistics for the number of bytes that are allocated, inuse, and overhead.

The Malloc Information view refreshes its display once per second.

The view includes the following panes:

� Total Heap

� Calls Made

� Core Requests

� Distribution

January 31, 2005 Chapter 10 � Finding Memory Errors 255

Page 281: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining your target’s memory 2005, QNX Software Systems Ltd.

� History

Total Heap

The Total Heap pane shows your total heap memory, which is the sumof 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 hasallocated, freed, or reallocated memory by callingmalloc(), free(),andrealloc() functions. (See theLibrary Reference.)

Core Requests

The Core Requests pane displays the number of allocations that thesystem allocator automatically made to accommodate the needs of theprogram you selected in the Target Navigator view. The systemallocator typically dispenses memory in increments of 4K (one page).

The number of allocations will never equal the number ofdeallocations, because when the program starts, it allocates memorythat isn’t released until it terminates.

Distribution

The Distribution pane shows a distribution of the memory allocationsizes. 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 orfree memory. For example, if your program

256 Chapter 10 � Finding Memory Errors January 31, 2005

Page 282: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Examining your target’s memory

reallocated memory from 10 bytes to 20 bytes, boththe free count for the 0-16 byte range and the malloccount for the 17-32 range would increment.

Allocated The remaining number of allocated blocks. The valueis equal to the number of allocations minus thenumber of deallocations.

% Returned The ratio of freed blocks to allocated blocks,expressed as a percentage. The value is calculated asthe number of deallocations divided by the number ofallocations.

Usage (min/max)

The calculated minimum and maximum memoryusage for a byte range. The values are calculated bymultiplying the number of allocated blocks by theminimum and maximum sizes of the range. Forexample, if the 65-128 byte range had two blocksallocated, the usage would be130/160. You shoulduse these values for estimated memory usage only;the actual memory usage will usually lie somewherein between.

History

The History pane shows a chronology of the heap usage shown in theTotal Heap pane. The pane automatically rescales as the selectedprocess increases its total heap.

The History pane updates the data every second, with a granularity of1K. Thus, two 512-byte allocations made over several seconds triggerone update.

January 31, 2005 Chapter 10 � Finding Memory Errors 257

Page 283: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining your target’s memory 2005, QNX Software Systems Ltd.

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 ( ), followed byShow.

2 Click the pane you want displayed.

Virtual address spaceThe Memory Information view displays the memory used by theprocess 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)

- data (light)

258 Chapter 10 � Finding Memory Errors January 31, 2005

Page 284: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Examining your target’s memory

- 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 keeplarge sections of memory from visually overwhelming smallersections, the view scales the display semilogarithmically and indicatescompressed sections with a split.

Below the Process Memory pane, the Process Memory subpaneshows your selected memory category (e.g. Stack, Library) linearly.The subpane colors the memory by subcategory (e.g. a stack’s guardpage), and shows unused memory.

The Memory Information view’s table lists all the memory segmentsand the associated virtual address, size, permissions, and offset. Themajor categories list the total sizes for the subcategories (e.g. Librarylists the sizes for code/data in the Size column). The Process Memorypane and subpane update their displays as you make selections in thetable.

The Memory Information view’s table includes the followingcolumns:

Name The name of the category.

V. Addr. The virtual address of the memory.

Size The size of the section of memory. For the majorcategories, the column lists the totals for the minorcategories.

January 31, 2005 Chapter 10 � Finding Memory Errors 259

Page 285: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining your target’s memory 2005, QNX Software Systems Ltd.

Map Flags The flags and protection bits for the memory block.See themmap()function’sflagsandprot arguments intheLibrary Reference.

Offset The memory block’s offset into shared memory, whichis equal to themmap()function’soff argument.

To toggle the Memory Information view’s table arrangement betweena flat list and a categorized list:

➤ Select the dropdown menu ( ) in the Memory Informationview’s title bar and selectCategorize.

260 Chapter 10 � Finding Memory Errors January 31, 2005

Page 286: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 11

Getting System Information

In this chapter. . .Introduction 263What the System Information perspective reveals264Controlling your system information session268Examining your target system’s attributes271Watching your processes 272Tracking thread activity 274Inspecting virtual address space277Tracking heap usage 277Examining process signals 278Getting channel information 279Tracking file descriptors 281Tracking resource usage 282

January 31, 2005 Chapter 11 � Getting System Information 261

Page 287: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 288: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter shows you how to work with the System Information perspective.

IntroductionThe IDE provides a rich environment not only for developing andmaintaining your software, but also for examining the details of yourrunning target systems.

Within the IDE, you’ll find several views whose goal is to provideanswers to such questions as: Are my processes running? What stateare they in? What resources are being used, and by which processes?Which processes/threads are communicating with which otherprocesses/threads?

Such questions play an important role in your overall system design.The answers to these questions often lie beyond examining a singleprocess or thread, as well as beyond the scope of a single tool, whichis why a structured suite of integrated tools can prove so invaluable.

The tools discussed in this chapter are designed to be mixed andmatched with the rest of the IDE’s development components to helpyou gain insight into your system and thereby develop better products.

January 31, 2005 Chapter 11 � Getting System Information 263

Page 289: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

What the System Information perspective reveals 2005, QNX Software Systems Ltd.

What the System Information perspectiverevealsThe System Information perspective provides a complete and detailedreport on your system’s resource allocation and use, along with keymetrics such as CPU usage, program layout, the interaction ofdifferent programs, and more:

The perspective’s metrics may prove useful throughout yourdevelopment cycle, from writing and debugging your code throughyour quality-control strategy.

Key termsBefore we describe how to work with the System Informationperspective, let’s first briefly discuss the terms used in the perspectiveitself. The main items are:

thread The minimum “unit of execution” that can be scheduledto run.

264 Chapter 11 � Getting System Information January 31, 2005

Page 290: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. What the System Information perspective reveals

process A “container” for threads, defining the virtual addressspace within which threads will execute. A process willalways contain at least one thread. Each process has itsown set of virtual addresses, typically ranging from 0 to4G.

Threads within a process share the same virtual memoryspace, but have their own stack. This common addressspace lets threads within the process easily access sharedcode and data, and lets you optimize or group commonfunctionality, while still providing process-levelprotection from the rest of the system.

scheduling priority

Neutrino uses priorities to establish the order in whichthreads get to execute when multiple threads arecompeting for CPU time.

Each thread can have a scheduling priority ranging from1 to 255 (the highest priority),independent of thescheduling policy. The specialidle thread (in the processmanager) has priority 0 and is always ready to run. Athread inherits the priority of its parent thread by default.

You can set a thread’s priority using thepthreadsetschedparam()function.

scheduling policy

When two or more threads share thesame priority(i.e.the threads are directly competing with each other for theCPU), the OS relies on the threads’ scheduling policy todetermine which thread should run next. Three policiesare available:

� Round-robin

� FIFO

� sporadic

You can set a thread’s scheduling policy using thepthreadsetschedparam()function or you can start a

January 31, 2005 Chapter 11 � Getting System Information 265

Page 291: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

What the System Information perspective reveals 2005, QNX Software Systems Ltd.

process with a specific priority and policy by using theon -p command (see theUtilities Referencefor details).

state Only one thread can actually run at any one time. If athread isn’t in this RUNNING state, it must either beREADY or BLOCKED (or in one of the many “blocked”variants).

message passing

The most fundamental form of communication inNeutrino. The OS relays messages from thread to threadvia a send-receive-reply protocol. For example, if athread callsMsgSend(), but the server hasn’t yet receivedthe message, the thread would be SEND-blocked; athread waiting for an answer is REPLY-blocked, and soon.

channel Message passing is directed towards channels andconnections, rather than targeted directly from thread tothread. A thread that wishes to receive messages firstcreates a channel; another thread that wishes to send amessage to that thread must first make a connection by“attaching” to that channel.

signal Asynchronous event notifications that can be sent to yourprocess. Signals may include:

� simple alarms based on a previously set timer

� a notification of unauthorized access of memory orhardware

� a request for termination

� user-definable alerts.

The OS supports the standard POSIX signals (as inUNIX) as well as the POSIX realtime signals. ThePOSIX signals interface specifies how signals target aparticular process, not a specific thread. To ensure thatsignals go to a thread that can handle specific signals,

266 Chapter 11 � Getting System Information January 31, 2005

Page 292: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. What the System Information perspective reveals

many applications mask most signals from all but onethread.

You can specify the action associated with a signal byusing thesigaction()function, and block signals by usingsigprocmask(). You can send signals by using theraise()function, or send them manually using the TargetNavigator view (see “Sending a signal” below).

For more information on all these terms and concepts, see the QNXNeutrino Microkernel chapter in theSystem Architectureguide.

The views in this perspectiveYou use the views in the System Information perspective for thesemain tasks:

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 BlockingGraph

Track file descriptors. ConnectionInformation

Track resource usage. System Resources

January 31, 2005 Chapter 11 � Getting System Information 267

Page 293: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your system information session 2005, QNX Software Systems Ltd.

Controlling your system informationsessionThe selections you make in theTarget Navigator view control theinformation 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 theReverse sort button

( ) in the view’s title bar.

268 Chapter 11 � Getting System Information January 31, 2005

Page 294: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Controlling your system information session

Sending a signalThe Target Navigator view lets you send signals to the processes onyour target. For example, you can terminate a process by sending it aSIGTERMsignal.

To send a signal to a process:

1 In the Target Navigator view, right-click a process and selectDeliver 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, causethat process to terminate.!

Updating the viewsTo update the views in the System Information perspective:

➤ In the Target Navigator view, expand a target and select aprocess. (You can also select groups of processes by using theCtrl or Shift keys.) The views reflect your selection.

By default, the IDE refreshes the views in the System Informationperspective every five seconds, but you can customize the frequency:

1 In the Target Navigator view, click the menu dropdown button

( ), then selectRefresh.

January 31, 2005 Chapter 11 � Getting System Information 269

Page 295: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Controlling your system information session 2005, QNX Software Systems Ltd.

2 Select either:

Manual Note that the views don’t update until you make anew selection in the Target Navigator view or

click theRefresh button ( ) in the title bar ofsome views:

Periodic The views are refreshed at the rate you specify. Tochange the rate, selectSet Rate and type a newvalue in the Refresh rate dialog.

Adding views to the System Information perspectiveBy default, some views don’t appear in the System Informationperspective. To add a view to the perspective:

1 From the main menu, selectWindow→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 newperspective, selectWindow→Save Perspective As from themain menu.

270 Chapter 11 � Getting System Information January 31, 2005

Page 296: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Examining your target system’s attributes

Some of the views associated with the System Informationperspective 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 usingit.

� Closing unneeded views within the perspective. You can instantlyreopen all the closed views by selectingWindow→ResetPerspective from the main menu.

� Reducing the refresh rate (as described above).

Examining your target system’s attributesTheSystem Summary view displays a listing of your target’s systemattributes, including your target’s processor(s), memory, activeservers, and processes:

January 31, 2005 Chapter 11 � Getting System Information 271

Page 297: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Watching your processes 2005, QNX Software Systems Ltd.

The System Summary view includes the following panes:

� System Specifications

� System Memory

� Processes

System Specifications paneThe System Specifications pane displays your system’s hostname,board type, OS version, boot date, and CPU information. If yourtarget is an SMP system, the pane lists CPU information for eachprocessor.

System Memory paneThe System Memory pane displays your system’s total memory andfree memory in numerical and graphical form.

Processes paneThe Processes pane displays the process name, heap usage, CPUusage time, and start time for the processes running on your selectedtarget. The pane lets you see application processes, server processes,or both. Server processes have a session ID of 1; applicationprocesses have a session ID greater than 1.

Watching your processesTheProcess Information view displays information about theprocesses you select in the Target Navigator view. The view showsthe name of the process, its arguments, environment variables, and soon. The view also shows the threads in the process and the states ofeach thread:

272 Chapter 11 � Getting System Information January 31, 2005

Page 298: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Watching your processes

The Process Information view includes the following panes:

� Arguments

� Thread Details

� Environment Variables

� Identification Details

January 31, 2005 Chapter 11 � Getting System Information 273

Page 299: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracking thread activity 2005, QNX Software Systems Ltd.

Arguments paneThe Arguments pane shows the arguments that were used to start yourselected process as they were passed to your process, but notnecessarily as you typed them. For example, if you typews *.c, thepane might showws cursor.c io.c my.c phditto.c

swaprelay.c, since the shell expands the*.c before launching theprogram.

Thread Details paneThe Thread Details pane shows some fixed information about yourselected process’s threads, including the thread’s ID, priority,scheduling policy, state, and stack usage. You can get moreinformation about threads and their attributes by using the ThreadInformation view (see “Tracking thread activity” in this chapter).

Environment Variables paneThe Environment Variables pane provides the values of theenvironment variables that are set for your selected process. (Formore information, see the Commonly Used Environment Variablesappendix in theUtilities Reference.

Identification Details paneThe Identification Details pane provides the values of the process’sIDs: 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 asroot, but use theseteuid()andsetegid()functions to run the program as the userjsmith, theprogram runs withjsmith’s permissions. By default, all programslaunched from the IDE run asroot.

Tracking thread activityTheThread Information view displays the attributes of the threadsthat are associated with the process or processes you select in theTarget Navigator view:

274 Chapter 11 � Getting System Information January 31, 2005

Page 300: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracking thread activity

The Thread Information view lets you display a substantial amount ofinformation about your threads, but some of the column entries aren’tshown by default.

To configure the information displayed in the Thread Informationview:

1 In the Thread Information view, click the menu dropdown

button ( ).

2 SelectConfigure. The Configure dialog appears:

January 31, 2005 Chapter 11 � Getting System Information 275

Page 301: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracking thread activity 2005, QNX Software Systems Ltd.

3 You can:

� Add entries to the view by selecting items from theAvailable Items list and clickingAdd.

� Remove entries from the view by selecting items in the NewItems list and clickingRemove.

� Adjust the order of the entries by selecting items in the NewItems list and clickingShift Up or Shift Down.

4 Click OK. The view displays the entries that you specified inthe 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 SelectTree View.

276 Chapter 11 � Getting System Information January 31, 2005

Page 302: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Inspecting virtual address space

Inspecting virtual address spaceTheMemory Information view displays the memory used by theprocess you select in the Target Navigator view:

For details on the Memory Information view, see the “Virtual addressspace (Memory Information view)” section in the Finding MemoryErrors chapter in this guide.

Tracking heap usageTheMalloc Information view displays statistical information fromthe general-purpose, process-level memory allocator:

January 31, 2005 Chapter 11 � Getting System Information 277

Page 303: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Examining process signals 2005, QNX Software Systems Ltd.

For details on the Malloc Information view, see the “Heap (MallocInformation view)” section in the Finding Memory Errors chapter inthis guide.

Examining process signalsTheSignal Information view shows the signal maps for theprocesses selected in the Target Navigator view. If you hover over asignal, you’ll see information about specific signals for a specificthread or process:

278 Chapter 11 � Getting System Information January 31, 2005

Page 304: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Getting channel information

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 Navigatorview (see the section “Sending a signal” in this chapter.)

Getting channel informationTheSystem Blocking Graph view presents a color-coded display ofall the active channels in the system and illustrates the interaction ofthreads with those channels.

Interaction with resource objects are such that a thread can be blockedwaiting for access to the resource or waiting for servicing (i.e. thethread is SEND-blocked on a channel).

January 31, 2005 Chapter 11 � Getting System Information 279

Page 305: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Getting channel information 2005, QNX Software Systems Ltd.

The thread could also be blocked waiting for a resource to be releasedback to the thread or waiting for servicing to terminate (i.e. the threadis REPLY-blocked).

Clients in such conditions are shown on the left side of the graph, andthe resource under examination is in the middle. Threads that arewaiting to service a request or are active owners of a resource, or areactively servicing a request, are displayed on the right side of thegraph:

In terms of “classical” QNX terminology, you can think of the itemsin 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. . .

280 Chapter 11 � Getting System Information January 31, 2005

Page 306: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracking file descriptors

Legend item Thread state

Waiting for reply REPLY-blocked

Waiting for service SEND-blocked

Tracking file descriptorsTheConnection Information view displays the file descriptors,server, and connection flags related to your selected process’sconnections. The view also shows (where applicable) the pathname ofthe resource that the process accesses through the connection:

The information in this view comes from the individual resourcemanager servers that are providing the connection. Certain resourcemanagers may not have the ability to return all the requestedinformation, so some fields will be left blank.

January 31, 2005 Chapter 11 � Getting System Information 281

Page 307: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracking resource usage 2005, QNX Software Systems Ltd.

The IOFlags column describes the read (r) and write (w) status of thefile. A double dash (--) indicates no read or write permission; a blankindicates that the information isn’t available.

The Seek Offset column indicates the connector’s offset from the startof the file.

Note that for some FDs, an “s” appears beside the number. Thismeans that the FD in question was created via aside channel— theconnection 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, seeConnectAttach()in theLibrary Reference.

To see the full side channel number:

1 In the Connection Information view, click the menu dropdown

button ( ).

2 SelectFull Side Channels.

Tracking resource usageTheSystem Resources view shows various pieces of informationabout your system’s processes. You can choose one of the followingdisplays:

� 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 displayThe System Uptime display provides information about the start time,CPU usage time, and the usage as a percent of the total uptime, for allthe processes running on your selected target:

282 Chapter 11 � Getting System Information January 31, 2005

Page 308: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracking resource usage

General Resources displayThe General Resources display provides information about CPUusage, heap size, and the number of open file descriptors, for all theprocesses running on your selected target.

January 31, 2005 Chapter 11 � Getting System Information 283

Page 309: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tracking resource usage 2005, QNX Software Systems Ltd.

Memory Resources displayThe Memory Resources display provides information about the heap,program, library, and stack usage for each process running on yourselected target:

284 Chapter 11 � Getting System Information January 31, 2005

Page 310: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tracking resource usage

To learn more about the meaning of the values shown in the MemoryResources display, see the Finding Memory Errors chapter in thisguide.

January 31, 2005 Chapter 11 � Getting System Information 285

Page 311: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 312: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 12

Analyzing Your System with KernelTracing

In this chapter. . .Introducing the QNX System Profiler 289Configuring a target for system profiling 293Capturing instrumentation data in event log files297Viewing and interpreting the captured data299

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 287

Page 313: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 314: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the QNX System Profiler

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Use the System Profiler to analyze your system via instrumentation.

Introducing the QNX System ProfilerThe System Profiler is a tool that works in concert with the Neutrinoinstrumented kernel (procnto-instr) to provide insight into theoperating system’s events and activities. Think of the System Profileras a system-level software logic analyzer. Like the ApplicationProfiler, the System Profiler can help pinpoint areas that needimprovement, but at asystem-widelevel.

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:

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 289

Page 315: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the QNX System Profiler 2005, QNX Software Systems Ltd.

� IPC bottlenecks (by observing the flow of messages amongthreads)

� resource contention (by watching threads as they change states)

� cache coherency in an SMP machine (by watching threads as theymigrate 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’sGuide.

The QNX System Profiler perspective includes several componentsthat are relevant to system profiling:

Navigator view

Events are stored inlog files(with the extension.kev) withinprojects in your workspace. These log files are associated withthe System Profiler editor.

Target Navigator view

When you right-click a target machine in the Target Navigator,you can selectKernel event tracing, which initiates the TraceLogging wizard. You use this wizard to specify which events tocapture, the duration of the capture period, as well as specificdetails about where the generated event log file (.kev file) willbe stored.

System Profiler editor

This editor provides the graphical representation of theinstrumentation events in the captured log file. Like all otherEclipse editors, the System Profiler editor shows up in the editorarea and can be brought into any perspective. This editor isautomatically associated with.kev files, but if you have otherfile types that contain instrumentation data, you could associatethe editor with those files as well.

290 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 316: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introducing the QNX System Profiler

Trace Event Log view

This view lists instrumentation events, as well as their details(time, owner, etc.), surrounding the selected position in thecurrently active System Profiler editor.

Trace Search panel

Unlike the other search panels in the IDE, the Trace Searchpanel can search for events only in the currently active SystemProfiler editor. You use this search panel to build conditions andthen combine them into an expression. A search will iteratethrough the events from the active log file and be appliedagainst the expression; “hits” appear in the Search Results viewand are highlighted in the System Profiler’s editor. By default,the Trace Search panel will return up to 1000 hits. You canchange this maximum on theQNX→System Profiler of thePreferences dialog (Window→Preferences).

Condition Statistics view

A tabular statistical representation of the conditions used in thesearch panel.

Event Owner Statistics view

A tabular statistical representation of events broken down perowner.

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 canbookmark particular locations and event ranges displayed in theSystem Profiler editor, then see your bookmarked events in theBookmarks view.

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 291

Page 317: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introducing the QNX System Profiler 2005, QNX Software Systems Ltd.

The System Profiler perspective may produce incorrect results whenmore than one IDE is communicating with the same target system. Touse this perspective, make sure only one IDE is connected to thetarget system.

Before you beginAs mentioned earlier, in order to capture instrumentation data foranalysis, the instrumented kernel (procnto-instr) must berunning. 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 isrunning the instrumented kernel.

To substitute theprocnto-instr module in the OS image on yourboard, you can either manually edit your buildfile, then runmkifs togenerate a new image, or use the System Builder to configure theimage’s properties.

Replacing the kernel using the System Builder1 In the System Builder Projects view, double-click the

project.bld file for the image you want to change.

2 In the Images pane of the Builder’s editor, select the image.

3 In the Properties view, click theProcnto field (underSystem).A dropdown-menu button appears in the field:

292 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 318: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring a target for system profiling

4 Selectprocnto-instr, pressEnter, then save your change.

5 Rebuild your project, then transfer your new OS image to yourboard.

Assuming you’re running the instrumented kernel on your board,you’re ready to use the System Profiler. A profiling session usuallyinvolves 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 aroot user.

Configuring a target for system profilingYou can gather trace events from the instrumented kernel in twodifferent 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

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 293

Page 319: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring a target for system profiling 2005, QNX Software Systems Ltd.

to your development environment for analysis. Or, you can captureevents directly from the IDE using theTrace Events Configurationwizard.

Using the command-line server currently offers more flexibility as towhen the data is captured, but requires that you set up and configurefilters yourself using theTraceEvent()API. The Trace EventsConfiguration wizard lets you set a variety of different static filtersand configure the duration of time that the events will be logged for.

For more information on thetracelogger utility, see its entry in theUtilities Reference. ForTraceEvent(), see theLibrary Reference.

Launching the System Profiler Configuration wizard➤ In the Target Navigator, right-click a target, then selectKernel

Events Tracing.

If you don’t already have a target project, you’ll have to create one:

➤ In the Target Navigator, right-click and selectAdd New Target.

You can use this target project for a number of different tasks(debugging, memory analysis, profiling), so once you create it, youwon’t have to worry about connecting to your target again. Note alsothat theqconn target agent must be running on your target machine.

Selecting options in the wizardThe wizard takes you through the process of selecting:

� the location of the captured log file (both on the target temporarilyand 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).

294 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 320: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Configuring a target for system profiling

Here are the main fields in this wizard:

Log filename Name you want to use for the kernel events log file(.kev) in your workspace.

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 295

Page 321: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Configuring a target for system profiling 2005, QNX Software Systems Ltd.

Tracing method, Type (Period of time)

The duration of the capture of events as defined by atime.

Tracing method, Period length

Floating-point value in seconds representing thelength of time to capture kernel events on the target.

Tracing method, Type (Iterations)

The duration of the capture of events as defined bythe number of kernel event buffers.

Tracing method, Number of Iterations

Total number of full kernel event buffers to log onthe target.

Trace file, Mode (Stream)

In this mode, no file is saved on the target. Kernelevent buffers are directly sent fromqconn to theIDE.

Trace file, Mode (Save on target then upload)

In this mode, kernel event buffers are first saved in afile on the target, then uploaded to your workspace.

Trace file, Filename on target

Name of the file used to save the kernel eventbuffers 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 thetarget.

Trace statistics File, Mode (Save on target then upload)The statistical information is first saved in a file onthe target, then uploaded to your workspace.

296 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 322: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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 statisticalinformation on the target.

Buffers, Number of kernel buffers

Size of the static ring of buffers allocated in thekernel.

Buffers, Number of qconn buffers

Maximum size of the dynamic ring of buffersallocated in theqconn target agent.

Capturing instrumentation data in event logfilesRegardless of how your log file is captured, you have a number ofdifferent options for how to regulate the amount of informationactually 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 SATUser’s Guide.)

The IDE lets you access the first three of the above filters. You canenable tracing (currently done by activating the tracing wizard), andthen select what kind of data is logged for various events in thesystem.

The events in the system are organized into different classes (kernelcalls, communication, thread states, interrupts, etc). You can toggleeach of these classes in order to indicate whether or not you want togenerate such events for logging.

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 297

Page 323: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Capturing instrumentation data in event log files 2005, QNX Software Systems Ltd.

The data logged with events comes in two modes:

Fast mode A small-payload data packet that conveys only themost important aspects of the particular event. Betterfor performance.

298 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 324: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Viewing and interpreting the captured data

Wide mode A larger-payload data packet that contains a morecomplete event definition, with more context. Betterfor understanding the data.

Depending on the purpose of the trace, you’ll want to selectivelyenable different tracing modes for different types of events so as tominimize the impact on the overall system. For its part in the analysisof these events, the IDE will do its best to work with whatever data ispresent. (But note that some functionality may not be available forpost-capture analysis if it isn’t present in the raw event log. ;-))

Viewing and interpreting the captured dataOnce an event file is generated and transferred back to thedevelopment host for analysis (whether it was done automatically bythe IDE or generated by usingtracelogger and manually extractedback to the IDE), you can then invoke the System Profiler editor.

The IDE includes a custom perspective for working with the SystemProfiler. This perspective sets up some of the more relevant views foreasy access.

The System Profiler editorIn order to start examining an event file, the easiest way is to name itwith a.kev (kernel event) extension. Files with this extension areautomatically 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 logfiles:

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 299

Page 325: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Viewing and interpreting the captured data 2005, 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 thoseparticular owners (where it makes sense to do so).

CPU Activity presentation

Displays the CPU activity associated with a particular thread ofprocess. For a thread, CPU activity is defined as the amount ofruntime for that thread. For a process, CPU activity is theamount of runtime for all the process’s threads combined.

CPU Usage presentation

Displays the percent of CPU usage associated with all eventowners. CPU usage is the amount of runtime that event ownersget.

Process Activity presentation

Displays CPU usage for an individual selected process orthread.

The timeline presentation is the default. To choose one of the otherthree types, right-click in the editor, then selectDisplay→Type.

Each of these visualizations is available as a “pane” in a stack of“panes.” Additionally, the visualization panes can be split — you can

300 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 326: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Viewing and interpreting the captured data

look at the different sections of the same log file and do comparativeanalysis.

All panes of the same stack share the same display information. Anew pane inherits the display information of the previous pane, butbecomes independent after it’s created.

To split the display, right-click in the editor, then selectDisplay→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 othercomponents of the IDE (such asFilters andFind).

If an owner has children (e.g. a parent process withthreads), you’ll see an arrow beside the parent’s name.To see a parent’s children, click the arrow (or pressE toexpand,C to collapse).

Filters Event owners and specific events can be filtered outusing theEvent Owner Filters andEvent Filters itemsin the right-click (context) menu. You can use thisfiltering feature to significantly cut down on theunwanted event “noise” in the display. Once filtered, thelog file can be saved as a new log file (usingSave As) toproduce a smaller, more succinct log file for furtherexamination.

For example, to view only processes that are sendingpulses, right-click in the timeline, then selectEventOwner Filters→Show Only→MsgSend Family.

Find PressingCtrl – F (or selectingEdit→Find/Replace) willopen up a dialog that lets you quickly move from eventto event. This is particularly useful when following the

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 301

Page 327: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Viewing and interpreting the captured data 2005, QNX Software Systems Ltd.

flow of activity for a particular event owner or whenlooking for particular events.

Markers You can place markers in the timeline editor just as youwould to annotate text files. Press theB key to add amarker.

These markers show up in the Bookmarks view and canrepresent a range of time or a single particular eventinstance.

Cursor tracking

The information from the System Profiler editor is alsomade available to other components in the IDE such asthe Trace Event Log and the Trace Event Statisticsviews. These views can synchronize with the cursor,event owner selections, and time ranges, and can adjusttheir content accordingly.

IPC representation

The flow of interprocess communication (e.g. messages,pulses) is represented by a vertical arrow between thetwo elements.

You can toggle IPC tracing on/off by pressingI orclicking 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.

302 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 328: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Viewing and interpreting the captured data

Elements

To select a single element, simply click the element’s name. Tounselect an element, press and hold theCtrl key, then click eachselected element’s name.

To select multiple elements, press and hold theCtrl key, then clickeach 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 andrelease at the end point.

Or, select the start point, then hold down theShift key and select theend point.

Zooming

When zooming in, the display will center the selection. If atime-range selection is smaller than the current display, the displaywill adjust to the range selection (or by a factor of two).

When zooming out, the display will center the selection and adjust bya factor of two.

When using a preset zoom factor (100% to 0.01%), the display willcenter 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:

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 303

Page 329: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Viewing and interpreting the captured data 2005, 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 (horizontalscrollbar 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 thumbsize).

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.).

Other views in the System ProfilerThere are a number of additional components outside of the editorthat you can use to examine the event data in more detail:

304 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 330: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Viewing and interpreting the captured data

Trace Event Log view

This view can display additional details for the eventssurrounding the cursor in the editor. The additional detailincludes the event number, time, class, type as well as decodingthe data associated with a particular event.

Trace Search panel

Invoked byCtrl – H (or viaSearch→Search. . . ), this panel letsyou execute more complex event queries than are possible withthe Find dialog.

You can define conditions, which may include regularexpressions for matching particular event data content (e.g. allMsgSendevents whose calling function corresponds tommap()). You can then evaluate these conditions and placeannotations directly into the System Profiler editor. The resultsare shown in the Search view.

Condition, Event Owner, General Statistics views

These views provide a tabular statistical representation ofparticular events. The statistics can be gathered for the entirelog file or for a selected range.

Here’s an example of the General Statistics view:

January 31, 2005 Chapter 12 � Analyzing Your System with Kernel Tracing 305

Page 331: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Viewing and interpreting the captured data 2005, QNX Software Systems Ltd.

Properties view

Shows information about the log file that was captured, such asthe date and time as well as the machine the log file wascaptured on.

306 Chapter 12 � Analyzing Your System with Kernel Tracing January 31, 2005

Page 332: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 13

Common Wizards Reference

In this chapter. . .Introduction 309Creating a C/C++ project 311Creating a target 324Converting projects 326Importing projects 337

January 31, 2005 Chapter 13 � Common Wizards Reference 307

Page 333: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 334: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

This chapter describes the IDE’s wizards.

IntroductionWizards guide you through a sequence of tasks, such as creating anew project or converting an existing non-IDE project to a QNXC/C++ application or library project.

Wizards aren’t directly connected to any perspective. You can accessall the project creation wizards from the main menu by selectingFile→New→Other. . . .

In the New Project dialog, the wizards are categorized according tothe nature of the project. If you selectC in the left pane, you’ll see allprojects that have a C nature listed in the right pane; selectQNX, andyou’ll see all the projects with a QNX nature:

January 31, 2005 Chapter 13 � Common Wizards Reference 309

Page 335: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Introduction 2005, QNX Software Systems Ltd.

Notice the overlap: theQNX C Project wizard appears in the rightpane for bothC andQNX.

Besides the nature-specific wizards, the IDE also has “simple”wizards that deal with the very basic elements of projects:Project,Folder, andFile. These elements have no natures associated withthem. You can access these wizards by selectingFile→New→Other. . . →Simple.

310 Chapter 13 � Common Wizards Reference January 31, 2005

Page 336: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

Although a project may seem to be nothing other than a directory inyour workspace, the IDE attaches special meaning to a project — itwon’t automatically recognize as a project any directory you happento create in yourworkspace.

But once you’ve created a project in the IDE, you can bring newfolders and files into your project folder, even if they were createdoutside the IDE (e.g. using Windows Explorer). To have the IDErecognize such folders and files:

➤ In the Navigator view, right-click the navigator pane and selectRefresh.

Creating a C/C++ projectYou use theNew Project wizard to create a C or C++ project, whichcan be one of these varieties:

QNX C Project (application)QNX C++ Project (application)

A C or C++ application for multiple target platforms. Itsupports the QNX-specific project structure usingcommon.mk

files to perform a QNX recursivemake.

If you open acommon.mk file in the editor, you can toggle the displayto reveal hidden internal code by clicking this icon in the toolbar:

January 31, 2005 Chapter 13 � Common Wizards Reference 311

Page 337: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

QNX C Project (library)QNX C++ Project (library)

A library that other projects can reference. In most otherrespects, library projects resemble QNX C/C++ applicationProjects.

Standard Make C ProjectStandard Make C++ Project

A basic C or C++ project that uses a standardmakefile andGNU make to build the source files. You don’t get the addedfunctionality of the QNX build organization and thecommon.mk file, but these standard projects adapt well to yourexisting code that you wish to bring into the IDE. (For moreabout makefiles and themake utility, see the Conventions forMakefiles and Directories appendix in theProgrammer’sGuide.)

As a rule, the IDE provides UI elements to control most of the buildproperties of QNX projects, but not of Standard Make projects (unlessyou consider a makefile a “UI element”).

How to create a C/C++ projectTo create a C/C++ project :

1 From the menu, selectFile→New→Project. . . .

2 In the left pane, select the project’s nature according to thistable:

If you want to build: Select:

Standard Make C project C

QNX C application project C or QNX

continued. . .

312 Chapter 13 � Common Wizards Reference January 31, 2005

Page 338: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

If you want to build: Select:

QNX C library project C or QNX

Standard Make C++ application projectC++

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 thatUse Default Location is checked.

7 Select the type (application or library):

January 31, 2005 Chapter 13 � Common Wizards Reference 313

Page 339: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

If you’re building a library, see below.

8 Click Next. The wizard displays the appropriate tabs.

9 Select each tab and fill in the required information. The fieldsfor 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 yourworkspace.

314 Chapter 13 � Common Wizards Reference January 31, 2005

Page 340: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

In the C/C++ Development perspective, you can also access the QNXC/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 willlater be directly linked into an executable.

January 31, 2005 Chapter 13 � Common Wizards Reference 315

Page 341: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

Shared library (libxx.so)

Combine binary objects together and join them so they’rerelocatable and can be shared by many processes. Sharedlibraries are named using the formatlibxx.so.version, whereversionis a number with a default of 1. Thelibxx.so file willbe 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 intoa shared object. The System Builder uses these types of librariesto create new shared libraries that contain only the symbols thatare absolutely required by a specific set of programs.

Shared library without export (xx.dll)

A shared library without versioning. Generally, you manuallyopen the library with thedlopen()function and look up specificfunctions with thedlsym()function.

If you’re building a Standard Make C/C++ project

Since this type of project doesn’t use the QNX recursive multivariantmakefile structure, you’ll have to set up your own makefile.

Here’s how to create a simple “Hello World” non-QNX project:

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 createda 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 thetoolbar:

316 Chapter 13 � Common Wizards Reference January 31, 2005

Page 342: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

5 Name your file “Makefile” and click Finish. The editorshould 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

UseTab characters to indent commands inside ofmake rules,notspaces.

6 When you’re finished editing, save your file (right-click, thenselect 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 thiswhen you’re done:#include <stdlib.h>#include <stdio.h>

int main(int argc, char *argv[]) {printf("Hello, world!\n");return EXIT SUCCESS;

}

January 31, 2005 Chapter 13 � Common Wizards Reference 317

Page 343: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

Tabs in the New C/C++ Project wizardDepending on the type of project you choose, the New Project wizarddisplays 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 compileexecutables for:

318 Chapter 13 � Common Wizards Reference January 31, 2005

Page 344: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

By default,all platforms are enabled. You might want to set yourpreferences for QNX projects to build only for the specific targetplatforms you want. To do this, open:Window→Preferences→QNX→New Project→Build Variants.

You can click theAdd button to add a new variant under the currentlyselected target architecture, or theDelete button to remove thecurrently selected variant.

You must choose at least one platform.

January 31, 2005 Chapter 13 � Common Wizards Reference 319

Page 345: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

Projects tab

The Projects tab lets you specify your preferred order of building:

For example, if you associatemyProjectwith mySubProject, the IDEbuildsmySubProjectfirst when you rebuild all your projects. If youchangemySubProject, the IDE doesn’t automatically rebuildmyProject.

Make Builder tab

The Make Builder tab lets you configure how the IDE handlesmake

errors, what command to use to build your project, and when to do abuild:

320 Chapter 13 � Common Wizards Reference January 31, 2005

Page 346: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

Build Setting If you want the IDE to stop building when itencounters amake or compile error, checkStop onError. Otherwise, checkKeep Going On Error.

Build Command

If you want the IDE to use the defaultmakecommand, checkUse Default. If you want to use adifferent utility, uncheckUse Default and enteryour own command in the Build Command field(e.g.C:/myCustomMakeProgram).

January 31, 2005 Chapter 13 � Common Wizards Reference 321

Page 347: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a C/C++ project 2005, QNX Software Systems Ltd.

Workbench Build Behavior

You can specify how you want the IDE to buildyour 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 ErrorParser, etc.) apply to this project and in which order. To change theorder, simply select an item, then use theUp or Down buttons toposition the item where you want in the list.

Options tab

The Options tab lets you specify several attributes for the projectyou’re building:

322 Chapter 13 � Common Wizards Reference January 31, 2005

Page 348: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a C/C++ project

General options By default, some project properties (e.g. activetargets) are local — they’re stored in the.metadata folder in your own workspace. If youwant other developers to shareall of your project’sproperties, then setShare all project propertieson. The IDE then stores the properties in a.cdtproject file, which you can save in yourversion control system so that others may share theproject file.

Build Options If you want to profile your application and take fulladvantage of the QNX Application Profiler, then

January 31, 2005 Chapter 13 � Common Wizards Reference 323

Page 349: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Creating a target 2005, QNX Software Systems Ltd.

checkBuild with Profiling (see the Profiling anApplication chapter in this guide).

If you want use the QNX Code Coverage tool, thencheckBuild with Code Coverage (see the UsingCode Coverage chapter in this guide).

If you want the IDE to do more dependencychecking than it normally would, then set theEnhanced dependency checking option on. Notethat this will mean slower builds, so you may wantto 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 letsyou define which binary parser (e.g. ELF Parser) should be used todeal with the project’s binary objects.

Paths and Symbols tab

If you’re building a Standard Make C/C++ project, then this tab letsyou specify the include paths and C/C++ macro definitions for thisparticular project. Certain features of the IDE (e.g. syntaxhighlighting, code assistance, etc.) rely on this information, as dosource-code parsers.

At a later time, you can supply this data using theSet QNX BuildEnvironment. . . item in the context menu of the C/C++ Projectsview.

Creating a targetYou must create aTarget System Projectfor every target you want touse with the IDE.

To create a new target:

1 From the menu, selectFile→New→Project. . . .

2 In the left pane, selectQNX.

324 Chapter 13 � Common Wizards Reference January 31, 2005

Page 350: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Creating a target

3 In the right pane, selectQNX Target System Project.

4 Click Next. The New QNX Target System Project wizardappears:

5 Complete the fields described below:

Target Name Type a descriptive name for your QNX TargetSystem Project.

Project contents

CheckUse default to store it in yourworkspace, or turn this option off and selectanother location in the Directory field.

January 31, 2005 Chapter 13 � Common Wizards Reference 325

Page 351: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, QNX Software Systems Ltd.

QNX Connector Selection

Type the target connection in the Hostname orIP and Port fields. If you’re running the IDEon a QNX Neutrino machine runningqconn,then checkUse local QNX Connector; theIDE automatically fills in the connectioninformation. (If you wish to connect to adifferent target, you may turnUse local QNXConnector off, and then fill in the fieldsmanually.)

Target Configuration

This section is for a future feature.

6 Click Finish. Your new QNX Target System Project appears inthe Navigator view. When you create a launch configuration,the target is listed under the Main tab in the Target Optionspane. Note that you can use theAdd New Target button in theTarget Options pane to open the New Target System Projectwizard.

You can also reach the New Target System Project wizard from withinthe Target Navigator (right-click, then selectAdd New Target).

Converting projectsAt various times, you may need to convert non-QNX projects to QNXprojects (i.e. give them a QNX nature). For example, suppose anotherdeveloper committed a project to CVS without the.project and.cdtproject files. The IDE won’t recognize that project as a QNXproject 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 QNXC/C++ project in order to take advantage of the QNX recursivemakefile hierarchy (a project with a QNX nature causes the IDE touse the QNXmake tools and structure when building that project).

The IDE lets you convert many projects at once, provided you’reconverting all those projects into projects of the same type.

326 Chapter 13 � Common Wizards Reference January 31, 2005

Page 352: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Converting projects

If you wish to convert a QNX project back into a Standard MakeC/C++ project, you can use the Convert C/C++ Projects wizard. Fromthe main menu, selectFile→New→Other. . . . In the left pane, selectC. In the right pane, selectConvert to a C or C++ Project.

Converting to a QNX projectTo convert a non-QNX project to a QNX Project:

1 From the menu, selectFile→New→Project. . . .

2 In the left pane, selectQNX.

3 In the right pane, selectConvert to a QNX Project. TheConvert C/C++ Projects wizard appears.

You can also use the Convert to a QNX Project button to bring up theconversion wizard:

4 Click Next.

5 Select the project(s) you want to convert in theCandidates forconversion 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.

January 31, 2005 Chapter 13 � Common Wizards Reference 327

Page 353: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, QNX Software Systems Ltd.

You now have a project with a QNX nature, but you’ll need to makefurther adjustments (e.g. specify a target platform) via the Propertiesdialog if you want it to be aworkingQNX Project.

Completing the conversionThe conversion wizard gave your Standard Make project a QNXnature; you now need to use theProperties dialog to fully convertyour project to a working QNX Project.

To bring up the Properties dialog of a project:

1 In the C/C++ Projects view (or the Navigator), right-click yourproject.

2 SelectProperties from the context menu. The Properties dialogappears:

3 In the left pane, selectQNX C/C++ Project.

4 Specify the properties you want using the available tabs:

328 Chapter 13 � Common Wizards Reference January 31, 2005

Page 354: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. 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 theInstallation directory field, you canspecify the destination directory (e.g.bin)for the output binary you’re building. (Formore information, see the Conventions forMakefiles and Directories appendix in theProgrammer’s Guide.)

In theTarget base name field, you canspecify your binary’s base name, i.e. thename without any prefixes or suffixes. Bydefault, the IDE uses your project name asthe executable’s base name. For example, ifyour project is called “Test1,” then a debugversion of your executable would be called“Test 1 g” by default.

In theUse file name, enter the name of thefile containing the usage message for yourexecutable. (For more on usage messages,see the entry forusemsg in theUtilitiesReference.

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.

5 When you’ve finished specifying the options you want, clickApply, thenOK. The conversion process is complete.

January 31, 2005 Chapter 13 � Common Wizards Reference 329

Page 355: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, QNX Software Systems Ltd.

Compiler tab

The Compiler tab changes depending on which of the three categoriesyou select:

� General options

� Extra source paths

� Extra include paths

Compiler type If you’ve selectedGeneral options, the first itemyou specify is the type of compiler. Currently, thechoices 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 thecompiler outputs. You can also choose to have thepreprocessor output intermediate code to a file; theIDE will name the output fileyour sourcefile.i (C)or your sourcefile.ii (C++), using the name ofyour source file as the base name.

Code generation For theOptimization level, you can specify fourlevels: from 0 (no optimization) to 3 (mostoptimization). In theStack size field, you canspecify the stack size, in bytes or kilobytes.

Definitions field Here you can specify the list of compiler defines tobe passed to the compiler on the command line inthe form-D name[=value], but you don’t have tobother with the-D part; the IDE adds itautomatically.

Other options field

Here you can specify any other command-lineoptions that aren’t already covered in the Compiler

330 Chapter 13 � Common Wizards Reference January 31, 2005

Page 356: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Converting projects

tab. For more information on the compiler’scommand-line options, seeqcc in theUtilitiesReference.

Extra source paths

If you want to specify source locations other thanyour project’s root directory, select this category.Then click the appropriate button to specify thelocation:

� Project. . . — You can add source from anotherproject in your current workspace. Note that theIDE uses relocatable notation, so even if otherteam members have different workspacelocations, they can all work successfullywithout having to make any additional projectadjustments.

� QNX target. . . — You can add source fromanywhere in or below your${QNX TARGET}

directory on your host.

� Disk. . . — You can choose to add source fromanywhere in your host’s filesystem.

Extra include paths

You can specify a list of directories where thecompiler should look for include files. The optionshere are the same as forExtra source paths,except that here you can change the order ofdirectories in the list, which can be important ifyou happen to have more than one header file withthe same name.

Linker tab

The Linker tab changes depending on which of the four categoriesyou select:

� General options

January 31, 2005 Chapter 13 � Common Wizards Reference 331

Page 357: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, QNX Software Systems Ltd.

� Extra library paths

� Extra libs

� Post-build actions

Export symbol options

This field lets you define the level of final strippingof your binary, ranging from exporting all symbolsto removing just the debugger symbols toremoving them all.

Generate map file

If you set this option on, the IDE will print a linkmap to the build console.

Build goal name Specify the output filename for an application orlibrary project. Note that the name you enter in thisfield will force the library’s shared-object name tomatch.

By default, a generated application will have thesame name as the project it’s built from. A librarywill have prefix of “lib” and a suffix of “.a” or“.so” after the project name. In addition, debugvariants of applications and libraries have a suffixof “ 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-objectname used in C/C++ library projects. Note that thiswill not affect the actual filename.

332 Chapter 13 � Common Wizards Reference January 31, 2005

Page 358: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Converting projects

If you specify a filename in theBuild goal name field, don’t use theLibrary shared object name field.

Library version This dropdown list lets you select a versionnumber for both the library’s shared-object nameand filename. If this is a library that doesn’t have aversion number (e.g. “platform.so”), thenselect “No.”

Note that you can still set the library version evenif Build goal name is specified.

Other options field

Here you can specify any other command-lineoptions that aren’t already covered in the Linkertab. For more information on the linker’s options,see the entry forld in theUtilities Reference.

Extra library paths

Select this category if you want to specifylocations where the linker should look for importlibraries (.so or .a files). Then click theappropriate button to specify the location. (Thesebuttons work the same as those in the Compiler tabwhen you selectExtra source paths.)

Extra libraries Here you can add a list of libraries (.so or .afiles) to search for unsatisfied references. For eachitem in this list, you can define:

� Stripped name, the base name without thelib

prefix (whichld adds automatically) andwithout the suffix (.so or .a).

� Library type (static or dynamic)

� Debug/Release mode. A “No” or “Yes” in thisfield indicates whether or not the builder willmatch the debug or release version of the

January 31, 2005 Chapter 13 � Common Wizards Reference 333

Page 359: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, QNX Software Systems Ltd.

library with the final binary’s type. Forexample, if you select “Yes” and you want tolink against a debug version of the library, theIDE will append “ g” to the library’s basename. If you select “No,” then the builderpasses (told) this name exactly as you enteredit. So, if you wanted to use a release version ofyour binary and link against adebugversion ofthe library, you’d specifyMyLibraryName g

as the name.

Adding a new element to the extra library list automatically adds thedirectory where this library resides to theExtra library paths list(see above), if it’s not already there. But if you remove an item fromthe list, its parent directory isnot automatically removed.

You can add a library in two ways:

� Add button — lets you create an empty elementand define it manually

� Add from project — lets you browse yourworkspace for the library. Note that when youadd a library from your workspace, the IDEuses relocatable notation so other members withdifferent workspace locations can all worksuccessfully without having to make any projectadjustments.

Extra object files This lets you link a project against any object fileor library, regardless of the filename.

334 Chapter 13 � Common Wizards Reference January 31, 2005

Page 360: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Converting projects

The file-selection dialog may seem slow when adding new files. Thisis because the system can’t make assumptions about namingconventions and instead must use a binary parser to determine if a fileis an object file or a library.

Note also that theExtra object files option is available for anindividual platform only. If a project has more than one activeplatform, you can’t use this feature. In that case, you can still specifyextra object files using the Advanced mode for each platformseparately.

Post-build actions

When you select this category and click theAddbutton, you’ll see a dialog that lets you select oneof four predefined post-build actions for yourproject:

� Copy result to other location

� Move result to other location

� Rename result

� Run other shell command

In theWhat field, you specify the item (e.g.application) you want to copy or move; in theWhere field, you specify the destination. You canuse theTo Workspace or To Filesystem buttons tolocate the place.

If you selectRename result, aNew Name fieldappears for you to enter the name. If you selectOther command, enter the shell command in thefield.

Note that you can set up more than one post-buildaction; each will be processed sequentially.

January 31, 2005 Chapter 13 � Common Wizards Reference 335

Page 361: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Converting projects 2005, 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 theAdvanced button at thebottom of the dialog:

To return to regular mode, press theRegular button:

In advanced mode, you can override various options that were set atthe 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 Cfile, specify which set of import libraries to use for a specificarchitecture, and so on.

336 Chapter 13 � Common Wizards Reference January 31, 2005

Page 362: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

During the final build, the IDE will merge the options you’ve set forthe project’s general configuration with the advanced options, givingpriority to the advanced settings.

Importing projectsUse theImport wizard to bring resources into your workspace from afilesystem, ZIP archive, or CVS repository.

To bring up theImport wizard:

➤ ChooseFile→Import. . . .

Or

Right-click in theNavigator view, then chooseImport. . . .

January 31, 2005 Chapter 13 � Common Wizards Reference 337

Page 363: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

The Import wizard

TheImport wizard can import resources from several differentsources:

� Existing Container Project into Workspace

� Existing Project into Workspace

� External Features

338 Chapter 13 � Common Wizards Reference January 31, 2005

Page 364: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

� External Plug-ins and Fragments

� File System

� GCC Coverage Data from Project

� QNX Board Support Package

� QNX mkifs Buildfile

� QNX Source Package

� Team Project Set

� Zip file

Existing Container Project into WorkspaceTo import a container project and its associated C/C++ projects fromanother workspace:

1 In theImport wizard, chooseExisting Container Project intoWorkspace and click theNext button.

The IDE displays theImport Container Project From FileSystem panel.

January 31, 2005 Chapter 13 � Common Wizards Reference 339

Page 365: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Importing a container project

2 Enter the full path to an existing container project directory intheProject contents field, or click theBrowse. . . button toselect a container project directory using the file selector.

Click Next to continue. The IDE displays theSelectcomponents to install panel.

340 Chapter 13 � Common Wizards Reference January 31, 2005

Page 366: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

Selecting container components to import

3 By default, every project reference by the container project willalso be imported. To exclude certain projects, expand theproject tree and de-select projects you don’t want to import.

Click Finish to import the container project and itssub-projects.

January 31, 2005 Chapter 13 � Common Wizards Reference 341

Page 367: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Existing Project into WorkspaceTo copy an existing project from another workspace:

1 In theImport wizard, chooseExisting Project intoWorkspace and click theNext button.

The IDE displays theImport Project From Filesystem panel.

Importing an existing project

342 Chapter 13 � Common Wizards Reference January 31, 2005

Page 368: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

2 Enter the full path to an existing project directory in theProjectcontents field, or click theBrowse. . . button to select a projectdirectory using the file selector.

3 Click theFinish button to import the selected project into yourworkspace.

External FeaturesEclipse developers use this for developing IDE plug-ins and features.

External Plug-ins and FragmentsEclipse developers use this for developing IDE plug-ins and features.

File SystemTo copy files and folders from your filesystem into an existing projectin your workspace:

1 In theImport wizard, chooseFile System and click theNextbutton.

The IDE displays theFile system panel.

January 31, 2005 Chapter 13 � Common Wizards Reference 343

Page 369: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Importing code from the filesystem

2 Enter the full path to the code in theFrom directory field, orclick theBrowse. . . button to select a source directory.

3 Use theFilter Types. . . , Select All andDeselect All buttons tocontrol which files will be imported.

Click a directory on the left panel to see a list of files in theright panel.

344 Chapter 13 � Common Wizards Reference January 31, 2005

Page 370: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

The Select Types dialog lets you filter imported files by selecting one

or more extensions.

4 Enter the name of a project or folder in theInto folder field, orclick theBrowse. . . button to select one.

January 31, 2005 Chapter 13 � Common Wizards Reference 345

Page 371: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

This project or folder must already exist before you bring up theImport wizard.

Browsing for a project or folder

5 To overwrite existing files, check theOverwrite existingresources without warning box.

346 Chapter 13 � Common Wizards Reference January 31, 2005

Page 372: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

6 To import only the selected folders, checkCreate selectedfolders only.

To import the selected folder and all sub folders, checkCreatecomplete folder structure.

7 Click Finish to import the selected resources.

GCC Coverage Data from ProjectTheGCC Coverage Data from Project option in theImport wizardlets you import code coverage data from applications that have beenrun outside of the IDE.

For example, in a self-hosted build environment, if you run a codecoverage enabled program from the command-line, it will write codecoverage data into aprogramname.da file in the same directory as theprogram’s code.

To import code coverage data:

1 In theImport wizard, chooseGCC Coverage Data fromProject and click theNext button.

The IDE displays theGCC Coverage Import panel.

January 31, 2005 Chapter 13 � Common Wizards Reference 347

Page 373: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Importing GCC coverage data

2 Enter a code coverage session name in theSession name field.

3 Enter a project name in theProject field, or click theBrowse. . .button to select a project.

4 Click Next to continue.

The IDE displays the next panel.

348 Chapter 13 � Common Wizards Reference January 31, 2005

Page 374: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

Referenced projects and comments

5 To include code coverage data from referenced projects, selectthem in theReferenced projects to include coverage datafrom list.

6 To include any comments with the new code coverage session(such as details about the data you’re importing), enter them intheComments for this coverage session field.

7 Click Finish to import the code coverage data as a new sessionin theCode Coverage Sessions view.

January 31, 2005 Chapter 13 � Common Wizards Reference 349

Page 375: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

QNX Board Support PackageTo copy a Board Support Package (BSP) into your workspace:

1 In theImport wizard, chooseQNX Board Support Packageand click theNext button.

The IDE displays theImport QNX BSP panel.

Importing a BSP

2 Select an installed BSP from theKnown Packages list.

350 Chapter 13 � Common Wizards Reference January 31, 2005

Page 376: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

You can also enter the full path to a BSP archive (.zip file) intheFilename field, or click theSelect Package. . . button tobrowse to a BSP archive.

Click Next to continue.

The IDE displays theSelect Source Projects panel.

Selecting source projects from a BSP archive

3 All of the projects in the BSP archive are imported by default.Uncheck any projects you don’t need to import. ClickNext tocontinue.

January 31, 2005 Chapter 13 � Common Wizards Reference 351

Page 377: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

The IDE displays theSelect Working Set panel.

Selecting a working set from a BSP archive

4 To change the working set name for the imported projects, entera new working set name in theWorking Set Name field, orselect one from the drop-down list.

To change the project name prefix, enter a new prefix in theProject Name Prefix field. This will be prepended to the nameof each project imported from the BSP archive.

352 Chapter 13 � Common Wizards Reference January 31, 2005

Page 378: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

To change the destination directory for the projects, enter a newpath in theDirectory for Projects field, or click theBrowse. . .button to select one. The default is your IDE workspace.

Click Finish to import the BSP projects.

The IDE imports the selected projects from the BSP archiveand displays theBuild Projects dialog.

Building BSP projects

5 Click Yes to build all of the BSP projects that were justimported. ClickNo to return to the IDE.

QNX mkifs BuildfileThe IDE can import the.build files used bymkifs into an existingSystem Builder project.

To import amkifs .build file:

1 In theImport wizard, chooseQNX mkifs Buildfile and clicktheNext button.

The IDE displays theImport mkifs Buildfile panel.

January 31, 2005 Chapter 13 � Common Wizards Reference 353

Page 379: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Importing a mkifs .build file

2 Enter the full path to amkifs .build file in theSelect the fileto import field, or click theBrowse. . . button to select one.

3 Click theBrowse. . . button besideSelect the destinationproject to select a destination for this import.

The IDE displays theSelect System Builder Project dialog.

354 Chapter 13 � Common Wizards Reference January 31, 2005

Page 380: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

Selecting a destination System Builder project

4 Select one or more project, then clickOK.

The IDE imports the selected.build file’s System Builderconfiguration.

January 31, 2005 Chapter 13 � Common Wizards Reference 355

Page 381: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

QNX Source PackageTo copy a QNX Source Package into your workspace:

1 In theImport wizard, chooseQNX Source Package and clicktheNext button.

The IDE displays theImport QNX Source Package panel.

Importing a QNX Source Package

2 Select an installed source package from theKnown Packageslist.

356 Chapter 13 � Common Wizards Reference January 31, 2005

Page 382: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

You can also enter the full path to a source package (.zip file)in theFilename field, or click theSelect Package. . . button tobrowse to a source package.

Click Next to continue.

The IDE displays theSelect Source Projects panel.

Selecting source projects from a source package

3 All of the projects in the source package are imported bydefault. Uncheck any projects you don’t need to import. ClickNext to continue.

January 31, 2005 Chapter 13 � Common Wizards Reference 357

Page 383: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

The IDE displays theSelect Working Set panel.

Selecting a working set from a BSP archive

4 To change the working set name for the imported projects, entera new working set name in theWorking Set Name field, orselect one from the drop-down list.

To change the project name prefix, enter a new prefix in theProject Name Prefix field. This will be prepended to the nameof each project imported from the source package.

358 Chapter 13 � Common Wizards Reference January 31, 2005

Page 384: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

To change the destination directory for the projects, enter a newpath in theDirectory for Projects field, or click theBrowse. . .button to select one. The default is your IDE workspace.

Click Finish to import the projects.

The IDE imports the selected projects from the source packageand displays theBuild Projects dialog.

Building package projects

5 Click Yes to build all of the projects that were just imported.Click No to return to the IDE.

Team Project SetTeam project sets are a convenient way of distributing a collection ofprojects stored in a CVS server among members of your developmentteam. Create them with theExport wizard.

To import a team project set and the projects it references:

1 In theImport wizard, chooseTeam Project Set and click theNext button.

The IDE displays theImport a Team Project Set panel.

January 31, 2005 Chapter 13 � Common Wizards Reference 359

Page 385: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Importing a Team Project Set

2 To create a working set for the imported projects, check theCreate a working set containing the imported projects box,and enter a name for the working set in theWorking Set Namefield.

Click Finish to import the projects from the CVS repository.

360 Chapter 13 � Common Wizards Reference January 31, 2005

Page 386: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

Zip fileTo copy files and folders from a ZIP archive into an existing project inyour workspace:

1 In theImport wizard, chooseZip File and click theNextbutton.

The IDE displays theZip File panel.

Importing code from a ZIP archive

2 Enter the full path to the ZIP archive in theFrom zip file field,or click theBrowse. . . button to select a ZIP archive.

3 Use theFilter Types. . . , Select All andDeselect All buttons tocontrol which files will be imported.

January 31, 2005 Chapter 13 � Common Wizards Reference 361

Page 387: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

Click a directory on the left panel to see a list of files in theright panel.

The Select Types dialog lets you filter imported files by selecting one

or more extensions.

4 Enter the name of a project or folder in theInto folder field, orclick theBrowse. . . button to select one.

362 Chapter 13 � Common Wizards Reference January 31, 2005

Page 388: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Importing projects

This project or folder must already exist before you bring up theImport wizard.

Browsing for a project or folder

5 To overwrite existing files, check theOverwrite existingresources without warning box.

January 31, 2005 Chapter 13 � Common Wizards Reference 363

Page 389: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Importing projects 2005, QNX Software Systems Ltd.

6 To import only the selected folders, checkCreate selectedfolders only.

To import the selected folder and all sub folders, checkCreatecomplete folder structure.

7 Click Finish to import the selected resources.

364 Chapter 13 � Common Wizards Reference January 31, 2005

Page 390: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Chapter 14

Launch Configurations Reference

In this chapter. . .What is a launch configuration? 367Types of launch configurations 367Running and debugging the first time369Running and debugging subsequent times373Setting execution options 375

January 31, 2005 Chapter 14 � Launch Configurations Reference 365

Page 391: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 392: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. What is a launch configuration?

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

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 alaunchconfigurationto define which programs to launch, the command-lineoptions to use, and what values to use for environment variables. Theconfigurations also define which special tools to run with yourprogram (e.g. Code Coverage tool).

The IDE saves your launch configurations so you can quicklyreproduce the particular execution conditions of a setup you’ve donebefore, no matter how complicated.

Each launch configuration specifies a single program running on asingle target. If you want to run your program on a different target,you can copy and modify an existing launch configuration. And youcan use the same configuration for both running and debugging yourprogram, provided that your options are the same.

Types of launch configurationsThe IDE supports these types of launch configurations:

January 31, 2005 Chapter 14 � Launch Configurations Reference 367

Page 393: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Types of launch configurations 2005, 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 machineis also your target). You’ll have full debuggercontrol and can use the Application Profiler,Memory Trace, and Code Coverage tools. Yourtarget must be runningqconn.

C/C++ QNX PDebug (Serial)

If you can access your target only via a serialconnection, select this configuration. Rather thanuseqconn, the IDE uses the serial capabilities ofgdb andpdebug directly. This option is availableonly when you selectDebug.

C/C++ Local If you’re developing on a self-hosted system, youmay create a C/C++ Local launch configuration.You don’t need to useqconn; the IDE launchesyour program throughgdb.

C/C++ Postmortem debugger

If your program produced a dump file (via thedumper utility) when it faulted, you can examinethe state of your program by loading it into thepostmortem debugger. This option is available onlywhen you selectDebug. When you debug, you’reprompted to select a dump file.

PhAB Application

If you wish to run a PhAB application, follow thesteps for creating a C/C++ QNX QConn (IP) launchconfiguration.

The main difference between the C/C++ QNX QConn (IP) launchconfigurations and the other types is that the C/C++ QNX QConn (IP)type supports the runtime analysis tools (Profiler andMemoryTrace).

368 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 394: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Running and debugging the first time

Running and debugging the first timeYou can use the same launch configuration to run or debug a program.Your choices in the Launch Configurations dialog may cause subtlechanges 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.

TheRun andDebug menu items appear in the C/C++ Developmentperspective by default, but they may not appear in all perspectives.You’ll need theRun→Run. . . menu item in order to set up a launchconfiguration. To bring the menu item into your current perspective:

1 From the main menu, selectWindow→CustomizePerspective.

2 In the left pane, selectOther→Launch.

3 Check theLaunch box.

4 Click OK.

Debugging a program the first timeTo create a launch configuration in order to debug a program for thefirst time:

1 In the C/C++ Projects view (or the Navigator view), select yourproject.

2 From the main menu, selectRun→Debug. . . (or, click theDebug icon and selectDebug. . . from the dropdown menu):

January 31, 2005 Chapter 14 � Launch Configurations Reference 369

Page 395: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Running and debugging the first time 2005, QNX Software Systems Ltd.

3 Select a launch configuration type:

370 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 396: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Running and debugging the first time

If you’re connecting to your target via IP, selectC/C++ QNXQConn (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 executionoptions” section in this chapter for details about each tab.

7 Click Debug. You can now launch and debug your program.

You can also use theDebug As menu item to conveniently select aparticular launch configuration:

Running a program the first timeWhen you configure a program to run, you should also configure it todebug 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 “Debugginga program the first time”), with the following changes:

� Instead of selectingRun→Debug from the main menu,selectRun→Run. . . (or, click theRun icon and selectRun. . . from the dropdown menu):

January 31, 2005 Chapter 14 � Launch Configurations Reference 371

Page 397: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Running and debugging the first time 2005, QNX Software Systems Ltd.

� Instead of clickingDebug when you’re done, clickRun.

� Instead of running under the control of a debugger, yourprogram simply runs.

You can also use theRun As menu item to conveniently select aparticular launch configuration:

The IDE also lets you run a program without creating a launchconfiguration, but the program’s output doesn’t appear in the Consoleview.

To run a program without using the launcher:

372 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 398: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Running and debugging subsequent times

1 After building the program, drag the executable from theC/C++ Projects view to a target listed in the File SystemNavigator view. (To learn more about the view, see the“Moving files between the host and target” in the Building OSand Flash Images chapter.)

2 In the File System Navigator view, right-click your file andselectRun. When the dialog appears, clickOK. Your programruns.

Running and debugging subsequent timesOnce you’ve created a launch configuration, running or debugging aprogram is as easy as selecting that configuration. You can do this inseveral 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 programTo debug or run a program that you’ve created a launch configurationfor:

1 From the main menu, selectRun→Debug. . . or Run→Run. . . .

2 In the left pane, select the launch configuration you createdwhen you first ran or debugged your program.

3 Click Debug or Run.

Launching from a list of favoritesIf you have a program that you launch frequently, you can add it totheDebug or Run dropdown menu so you can launch it quickly.

January 31, 2005 Chapter 14 � Launch Configurations Reference 373

Page 399: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Running and debugging subsequent times 2005, QNX Software Systems Ltd.

To use this method, you must have selectedDisplay in favoriteswhen you first created your launch configuration. If you didn’t, edittheDisplay 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, selectRun→Run History.

� Run: Click the dropdown menu part of the run menu

button set .

� Debug: From the main menu, selectRun→Debug History.

� Debug: Click the dropdown menu part of the debug

menu button set .

You’ll see a list of all the launch configurations you specified intheDisplay in favorites menu:

374 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 400: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

2 Select your launch configuration.

Launching the last-launched programTo relaunch the last program you ran or debugged:

➤ PressF11 or click the Debug or Run dropdown button ( ),then selectyour launchconfiguration.

Setting execution optionsThe Launch Configurations dialog has several tabs:

� Main

� Arguments

� Environment

� Download

� Debugger

� Source

� Common

� Tools

All of these tabs appear when you select theC/C++ QNX QConn(IP) type of launch configuration; only some tabs appear when youselect the other types.

Main tabThis tab lets you specify the project and the executable that you wantto run or debug. The IDE might fill in some of the fields for you:

January 31, 2005 Chapter 14 � Launch Configurations Reference 375

Page 401: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Setting execution options 2005, QNX Software Systems Ltd.

Different fields appear in the Main tab, depending on the type ofconfiguration you’re creating. Here are descriptions of all the fields:

Project Enter the name of the project that contains the executableyou want to launch. You may also locate a project byclicking Browse. . . . You can create or edit launchconfigurations 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, anexecutable with a suffix ofg indicates it was compiledfor debugging. You may also locate an availableexecutable by clickingSearch. . . .

376 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 402: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

Target Options

1 If you don’t want the IDE to create a “pseudoterminal” on the target that sends terminal output tothe Console view on a line-by-line basis, then checktheDon’t use terminal emulation on target option.To use terminal emulation, your target must berunning thedevc-pty utility.

2 If you want to filter-out platforms that don’t matchyour selected executable, then set theFilter targetsbased on C/C++ Application selection on. Forexample, if you’ve chosen a program compiled forPPC, you’ll see only PPC targets and offline targets.

3 Select a target from the available list. If you haven’tcreated a target, click theAdd New Target button.For more information about creating a target, see theCommon Wizards Reference chapter.

General Options

If you’re creating aC/C++ QNX PDebug (Serial) launchconfiguration, then you’ll see theStop in main option,which is set on by default. This means that after you startthe debugger, it stops inmain()and waits for your input.

For serial debugging, make sure that the pseudo-terminalcommunications manager (devc-pty) is running.

Serial Port Options

Here you can specify the serial port (e.g.COM1 forWindows hosts;/dev/ser1 for Neutrino) and the baudrate, which you select from the dropdown list.

Arguments tabThis tab lets you specify the arguments your program uses and thedirectory where it runs.

January 31, 2005 Chapter 14 � Launch Configurations Reference 377

Page 403: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Setting execution options 2005, 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 ofmyProgram

-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 theentire contents together.

Working directory on target

The optionUse default working directory is set on by default.This means the executable will run in the/tmp directory onyour target. If you turn off this option, you can clickBrowse. . .to locate a different directory.

Environment tabThe Environment tab lets you set the environment variables andvalues to use when the program launches. For example, if you want toset the environment variable namedPHOTON to the value/dev/photon 2 when you run your program, use this tab. ClickNew to add an environment variable.

Download tabThe Download tab lets you tell the IDE whether to transfer anexecutable from the host machine to the target, or to select one thatalready resides on the target.

Executable field If you selectDownload executable to target, theIDE sends a fresh copy of the executable everytime you run or debug.

TheDownload directory on target field showsthe default directory of/tmp on your target. If youselect theUse executable on target option, you’llneed to specify a directory here. You can also usetheBrowse. . . button to locate a directory.

TheStrip debug information beforedownloading option is set on by default. Turn it

378 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 404: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

off if you don’t want the IDE to strip theexecutable you’re downloading to your target.

TheUse unique name option is set on by default.This means the IDE will make your executable’sfilename unique (e.g. append a number) duringeach download session.

Extra libraries TheExtra libraries pane lets you select the sharedlibraries your program needs. If you click theAutobutton, the IDE tries to automatically find thelibraries needed. If you clickFrom project, theIDE will look in your workspace for libraries.

You also have the option of not downloading anyshared libraries to your target.

By default, the IDE removes the files it has downloaded after eachsession. If you don’t want the IDE to “clean up” after itself, then turnoff the Remove downloaded components after session option.

Debugger tabThe Debugger tab lets you configure how your debugger works. Thecontent in the Debugger Options pane changes depending on the typeof debugger you select:

January 31, 2005 Chapter 14 � Launch Configurations Reference 379

Page 405: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Setting execution options 2005, QNX Software Systems Ltd.

The settings in the Debugger tab affect your executable only whenyou debug it, not when you run it.

Generic debugger settings

Debugger The debugger dropdown list includes the availabledebuggers for the selected launch-configuration type.The list also varies depending on whether you’redebugging a remote or a local target.

Run program in debugger/Attach to running process

Most of the time, you’ll want to chooseRun programin debugger. If you click Attach to running process,you’re prompted to select a process from a list at runtime. Note the following limitations:

� You can’t use the Memory Trace tool.

380 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 406: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

� The console output isn’t available in the Consoleview.

Stop at main() on startup

This option is set on by default. If you turn it off, theprogram runs until you interrupt it manually, or until ithits a breakpoint.

Automatically track the values of variables.

Enable this option if you want the system to trackeveryvariable as you step through your program. Disable theoption if you want tomanuallyselect individualvariables to work with in the Variables view in thedebugger (see the Debugging Your Programs chapter).

Debugger Options

GDB command file

This field lets you specify a file for runninggdb using the-command option (see theUtilities Reference).

Load shared library symbols automatically

This option (on by default) lets you watch line-by-line steppingof library functions in the C/C++ Editor. You may wish to turnthis option off if your target doesn’t have much memory; thelibrary symbols take up RAM on the target.

You can use the pane to select specific libraries or use theAutobutton to have the IDE attempt to select your libraries.

Stop on shared library events

Choose this option if you want the debugger to breakautomatically when a shared library or DLL is loaded orunloaded.

January 31, 2005 Chapter 14 � Launch Configurations Reference 381

Page 407: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Setting execution options 2005, QNX Software Systems Ltd.

Source tabThe Source tab lets you specify where the debugger should look forsource files. By default, the debugger uses the source from yourproject in your workspace, but you can specify source from otherlocations (e.g. from a central repository).

To specify a new source location:

1 On the Source tab, clickAdd. . . . The Add Source Locationdialog appears. You may choose to add the source either fromyour workspace or elsewhere:

1a If you wish to add source from your workspace, selectExisting Project Into Workspace, click Next, selectyour project, then clickFinish.

1b If you wish to add source from outside your workspace,selectFile System Directory, then clickNext.

2 Type the path to your source in theSelect location directoryfield or use theBrowse button to locate your source.

If you want to specify a mapping between directories, choosetheAssociate with option and enter the directory in theavailable field. For example, if your program was built in theC:/source1 directory and the source is available in theC:/source2 directory, enterC:/source2 in the first field andassociate it withC:/source1 using the second field.

If you want the IDE to recurse down the directories you pointedit at to find the source, then choose theSearch subfoldersoption.

3 Click Finish. The IDE adds the new source location.

Common tabThe Common tab lets you define where the launch configuration isstored, how you access it, and what perspective you change to whenyou launch.

382 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 408: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

Type of launch configuration

When you create a launch configuration, the IDE saves it as a.launch file. If you selectLocal, the IDE stores theconfiguration in one of its own plugin directories. If you selectShared, you can save it in a location you specify (such as inyour project). Saving asShared lets you commit the.launchfile to CVS, which allows other to run the program using thesame configuration.

Perspective to switch to or open when launched in

You can tell the IDE which perspectives to change to when yourun or debug. You can specify the perspectives, or simply setthem toDefault. To determine the default perspectives for bothrunning and debugging, selectWindow→Preferences from themain menu and selectDebug from the left pane.

Display in favorites

You can have your launch configuration displayed when youclick the Run or Debug dropdown menus in the toolbar. To doso, check the Run or Debug options under theDisplay infavorites menu heading.

Tools tabThe Tools tab lets you add runtime analysis tools to the launch. To dothis, click theAdd/Delete Tool button at the bottom of the tab:

January 31, 2005 Chapter 14 � Launch Configurations Reference 383

Page 409: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Setting execution options 2005, QNX Software Systems Ltd.

You can add the following tools (some launch options affect whichtools are available):

Application Profiler

Lets you count how many times functions are called, who calledwhich functions, and so on. For more on this tool, see theProfiling Your Application chapter.

Memory Trace

Lets you track memory errors. For more on this tool, see theFinding Memory Errors chapter.

Code Coverage

Lets you measure what parts of your program have run, andwhat parts still need to be tested. For more on this tool, see theCode Coverage chapter.

384 Chapter 14 � Launch Configurations Reference January 31, 2005

Page 410: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Setting execution options

If you want the IDE to open the appropriate perspective for thetool during the launch, then checkSwitch to this tool’sperspective on launch.

January 31, 2005 Chapter 14 � Launch Configurations Reference 385

Page 411: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 412: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Appendix A

Tutorials

In this appendix. . .Before you start. . . 389Tutorial 1 — creating a standard make C/C++ project389Tutorial 2 — creating a QNX C/C++ project 392Tutorial 3 — importing an existing project into the IDE 394Tutorial 4 — importing a QNX BSP into the IDE 395

January 31, 2005 Appendix: A � Tutorials 387

Page 413: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 414: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Before you start. . .

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

Here are several tutorials to help you get going with the IDE.

Before you start. . .Before you begin the tutorials, we recommend that you firstfamiliarize yourself with the IDE’s components and interface byreading the IDE Concepts chapter.

You might also want to look at the core Eclipse basic tutorial on usingthe workbench in theWorkbench User Guide(Gettingstarted→Basic tutorial).

Tutorial 1 — creating a standard makeC/C++ projectIn this tutorial, you’ll create a simple, standard make project (i.e. aproject that doesn’t involve the QNX multivariant makefile structure).

You use theNew Project wizard whenever you create a new project inthe IDE. Follow these steps to create a simple “hello world” project:

1 To open the New Project wizard, selectFile→New→Project. . .from the main menu of the workbench.

January 31, 2005 Appendix: A � Tutorials 389

Page 415: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 1 — creating a standard make C/C++ project 2005, QNX Software Systems Ltd.

2 In the wizard’s left pane, selectC (or C++). In the right pane,select Standard Make C (or C++) Project, then click Next:

3 Name your project (e.g. “MyFirstProject”), then clickFinish. The IDE has now created a project structure.

4 Now you’ll create a makefile for your project. In the Navigatorview (or the C/C++ Projects view — it doesn’t matter which),highlight your project:

390 Appendix: A � Tutorials January 31, 2005

Page 416: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 1 — creating a standard make C/C++ project

5 Click theCreate a File button on the toolbar:

6 Name your file “Makefile” and clickFinish. The editorshould 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

UseTab characters to indent commands inside ofmake rules,notspaces.

7 When you’re finished editing, save your file (right-click, thenselectSave, or click the Save button in the tool bar).

January 31, 2005 Appendix: A � Tutorials 391

Page 417: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 2 — creating a QNX C/C++ project 2005, QNX Software Systems Ltd.

8 Finally, you’ll create your “hello world” C (or C++) source file.Again, open a new file calledhello.c, which might looksomething 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 projectin the IDE.

For instructions on building your program, see the section “Buildingprojects” in the Developing C/C++ Programs chapter.

In order to run your program, you must first set up aNeutrino targetsystem. For details, see:

� the Preparing Your Target chapter

� the section “Running projects” in the Developing C/C++ Programschapter.

Tutorial 2 — creating a QNX C/C++ projectUnlike standard make projects, a QNX project relies on the QNXrecursive makefile hierarchy to support multiple CPU targets. (Formore on the QNX recursive makefile hierarchy, see the Conventionsfor Makefiles and Directories appendix in theProgrammer’s Guide.)

Follow these steps to create a simple QNX C (or C++) “hello world”project:

1 In the C/C++ Development perspective, click theNew QNX CProject (or New QNX C++ Project) button in the toolbar:

392 Appendix: A � Tutorials January 31, 2005

Page 418: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 2 — creating a QNX C/C++ project

The New Project wizard appears.

2 Name your project, then select thetype(e.g.Application):

3 Click Next – but don’t pressEnter! (PressingEnter at this pointamounts to clicking the Finish button, which will cause the IDEto create the project forall CPU variants, which you may notwant.)

4 In the Build Variants tab, check the build variant that matchesyour target type, such as X86 (Little Endian), PPC (BigEndian), etc. and the appropriate build version (Release orDebug).

5 Click Finish. The IDE creates your QNX project and displaysthe source file in the editor.

Congratulations! You’ve just created your first QNX project.

For instructions on building your program, see the section “Buildingprojects” in the Developing C/C++ Programs chapter.

January 31, 2005 Appendix: A � Tutorials 393

Page 419: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 3 — importing an existing project into the IDE 2005, QNX Software Systems Ltd.

In order to run your program, you must first set up aNeutrino targetsystem. For details, see:

� the Preparing Your Target chapter

� the section “Running projects” in the Developing C/C++ Programschapter.

Tutorial 3 — importing an existing projectinto the IDEIn this tutorial, you’ll use the IDE’sImport wizard, which lets youimport existing projects, files, even files from ZIP archives into yourworkspace.

You can use various methods to import source into the IDE. Fordetails, see the chapter Managing Source Code.

Follow these steps to bring one of your existing C or C++ projectsinto the IDE:

1 SelectFile→Import. . . to bring up theImport wizard.

2 In theImport wizard, chooseExisting Project intoWorkspace and click theNext button.

The IDE displays theImport Project From Filesystem panel.

3 Enter the full path to an existing project directory in theProjectcontents field, or click theBrowse. . . button to select a projectdirectory using the file selector.

4 Click theFinish button to import the selected project into yourworkspace.

Congratulations! You’ve just imported one of your existing projectsinto the IDE.

394 Appendix: A � Tutorials January 31, 2005

Page 420: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 4 — importing a QNX BSP into the IDE

Tutorial 4 — importing a QNX BSP into theIDEQNX BSPs and other source packages are distributed as.zip

archives. The IDE lets you import both kinds of packages into theIDE:

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 libraryproject.

For more information on System Builder projects, see the chapterBuilding OS and Flash Images.

Step 1: Use File→Import. . .You import a QNX source archive using the standard Eclipse importdialog:

January 31, 2005 Appendix: A � Tutorials 395

Page 421: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 4 — importing a QNX BSP into the IDE 2005, 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 containssource code, the two types are structured differently and will generatedifferent types of projects. If you try to import a BSP archive as aQNX Source Package, the IDE won’t create a System Builder project.

396 Appendix: A � Tutorials January 31, 2005

Page 422: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 4 — importing a QNX BSP into the IDE

Step 2: Select the packageAfter you choose the type of package you’re importing, the wizardthen 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 thatpackage is displayed.

To add more packages to the list:

1 Click theSelect Package. . . button.

January 31, 2005 Appendix: A � Tutorials 397

Page 423: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 4 — importing a QNX BSP into the IDE 2005, QNX Software Systems Ltd.

2 Select the.zip source archive you want to add.

Step 3: Select the source projectsEach source package contains several components (orprojectsto usethe IDE term). For the package you selected, the wizard then givesyou 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

398 Appendix: A � Tutorials January 31, 2005

Page 424: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 4 — importing a QNX BSP into the IDE

default). Again, as you highlight a component, you’ll see itsdescription in the bottom pane.

Step 4: Select a working setThe last page of the import wizard lets you name your sourceprojects. You can specify:

� Working Set Name — to group all related imported projectstogether as a set

� Project Name Prefix — for BSPs, this becomes the name of theSystem Builder project; for other source projects, this prefix allowsthe same source to be imported several times without any conflicts.

January 31, 2005 Appendix: A � Tutorials 399

Page 425: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 4 — importing a QNX BSP into the IDE 2005, QNX Software Systems Ltd.

If you plan to import a source BSPanda binary BSP into the IDE,remember to give each project a different name.

Step 5: BuildWhen you finish with the wizard, it creates all the projects and bringsin the sources from the archive. It will then ask if you want to buildall the projects you’ve just imported.

400 Appendix: A � Tutorials January 31, 2005

Page 426: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Tutorial 4 — importing a QNX BSP into the IDE

If you answerYes, the IDE will begin the build process, which maytake several minutes (depending on how much source you’veimported).

If you decide not to build now, you can always do aRebuild All fromthe main toolbar’sProject menu at a later time.

If you didn’t import all the components from a BSP package, you canbring in the rest of them by selecting the System Builder project andopening the import wizard (right-click the project, then selectImport. . . ). The IDE detects your selection and then extends theexisting BSP (rather than making a new one).

QNX BSP Perspective

When you import a QNX Board Support Package, the IDE opens theQNX BSP Perspective. This perspective combines the minimumelements from both the C/C++ Development Perspective and theSystem Builder Perspective:

January 31, 2005 Appendix: A � Tutorials 401

Page 427: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Tutorial 4 — importing a QNX BSP into the IDE 2005, QNX Software Systems Ltd.

Congratulations! You’ve just imported a QNX BSP into the IDE.

402 Appendix: A � Tutorials January 31, 2005

Page 428: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Appendix B

Where Files Are Stored

January 31, 2005 Appendix: B � Where Files Are Stored 403

Page 429: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 430: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

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

You can specify where you want yourworkspace folder to reside.For details, see the section “Running Eclipse” in the Tasks chapter oftheWorkbench User Guide. (To access the guide, openHelp→HelpContents, then selectWorkbench User Guidefrom the list.)

January 31, 2005 Appendix: B � Where Files Are Stored 405

Page 431: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 432: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Appendix C

Utilities Used by the IDE

January 31, 2005 Appendix: C � Utilities Used by the IDE 407

Page 433: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 434: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

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)

January 31, 2005 Appendix: C � Utilities Used by the IDE 409

Page 435: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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 andconfigurations

� qconn — Provide service support to remote IDE components

� QWinCfg — Query and display QNX installations andconfigurations

� sendnto — Send an OS image to a target over a serial or parallelport (QNX4)

� strip — Remove unnecessary information from executable files(POSIX)

� tracelogger — Log tracing information

� usemsg — Change the usage message for a command (QNXNeutrino)

410 Appendix: C � Utilities Used by the IDE January 31, 2005

Page 436: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Appendix D

Migrating to the 6.3 Release

In this appendix. . .Introduction 413From 6.2.1 to 6.3.0 414From 6.2.0 to 6.3.0 417

January 31, 2005 Appendix: D � Migrating to the 6.3 Release 411

Page 437: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 438: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Introduction

About ThisGuide

IDE Concepts

ManagingSource Code

DebuggingPrograms

FindingMemory Errors

Profiling anApplication

AnalyzingYour System

Tutorials

LaunchConfigurations

Migrating to6.3

GettingStarted Development

Running &Debugging

ProgramAnalysis

Target SystemAnalysis

Reference material

Where FilesAre Stored

BuildingOS and Flash

Images

DevelopingC/C++

Programs

DevelopingPhoton

Applications

PreparingYour Target

CommonWizards

Using CodeCoverage

GettingSystem

Information

Utilities Usedby the IDE

You can easily migrate your old workspace and projects to this release.

IntroductionUpgrading from a previous version of the IDE involves two basicsteps:

Step 1 — converting your development workspace to be compliantwith the latest version of the IDE framework. The IDE performs thisprocess automatically at startup when it detects an older workspaceversion.

You can redirect the IDE to point at different workspaces simply byrunning this command:

qde -data path to workspace

Step 2 — converting your individual projects. Depending on whichversion 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.

January 31, 2005 Appendix: D � Migrating to the 6.3 Release 413

Page 439: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

From 6.2.1 to 6.3.0 2005, QNX Software Systems Ltd.

From 6.2.1 to 6.3.0Migrating your workspace

This conversion is a one-way process. Although your data files willremain intact, you won’t be able to use this workspace with earlierversions of the IDE.

1 Start the IDE pointing at your 6.2.1 workspace. You’ll see asplash page (“Please wait — Completing the install”), followedby theDifferent Workspace Version dialog:

2 Click OK to convert your workspace.

3 If a System Builder project exists in your workspace, theMigrate Project dialog is displayed:

Click Yes to update your System Builder project, orNo to leaveit in the 6.2.1 format. You won’t be able to use the project withthe 6.3 IDE unless you update it.

4 Next theWorkbench Layout dialog tells you that the layout ofsome of the views and editors can’t be restored:

414 Appendix: D � Migrating to the 6.3 Release January 31, 2005

Page 440: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. From 6.2.1 to 6.3.0

This is to be expected, because we’re upgrading the minorversion of installed components, so there may be some UIadjustments. ClickOK.

Now you’re ready to migrate your existing projects to 6.3.0.

Migrating your projectsIf the 6.3.0 IDE detects any 6.2.1 C/C++ standard make projects atstartup, you’ll be prompted to convert these projects to the newformat:

You must run this conversion process overeach 6.2.1 projectso it cantake full advantage of the new features of the C/C++ DevelopmentTools.

QNX C/C++ projects areautomaticallyconverted to the new projectformat.

January 31, 2005 Appendix: D � Migrating to the 6.3 Release 415

Page 441: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

From 6.2.1 to 6.3.0 2005, QNX Software Systems Ltd.

Running the conversion wizard

At startup, the conversion wizard automatically checks for projects toconvert. Note that you can convert older projects that were never inthe workspace (e.g. projects you’ve brought in via a revision controlsystem).

You can access theMake Project Migration wizard at any time:

➤ OpenWindow→Customize Perspective. . . →Other→UpdateMake Projects

The IDE will then add an icon (Update Old Make Project) to thetoolbar so you can launch the conversion wizard. The icon is activatedwhenever you select projects that are candidates for conversion.

The conversion wizard looks like this:

416 Appendix: D � Migrating to the 6.3 Release January 31, 2005

Page 442: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. From 6.2.0 to 6.3.0

From 6.2.0 to 6.3.01 Start the IDE pointing at your 6.2.0 workspace. You’ll see a

splash page (“Please wait — Completing the install”), followedby theDifferent Workspace Version dialog:

January 31, 2005 Appendix: D � Migrating to the 6.3 Release 417

Page 443: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

From 6.2.0 to 6.3.0 2005, QNX Software Systems Ltd.

2 Click OK to convert your workspace.

3 Next theCannot Preserve Layout dialog tells you that thesaved interface layout can’t be preserved:

This is to be expected, because we’re upgrading the major,incompatible versions of installed components and of theworkspace itself. ClickOK.

Now you’re ready to migrate your existing projects to 6.3.0.

Migrating your projectsThe format of 6.2.0 C/C++ projects (include QNX projects) isincompatible with the 6.3.0 format — you must follow these steps toconvert 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 typeof project it was originally stored as:

� Standard C/C++ projects (which are based on an externalbuild configuration such as aMakefile)

418 Appendix: D � Migrating to the 6.3 Release January 31, 2005

Page 444: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. From 6.2.0 to 6.3.0

� QNX C/C++ projects (which are based specifically on theQNX multiplatformMakefile 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.0Projects

2 Go through this conversion process foreach 6.2.0 projectso itcan take full advantage of the new features of the C/C++Development Tools. You must also do this for any projects thatare stored outside your workspace (e.g. in a revision controlsystem).

Many project options have changed from QNX 6.2.0 to QNX 6.3.0.Although the conversion process will attempt to maintainconfiguration options, you should verify your individual project filesto make sure any new settings have been initialized to the values youwant.

January 31, 2005 Appendix: D � Migrating to the 6.3 Release 419

Page 445: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 446: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Glossary

January 31, 2005 Glossary 421

Page 447: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 448: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, 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 normalpointer changes into a different image to indicate where you can dockthe view.

Eclipse

Name of a tools project and platform developed by an openconsortium of vendors (Eclipse.org), including QNX SoftwareSystems.

The QNX Developer Tools Suite consists of a set of special pluginsintegrated into the standard Eclipse framework.

editors

Visual components within theworkbench that let you edit or browsea resource such as a file.

navigator

One of the mainviews in theworkbench, the Navigator shows you ahierarchical view of your availableresources.

outline

A view that shows a hierarchy of items, as the functions and headerfiles used in a C-language source file.

perspectives

Visual “containers” that define which views and editors appear in theworkspace.

January 31, 2005 Glossary 423

Page 449: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

plugins

In the context of the Eclipse Project, plugins are individual tools thatseamlessly integrate into the Eclipse framework. QNX SoftwareSystems and other vendors provide such plugins as part of their IDEofferings.

profiler

A QNX perspective that lets you gather sample “snapshots” of arunning process in order to examine areas where its performance canbe improved. This perspective includes a Profiler view to see theprocesses selected for profiling.

project

A collection of related resources (i.e. folders and files) for managingyour 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, resourcesare the memory, CPU, and other system components available for arunning process to use.

script

A special section within a QNX buildfile containing the commandlines 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 asoftwareterm, refers to the file that themake command examinesand updates during a build process. Sometimes called a “make target.”

424 Glossary January 31, 2005

Page 450: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd.

As ahardwareterm, refers to the Neutrino-based PC or embeddedsystem that’s connected to the host PC during cross-development.

tasks

A view showing the resources or the specific lines within a file thatyou’ve marked for later attention.

UI

User interface.

views

Alternate ways of presenting the information in your workbench. Forexample, in the QNX System Informationperspective, you haveseveral views available: Memory Information, Malloc Information,etc.

workbench

The Eclipse UI consisting ofperspectives, views, andeditors forworking with yourresources.

January 31, 2005 Glossary 425

Page 451: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287
Page 452: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index

!

.bsh file (System Builder) 143

.efs file (System Builder) 151

.ifs file (System Builder) 150

.kev files (System Profiler) 290

.launch file 383

.project file 153

.sysbldr meta file 153

.zip archives 90/dev/dbgmem 248

A

Add New Target 180advanced mode (Properties

dialog) 336using to override regular

options 336Allocation Trace tab (Memory

Events view) 245, 251analysis tools

specifying for launch 384Application Profiler 195–214

specifying for launch 384Application Profiler Editor 209

colors used in 209Application Profiler perspective

configuring the IDE toautomatically change to202

Arguments pane (ProcessInformation view) 274

Arguments tab (launchconfigurations dialog)375, 377

assumptions in this guide xxiiiautobuild

turning off 40

B

binariesseeing usage messages for 142

Binary Inspector view 140, 142Binary Parser tab (New Project

wizard) 324block coverage 217

January 31, 2005 Index 427

Page 453: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

defined 218bookmarks

for Help documents 9Bookmarks view 291boot order 145boot script 148boot scripts 143branch coverage 217

currently not provided in theIDE 218

defined 218breakpoints 119–126

removing 126BSP

importing source into theIDE 90

perspective 96BSPs

buildfiles ship with 143filename conventions in 149

buildall projects 42automatic feature 40configurations 82CPULIST 44executables with code coverage

enabled 220options 44order of projects 43saving resources before 42single projects 42terminology 40turning off the autobuild

feature 40variants 39

Build Command field (New Projectwizard) 321

Build Setting field (New Projectwizard) 321

Build Variants tab (New Projectwizard) 318

buildfiledefined 143importing a 155

C

C projectstandard make, as distinct from a

QNX multivariant project13

C++ libraryselecting a 332

C-Build view 40C/C++ Development

perspective 33–61C/C++ Local launch

configuration 368C/C++ Postmortem debugger launch

configuration 368C/C++ Projects view 33, 34

adding standard includes anddefines 62

compared with Navigatorview 35

C/C++ QNX PDebug (Serial) launchconfiguration 368

C/C++ QNX QConn (IP) launchconfiguration 368

C/C++ Editor 48–55adding comments to code in 52color 53

428 Index January 31, 2005

Page 454: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

debugging from 114font 53line numbers 53preferences 53

C/C++ Editor view 33call counts See alsocall pairscall pairs 213Calls Made pane (Malloc

Information view) 256case

don’t use to distinguish a projector file 13

channelsshown in the System Blocking

Graph view 279clean (build term) 40code coverage 217–229

block coverage 217branch coverage 217combining sessions 225defined 217enabling 220for non-QNX projects 220icons 225IDE tool is a visual font end to

gcov 217line-by-line information 226markers 227measures quality of tests 217scan interval 223should be set for only one build

variant at a time 220summary report 229viewing reports in a

browser 229Code Coverage Report view 227Code Coverage Sessions view 224

code coverage toolspecifying for launch 384

coexistence of OS versions 17color

in the C/C++ Editor 53colors

for signals 279combined image 148, 151comments

adding to code inC/C++ Editor 52

Common tab (launch configurationsdialog) 375, 382

common.mk filetoggle to reveal hidden internal

code 311communications

IP 23serial 23

compileroptimization levels 330selecting type of 330specifying command-line

options 331specifying defines to be passed

to 330warning levels 330

Compiler tab (Propertiesdialog) 330

Condition Statistics view 291Connection Information view 267,

281Console view (Debugger) 133containers

build configurationscreating 85editing 86

January 31, 2005 Index 429

Page 455: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

build configurations for 85building 89creating 82defined 82editing configurations for 86seeing tree-view of 86

Content Assist 49conventions

for filenames in QNXBSPs 149

for filenames in the SystemBuilder 150

POSIX/UNIX filesystem xxivconversion wizard 327Core Requests pane (Malloc

Information view) 256CPULIST 44CVS

default source-managementsystem in the IDE 67

CVS Repositories view 70CVS Repository Exploring

perspective 68

D

dbgmallog g.so 246DDK

importing source into theIDE 91

debugagent 25

Debug perspectiveviews in 116

Debug view 109

selections in drive otherviews 109

Debug/Release modefor adding extra libraries (Linker

tab in Properties dialog)334

debugger 105–135options in launch

configuration 381specifying source locations

for 382Debugger tab (launch configurations

dialog) 375, 379debugging

assembly-languagefunctions 115

building an executable for 106controls for 110session

controlling a 114several programs

simultaneously 105via C/C++ editor 114via hotkeys 112without the Debug view 112

devc-pty 377Dietician (System Builder) 176disassembly mode (Debugger) 115Distribution pane (Malloc

Information view) 256Download tab (launch configurations

dialog) 375, 378drag-and-drop 70, 97dumper command 409

430 Index January 31, 2005

Page 456: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

E

Eclipseconsortium 3documentation on using CVS in

the IDE 68Platform 3

editorC/C++ 48, 61Content Assist feature 49defined 11enhanced source navigation 61jumping to function source

(F3) 61opening headers (Ctrl – Shift –

o) 61System Builder 140

editor (System Profiler) 290editors

alternatearen’t integrated with rest of

IDE 11inside the IDE 11, 54outside the IDE 11, 54

Element Statistics view 291Environment tab (launch

configurations dialog)375, 378

environment variablesCPULIST 44MAKEFLAGS 19QNX CONFIGURATION 17,

19QNX HOST 19QNX TARGET 19setting in launch configurations

dialog 378

TMPDIR 19Environment Variables pane (Process

Information view) 274Error events tree 249error log file 405Error Parsers tab (New Project

wizard) 322errors

markers used to indicate 56Event backtrace pane 251executable

sending fresh copy of wheneveryou run or debug 378

stripping debug informationbefore downloading 379

unique name of for eachdownload session 379

executablesbuilding for debugging 106

Export wizard 97expressions

evaluating/examining in thedebugger 126

Expressions view 126extra libraries

adding to launchconfiguration 379

F

F3 (jump to function source) 61FDs

side channels shown for 282file

locations in workspace 405

January 31, 2005 Index 431

Page 457: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

File System Navigator view 179Add New Target option 180

filename conventionsin QNX BSPs 149in the System Builder 150

filesassociations with editors 54bringing into a project

folder 311created outside the IDE 311creating from scratch 55exporting 97filtering 36host-specific 19IDE removes from target after

downloading 379importing 70moving between host and target

machines 179opening 35opening headers 61target-specific 19

Filesystem pane (SystemBuilder) 140

flash filesystemappending to an OS image 173

flashcmp command 409font

in the C/C++ Editor 53functions

finishing names of in theeditor 49

jumping to source for 61

G

gcc command 409gcov command 409GDB

using directly from theIDE 135

gdb command 409General Resources display (System

Resources view) 283General Statistics view 291gmon.out file 198

importing a 205gprof command 409

H

heap usage 243hello world 38

running 46Help

creating bookmarks in 9HTML server within the IDE 7navigating 7tips and tricks 9

helphover for function synopsis 51

History pane (Malloc Informationview) 257

hostshost-specific files, location

of 19hovering (in System Profiler

editor) 304

432 Index January 31, 2005

Page 458: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

I

icc command 409icons

in Code Coverage Sessionsview 225

IDEconvenience of 3help system 7migrating to the current

version 413starting via icon or menu

item 4starting via theqde

command 4IDE User’s Guide

how to use xxiIdentification Details pane (Process

Information view) 274image

adding files to 163booting 145combined 148combines 151downloading a 157final format of 173flash filesystem 148, 151OS 148, 150properties of 166types of in System Builder 148

Image Combine (SystemBuilder) 172

Images directory 153Images pane (System Builder) 140Import wizard 70include paths

adding standard includes anddefines 62

specifying 331instrumented kernel 292IOFlags column (Connection

Information view) 282IP communications 23IPL 146

adding to an image 172

K

kernelinstrumented 292

keyboard shortcuts 15

L

launch configurations 45, 367–385creating for debugging 369creating for running 371dialog 375

tabs in 375for a debuggable

executable 108list of favorites 373, 383not automatically deleted when

you delete associatedprojects 48

types of 367launcher 15

running a program without 372launches

old

January 31, 2005 Index 433

Page 459: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

removing 208ld command 409LD PRELOAD 247libraries

buttons for adding (Linker tab inProperties dialog) 334

how to build 315optimizing in System

Builder 176shared 316shared without export 316specifying locations of for the

linker 333static 315static for shared objects 316

line numbershow to show them in the

C/C++ Editor 53link map

generating a 332linked resources 70linker

command-line options 333Linker tab (Properties dialog) 331log files (System Profiler) 290

M

Main tab (launch configurationsdialog) 375

make

targetsadding 44removing 45

Make Builder tab (New Projectwizard) 320

make command 409Make Project Migration wizard 416makefile

recursive hierarchy 38MAKEFLAGS 19Malloc Information view 242, 243,

253, 254, 267MALLOC DEBUG 248MALLOC EVENTFILE 248MALLOC TRACE 248markers

for errors 56memory

changing a process’s 129errors 233–260events 243

filtering 253leaks 242management 234

Memory Event Action 245Memory Events view 242, 243, 249Memory Information view 243,

253, 258, 267Memory Resources display (System

Resources view) 284Memory Trace 241Memory Trace tool

launching a program touse 244

manuallylaunching a programto use 246

specifying for launch 384Memory view

customizing 131Memory view (Debugger) 128

434 Index January 31, 2005

Page 460: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

migratinginvolves two steps 413to the current version of the

IDE 413–419mkefs 140mkefs command 409mkifs 140mkifs command 409mkimage command 409mkrec command 409mksbp 140mksbp command 409multivariant project

as distinct from a standard makeC project 13

N

natures 13Navigator view 33

compared with C/C++ Projectsview 35

New Project wizard 38, 311tabs in 318

New QNX Target System Projectwizard 325

O

objcopy command 409opening headers 61Options tab (New Project

wizard) 322OS image

components of 145OS versions

coexistence of 17specifying which to build

for 18Outline view 37Overrides directory 153

must be first in the list of searchpaths 176

P

padding (System Builder) 152pathname delimiter in QNX

docs xxiiiPaths and Symbols tab (New Project

wizard) 324pdebug 25, 368pdebug command 409perspective

C/C++ Development 33–61defined 9

perspectivesgovern which views appear 10specifying which to switch to

during launch 383, 385PhAB

editing code in 189how to close 188reopening 188

PhAB (Photon ApplicationBuilder) 185

Phindows 29Photon Application Builder

(PhAB) 185

January 31, 2005 Index 435

Page 461: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

pidin command 409platforms

all are enabled by default 319how to specify which to build

for 319position-independent code

(PIC) 316post-build actions (Linker tab in

Properties dialog) 335preferences 16

C/C++ Editor 53Process Information view 267, 272Processes pane (System Summary

view) 272procnto 146, 147, 168

variants 147procnto command 409procnto-instr 292PROFDIR 204profiling

a running process 202building a program for 198instrumented 197non-QNX projects 200per-function 210per-line 208per-thread 211postmortem 197, 204running and profiling a

process 200sessions

how to control 206statistical 196types of 196

programdebugging for the first

time 369

relaunching a 375running for the first time 371running/debugging once you’ve

created a launchconfiguration 373

programscreating 34running 34, 45

projectdefined 12names

don’t use case alone todistinguish 13

don’t use spaces in 13Project Name Prefix (BSP import

wizard) 94project.bld file (System

Builder) 144, 153projects

building 156container 82converting to QNX type 326creating 38creating in the System

Builder 155deleting 47

does not also delete launchconfiguration 48

different types of 312exporting 97flash filesystem 155how to create 312importing 70migrating from 6.2.0 to

6.3.0 418migrating from 6.2.1 to

6.3.0 415

436 Index January 31, 2005

Page 462: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

nestingnot yet supported in

Eclipse 72non-QNX

how to create 316opening 35properties of

setting 336System Builder 153

configuring 162, 171target system 324

Projects tab (New Projectwizard) 320

propertiesimage (System Builder) 167item (System Builder) 170

Properties dialogadvanced mode 336used when converting a

project 328Properties view

in System Builder 162

Q

qcc command 409qconfig 17qconfig command 409qconn 247, 368qconn command 409qde command 4

location of executable file 4QNX

recursive makefilehierarchy 38

QNX BSP Perspective 96QNX C/C++ Application Project

relies on QNX recursivemakefile hierarchy 38

QNX C/C++ projectas distinct from a standard make

C/C++ project 13QNX Code Coverage

perspective 226QNX GDB Console view

enabling 134QNX Memory Analysis

perspective 233switching to automatically 246

QNX Momenticsversion of on host must be the

same or newer than versionon target 24

QNX Neutrinomemory management in 234robust architecture of 234

QNX System Builderperspective 139

QNX Target System Projectcreating a 46

QNX toolsoverview 4

QNX CONFIGURATION 17, 19QNX HOST 19QNX TARGET 19qwincfg command 409

R

rebuild 40

January 31, 2005 Index 437

Page 463: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

Reductions directory 153, 179must be second in the list of

search paths 176Registers view 127regular mode (Properties

dialog) 336resources

defined 15linked 70

ROM monitor 139, 157, 161root

all programs launched from theIDE run as 274

Run→Run. . . menu item 369

S

scan interval (code coverage) 223scrolling (in System Profiler

editor) 303search paths (System Builder) 174Seek Offset column (Connection

Information view) 282selection

types of in the System Profilereditor 302

sendnto 139, 159sendnto command 409serial communications 24serial terminal 157Set QNX Build Environment

wizard 62shared libraries

deleting reduced versionsof 179

Shared Libraries view(Debugger) 131

shortcuts, keyboard 15side channels 282signal

sending to a runningprocess 269

Signal Information view 267, 278signals

color-coding for 279sending to a suspended

program 133Signals view (Debugger) 132source

specifying locations of 331source (from QNX)

importing into the IDE 90source code

exportingto a.zip file 97to the filesystem 97

importing into the IDE 70Source tab (launch configurations

dialog) 375, 382spaces

don’t use when naming a projector file 13

stack errors 243startup code 146, 147strip command 409stripped name (Linker tab in

Properties dialog) 333symbols

loading 131stripping from a binary 332

System Blocking Graph view 267,279

438 Index January 31, 2005

Page 464: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

System Buildereditor 140Filesystem pane 140Images pane 140toolbar 141

System Builder Console view 156System Builder project

creating a 155System Builder Projects view 143System Information

perspective 263CPU processing load and 271key terms used in 264updating views in 269views in 267

System Memory pane (SystemSummary view) 272

System Resources view 267, 282selecting which display to

see 282System Specifications pane (System

Summary view) 272System Summary view 267, 271System Uptime display (System

Resources view) 282

T

target (machine) 23CPULIST 44

Target Navigator view 267customizing 268sending a signal using 269

using to control MallocInformation and MemoryInformation views 253

target system projectcreating a 324

target-specific files, location of 19targets (make) 44

adding 44removing 45

Tasks view 56terminal emulation 377TFTP server 157, 159TFTP server view 139Thread Details pane (Process

Information view) 274Thread Information view 267, 274

configuring 275tips and tricks (item in Help

menu) 9TMPDIR 19toolbar

System Builder 141Tools tab (launch configurations

dialog) 375, 383Total Heap pane (Malloc Information

view) 256Trace Event Log view 291Trace Search 291tracelogger command 409

U

Unmatched allocations tab (MemoryEvents view) 253

January 31, 2005 Index 439

Page 465: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

Index 2005, QNX Software Systems Ltd.

Unmatched deallocations (MemoryEvents view) 253

update interval (QNX ApplicationProfiler) 201, 203

Update Old Make Project icon 416usage message

for binaries in SystemBuilder 142

usage message, displayed for eachitem in System Builder140

usemsg command 409user’s guide

how to use this xxiutilities

used by the SystemBuilder 156

V

variablespreventing the debugger from

reading 118Variables view 119view

Application Profiler 207Binary Inspector 140, 142Bookmarks 291C-Build 40C/C++ Projects 33, 34C/C++ Editor 33Code Coverage Report 227Code Coverage Sessions 224Condition Statistics 291Debug 109

Element Statistics 291File System Navigator 179General Statistics 291Navigator 33Outline 37System Builder Console 156System Builder Projects 143Trace Event Log 291

viewsdefined 10

W

watchpoints 119–126removing 126

wizardconversion 416Make Project Migration 416

wizards 309–329are categorized according to

natures 309creating “nature-free” files,

folders, or projects 310creating a new project 311how to access 309New Project 38, 318New QNX Target System

Project 325Set QNX Build

Environment 62simple 310

workbench 5menus 6

Workbench Build Behavior field(New Project wizard) 322

440 Index January 31, 2005

Page 466: INTEGRATED DEVELOPMENT ENVIRONMENT …support7.qnx.com/download/download/10404/IDE_userguide.pdfIDE User’s Guide For Windows ... 12 Analyzing Your System with Kernel Tracing 287

2005, QNX Software Systems Ltd. Index

Workbench User Guide33references to CVS in 68

working directoryon target machine 378

Working Set Name (BSP importwizard) 94

workspacedefined 12migrating from 6.2.0 to

6.3.0 417migrating from 6.2.1 to

6.3.0 414specifying where the IDE should

look for a 12

X

XIP 168

Z

zooming (in System Profilereditor) 303

January 31, 2005 Index 441