This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 6828424c001dea5e3fe968683f0c2f324d5d422c Author: Bowen Wang <[email protected]> AuthorDate: Mon Apr 13 19:40:42 2026 +0800 dumpstack: use printf instead of syslog for backtrace output Replace sched_dumpstack() with sched_backtrace() + backtrace_format() + printf() so that backtrace output goes through stdout instead of syslog, making it easier to capture and redirect. Signed-off-by: Bowen Wang <[email protected]> --- system/dumpstack/dumpstack.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/system/dumpstack/dumpstack.c b/system/dumpstack/dumpstack.c index 4c7731740..92b9e87c9 100644 --- a/system/dumpstack/dumpstack.c +++ b/system/dumpstack/dumpstack.c @@ -28,25 +28,34 @@ #include <sys/types.h> -#include <unistd.h> +#include <stdio.h> #include <stdlib.h> -#include <syslog.h> +#include <unistd.h> #include <execinfo.h> +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define DUMP_DEPTH 16 + /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * hello_main + * main ****************************************************************************/ int main(int argc, FAR char *argv[]) { + FAR void *backtrace_buf[DUMP_DEPTH]; + char fmt[BACKTRACE_BUFFER_SIZE(DUMP_DEPTH)]; int spid = -1; int epid = -1; int tmp = -1; + int depth; if (argc == 2) { @@ -72,7 +81,12 @@ int main(int argc, FAR char *argv[]) do { - sched_dumpstack(spid); + depth = sched_backtrace(spid, backtrace_buf, DUMP_DEPTH, 0); + if (depth > 0) + { + backtrace_format(fmt, sizeof(fmt), backtrace_buf, depth); + printf("backtrace|%d: %s\n", spid, fmt); + } } while (spid++ != epid);
