Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds additional stack-backtrace option for specially-compiled ELKS applications to display a stack backtrace in addition to the existing function tracing capability. This option can be turned on either through
export FTRACE=2or--ftrace2as the first argument command. Normal function tracing remains available throughexport FTRACEor--ftracecommand line.Applications must be compiled with the following additional ia16-elf-gcc command line options in order to link in runtime function tracing:
The combined stack tracing was developed to track down a stack corruption bug in DCC (Open DeSmet C Compiler for ELKS) which is a work in progress. This particular C compiler is able to compile itself on ELKS, possibly providing the capability of compiling the toolchain itself inside ELKS, slowly marching towards a self-replicating system.
Some examples of the usage of function tracing output follow.
DCC --ftrace function tracing showing recursive descent parser functions being called:

ELKS kernel catching stack underflow as the result of SP being clobbered (pretty cool for non-MMU system):

DCC --ftrace2 stack backtrace display showing BP being zeroed (clobbered) directly before tree4() is called from heir25(). This information finally allowed finding the buggy source code, which ended up being that of writing outside the bounds of a local array which clobbered BP and SP in the addresses directly above the array variable:
