Cross Debugging with GDB: Embedded Linux

This is suitable for environments with limited resources and insufficient memory, to avoid out-of-memory errors caused by running gdb.

The uclibc platform does not yet support this functionality.

文章目录

    • Install gdb-multiarch on PC
    • Run gdbserver on DUT
    • Prepare sysroot
    • Run gdb-multiiarch on PC
    • GDB Debug by Reading Coredump
      • About coredump
      • Prepare FW with coredump enabled
      • Enable coredump size & name
      • Permernently enable coredump size when build SDK
    • Check Symbol From File
      • Check library or program dependencies
      • Make sure that the debugging program have symbols

Install gdb-multiarch on PC

install MINGW64 MSYS2 environment
in MSYS2 environment install MINGW gdb-multiarch

$ pacman -S mingw-w64-x86_64-gdb-multiarch

press ‘Y’ to install all depended libraries

Run gdbserver on DUT

  1. prepare gdbserver on buildroot for target platform
  2. change gdbserver $ chmod 755 gdbserver
  3. gdbserver cmd
    ./gdbserver localhost:2001 <bin + args>
  4. check LD_LIBRARY_PATH
$ echo $LD_LIBRARY_PATH
/system/lib

Prepare sysroot

Downlaod target_debug to C:\msys64\home\imxx\ 下, this is MYSYS2 home

Run gdb-multiiarch on PC

  1. open MINGW
(gdb) gdb-multiarch ./testOnDemandRTSPServer # 這個檔案必須是DUT 上執行的相同一個
//(gdb) gdb-multiarch ./target_debug/system/bin/testOnDemandRTSPServer   # 或是直接執行 sysroot 裡面的對應執行檔
(gdb) set architecture arm
(gdb) set sysroot ./target_debug # 這就是方才複製 SDK/fs/rootfs/output/target_debug 位置
(gdb) set solib-search-path ./target_debug/system/lib # 此位置必須取代 DUT $LD_LIBRARY_PATH
(gdb) target remote 172.16.35.42:2001 # 也就是 DUT IP + gdb server port
(gdb) b main # 設置中斷點在 main function
(gdb) continue
  1. Check shared library info
(gdb)  info shared

output

(gdb) info shared
From        To          Syms Read   Shared Object Library
0xb6f84800  0xb6f97408  Yes         ./target_debug/lib/ld-linux-armhf.so.3
0xb6f3c930  0xb6f6c860  Yes         ./target_debug/system/lib/libinf.so.1
0xb6f235e8  0xb6f23cd4  Yes         ./target_debug/system/lib/libaftr.so.3
0xb6f082e8  0xb6f0fc28  Yes         ./target_debug/system/lib/libvftr.so.3
0xb6d86704  0xb6e7c618  Yes         ./target_debug/system/lib/libmpp.so.3
0xb6daee78  0xb6db1d8c  Yes         ./target_debug/usr/lib/libjson-c.so.2
0xb6d98810  0xb6d9ae68  Yes         ./target_debug/lib/librt.so.1
0xb6d1c9b8  0xb6d6f76c  Yes         ./target_debug/usr/lib/libasound.so.2
0xb6c07d58  0xb6cd81fc  Yes         ./target_debug/usr/lib/libtensorflow-lite-optim.so
0xb6bb4974  0xb6bbbd4c  Yes         ./target_debug/usr/lib/libz.so.1
0xb6b6b0d0  0xb6b99c70  Yes         ./target_debug/usr/lib/libcurl.so.4
0xb6b1a414  0xb6b44020  Yes         ./target_debug/usr/lib/libssl.so.1.1
0xb69bd000  0xb6a9c950  Yes         ./target_debug/usr/lib/libcrypto.so.1.1
0xb6906048  0xb694d398  Yes         ./target_debug/lib/libstdc++.so.6No          /lib/libm.so.6
0xb682fdf8  0xb683abe4  Yes         ./target_debug/lib/libgcc_s.so.1No          /lib/libpthread.so.0No          /lib/libc.so.6
0xb66fb97c  0xb66fc234  Yes         ./target_debug/lib/libdl.so.2No          /lib/libatomic.so.1No          /lib/libnss_files.so.2

GDB Debug by Reading Coredump

About coredump

A core dump, also known as a “core dump,” is a snapshot of memory taken at the moment a process crashes abruptly during its execution.

When a program encounters an unhandled exception internally within a process, the operating system saves a dump of the process’s current memory, register states, running stack, and other information into a file. This file is a binary file that can be analyzed using tools like gdb, elfdump, and objdump to examine specific contents.

Reading a core dump typically consumes less memory compared to running the binary with libraries containing symbols, as it doesn’t require loading those libraries during the analysis process.

Prepare FW with coredump enabled

Core dumps are not enabled by default in the most SDK. You need to recompile the Linux kernel configuration to generate the firmware.

$ cd SDK/linux; make menuconfig
General setup -> configure standard kernel features -> Enable ELF core dumps

Enable coredump size & name

  1. file size
$ ulimit -a 
core file size (blocks)         (-c) 0 << 
data seg size (kb)              (-d) unlimited
scheduling priority             (-e) 0
file size (blocks)              (-f) unlimited
pending signals                 (-i) 3321
max locked memory (kb)          (-l) 64
max memory size (kb)            (-m) unlimited
open files                      (-n) 1024
POSIX message queues (bytes)    (-q) 819200
real-time priority              (-r) 0
stack size (kb)                 (-s) 8192
cpu time (seconds)              (-t) unlimited
max user processes              (-u) 3321
virtual memory (kb)             (-v) unlimited
file locks                      (-x) unlimited
$  ulimit -c unlmited << set coredump unlimited size
  1. coredump path
$ cat  /proc/sys/kernel/core_pattern
core
$ echo "/tmp/core.%p" > /proc/sys/kernel/core_pattern --> set to pid name

coredump naming rules
3. GDB read coredump

  • you need to prepare target binary with debug symbol & sysroot
  • active GDB
$ ./gdb <binary with debug symbol> <coredump name>
$ (gdb) set sysroot ./target_debug/
$ info shared  << 查看有關library
$ info stack << 查看發生segfault 的函數傳遞

Permernently enable coredump size when build SDK

ulimit needs to be used after the user logs in and applies only to that logged-in environment.

To change the default ulimit of Linux kernel so that it takes effect during the rcS stage, modifications are required in linux/include/asm-generic/resource.h. However, defining this could lead to customers altering our Linux default values, which is why SDK does not use it by default.

[RLIMIT_CORE]        = {   64*1024*1024,  RLIM_INFINITY }

Check Symbol From File

Check library or program dependencies

Before debugging, you may need to know the dependency of target program

$ arm-augentix-linux-gnueabi-ldd --root . <file>libpthread.so.0 => /lib/libpthread.so.0 (0x8badf00d)libc.so.6 => /lib/libc.so.6 (0x8badf00d)ld-linux.so.3 => /lib/ld-linux.so.3 (0x8badf00d)
(ignore)

Make sure that the debugging program have symbols

You might check whether debug symbols exist with utils file in DUT.

$ file ld-2.22.so
ld-2.22.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, not stripped

On the other hand, check whether the section debug_info is in the ELF works also

$ arm-augentix-linux-gnueabi-objdump --syms ld-2.22.so | grep .debug_info
00000000 l    d  .debug_info    00000000              .debug_info

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/867139.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

springboot的健身房预约管理系统-计算机毕业设计源码75535

目录 1 绪论 1.1 选题背景与意义 1.2国内外研究现状 1.3论文结构与章节安排 1.4开发技术 1.4.1 Java技术 1.4.2MVVM模式 1.4.3B/S结构 1.4.4SpringBoot框架 1.4.5 Mysql数据库 2系统分析 2.1 可行性分析 2.1.1经济可行性 2.1.2技术可行性 2.1.3操作可行性 2.2 系…

matlab 花瓣线绘制

matlab 花瓣线绘制 clc,clear,close all; % 创建一个范围内的 x 和 y 值 x linspace(-1.5, 1.5, 100); y linspace(-1.5, 1.5, 100);% 创建一个网格来表示 x 和 y 值的组合 [X, Y] meshgrid(x, y);% 计算方程的左边和右边的值 LHS1 X.^2 Y.^2; RHS1 X.^4 Y.^4;LHS2 X.…

vue2-vue3响应式原理

我们先来看一下响应式意味着什么&#xff1f;我们来看一段代码&#xff1a; m有一个初始化的值&#xff0c;有一段代码使用了这个值&#xff1b;那么在m有一个新的值时&#xff0c;这段代码可以自动重新执行&#xff1b; let m 20 console.log(m) console.log(m * 2)m 40上…

计算机网络-IP组播基础

一、概述 在前面的学习交换机和路由协议&#xff0c;二层通信是数据链路层间通信&#xff0c;在同一个广播域间通过源MAC地址和目的MAC地址进行通信&#xff0c;当两台主机第一次通信由于不清楚目的MAC地址需要进行广播泛洪&#xff0c;目的主机回复自身MAC地址&#xff0c;然后…

MySQL数据库树状结构查询

一、树状结构 MySQL数据库本身并不直接支持树状结构的存储&#xff0c;但它提供了足够的灵活性&#xff0c;允许我们通过不同的方法来模拟和实现树状数据结构。具体方法看下文。 数据库表结构&#xff1a; 实现效果 查询的结果像树一样 二、使用 以Catalog数据表&#xff0c…

昇思25天学习打卡营第18天 | 基于MobileNetv2的垃圾分类

内容介绍&#xff1a; MobileNet网络是由Google团队于2017年提出的专注于移动端、嵌入式或IoT设备的轻量级CNN网络&#xff0c;相比于传统的卷积神经网络&#xff0c;MobileNet网络使用深度可分离卷积&#xff08;Depthwise Separable Convolution&#xff09;的思想在准确率小…

CSS选择器:nth-child()

CSS3 :nth-child() 选择器 :nth-child(n) 选择器匹配属于其父元素的第 N 个子元素&#xff0c;不论元素的类型。 n 可以是数字、关键词或公式。 Odd 和 even 是可用于匹配下标是奇数或偶数的子元素的关键词&#xff08;第一个子元素的下标是 1&#xff09;。 使用公式 (an b)。…

Nginx-http_limit_req_module模块

文章目录 前言一、ngx_http_limit_req_module模块二、指令1.limit_req_zone2.limit_req3.limit_req_log_level4.limit_req_status 实验burst取默认0的情况burst不取默认值 总结 前言 如何限制每个客户端每秒处理请求数 一、ngx_http_limit_req_module模块 生效阶段&#xff1…

间接平差——以水准网平差为例 (matlab详细过程版)

目录 一、原理概述二、案例分析三、代码实现四、结果展示本文由CSDN点云侠原创,间接平差——以水准网平差为例 (matlab详细过程版),爬虫自重。如果你不是在点云侠的博客中看到该文章,那么此处便是不要脸的爬虫与GPT生成的文章。 一、原理概述 间接平差的函数模型和随机模型…

加盖骑缝章软件、可以给PDF软件加盖自己的骑缝章

加盖骑缝章的软件多种多样&#xff0c;尤其是针对PDF文件&#xff0c;有多种软件可以实现给PDF文件加盖自己的骑缝章。以下是一些常用的软件及其特点&#xff1a; 1. Adobe Acrobat Pro DC 特点&#xff1a; 多功能PDF编辑&#xff1a;Adobe Acrobat Pro DC是一款功能强大的…

加入运动健康数据开放平台,共赢鸿蒙未来

HarmonyOS SDK运动健康服务&#xff08;Health Service Kit&#xff09;是为华为生态应用打造的基于华为帐号和用户授权的运动健康数据开放平台。在获取用户授权后&#xff0c;开发者可以使用运动健康服务提供的开放能力获取运动健康数据&#xff0c;基于多种类型数据构建运动健…

【Qwen2部署实战】Ollama上的Qwen2-7B:一键部署大型语言模型指南

系列篇章&#x1f4a5; No.文章1【Qwen部署实战】探索Qwen-7B-Chat&#xff1a;阿里云大型语言模型的对话实践2【Qwen2部署实战】Qwen2初体验&#xff1a;用Transformers打造智能聊天机器人3【Qwen2部署实战】探索Qwen2-7B&#xff1a;通过FastApi框架实现API的部署与调用4【Q…

Python创建MySQL数据库

一、使用Docker部署本地MySQL数据库 docker run --restartalways -p 3307:3306 --name mysql -e MYSOL_ROOT_PASSWORDlms123456 -d mysql:8.0.25 参数解析: 用户名:root 密码:lms123456 端口:3307 二、在Pycharm开发工具中配置连接MySQL数据库 三、安装zdppy_mysql pip inst…

沉浸式三维园区场景漫游体验

利用图扑三维可视化技术展示园区在不同时间段的变化&#xff0c;提供全景漫游体验&#xff0c;帮助用户全方位感受和理解园区环境&#xff0c;实现智能化管理与优化。

Linux 进程间的信号

1.信号的初认识 信号是进程之间事件异步通知的一种方式&#xff0c;属于软中断。通俗来说信号就是让用户或进程给其他用户和进程发生异步信息的一种方式。对于信号我们可以根据实际生活&#xff0c;对他有以下几点认识&#xff1a;1.在没有产生信号时我们就知道产生信号要怎么处…

LLM - 卷积神经网络(CNN)

1. 卷积神经网络结构&#xff1a;分为输入层&#xff0c;卷积层&#xff0c;池化层&#xff0c;全连接层&#xff1b; &#xff08;1&#xff09;首先进入输入层&#xff0c;对数据数据进行处理&#xff0c;将输入数据向量化处理&#xff0c;最终形成输入矩阵。 &#xff08;…

电脑录歌用什么软件好?分享电脑录音软件:6款

短视频普遍的今天&#xff0c;越来越多的人喜欢通过电脑进行音乐创作和录制。然而&#xff0c;面对市面上琳琅满目的电脑录音软件&#xff0c;很多人可能会感到困惑&#xff1a;电脑录歌用什么软件好呢&#xff1f;本文将为大家分享六款精选的录音软件&#xff0c;帮助大家找到…

校园电动车安全监控和调度系统-计算机毕业设计源码13028

摘要 校园电动车安全监控和调度系统是为了确保校园内电动车的安全和高效运行而设计的。该系统通过安装在电动车上的监控设备&#xff0c;实时监测电动车的运行状态&#xff0c;包括速度、位置、电池电量等&#xff0c;一旦发现异常情况&#xff0c;系统会立即发出警报并通知相关…

【matlab】分类回归——智能优化算法优化径向基神经网络

径向基&#xff08;Radial Basis Function, RBF&#xff09;神经网络 一、基本概念 径向基函数&#xff08;RBF&#xff09;&#xff1a;是一个取值仅仅依赖于离原点&#xff08;或某一中心点&#xff09;距离的实值函数。在RBF神经网络中&#xff0c;最常用的径向基函数是高…

使用patch-package自动修改node_modules中的内容/打补丁

背景 在使用VuePress搭建个人博客的过程中&#xff0c;我需要使用到一个用来复制代码块的插件uepress-plugin-nuggets-style-copy。 问题&#xff1a;插件可以正常安装&#xff0c;但是启动会报错。通过查看错误信息&#xff0c;定位是插件中的copy.vue文件出现错误&#xff0c…