A
plethora of tools can be used in developing applications for
SymbianOS-based devices. Developing for SymbianOS is relatively
straightforward, although it can at times appear daunting due to the
large number of SDKs and runtime environments. Developers can choose
between writing code in Symbian C++, Open C, Python, and Java, among
others. This article focuses on Symbian C++ (because it remains the most
popular option) and briefly mentions Open C and Python. Other runtime
environments either do not come preinstalled on the device or do not
provide access to the newest APIs.
Development Environment
Development for SymbianOS can be
performed solely with a text editor and an SDK (providing both
libraries and a compiler). However, the use of an integrated development
environment (IDE) is encouraged to assist in correct and rapid
development. As such, Symbian provides Carbide.c++ as an IDE (see Figure 1).
It consists of a modified version of Eclipse and the C development
toolkit (CDT). The majority of the modifications have been implemented
in the form of additional plug-ins to Eclipse, including primarily the
customized build system.
The current version of
Carbide.c++ comes in three editions: Developer, Professional, and OEM.
Developer includes features commonly available in any development
environment. It provides wizards for creating new projects and source
files, an editor for modifying build system files, debugging support
using either the emulator or a physical device, and an integrated
mechanism for signing application installers.
Professional includes all
of the features that come with Developer, plus support for using
development devices, debugging of kernel-context code on device, an
application profiler, and basic static analysis. OEM builds further,
including all of the features of Developer and Professional, and
provides support for stop-mode debugging on the device.
Previous
versions of Carbide.c++ were not freely available, and the different
editions were sold at several different price points. However, since the
release of version 2.0, each of the editions is available free of
charge. A single installer is downloaded and the desired edition is
selected during the installation process. Because Carbide.c++ is freely
available, all developers should install the Professional edition at the
very least to make use of the application profiler and static analysis
tool.
Carbide can be downloaded as a part of the application development toolkit (ADT) at http://developer.symbian.org/main/tools_and_kits/downloads/view.php?id=2.
Software Development Kits
In order to develop for
SymbianOS-based phones, you must obtain an SDK. Previously, there was
not a single “SymbianOS” SDK, although this has changed with the release
of Symbian ^ 1 and the forthcoming Symbian ^ 2. A separate SDK is
required to develop for both S60- and UIQ-based phones.
Each
of the platform SDKs is largely self-contained, with everything
required to perform application development. This includes a version of
the GCC compiler, a phone emulator, header files, and libraries
targeting the emulator. The differences among the SDKs arise with the
additional header files and libraries that are included. For example,
the S60 SDK includes the header files required to compile against the
S60 libraries.
Other add-on SDKs
provide additional header files and libraries targeting both the
emulator and actual devices. These can be used to access additional
functionality, as provided by the encryption API, to reduce the
programming burden on the developer, as with the core idioms library, or
to facilitate development in additional programming languages, such as
Python.
The base platform SDK (for Symbian ^ 1 as well as S60) is available at http://developer.symbian.org/main/tools_and_kits/downloads/view.php?id=3.
Additional SDKs and libraries include:
Emulator
A Symbian device emulator for Windows computers is included with the various platform SDKs (see Figure 2).
Its use increases the pace of the test/development cycle by eliminating
the need to load test code onto a physical device until the final
stages of development. It should not be used as a complete replacement
for testing on a physical device. Although the emulator provides an
appropriate environment for most aspects of development, it is not a
completely accurate representation of what would be found on a physical
device.
The emulator provides
for triggering events to observe application behavior, including
sending SMS/MMS messages, low battery, attaching the charger, and so on.
It also supports bridging COMMS through the host Windows machine in
order to allow testing of Internet-based applications.
One key difference between
a physical device and the emulator is the memory model exposed. The
emulator exists within a Windows process, and memory management is
performed using standard Windows APIs. This means that code is also
compiled into the standard Windows DLL format. For example, memory allocation
is performed using VirtualAlloc(), libraries are loaded using
LoadLibrary(), and Symbian threads are created on top of native Windows
threads. Because all code on the emulator is running within a single
Windows process, there is a single Windows address space. This means
that there is no memory protection between emulated Symbian OS processes
or even between “user mode” and “kernel mode.” As such, what works
within the confines of the emulator might not work on a physical device.
The design was implemented in this way to take advantage of preexisting
Windows debugging tools and techniques.
Debugging
Debugging
of Symbian applications can be performed both through the use of the
emulator as well as via a serial connection to a physical device.
Debugging within the emulator is a straightforward process. However, due
to the differences against debugging using a physical phone, it is also
necessary to perform on-device debugging.
Emulator Debugging
Emulator debugging is
performed through the debugging view of Carbide.c++. Starting a
debugging session for a project will automatically launch the target
application within the emulator and attach to the emulator process. The
debugging view provides several additional frames to the user interface.
The top left lists the threads running within the emulator, and the top
right lists the watch variables, current breakpoints, and
SymbianOS-specific data.
To create a new breakpoint,
double-click on the margin of the line of source code where you would
like to explore the program flow control. At this point, variables can
be examined to determine whether they contain the expected value. If
they do, step over, step out, and step into functionality is supported.
This allows the developer the flexibility to only delve into the
functions they are interested in.
On-Device Debugging
On-device debugging can
be separated into three separate categories, each provided by a
different edition of Carbide.c++. Application-level debugging is
performed using the AppTRK device agent, where the debugger can attach
to user threads and has a generally restricted view of system memory.
System-level debugging is performed using the SysTRK device agent, where
the debugger can attach to system threads and processes that were
loaded from the ROM image. It has a largely unrestricted view system
memory. This can only be performed on a development device. Finally,
debugging can also be performed through a dedicated JTAG link. This
provides the deepest view of code executing on the device. System-level
and dedicated JTAG debugging are not available to the average SymbianOS
developer.
IDA Pro
IDA Pro from Hex-Rays (www.hex-rays.com) is a ubiquitous tool for binary disassembly and reverse engineering (see Figure 3) and has supported SymbianOS 9.x
as a first-class target since version 5.3. IDA Pro supports more than
just disassembly—it can also connect to the AppTRK debugging agent to
perform live debugging.
IDA Pro Standard supports loading Executable Linker Format (ELF) files
and includes an ARMv4 processor module. IDA can parse SIS installation
scripts and list the available binaries for review inside.
IDA Pro can also act as a
debugger instead of Carbide.c++. In doing so, IDA will communicate with
the AppTRK debugging agent. This allows you to take advantage of the
advanced visualization tools that IDA provides during debugging.