MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_backtrace_frame

Function lwp_backtrace_frame

components/lwp/lwp.c:773–807  ·  view source on GitHub ↗

* @brief Prints a backtrace of the current thread's call stack * * @param[in] uthread The thread to backtrace (must be associated with an LWP) * @param[in] frame Pointer to the initial stack frame * * @return RT_EOK on success, -RT_ERROR on failure * * @note This function prints a backtrace of the call stack for the specified user thread, * providing addresses that can be used with a

Source from the content-addressed store, hash-verified

771 * providing addresses that can be used with addr2line to get file and line information.
772 */
773rt_err_t lwp_backtrace_frame(rt_thread_t uthread, struct rt_hw_backtrace_frame *frame)
774{
775 rt_err_t rc = -RT_ERROR;
776 long nesting = 0;
777 char **argv;
778 rt_lwp_t lwp;
779
780 if (uthread && uthread->lwp && rt_scheduler_is_available())
781 {
782 lwp = uthread->lwp;
783 argv = lwp_get_command_line_args(lwp);
784 if (argv)
785 {
786 rt_kprintf("please use: addr2line -e %s -a -f\n", argv[0]);
787 lwp_free_command_line_args(argv);
788 }
789 else
790 {
791 rt_kprintf("please use: addr2line -e %s -a -f\n", lwp->cmd);
792 }
793
794 while (nesting < RT_BACKTRACE_LEVEL_MAX_NR)
795 {
796 rt_kprintf(" 0x%lx", frame->pc);
797 if (rt_hw_backtrace_frame_unwind(uthread, frame))
798 {
799 break;
800 }
801 nesting++;
802 }
803 rt_kprintf("\n");
804 rc = RT_EOK;
805 }
806 return rc;
807}

Callers 4

arch_backtrace_uthreadFunction · 0.85
arch_backtrace_uthreadFunction · 0.85
handle_userFunction · 0.85
handle_trapFunction · 0.85

Calls 5

rt_kprintfFunction · 0.85

Tested by

no test coverage detected