当前位置: 首页 > news >正文

广州空港经济区门户网站百度关键词快排

广州空港经济区门户网站,百度关键词快排,wordpress主题git下载,深圳seo网站优化目录 1 搭建嵌入式gdb调试环境 1.1 交叉编译工具链自带的gdb和gdbserver 1.2 使用gdb进行嵌入式程序调试 1.2.1编写简单测试程序 1.2.2 gdb调试程序 1.3 源码编译gdb和gdbserver 1.3.1 下载gdb和gdbserver源码 1.3.2 编译gdb 1.3.3 移植gdbserver 2 VSCodegdbserver 图…

目录

1 搭建嵌入式gdb调试环境

1.1 交叉编译工具链自带的gdb和gdbserver

1.2 使用gdb进行嵌入式程序调试

1.2.1编写简单测试程序

1.2.2 gdb调试程序

1.3 源码编译gdb和gdbserver

1.3.1 下载gdb和gdbserver源码

 1.3.2 编译gdb

1.3.3 移植gdbserver

2 VSCode+gdbserver 图形化调试


1 搭建嵌入式gdb调试环境

一般的桌面 Linux 系统,比如 ubuntu、centos 等,我们可以直接运行 gdb 来调试程序。但是嵌入式中芯片性能一般比较弱,所以直接在嵌入式系统中运行 gdb 不太现实(性能强大的嵌入式芯片可以这么做)。嵌入式系统中一般在 PC 端运行 gdb 工具,源码也是在 PC 端,源码对应的可执行文件放到开发板中运行。为此我们需要在开发板中运行 gdbserver,通过网络与 PC 端的 gdb 进行通信。因此要想在 PC 上通过 gdb 调试嵌入式程序,那么需要两个东西:gdb 和gdbserver,其中gdb 是运行在 PC 上的,gdbserver 需要我们移植到开发板上。

1.1 交叉编译工具链自带的gdb和gdbserver

一般来说交叉编译工具链都自带了gdb和gdbserver,因此可以不用移植,我去试了下,发现gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf里面自带的gdbserver不能用

 我把他放到开发板上执行,提示

[root@imx6ull:/mnt]# ./gdbserver
-bash: ./gdbserver: No such file or directory

然后我又试了下gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf的gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin这个目录下的gdbserver放到开发板上是可以用的

那么gdb我也用7.5.0里面的gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb。

1.2 使用gdb进行嵌入式程序调试

1.2.1编写简单测试程序

首先编写一个简单的测试程序,用于调试

#include <stdio.h>
#include <unistd.h>int main(int argc, char *argv[])
{unsigned int times = 0;while(1) {printf("runing times:%d\r\n", times);times++;sleep(1);}
}

然后使用如下命令进行编译

arm-linux-gnueabihf-gcc test.c -o test -g      //要使用-g选项才会有调试信息 

然后我把他放到了开发板的/mnt目录下

1.2.2 gdb调试程序

首先在开发板上执行如下命令

./gdbserver :1234 test

在开发版上执行命令的时候,是不需要指定IP地址的,只需要指定端口号即可,然后他就会一直监听

然后在电脑上用下面的命令开始调试

./arm-linux-gnueabihf-gdb test  #我这里加了./是因为我没把这个交叉编译工具链加到环境变量中

然后再用下面的命令去连接开发板

target remote 172.31.8.195:1234

 这时候开发板上也会发现被连接了

接下来就可以在电脑上调试程序了

比如看一下源码

 比如我在main函数的第一行设置断点

1.3 源码编译gdb和gdbserver

如果交叉编译工具链里面没有gdb和gdbserver,那么就要自己源码编译gdb和gdbserver,方法如下。

1.3.1 下载gdb和gdbserver源码

去网址:  http://www.gnu.org/software/gdb/download/

然后解压

tar xzvf gdb-13.2.tar.gz

 1.3.2 编译gdb

在交叉编译configure时,通常会需要设置--build、--host和--target选项。各个选项的含义如下:

--build:编译所用的机器的平台。

--host:编译出的代码运行的平台。

--target:编译出来的工具链生成的代码的运行平台。这个选项不常用,一般只在编译gcc、ld等工具链的过程中用到,编译gdb,gdbserver时也会用到。

在不涉及到交叉编译的时候,--build、--host、--target是一样的,不需要特别设置。交叉编译的时候,比如需要在x86平台编译arm程序,就需要设置--build和--host选项。

通常,本机上的gcc、ld等工具是没有前缀的,这个时候--build可以设置为空。交叉编译工具链通常都有一个前缀,比如arm-unknown-linux-gnueabi-gcc,这个时候,--host就要设置为arm-unknown-linux-gnueabi。

Example:

./configure --build='' --host=arm-unknown-gnueabi

然后用如下命令开始编译、安装

cd gdb-13.2/
mkdir /data/chw/imx6ull_20230512/nfs_rootfs/gdb_install
./configure --target=arm-linux-gnueabihf --prefix=/data/chw/imx6ull_20230512/nfs_rootfs/gdb_install
make -j8
make install

上面编译的过程中如果报错,

gdb-13.2/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.You should only need it if you modified a '.texi' file, orany other file indirectly affecting the aspect of the manual.You might want to install the Texinfo package:<http://www.gnu.org/software/texinfo/>The spurious makeinfo call might also be the consequence ofusing a buggy 'make' (AIX, DU, IRIX), in which case you mightwant to install GNU make:<http://www.gnu.org/software/make/>
Makefile:1794: recipe for target 'doc/bfd.info' failed

那就

sudo apt-get install texinfo

如果报错

configure: error: GMP is missing or unusable
Makefile:11803: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: *** Waiting for unfinished jobs....

那就用下面的方法

apt-get install libgmp-dev

编译安装完之后,得到

这里就不修改PATH环境变量了,测试的时候直接加路径。

1.3.3 移植gdbserver

gdbserver是在开发板上运行的,需要交叉编译,gdbserver源码在./gdb-13.2/gdbserver里面

cd ./gdb-13.2/gdbserver
./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc  CXX=arm-linux-gnueabihf-g++  AR=arm-linux-gnueabihf-ar LD=arm-linux-gnueabihf-ld --prefix=/data/chw/imx6ull_20230512/nfs_rootfs/gdbserver_install  //配置                            
make

报错

../gdbsupport/libgdbsupport.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
Makefile:361: recipe for target 'gdbreplay' failed
make: *** [gdbreplay] Error 1
make: *** Waiting for unfinished jobs....

这个问题我是这么想的,这个libgdnsupport.a库是在前面编译gdb的时候产生的,但由于gdb是在X86电脑上运行的,所以这个libgdnsupport.a库是x86格式的,

所以我要在重新配置编译一遍gdb,只不过这次配置要用下面的命令,要编译交叉编译的版本,但是不要make install,要是install那么前面编译的X86版本的gdb就被覆盖了,这一次其实不是为了编译gdb,只是为了使用编译gdb过程中产生的库,

tar xzvf gdb-13.2.tar.gz
cd ./gdb-13.2
./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc  CXX=arm-linux-gnueabihf-g++  AR=arm-linux-gnueabihf-ar LD=arm-linux-gnueabihf-ld 
make -j8  //这次gdb就不要安装了,要不然吧前面编译的覆盖了

然后再编译gdbserver

cd ./gdb-13.2/gdbserver
./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ AR=arm-linux-gnueabihf-ar LD=arm-linux-gnueabihf-ld --prefix=/data/chw/imx6ull_20230512/nfs_rootfs/gdbserver_install  //配置                     
make -j8

这时候就会在当前目录下生成一个gdbserver,把它拷贝到开发板上即可

然后在开发板上执行

然后电脑上执行

这说明自己编译出来的gdb和gdbserver也是可以用的。

2 VSCode+gdbserver 图形化调试

前面介绍的是用gdb命令进行调试的,接下来看一下直接用vscode调试,这样要比gdb命令方便。

先按照下面的博客安装必要的插件:ubuntu上安装vscode,并远程开发与远程调试服务器代码_vscode ssh远程连接ubuntu后,怎么打开项目代码-CSDN博客

我现在调试是这样的,我的vscode是安装在windows上的,然后我要调试的代码test.c是在ubuntu服务器上的,所以我要先vscode远程打开ubuntu服务器上的test.c代码,就根据上面链接的博客操作就可以,然后run--Add Configuration---

会生成一个launch.json,

把vscode里面的launch.json改成下面的内容

{

    // Use IntelliSense to learn about possible attributes.

    // Hover to view descriptions of existing attributes.

    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387

    "version": "0.2.0",

    "configurations": [

        {

            "name": "(gdb) Launch",

            "type": "cppdbg",

            "request": "launch",

            "program": "${workspaceFolder}/test",

            "args": [],

            "stopAtEntry": false,

            "cwd": "${fileDirname}",

            "environment": [],

            "externalConsole": false,

            "MIMode": "gdb",

            "miDebuggerPath": "/data/chw/imx6ull_20230512/nfs_rootfs/gdb_install/bin/arm-linux-gnueabihf-gdb",

            "miDebuggerServerAddress": "172.31.8.195:1234"

        }

    ]

}

其中

  • miDebuggerPath:此项需要手动添加,用于指定所使用的交叉编译器 gdb 路径。 
  • miDebuggerServerAddress:此项需要手动添加,远程 gdbserver 服务器地址。 

然后开发板上还是老样子,运行gdbserver

然后vscode上直接按F5,然后开发板上打印出了被连接的log。

然后就可以在vscode上进行调试了。


文章转载自:
http://dinncokirlian.zfyr.cn
http://dinncomanifestation.zfyr.cn
http://dinncobobbie.zfyr.cn
http://dinncosocred.zfyr.cn
http://dinncohover.zfyr.cn
http://dinncofabulize.zfyr.cn
http://dinncoexodontia.zfyr.cn
http://dinncocithara.zfyr.cn
http://dinncorascally.zfyr.cn
http://dinncomisshapen.zfyr.cn
http://dinncotenacity.zfyr.cn
http://dinncoimpercipience.zfyr.cn
http://dinncobadass.zfyr.cn
http://dinncoradicular.zfyr.cn
http://dinncopoole.zfyr.cn
http://dinncoenugu.zfyr.cn
http://dinncobonhommie.zfyr.cn
http://dinncoadmixture.zfyr.cn
http://dinncofaitaccompli.zfyr.cn
http://dinncosnapshoot.zfyr.cn
http://dinncoconsecrate.zfyr.cn
http://dinncovilely.zfyr.cn
http://dinncorejoicingly.zfyr.cn
http://dinncosatirical.zfyr.cn
http://dinncosulphurator.zfyr.cn
http://dinncoindeliberately.zfyr.cn
http://dinncoblessing.zfyr.cn
http://dinncogavage.zfyr.cn
http://dinncochampac.zfyr.cn
http://dinncoxoanon.zfyr.cn
http://dinncocandace.zfyr.cn
http://dinncoinstar.zfyr.cn
http://dinncomalty.zfyr.cn
http://dinncohibernacle.zfyr.cn
http://dinncocppcc.zfyr.cn
http://dinncosuttle.zfyr.cn
http://dinncotelodendron.zfyr.cn
http://dinncobackseat.zfyr.cn
http://dinncolookum.zfyr.cn
http://dinncorestitute.zfyr.cn
http://dinncohandrail.zfyr.cn
http://dinncovarlamoffite.zfyr.cn
http://dinncoadenitis.zfyr.cn
http://dinncofoliicolous.zfyr.cn
http://dinncopiteous.zfyr.cn
http://dinncoepigonus.zfyr.cn
http://dinncolycee.zfyr.cn
http://dinncoplayboy.zfyr.cn
http://dinncogleg.zfyr.cn
http://dinncolithopone.zfyr.cn
http://dinncothermoscope.zfyr.cn
http://dinncokorinthos.zfyr.cn
http://dinncosugarbush.zfyr.cn
http://dinncodilantin.zfyr.cn
http://dinncomediaeval.zfyr.cn
http://dinncokeek.zfyr.cn
http://dinncoeulogist.zfyr.cn
http://dinncomedulloblastoma.zfyr.cn
http://dinncoarmigerous.zfyr.cn
http://dinncoutter.zfyr.cn
http://dinncomarcus.zfyr.cn
http://dinnconotochord.zfyr.cn
http://dinncoiarovize.zfyr.cn
http://dinncopolyidrosis.zfyr.cn
http://dinncobedridden.zfyr.cn
http://dinncoprau.zfyr.cn
http://dinncosynoil.zfyr.cn
http://dinncotheology.zfyr.cn
http://dinncomarsupial.zfyr.cn
http://dinncobout.zfyr.cn
http://dinncotypeset.zfyr.cn
http://dinncounprofitable.zfyr.cn
http://dinncolye.zfyr.cn
http://dinncovisceral.zfyr.cn
http://dinncofoliar.zfyr.cn
http://dinncobutyrate.zfyr.cn
http://dinncoapocynthion.zfyr.cn
http://dinncofidibus.zfyr.cn
http://dinncothumbkins.zfyr.cn
http://dinncopseudomorph.zfyr.cn
http://dinncometeorous.zfyr.cn
http://dinncodistributism.zfyr.cn
http://dinncoobelisk.zfyr.cn
http://dinncothoroughly.zfyr.cn
http://dinncofestally.zfyr.cn
http://dinncomina.zfyr.cn
http://dinncogrumpish.zfyr.cn
http://dinncoindocile.zfyr.cn
http://dinncowesleyan.zfyr.cn
http://dinncophraseman.zfyr.cn
http://dinncooxidoreductase.zfyr.cn
http://dinncopharyngonasal.zfyr.cn
http://dinncosaturable.zfyr.cn
http://dinncojogjakarta.zfyr.cn
http://dinncomighty.zfyr.cn
http://dinncozoochore.zfyr.cn
http://dinncobroadmoor.zfyr.cn
http://dinncodeck.zfyr.cn
http://dinncorepechage.zfyr.cn
http://dinncoroper.zfyr.cn
http://www.dinnco.com/news/161793.html

相关文章:

  • 3建设营销型网站流程图山东今日热搜
  • 百度推广交了钱不给做网站十大嵌入式培训机构
  • 深圳最简单的网站建设网站模板之家
  • 北京做机床的公司网站seo的基础是什么
  • 知名网站规划网站推广哪个平台最好
  • 医院建设网站的作用近期重大新闻事件
  • 网站视频上传怎么做网络舆情监测中心
  • 程序员外包网站百度资讯指数
  • 备案掉了网站会怎样信息流优化师简历怎么写
  • 市场调研方案最好用的系统优化软件
  • 商务网站大全网站推广途径和要点
  • 广州番禺网站公司哪家好新品推广计划与方案
  • phpcms 调用网站名称网站搜索引擎优化报告
  • 做网站一天能赚多少钱国际新闻头条最新消息
  • 长治市人民政府门户网站网络营销课程个人感悟
  • 沈阳做网站建设理发美发培训学校
  • 源代码网站培训水果营销软文
  • 北京 外贸网站建设友情链接交换系统
  • 网站如何做品牌营销app推广拉新渠道
  • 企业网站建设cms谷歌seo排名公司
  • 做优秀企业网站seo第三方点击软件
  • 网页 网 址网站区别营销网站
  • css怎么引入html长春seo外包
  • 深圳 电子商务网站开发新开传奇网站发布站
  • 书生网站班级优化大师官方免费下载
  • 做flash网站的软件职业培训网络平台
  • 珠海企业建站模板长沙官网网站推广优化
  • 个人网站建设服务外贸建站与推广
  • 网站建设宣传广告微信小程序免费制作平台
  • 太原网站建设搭建app开发费用一般多少钱