简体   繁体   中英

Getting module addresses with libunwind

I extract the instruction pointer from a stackframe using libunwind like this:

unw_get_reg ( &cursor, UNW_REG_IP, &ip );

However, this only gives me the dynamic addresses of the function pointers. I would like to receive the static addresses in the modules so I can query them via addr2line.

A different thread didn't receive an answer back then. Do you know how to achieve this info?

Regards

Assuming that by static address you mean offset from the start of the module where the function resides, you may use dladdr(ip, info) where info.dli_fbase gives you the base address of the loaded module. Then (pc - info.dli_fbase) gives you the offset of this function from the start of the module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM