gdb include stdio h main void hanoiintcharchar int
gdb调试命令的使用方法 以下程序是汉诺塔的源程序: #include "stdio. h" main() { void hanoi(int,char,char); int m; printf("input the number of disks:"); scanf("%d",&m); printf("The step to moving %d disks:n",m); hanoi(m,'A','B','C'); } void hanoi(int n,char a,char b,char c) { void move(char,char); if(n==1) move(a,c); else { hanoi(n-1,a,c,b); move(a,c); hanoi(n-1,b,a,c); } } void move(char x,char y) { printf("%c-->%cn",x,y); }
gdb调试命令的使用方法 为了方便调试可执行程序,可以用下面的语句来编译程序。 #gcc –g –o test. c 开始调试: #gdb –Qtest (gdb) 1. 查看源代码,使用list命令 (gdb) list 1 #include<stdio. h> 2 main() 3 { 4 void Hanoi(int, char, char); 5 int m; 6 scanf("%d",&m); 7 printf("The step to move %d disks:n",m); 8 hanoi(m,'A','B','C'); 9 } 10 void hanoi(int n,char a,char b,char c) (gdb)
gdb调试命令的使用方法 2. 运行源程序,使用run命令。 (gdb)run Starting program /home/ding/test. exe Input the number of disks; 3 The step to move 3 disks: A-->C A-->B C-->B A-->C B-->A B-->C A-->C Program exited normally (gdb) 如上所述,使用run命令会执行一个可执行程序。
ARM Linux的开发环境的建立 n 2. Toolchain的安装与配置 在本书使用的所有的Toolchain均以压缩文件的 形式提供,如下所示: binutils-2. 15. tar. gz gcc-3. 3. 2. tar. gz glibc-2. 3. 2. tar. gz glibc-linuxthreads-2. 3. 2. tar. gz
ARM Linux的开发环境的建立 II. 检查CD-ROM正确挂载后,需要在开 发主机上创建目录,并将光盘内容拷贝到目录 中。在根目录创建了一个名为PXA 270_Linux 的目录,将光盘中的内容拷贝到了该目录中。 n [root@localhost root]# mkdir /PXA 270_Linux [root@localhost root]# cd /PXA 270_Linux [root@localhost PXA 270_Linux]# cp /mnt/cdrom/ PXA 270_Linux/* -a. / n n
ARM Linux的交叉编译 使用vi编辑器创建一个hello. c文件。编写一个简单的程序来打 印出一行简单的信息:Hello World。程序如下所示: #include "stdio. h" main() { printf("Hello Worldn "); return 0; } 保存并退出该文件。使用如下的命令来编译该文件。 n [root@localhost root]# gcc –o hello. c n [root@localhost root]# arm-linux-gcc –o helloarm hello. c n [root@localhost root]# file hello n [root@localhost root]# file hello-arm
Minicom的使用
Minicom的使用
Minicom的使用
Minicom的使用
Minicom的使用
ARM Linux内核的配置与编译 5. 内核配置项介绍 n 首先将压缩的linux内核源代码文件linux-2. 4. 21 PXA 270. tar. gz解压,进入linux内核源代码所在的目录, 并 在终端输入make menuconfig, 系统弹出基于Ncurses内核配置 图形界面,便可进行内核选项的配置。 n[root@localhost root]# tar xvfz linux-2. 4. 21 PXA 270. tar. gz n[root@localhost root]# cd PXA 270_Linux/kernel/ n[root@localhost kernel]# make xsbase 270_config n[root@localhost kernel]# make oldconfig n[root@localhost kernel]# make menuconfig
UART应用程序设计 n n 3 串口通信源代码的编译 1) PC平台的串口通信程序编译 将光盘提供的serial. c的源代码复制到硬盘中(假设 将源码复制在/root/PAX 270_Linux目录下)对源 码进行编译。 [root@localhost PAX 270_Linux]#cd serial [root@localhost serial]#gcc –o serial. c 在PC机上运行serial程序; [root@localhost serial]#. /serial 1
UART应用程序设计 a) b) n n c) 2)ARM平台的串口通信程序的编译 将光盘提供的serialarm的源代码复制到硬盘中( 假设将源码复制在/root/PAX 270_Linux目录下) 设置交叉编译 具参数(arm-linux-gcc)。 对源代码进行编译。 [root@localhost PAX 270_Linux]#cd serialarm [root@localhost serialarm]#arm-linuxgcc –o serialarm. c 将编译好的程序serial下载到开发板的 /usr/qpe/bin目录下。 在目标板上利用chmod命令修改serial的属性 # chmod 755 serial
- Slides: 59