How to make backtrace()/backtrace_symbols() print the function names?

后端 未结 5 1885
别那么骄傲
别那么骄傲 2020-11-29 16:57

The Linux specific backtrace() and backtrace_symbols() allows you to produce a call trace of the program. However, it only prints function addresse

5条回答
  •  既然无缘
    2020-11-29 17:19

    the answer on the top has a bug if ret == -1 and errno is EINTER you should try again, but not count ret as copied (not going to make an account just for this, if you don't like it tough)

    static void full_write(int fd, const char *buf, size_t len)
    {
            while (len > 0) {
                    ssize_t ret = write(fd, buf, len);
    
                    if ((ret == -1) {
                            if (errno != EINTR))
                                    break;
                            //else
                            continue;
                    }
                    buf += (size_t) ret;
                    len -= (size_t) ret;
            }
    }
    

提交回复
热议问题