addr2line to find function names

addr2line to find function names

#include
static inline void call_trace()
{
    void* callstack[128];
    int i, frames = backtrace(callstack, 128);
    char** strs = backtrace_symbols(callstack, frames);

    for (i = 0; i < frames; ++i) {
        fprintf(stderr, "%s\n", strs[i]);
    }
    free(strs);
}

sometimes the functions name can not be printed. For example
"
ovs-vswitchd() [0x53623a]
ovs-vswitchd() [0x536748]
ovs-vswitchd() [0x537aff]
ovs-vswitchd() [0x52b819]
ovs-vswitchd() [0x477802]
ovs-vswitchd() [0x43eecf]
ovs-vswitchd() [0x43f616]
ovs-vswitchd() [0x4ed21d]
/lib64/libpthread.so.0(+0x7e25) [0x7fabd1f88e25]
"
only function address, but no functon name.
"
addr2line -f -e vswitchd/ovs-vswitchd 0x53623a
addr2line -f -e vswitchd/ovs-vswitchd 0x536748
addr2line -f -e vswitchd/ovs-vswitchd 0x537aff
addr2line -f -e vswitchd/ovs-vswitchd 0x52b819
addr2line -f -e vswitchd/ovs-vswitchd 0x477802
addr2line -f -e vswitchd/ovs-vswitchd 0x43eecf
addr2line -f -e vswitchd/ovs-vswitchd 0x43f616
addr2line -f -e vswitchd/ovs-vswitchd 0x4ed21d
"
The above can help to find the function names.
The followings are the results.
"
call_trace
lib/netdev-tc-offloads.c:774
parse_tc_flower_to_match
lib/netdev-tc-offloads.c:913
netdev_tc_flow_dump_next
lib/netdev-tc-offloads.c:1090
dpif_netlink_flow_dump_next
lib/dpif-netlink.c:1679
dpif_flow_dump_next
lib/dpif.c:1136
revalidate
ofproto/ofproto-dpif-upcall.c:2559
udpif_revalidator
ofproto/ofproto-dpif-upcall.c:999
ovsthread_wrapper
lib/ovs-thread.c:355
"

你可能感兴趣的:(Linux,kernel)