首页 > 编程知识 正文

android登录注册功能实现,android实现推送一直

时间:2023-05-03 11:40:55 阅读:181672 作者:2359

backtrace概述有些系统未实现名为backtrace的函数。 常见的是linux和一些docker的库。 确定是否支持backtrace # include stdio.h # include dlfcn.hint main ({ void * Bt=} )!=bt )打印(support (n ) ); }else{printf('notsupportn ' ); } return 0; }输出[ root @ localhost Bt _ support ] # gcc test.c-LDL-g [ root @ localhost Bt _ support ] #./a.out support堆栈查看某个时间常见的工具pstack -p pid是正在运行的进程的某个时刻的堆栈. gdb .事例(gdb ) bt#0 show ) (attest.c :3 # 10x 000000000501 incool ) ) atttt 否则,结果呢? 是什么?00这样无意义的数据。 堆栈说明获取堆栈一般采用代码地址。 可能是共享库的映射地址。 地址#include execinfo.hvoid show () ) { void * s[30]={0}; backtrace(s,30; 返回; }void cool () {show ); }int main () { cool; }输出(gdb ) bt#0 show ) ) attest.c :6 # 10x 000000000400587 incool ) ) attest.c:11# 20x00000000400597inmain ) ) )0x 0000000003xgs0x7ffffffe 32033600 x 000000000000000000000000000 x 000000000000 x7 p show$2={void ) ) 00000000000000040005970x 40053 d show backtrace获取的地址与gdb bt命令获取的地址相同。 addr2line [ root @ localhost Bt _ support ] # ADR2line-FAP0x 00000000000000000000400000004000000000000000000000000000004000000000000000000000000000000000000000000000000000000000 Bt _ suppppppppppppppppppppppp test.c :60 x 000000000000400587: coolat/root/cfile/Bt _ support/test.c 3:00000000120 x 000000000 x 00000000000000000000000000000000 动态库获取堆栈test.c # define _ GNU _ source # include dlfcn.h # includeexecinfo.hvoidshow ({ void * s } intn=backtrace int i; Dl_info info; for(I=0; i n; I ) {dladdr(s[I],info ); //info.dli_saddr失效时,可以使用s[i]获取函数堆栈的指针。 dladdr主要获取so的装载开始地址。

i=0; } return; }void cool () {show ); } main.c extern void cool (; int main () { cool; } gcc-fpic-shared-o test.so test.c-ggcc./test.soma in.c-g-LDL调试输出(gdb ) pinfo $1={ DLI _ fname=0xname dli_sname=0x7ffff7bd942d 'show ', DLI _ saddr=0x7ffff 7bd 9785 show } (gdb ) printf ' addr2line-e./test.so 806/root/cfile/Bt _ support/test.c 306 1 )0x 20x000000000040063b in main () at main.c:4 addr信息必须在dladdr .中获取地址信息。 实现backtrace参考链接https://stack overflow.com/questions/811555的安卓- ndk-getting-the-backtrace APP场景包括有些函数不存在,例如docker .堆栈# include unwind.hstructbacktracestate { void * * cude }; (; static _ unwind _ reason _ codeunwindcallback (struct _ unwind _ context * context,void* arg ) backtraceste * state if(PC ) if ) state-current==state-end ) { return _URC_END_OF_STACK; } else { * state-current=reinterpret _ cast void * (PC; } } return _URC_NO_REASON; } size _ tcapturebacktrace (void * * buffer,size_t max ) { BacktraceState state={buffer,buffer max}; _ unwind _ backtrace (unwind callback,state ); return state.current - buffer; }结构备份状态, 头尾指针数组.存储void*类型数据的指针数组. _Unwind_Reason_Code回调函数返回值. struct _Unwind_Context* context回调函数第一参数. (struct_uuuunwind_context回调函数任意类型. unwindCallback自定义回调函数,传入堆栈信息content,用户的容器组件

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。