Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Get --ftrace option working on all commands #2025

Merged
merged 2 commits into from
Sep 20, 2024
Merged

[libc] Get --ftrace option working on all commands #2025

merged 2 commits into from
Sep 20, 2024

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Sep 20, 2024

Setting CONFIG_APPS_FTRACE=y now builds all applications, including the shell, with a full symbol table, allowing for symbolic function tracing during execution. Setting FTRACE=1 in /bootopts will turn on function tracing for all apps, or any app can be started with --ftrace as the first argument and it will display it execution to /dev/console.

While some of this was already present, it is now debugged. Turns out that /bin/sh actually has function nesting depth of over 100 and was overflowing the stack.

The stripped-down "tiny_printf.c" had to be slightly reworked for this to work, and it was then found that GCC was replacing some calls to printf with calls to puts or fputs, which complicated matters and unknowingly increased code size. The -fno-builtin-printf was added to stop that.

The debug option in /bootopts now turns on some basic debugging, showing which files are being exec'd, which is helpful when running a system ftrace. If you really want to see what's going on, set CONFIG_TRACE=y and strace in /bootopts, along with FTRACE=1. This will trace all system calls and all function calls for every program. Set console=/dev/ttyS0 also in /bootopts and widen the terminal emulator window to 200 columns for best clarity.

When CONFIG_APPS_FTRACE=y, the disk image is so large that 2880k floppy or HD must be selected also, and man pages aren't added so there's enough space.

@ghaerr ghaerr merged commit 6b49a51 into master Sep 20, 2024
2 checks passed
@ghaerr ghaerr deleted the ftrace branch September 20, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant