I. probe the stack frame structure The original idea is to unwind the function call stack according to a determined prologue on the begin of a frame. For example:

-------

PC

-------

LR

-------

SP

-------

FP

-------

.......

The precondition of this idea is that every frame stores all these infomations in same order at the front of the frame. But the practices tell us that's not true. In fact, some functions do so, some not. Why do some functions not do so? (Not understand till now. Maybe in order to save some memery, maybe it is not necessary to do so, maybe other unknown reasons.)

To prove this jugement, we did following things.

1. The output call stack is not complete with the method refered above.

2. Produce coredump file, then analyze the frame structures with gdb. We found three strange things:

1st, the caller frame of the frame before the signal process frame is itself, so we can't unwind to inner frame.

2nd, in stack memery we can't find any frame address showed by "info frame" command. How so?

3rd, then we dissamble different frames, we were astonished to found that different functions push very different  registers to the stack, even some functions didn't push any register at all.

3. Finally, we found an offical hint on gdb web site: "whether each function has a frame pointer and if not".

II. Try with backtrace of glibc.   Since there is not a determined frame structure, can the backtrace function of glibc work?   We did a lot of tries. But the results are the same with the above method. We are so wondering. So we read the   source code of backtrace function of glibc-linaro. The answer is it use the same method we did before. So the   results are same.

III. Try with unwind library first time.   Search on google and baidu. We found a library unwind. It's the library to unwind function call stack. And we   integrated it in our project immedially. Soon we got the result. It only has one frame more than the backtrace   function, and there is some other unkown error messages. It seems not suit to our project still. We guess, maybe   our project is more complicated than libunwind can apply, because we have 64bit CPU and OS, but 32bit application.   Or maybe it's not suitable for EABI.

IV. Try to learn from GDB.   Hitherto, the only one practicable method is GDB, why not to find the method that GDB use? Factually, She gong   and I had tried to read GDB's code before. But had to terminate for it's too complicated and too big to understand   in a short time. This time, we returned to it again. Though we didn't understand how it unwind the stack still, we   found some usefull infomations.   1. GDB use ptrace to get the registers.   2. GDB try to parse the function prologues when there isn't frame pointer. But how and what's the criteria, we      didn't know still.

V. Try with unwind library second time.   During we try to understand GDB's unwinding method. We found a usefull infomation that .eh_frame or .ARM.exidx or   .ARM.extab section in elf file can help to unwind the stack. This inspired a sparkle: can we unwind stack only with   these section? We tried to find a way and found the attachment document. It introduced these sections and   the compile paramter "-funwind-tables" and the related libunwind. So we try according it. It works!

[References]:

https://wiki.linaro.org/KenWerner/Sandbox/libunwind?action=AttachFile&do=get&target=libunwind-LDS.pdf

https://sourceware.org/gdb/papers/unwind.html

https://www.airs.com/blog/archives/460

https://www.facebook.com/notes/scott-tsai/%E5%9C%A8%E6%B2%92%E6%9C%89-frame-pointer-%E7%9A%84%E6%83%85%E6%B3%81%E4%B8%8B%E9%80%B2%E8%A1%8C-stack-unwind/784226238316104/

[A sparkle]:

Can we use _Unwind_Backtrace() of ligcc_s.so to unwind the function stack?

The way to unwind the stack on Linux EABI的更多相关文章

  1. Extended TCP/IP Stack In Linux: Netfilter Hooks and IP Table

    https://www.amazon.com/gp/product/1118887735 The chapter about debugging is rather outdated - it des ...

  2. Linux常用获取进程占用资源情况手段

    测试环境:Ubuntu14.04 1.  获取进程ID号 ps -aux | grep your_process_name 例如: xxx@xxx:~$ ps -e |grep Midlet|awk ...

  3. Coping with the TCP TIME-WAIT state on busy Linux servers

    Coping with the TCP TIME-WAIT state on busy Linux servers 文章源自于:https://vincent.bernat.im/en/blog/20 ...

  4. Linux: 20 Iptables Examples For New SysAdmins

    Linux comes with a host based firewall called Netfilter. According to the official project site: net ...

  5. linux 内核参数图解

    https://www.suse.com/documentation/sles11/book_sle_tuning/data/part_tuning_kernel.html http://blog.c ...

  6. Error handling in Swift does not involve stack unwinding. What does it mean?

    Stack unwinding is just the process of navigating up the stack looking for the handler. Wikipedia su ...

  7. Linux 驱动开发

    linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...

  8. android 官方文档 JNI TIPS

    文章地址  http://developer.android.com/training/articles/perf-jni.html JNI Tips JNI is the Java Native I ...

  9. NDK(5) Android JNI官方综合教程[JavaVM and JNIEnv,Threads ,jclass, jmethodID, and jfieldID,UTF-8 and UTF-16 Strings,Exceptions,Native Libraries等等]

    JNI Tips In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Global ...

随机推荐

  1. spring+springmvc+ibatis整合注解方式实例

    需求说明 实现用户通过数据库验证登录需求.採用 Myeclipse+Tomcat 6.0+Mysql 5.0+JDK 1.6 2.数据库表 开发所用是Mysql数据库,仅仅建立单张用户表T_USER, ...

  2. Swift实时画箭头的实现

    iOS上实现画箭头,如果是指定了坐标点,那是很简单的,但如果需要做到实时绘制,就需要计算一下了 需求: 在白板上,根据手势落下点和移动点,实时绘制一条箭头直线(如下图) 实现代码: /// 获取箭头的 ...

  3. 单片机成长之路(51基础篇) - 006 在Linux下搭建51单片机的开发烧写环境

    在Linux下没有像keli那样好用的IDE来开发51单片机,开发环境只能自己搭建了. 第一步:安装交叉编译工具 a) 安装SDCC sudo apt-get install sdcc b)测试SDC ...

  4. OSI(Open System Interconnect) 网络七层协议

    你作为用户想发个快递,你叫来了顺丰,顺丰快递员从你手里拿走了快递,又装进一个盒子,然后把一个快递单子贴在了上面. 快递员回到集散中心,将快递往那一扔不管了,分拣员把快递按投递的省市分开,发往同一地区的 ...

  5. 【ThinkPHP】ThinkPHP环境的安装与配置

    ThinkPHP是一个免费开源的,快速.简单的面向对象的轻量级PHP开发框架. 严格来说,ThinkPHP无需安装过程,这里所说的安装其实就是把ThinkPHP框架放入WEB运行环境(前提是你的WEB ...

  6. SNF软件开发机器人2018最新更新内容

    SNF软件开发机器人从10月份到现在的更新升级情况如下: 1 表单 表单控件占多列时,宽度默认0,自适应宽度2 excel导出 部分excel导出方法移动到框架中,可通用获取3 生成代码 生成的代码, ...

  7. SNF软件开发机器人-子系统-功能-启用大按钮样式如何配置

    启用大按钮 当启用大按钮被选中后,页面的按钮图表将以按钮配置中的大按钮样式显示. 1.效果展示: 2.使用说明: 打开显示页面,点击开发者选项的简单配置按钮.在功能表信息中选择启用大按钮复选框后保存.

  8. 关于web项目创建后WEB-INF下面没有出现web.xml的解决方法

    提供两种解决方案: 第一种:创建完项目后,需要手动创建出web.xml 第一步:选取创建的项目名称右击 第二步:eclipse的同学找到 java EE Tools 中的 下图画圈部分.  MyEcl ...

  9. svg中实现文字随曲线走向,HTML直接写和JavaScript创建对象两种方式

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=&qu ...

  10. React Native常用组件之ListView

    1. ListView常用属性 ScrollView 相关属性样式全部继承 dataSource ListViewDataSource 设置ListView的数据源 initialListSize n ...