01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

CH08.fm Page 252 Monday, October 7, 2002 9:16 PM<br />

252 Chapter 8 • Cross-<strong>Platform</strong> <strong>and</strong> Embedded Systems <strong>Development</strong><br />

It is the same program that was used in Chapter 5 for different examples.<br />

8.5.1.2 Running gdb on Host <strong>Using</strong> TCP/IP<br />

After starting gdbserver on the target, now you can start the GNU debugger on host.<br />

<strong>The</strong> host <strong>and</strong> target must be connected over a TCP/IP network for this example. In the following<br />

session on the host machine, file sum is a non-stripped version of the program that you uploaded<br />

to the target machine as it provides the symbol table to the debugger. After starting the debugger,<br />

you use the “target remote 192.168.1.10:2000” comm<strong>and</strong> to connect to the gdbserver<br />

running on the target machine 192.168.1.10. After that you can continue with normal<br />

debugging process.<br />

[rrehman@desktop 5]$ gdb sum<br />

GNU gdb 5.1.1<br />

Copyright 2002 Free Software Foundation, Inc.<br />

GDB is free software, covered by the GNU General Public<br />

License, <strong>and</strong> you are<br />

welcome to change it <strong>and</strong>/or distribute copies of it under<br />

certain conditions.<br />

Type "show copying" to see the conditions.<br />

<strong>The</strong>re is absolutely no warranty for GDB. Type "show warranty"<br />

for details.<br />

This GDB was configured as "i686-pc-linux-gnu"...<br />

(gdb) target remote 192.168.1.10:2000<br />

Remote debugging using 192.168.1.10:2000<br />

0x40001930 in ?? ()<br />

(gdb) break main<br />

Breakpoint 1 at 0x8048496: file sum.c, line 6.<br />

(gdb) continue<br />

Continuing.<br />

Breakpoint 1, main () at sum.c:6<br />

6 printf("Enter first number : ");<br />

(gdb) n<br />

7 scanf("%d", &num1);<br />

(gdb) n<br />

8 printf("Enter second number : ");<br />

(gdb) n<br />

9 scanf("%d", &num2);<br />

(gdb) n<br />

11 total = num1 + num2;<br />

(gdb) n<br />

13 printf("\n<strong>The</strong> sum is : %d\n", total);<br />

(gdb) n<br />

14 }<br />

(gdb) n<br />

warning: Cannot insert breakpoint 0:<br />

Cannot access memory at address 0x1

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

Saved successfully!

Ooh no, something went wrong!