首页 > 系统相关 >gdb本地调试版本移植至ARM-Linux系统

gdb本地调试版本移植至ARM-Linux系统

时间:2023-12-12 15:32:44浏览次数:27  
标签:编译 -- Linux arm ncurses gdb linux ARM

gdb本地调试版本移植至ARM-Linux系统_测试程序

移植ncurses库

本文使用的ncurses版本为ncurses-5.9.tar.gz

下载地址:https://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz

 

1.       将ncurses压缩包拷贝至Linux主机或使用wget命令下载并解压

 

tar-zxvf ncurses-5.9.tar.gz

 

2.       解压后进入到ncurses-5.9目录下

 

cdncurses-5.9

 

3.       在ncurses-5.9目录下创建编译完成后生成文件位置

mkdiroutput

cdoutput

mkdirarm-linux

 

4.       生成Makefile文件

./configure--target=arm-none-linux-gnueabi --prefix=$PWD/output/arm-linux  --enable-termcap --with-shared --without-ada

l  --target表示编译器的前缀,需要根据编译的不同需求进行修改

l  --prefix表示编译完成后生成文件的位置

l  --nable-termcap表示 关键代码使用 termcap(terminalcapabilities)数据库 [自动检测]

l  --with-shared表示动态编译

 

5.       编译

make

当遇到如下报错时

Makefile:794:recipe for target '../obj_s/lib_gen.o' failed

make[1]:*** [../obj_s/lib_gen.o] Error 1

make[1]:Leaving directory '.../ncurses-5.9/ncurses'

Makefile:109:recipe for target 'all' failed

make:*** [all] Error 2

 

需要进入ncurses-5.9/include文件夹,修改 curses.tail 文件下的如下内容,将注释 /* generated */ 去掉

externNCURSES_EXPORT(bool)    mouse_trafo(int*, int*, bool);         /* generated*/

 

6.       安装

Makeinstall

 

7.       安装完成后会在/output/arm-linux目录下生成库文件,我们只需将lib目录下的libncurses.so.5 库拷贝至开发板

 

 

移植gdb

本文使用的gdb版本为gdb-7.12.tar.gz

下载地址:https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz

 

1.       将gdb压缩包拷贝至Linux主机或使用wget命令下载并解压

 

tar-zxvf gdb-7.12.tar.gz

 

2.       解压后进入到ncurses-5.9目录下

 

cdgdb-7.12

 

3.       生成Makefile文件

./configure -host=arm-none-linux-gnueabi CC=/home/vanxoak/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc  --enable-shared--prefix=$PWD/output/arm-linux --disable-werror --without-x --disable-gdbtk--disable-tui --without-included-regex --without-included-gettextLDFLAGS="-L$PWD/../output/arm-linux/lib"CPPFLASS="-I$PWD/../output/arm-linux/include"

 

l  --host=arm-none-linux-gnueabi 用arm-none-linux-gnueabi编译

l  CC为交叉编译器绝对路径

l  --enable-shared 动态编译

l  prefix=“$PWD/output/arm-linux” 安装目录

l  --disable-werror 屏蔽werror报警

l  --without-x 取消x windows 支持

l  --disable-gdbtk 取消gdbtk

l  --disable-tui 取消tui 界面

l  --without-included-gettext 去掉用于多语言处理的gettext库

l  "LDFLAGS=XXX"指交叉编译完成的ncurse的lib目录路径

l  "CPPFLAGS=XXX"指是交叉编译完成的ncurse的include目录路径

 

4.       编译

make

 

5.       安装

makeinstall

 

安装完成后会在.../gdb-7.12/output/arm-linux/bin/目录下生成gdb可执行程序。

 

移植至HDT3-EVM 开发板

1.       将libncurses.so.5库 文件拷贝至/usr/lib目录下,若/usr目录下无lib目录可手动创建mkdir lib

2.       将gdb程序拷贝至/bin目录下

gdb本地调试版本移植至ARM-Linux系统_linux_02

 

测试调试

1.  编写可执行测试程序,示例hello.c代码如下,该代码执行后会打印Hello World。

#include<stdio.h> 

intmain(int argc, char *argv[]) 

    printf("Hello World\n"); 

    return 0; 

}

 

2.  使用交叉编译器进行编译,需要注意的是,要使用gdb调试程序,需要在使用交叉编译器编译源代码时加上 " -g " 参数保留调试信息,否则不能使用GDB进行调试且报如下最后一行所示错误:

/home# gdb hello

GNUgdb (GDB) 7.12

Copyright(C) 2016 Free Software Foundation, Inc.

LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Thisis free software: you are free to change and redistribute it.

Thereis NO WARRANTY, to the extent permitted by law. Type "show copying"

and"show warranty" for details.

ThisGDB was configured as "arm-none-linux-gnueabi".

Type"show configuration" for configuration details.

Forbug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

Findthe GDB manual and other documentation resources online at:

<http://www.gnu.org/software/gdb/documentation/>.

Forhelp, type "help".

Type"apropos word" to search for commands related to "word"...

Readingsymbols from hello...(no debugging symbols found)...done.

 

3.       使用交叉编译器编译测试程序

arm-none-linux-gnueabi-gcc-g  -o hello hello.c

 

4.       将生成的hello文件拷贝至HDT3-EVM 开发板上并使用sync命令保存

 

5.       输入gbd命令启动gdb程序

/home# gdb

GNUgdb (GDB) 7.12

Copyright(C) 2016 Free Software Foundation, Inc.

LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Thisis free software: you are free to change and redistribute it.

Thereis NO WARRANTY, to the extent permitted by law. Type "show copying"

and"show warranty" for details.

ThisGDB was configured as "arm-none-linux-gnueabi".

Type"show configuration" for configuration details.

Forbug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

Findthe GDB manual and other documentation resources online at:

<http://www.gnu.org/software/gdb/documentation/>.

Forhelp, type "help".

Type"apropos word" to search for commands related to "word".

(gdb)

 

上述代码(gdb)为GBD内部命令引导符,表示等待用户输入gbd命令

 

6.       使用 " file hello " 命令载入被调试的测试程序

(gdb)file hello

Readingsymbols from hello...done.

 

显示Reading symbols from hello...done.表示被测程序加载成功

 

7.       使用 " r "命令执行调试测试程序

(gdb)r

Startingprogram: /home/hello

HelloWorld

[Inferior1 (process 849) exited normally]

如上述代码显示 " Hello World " 即表示hello程序执行完成

 

 

(gdb)help

Listof classes of commands:

 

aliases-- Aliases of other commands

breakpoints-- Making program stop at certain points

data-- Examining data

files-- Specifying and examining files

internals-- Maintenance commands

obscure-- Obscure features

running-- Running the program

stack-- Examining the stack

status-- Status inquiries

support-- Support facilities

tracepoints-- Tracing of program execution without stopping the program

user-defined-- User-defined commands

 

Type"help" followed by a class name for a list of commands in that class.

Type"help all" for the list of all commands.

Type"help" followed by command name for full documentation.

Type"apropos word" to search for commands related to "word".

Commandname abbreviations are allowed if unambiguous.


标签:编译,--,Linux,arm,ncurses,gdb,linux,ARM
From: https://blog.51cto.com/u_15595051/8788269

相关文章

  • HarmonyOS:NativeWindow 开发指导
     场景介绍NativeWindow是HarmonyOS本地平台化窗口,表示图形队列的生产者端。开发者可以通过NativeWindow接口进行申请和提交Buffer,配置Buffer属性信息。针对NativeWindow,常见的开发场景如下:● 通过NativeWindow提供的Native API接口申请图形Buffer,并将生产图形内容写入图......
  • Linux常用命令
    前言本文意在记录平时在linux系统中的常用命令,还有一些常用软件(比如:nginx、redis、mysql等)的常用命令。以提高自己平常开发效率,因为有的时候会突然忘记。......
  • Linux软件管理
    rpm命令Linuxrpm命令Linuxrpm命令用于管理套件。rpm(英文全拼:redhatpackagemanager)原本是RedHatLinux发行版专门用来管理Linux各项套件的程序,由于它遵循GPL规则且功能强大方便,因而广受欢迎。逐渐受到其他发行版的采用。RPM套件管理方式的出现,让Linux易于安装,......
  • linux 中实现字符串的拼接
     001、简单测试[root@pc1test01]#str1=ab##测试字符串[root@pc1test01]#str2=xy[root@pc1test01]#echo$str1##测试字符串ab[root@pc1test01]#echo$str2xy[root@pc1test01]#str3="$str1$str2"##字符串拼接[root@pc1test01]#echo......
  • in /etc/default/grub:将标志添加intel_iommu=off到GRUB_CMDLINE_LINUX_DEFAULT 禁用英
    in /etc/default/grub:将标志添加intel_iommu=off到GRUB_CMDLINE_LINUX_DEFAULT禁用英特尔睿频加速:echo1|sudotee/sys/devices/system/cpu/intel_pstate/no_turbo......
  • 0x02 Linux Fundamentals Part 3
    Task1、引言这个房间将展示一些您可能日常的实用程序和应用程序,还将通过学习自动化、包管理和服务/应用程序日志记录来提高您的Linux-fu技能。Task2、部署Linux机器 Task3、终端文本编辑器①Nano用法:nanofilename 功能:搜索文本复制和粘贴跳转到行号找出您所在......
  • linux下创建ssh账号并设置指定使用目录
    场景:在linux系统下创建用户,并使用xshell登录,一般我们使用key登录,安全性高1.使用xshell连接服务器,使用root账号sudosu2.创建一个新的系统用户,使用以下命令:sudouseradd-m<username>3.设置该用户的密码,使用以下命令:sudopasswd<username>系统将提示你输入该用户的新密码......
  • HarmonyOS第二课,TypeScript语法知识
    1、TypeScript中常用的变量类型1、布尔值TypeScript中可以使用boolean来表示这个变量是布尔值,可以赋值为true或者false。letisDone:boolean=false;2、数字TypeScript里的所有数字都是浮点数,这些浮点数的类型是number。除了支持十进制,还支持二进制、八进制......
  • OpenHarmony创新赛人气投票活动,最佳人气作品由你来定!
     12月1日至12月15日十大入围作品线上投票激战正酣最佳人气作品,由你来定!  投票链接:https://forums.openharmony.cn/forum.php?mod=viewthread&tid=1284&extra=......
  • 开源的linux可视化管理项目-1panel面板
    推荐一款开源的linux可视化管理项目,运维效率翻倍原创 小羊架构 小羊架构 2023-12-0316:19 发表于广东收录于合集#linux3个#开源5个#编程9个#IT16个#互联网17个  你好呀,我是小羊。linux是个非常好的开源操作系统,功能强大,使用也非常广泛,唯一的缺点就是上手有点难......