-
Notifications
You must be signed in to change notification settings - Fork 133
Implement stack traces #418
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
Conversation
024d332 to
2d1ee66
Compare
d2f0095 to
0723f1c
Compare
8f7a114 to
c3a508f
Compare
pguyot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed elsewhere, another approach would be to modify the code loading function (or create a new one) and call it when a stack trace is needed, so that the data structures are not kept with the modules but are only generated on stack trace creation.
726edb8 to
6263486
Compare
Wow, that would be a challenge! I think I would like to treat that as an optimization (future tense) and maybe give this some soak time to flush out any bugs. What do you think? |
Let's choose the memory optimizations we want. Personally, I'm perfectly fine with the additional memory impact, and I believe larger memory gains can be obtained elsewhere (especially with gc / heaps) and the actual optimization target (or memory constraint) should be known. I'm also pointing that possible optimization as opposed to have strings in binaries vs lists. Let's move forward with stack traces which are a huge benefit, but also let's try to stick to OTP specifications. As a recent user of AtomVM, I found it difficult to not find usual Erlang stuff. |
f29b690 to
d672cae
Compare
c60db00 to
b121049
Compare
…M files, and CMake (AVM_RELEASE) variable to disable line information (enabled by default on development builds) Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
…dule in a stacktrace. Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Signed-off-by: Fred Dushin <fred@dushin.net>
Implement stack traces
This PR adds support for stacktraces, both in the display of crash reports, as
well as programmatic access to stacktrace data as terms in catch clauses.
Stacktrace data is represented as a list of tuples, each of which represents a
stack “frame”. Each tuple is of the form:
```
[{Module :: module(), Function :: atom(), Arity :: non_neg_integer(), AuxData :: aux_data()}]
```
where `aux_data()` is a (possibly empty) properties list containing the following elements:
```
[{file, File :: string(), line, Line :: pos_integer()}]
```
Stack frames are ordered from the frame “closest“ to the point of failure
(the “top” of the stack) to the frame furthest from the point of failure
(the “bottom” of the stack).
Stack frames will contain file and line information in the `AuxData` list if the
BEAM files (typically embedded in AVM files) include `<<“Line”>>` chunks
generated by the compiler. Otherwise, the `AuxData` will be empty.
Note that adding line information to BEAM files not only increases the size of
BEAM files in storage, but calculation of file and line information can have a
non-negligible impact on memory usage. Memory-sensitive applications should
consider not including line information in BEAM files.
Addresses issue #254.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
|
Merged. |
This PR adds support for stacktraces, both in the display of crash reports, as well as programmatic access to stacktrace data as terms in catch clauses.
Stacktrace data is represented as a list of tuples, each of which represents a stack “frame”. Each tuple is of the form:
where
aux_data()is a (possibly empty) properties list containing the following elements:Stack frames are ordered from the frame “closest“ to the point of failure (the “top” of the stack) to the frame furthest from the point of failure (the “bottom” of the stack).
Stack frames will contain file and line information in the
AuxDatalist if the BEAM files (typically embedded in AVM files) include<<“Line”>>chunks generated by the compiler. Otherwise, theAuxDatawill be empty.Note that adding line information to BEAM files not only increases the size of BEAM files in storage, but calculation of file and line information can have a non-negligible impact on memory usage. Memory-sensitive applications should consider not including line information in BEAM files.
Addresses issue #254.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later