Delete docs directory

pull/53/head
removedporn 4 years ago committed by GitHub
parent f4c50b13be
commit e2f123c9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +0,0 @@
|File or folder name |Description|
|:----- |:----|
|en |English documents|
|zh |中文文档(简体)|

@ -1,51 +0,0 @@
# 一步开启 Keil/IAR/GCC 的 C99 支持
## 背景
C99 标准于 1999 年发布至今2016-12-28将近 20 年的时间,相比早期的 C89 C99 有如下新特性(摘自 [维基百科](https://zh.wikipedia.org/wiki/C%E8%AF%AD%E8%A8%80#C99)
- 增加了对编译器的限制,比如源程序每行要求至少支持到 4095 字节,变量名函数名的要求支持到 63 字节extern 要求支持到 31
- 增强了预处理功能。例如:
- 宏支持取可变参数 #define Macro(...) `__VA_ARGS__`
- 使用宏的时候,允许省略参数,被省略的参数会被扩展成空串。
- 支持 // 开头的单行注释这个特性实际上在C89的很多编译器上已经被支持了
- 增加了新关键字 restrict, inline, _Complex, _Imaginary, _Bool
- 支持 long long, long double _Complex, float _Complex 等类型
- 支持不定长的数组,即数组长度可以在运行时决定,比如利用变量作为数组长度。声明时使用 int a[var] 的形式。不过考虑到效率和实现,不定长数组不能用在全局,或 struct 与 union 里。
- 变量声明不必放在语句块的开头for 语句提倡写成 for(int i=0;i<100;++i) i for
- 允许采用type_name{xx,xx,xx} 类似于 C++ 的构造函数的形式构造匿名的结构体。
- 初始化结构的时候允许对特定的元素赋值,形式为:
- `struct test{int a[3]b;} foo[] = { [0].a = {1}, [1].a = 2 };`
- `struct test{int a, b, c, d;} foo = { .a = 1, .c = 3, 4, .b = 5 }; // 3,4 是对 .c,.d 赋值的`
- 格式化字符串中,利用 \u 支持 unicode 的字符。
- 支持 16 进制的浮点数的描述。
- printf scanf 的格式化串增加了对 long long int 类型的支持。
- 浮点数的内部数据描述支持了新标准,可以使用 #pragma 编译器指令指定。
- 除了已有的 `__line__` `__file__` 以外,增加了 `__func__` 得到当前的函数名。
- 允许编译器化简非常数的表达式。
- 修改了 / % 处理负数时的定义这样可以给出明确的结果例如在C89中-22 / 7 = -3, -22 % 7 = -1也可以-22 / 7= -4, -22 % 7 = 6。 而C99中明确为 -22 / 7 = -3, -22 % 7 = -1只有一种结果。
- 取消了函数返回类型默认为 int 的规定。
- 允许在 struct 的最后定义的数组不指定其长度,写做 [](flexible array member)。
- const const int i 将被当作 const int i 处理。
- 增加和修改了一些标准头文件,比如定义 bool 的 <stdbool.h> ,定义一些标准长度的 int 的 <inttypes.h> ,定义复数的 <complex.h> ,定义宽字符的 <wctype.h> ,类似于泛型的数学函数 <tgmath.h> 浮点数相关的 <fenv.h>。 在<stdarg.h> 增加了 va_copy 用于复制 ... 的参数。<time.h> 里增加了 struct tmx ,对 struct tm 做了扩展。
- 输入输出对宽字符以及长整数等做了相应的支持。
> C99 提供了众多的便利,也提高了程序开发的效率,但是一些嵌入式工具链并不是默认开启 C99接下来将会针对不同的工具链介绍如何开启 C99 模式。
## Keil 4
![keil4_enable_c99](https://raw.githubusercontent.com/armink/CmBacktrace/master/docs/zh/images/keil4_enable_c99.jpg)
## Keil 5
![keil5_enable_c99](https://raw.githubusercontent.com/armink/CmBacktrace/master/docs/zh/images/keil5_enable_c99.jpg)
## IAR
IAR 新建完的工程,默认开启 C99 ,如果工程没有开启,请使用下面的方法
![iar_enable_c99](https://raw.githubusercontent.com/armink/CmBacktrace/master/docs/zh/images/iar_enable_c99.png)
## GCC
在编译配置中增加 `-std=c99` 即可

@ -1,59 +0,0 @@
# 如何使用 addr2line 工具获取函数调用栈详细信息
## addr2line 是什么
addr2line (它是标准的 [GNU Binutils](https://www.gnu.org/software/binutils/) 中的一部分)是一个可以将指令的地址和可执行映像转换成文件名、函数名和源代码行数的工具。
## 如何获得 addr2line
Linux 系统一般会集成这个工具,本文重点介绍 Windows 系统下如何获取该工具。方法很多,我这里仅介绍两种方式
- 第一种:安装 MinGW网上教程很多自行搜索安装后在其安装目录的 `bin` 文件夹里会包含 `addr2line.exe` ,此时只用保证环境变量 `path` 中包含该路径即可;
- 第二种XP 平台除外):在本项目的 `tools` 文件夹中已存放 `addr2line.exe` ,可以将其直接拷贝至 `C:\Windows` 下,或者将 CmBacktrace 仓库的 `tools` 文件夹路径添加至到环境变量 `path` 中,这样都能保证命令行工具能正常使用 `addr2line` 命令。
## addr2line 如何使用
使用 `addr2line --help` 可以看到如下介绍:
```
$addr2line --help
Usage: addr2line [option(s)] [addr(s)]
Convert addresses into line number/file name pairs.
If no addresses are specified on the command line, they will be read from stdin
The options are:
@<file> Read options from <file>
-a --addresses Show addresses
-b --target=<bfdname> Set the binary file format
-e --exe=<executable> Set the input file name (default is a.out)
-i --inlines Unwind inlined functions
-j --section=<name> Read section-relative offsets instead of addresses
-p --pretty-print Make the output easier to read for humans
-s --basenames Strip directory names
-f --functions Show function names
-C --demangle[=style] Demangle function names
-h --help Display this information
-v --version Display the program's version
addr2line: supported targets: pe-x86-64 pei-x86-64 pe-bigobj-x86-64 elf64-x86-64 elf64-l1om elf64-k1om pe-i386 pei-i386 elf32-i386 elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
Report bugs to <http://www.sourceware.org/bugzilla/>
```
这里常用的是以下参数
- `-e` :指定可执行映像名称
- `-a` :显示函数地址
- `-f` :显示函数名称
例如命令 `addr2line -e CmBacktrace.out -f 08000a60 08000141 0800313f` 将会显示名称为 `CmBacktrace.out` 的可执行映像,在地址为 `08000a60` `08000141` `0800313f` 对应的函数名称及源代码信息。执行结果如下:
```
$addr2line -e CmBacktrace.out -a -f 08000a60 08000141 0800313f
fault_test_by_div0
D:\Program\STM32\CmBacktrace\demo\non_os\stm32f10x\app\src/fault_test.c:38
main
D:\Program\STM32\CmBacktrace\demo\non_os\stm32f10x\app\src/app.c:20
_call_main
??:?
```
> 更多使用指南,请 [参考官方说明文档](https://sourceware.org/binutils/docs-2.27/binutils/addr2line.html#addr2line) 。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Loading…
Cancel
Save