05.06.2014 Views

QNX Neutrino Programmer's Guide [6.5.0 SP1] - QNX Software ...

QNX Neutrino Programmer's Guide [6.5.0 SP1] - QNX Software ...

QNX Neutrino Programmer's Guide [6.5.0 SP1] - QNX Software ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© 2012, <strong>QNX</strong> <strong>Software</strong> Systems Limited A simple debug session<br />

telnet stream tcp nowait root /bin/telnetd telnetd<br />

finger stream tcp nowait root /bin fingerd<br />

pdebug stream tcp nowait root /bin/pdebug pdebug -<br />

}<br />

A simple debug session<br />

Configure the target<br />

In this example, we’ll be debugging our “Hello, world!” program via a TCP/IP link.<br />

We go through the following steps:<br />

• configuring the target<br />

• compiling for debugging<br />

• starting the debug session<br />

• getting help<br />

Compile for debugging<br />

Let’s assume an x86 target using a basic TCP/IP configuration. The following lines<br />

(from the sample boot file at the end of this chapter) show what’s needed to host the<br />

sample session:<br />

io-pkt-v4 -dne2000 -ptcpip if=ndi0:10.0.1.172 &<br />

devc-pty &<br />

[+session] pdebug 8000 &<br />

The above specifies that the host IP address is 10.0.1.172 (or 10.428 for short). The<br />

pdebug program is configured to use port 8000.<br />

We’ll be using the x86 compiler. Note the -g option, which enables debugging<br />

information to be included:<br />

$ qcc -V gcc_ntox86 -g -o hello hello.c<br />

Start the debug session<br />

For this simple example, the sources can be found in our working directory. The gdb<br />

debugger provides its own shell; by default its prompt is (gdb). The following<br />

commands would be used to start the session. To reduce document clutter, we’ll run<br />

the debugger in quiet mode:<br />

# Working from the source directory:<br />

(61) con1 /home/allan/src >ntox86-gdb -quiet<br />

# Specifying the target IP address and the port<br />

# used by pdebug:<br />

(gdb) target qnx 10.428:8000<br />

Remote debugging using 10.428:8000<br />

0x0 in ?? ()<br />

June 14, 2012 Chapter 1 • Compiling and Debugging 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!