Linux??????????????????
???????????? ???????[ 2015/11/16 11:40:54 ] ??????????????
??????????????????????????μ?????????????????????л??????????????Pop????????????Push??????????????????????Pop?????????????????????????????????GDB???????????????????????????з???????????????????????£?????н?????????????????????????????????????????Pop?????????Σ?????????????к?????????????????????????????????????о???????з??????????????????????????QQ?????????£?????????澭??????????????
????????????backtrace??????????????????backtrace_symbols???????????????????Linux???и?????addr2line????????????????????к????????????addr2line??????????????
1 #include <execinfo.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 /*
6 * ?????
7 *
8 * ???backtrace??backtrace_symbols???????????????????????addr2line????
9 *
10 */
11
12 int32_t myexec(const char *cmd)
13 {
14 FILE *pp = popen(cmd?? "r"); //???????
15 if (!pp)
16 {
17 return -1;
18 }
19 char tmp[1024];
while (fgets(tmp?? sizeof(tmp)?? pp) != NULL)
22 {
23 if (tmp[strlen(tmp) - 1] == '
')
24 {
25 tmp[strlen(tmp) - 1] = '