From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Egor Elchinov via Tarantool-patches <tarantool-patches@dev.tarantool.org> Cc: Egor Elchinov <elchinov.es@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v2 1/4] fiber: add PoC for fiber creation backtrace Date: Mon, 12 Jul 2021 14:42:59 +0300 [thread overview] Message-ID: <YOwqw7ne4UyX5u0S@grain> (raw) In-Reply-To: <33f4fb50a51ba31e09685d0c7f85b1f8543e7fbd.1625827535.git.elchinov.es@gmail.com> On Fri, Jul 09, 2021 at 02:03:50PM +0300, Egor Elchinov via Tarantool-patches wrote: > +void > +backtrace_foreach_ip(backtrace_cb cb, void **ip_buf, int limit, > + void *cb_ctx) > +{ > +#ifndef TARGET_OS_DARWIN > + char proc_name[BACKTRACE_NAME_MAX]; > + unw_word_t ip = 0, offset = 0; > + unw_proc_info_t pi; > + int frame_no, ret = 0; > + char *proc = NULL; > + > + unw_accessors_t *acc = unw_get_accessors(unw_local_addr_space); > + > + /* > + * RIPs collecting comes from inside a helper routine > + * so we skip the collector function address itself thus > + * start fetching functions with frame number = 1. > + */ > + for (frame_no = 1; frame_no < limit && ip_buf[frame_no] != NULL; > + frame_no++) { > + ip = (unw_word_t)ip_buf[frame_no]; > + > + if (acc->get_proc_name == NULL) { > + ret = unw_get_proc_info_by_ip(unw_local_addr_space, > + ip, &pi, NULL); > + offset = ip - pi.start_ip; > + } else { > + ret = acc->get_proc_name(unw_local_addr_space, ip, > + proc_name, sizeof(proc_name), > + &offset, NULL); > + proc = proc_name; > + } > + if (ret != 0 || cb(frame_no - 1, (void *)ip, proc, > + (size_t)offset, cb_ctx) != 0) > + break; > + } > + > + if (ret != 0) > + say_debug("unwinding error: %s", unw_strerror(ret)); > +#else > + int frame_no, ret = 1; > + void *ip = NULL; > + size_t offset = 0; > + Dl_info dli; > + > + for (frame_no = 1; frame_no < limit && ip_buf[frame_no] != NULL; > + ++frame_no) { > + ip = ip_buf[frame_no]; > + ret = dladdr(ip, &dli); > + offset = (char *)ip - (char *)dli.dli_saddr; > + > + if (cb(frame_no - 1, ip, dli.dli_sname, offset, cb_ctx) != 0) > + break; Looks like you forgot to test for dladdr error if I'm not missing something obvious. So it could be like ret = dladdr(ip, &dli); if (ret == 0) break; offset = (char *)ip - (char *)dli.dli_saddr; if (cb(frame_no - 1, ip, dli.dli_sname, offset, cb_ctx) != 0) break; no? > + } > + > + if (ret == 0) > + say_debug("unwinding error: %i", ret); > +#endif > +}
next prev parent reply other threads:[~2021-07-12 11:43 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-09 11:03 [Tarantool-patches] [PATCH v2 0/4] fiber: introduce " Egor Elchinov via Tarantool-patches 2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 1/4] fiber: add PoC for fiber " Egor Elchinov via Tarantool-patches 2021-07-12 11:42 ` Cyrill Gorcunov via Tarantool-patches [this message] 2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 2/4] fiber: add option and PoC for Lua parent backtrace Egor Elchinov via Tarantool-patches 2021-07-12 12:09 ` Cyrill Gorcunov via Tarantool-patches 2021-07-14 9:29 ` Egor Elchinov via Tarantool-patches 2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 3/4] fiber: refactor lua backtrace routines Egor Elchinov via Tarantool-patches 2021-07-12 12:13 ` Cyrill Gorcunov via Tarantool-patches 2021-07-14 9:42 ` Egor Elchinov via Tarantool-patches 2021-07-09 11:03 ` [Tarantool-patches] [PATCH v2 4/4] fiber: refactor C backtrace and add changelog Egor Elchinov via Tarantool-patches 2021-07-12 12:35 ` Cyrill Gorcunov via Tarantool-patches 2021-07-14 9:42 ` Egor Elchinov via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YOwqw7ne4UyX5u0S@grain \ --to=tarantool-patches@dev.tarantool.org \ --cc=elchinov.es@gmail.com \ --cc=gorcunov@gmail.com \ --subject='Re: [Tarantool-patches] [PATCH v2 1/4] fiber: add PoC for fiber creation backtrace' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox