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

✨ Print stack trace to brain screen on data abort #651

Open
wants to merge 13 commits into
base: develop-pros-4
Choose a base branch
from

Conversation

ion098
Copy link

@ion098 ion098 commented Apr 22, 2024

Summary:

This pr prints the stack addresses to the brain screen during a data abort exception

Motivation:

This change makes it easier to debug data abort exceptions if the user is not connected to the terminal.

References (optional):

N/A

Test Plan:

  • Check that it compiles
  • Trigger some data abort exceptions and check that the output is correct

Copy link
Contributor

@noam987 noam987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea behind this PR looks good but there are a few major issues, both stylistically and content wise. I would like the trace to not be global and instead passed into the trace function via __gnu_unwind_Backtrace (source for that can be found here if you want to look at it for your reference: https://github.com/gcc-mirror/gcc/blob/master/libgcc/unwind-arm-common.inc). Feel free to ask follow up questions here or ping me on discord in our beta server or in a help post on VTOW.

src/system/unwind.c Outdated Show resolved Hide resolved
src/system/unwind.c Outdated Show resolved Hide resolved
src/system/unwind.c Outdated Show resolved Hide resolved
src/system/unwind.c Outdated Show resolved Hide resolved
src/system/unwind.c Outdated Show resolved Hide resolved
@noam987
Copy link
Contributor

noam987 commented Apr 26, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@noam987
Copy link
Contributor

noam987 commented Apr 26, 2024

Your code also does not compile. Here is a list of the compile errors generated by the pipeline:

src/system/unwind.c:100:10: error: expected identifier or '(' before '[' token
  100 |  uint32_t[12] pcs;
      |          ^
src/system/unwind.c: In function 'trace_fn':
src/system/unwind.c:107:31: error: 'struct <anonymous>' has no member named 'pcs'
  107 |  if (trace.size < sizeof(trace.pcs) / sizeof(trace.pcs[0]))
      |                               ^
src/system/unwind.c:107:51: error: 'struct <anonymous>' has no member named 'pcs'
  107 |  if (trace.size < sizeof(trace.pcs) / sizeof(trace.pcs[0]))
      |                                                   ^
src/system/unwind.c:108:8: error: 'struct <anonymous>' has no member named 'pcs'
  108 |   trace.pcs[trace.size++] = pc;
      |        ^
src/system/unwind.c: In function 'report_data_abort':
src/system/unwind.c:172:64: error: 'struct <anonymous>' has no member named 'pcs'
  172 |   vexDisplayString(brain_line_no++, "%p %p %p %p", (void*)trace.pcs[4*i], (void*)trace.pcs[4*i+1], (void*)trace.pcs[4*i+2], (void*)trace.pcs[4*i+3]);
      |                                                                ^
src/system/unwind.c:172:87: error: 'struct <anonymous>' has no member named 'pcs'
  172 |   vexDisplayString(brain_line_no++, "%p %p %p %p", (void*)trace.pcs[4*i], (void*)trace.pcs[4*i+1], (void*)trace.pcs[4*i+2], (void*)trace.pcs[4*i+3]);
      |                                                                                       ^
src/system/unwind.c:172:112: error: 'struct <anonymous>' has no member named 'pcs'
  172 |   vexDisplayString(brain_line_no++, "%p %p %p %p", (void*)trace.pcs[4*i], (void*)trace.pcs[4*i+1], (void*)trace.pcs[4*i+2], (void*)trace.pcs[4*i+3]);
      |                                                                                                                ^
src/system/unwind.c:172:137: error: 'struct <anonymous>' has no member named 'pcs'
  172 |   vexDisplayString(brain_line_no++, "%p %p %p %p", (void*)trace.pcs[4*i], (void*)trace.pcs[4*i+1], (void*)trace.pcs[4*i+2], (void*)trace.pcs[4*i+3]);
      |                                                                                                                                         ^
src/system/unwind.c:176:62: error: 'struct <anonymous>' has no member named 'pcs'
  176 |    vexDisplayString(brain_line_no++, "%p %p %p", (void*)trace.pcs[trace.size-2], (void*)trace.pcs[trace.size-1], (void*)trace.pcs[trace.size]);
      |                                                              ^
src/system/unwind.c:176:94: error: 'struct <anonymous>' has no member named 'pcs'
  176 |    vexDisplayString(brain_line_no++, "%p %p %p", (void*)trace.pcs[trace.size-2], (void*)trace.pcs[trace.size-1], (void*)trace.pcs[trace.size]);
      |                                                                                              ^
src/system/unwind.c:176:126: error: 'struct <anonymous>' has no member named 'pcs'
  176 |    vexDisplayString(brain_line_no++, "%p %p %p", (void*)trace.pcs[trace.size-2], (void*)trace.pcs[trace.size-1], (void*)trace.pcs[trace.size]);
      |                                                                                                                              ^
src/system/unwind.c:179:59: error: 'struct <anonymous>' has no member named 'pcs'
  179 |    vexDisplayString(brain_line_no++, "%p %p", (void*)trace.pcs[trace.size-1], (void*)trace.pcs[trace.size]);
      |                                                           ^
src/system/unwind.c:179:91: error: 'struct <anonymous>' has no member named 'pcs'
  179 |    vexDisplayString(brain_line_no++, "%p %p", (void*)trace.pcs[trace.size-1], (void*)trace.pcs[trace.size]);
      |                                                                                           ^
src/system/unwind.c:182:56: error: 'struct <anonymous>' has no member named 'pcs'
  182 |    vexDisplayString(brain_line_no++, "%p", (void*)trace.pcs[trace.size]);
      |                                                        ^
make: *** [common.mk:273: bin/system/unwind.c.o] Error 1

@noam987
Copy link
Contributor

noam987 commented Apr 28, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ion098
Copy link
Author

ion098 commented Apr 29, 2024

@noam987 Do you think that the registers and the heap used and stack remaining should also be printed to the brain screen? Is there enough space to print those? If not, should they be written to a log file on the SD card, if present?

@ion098
Copy link
Author

ion098 commented Apr 30, 2024

Also, does the stacktrace contain the PC? If so, then that should save a line on the brain screen.

@noam987 noam987 dismissed their stale review April 30, 2024 18:17

Issues were addressed

@noam987
Copy link
Contributor

noam987 commented Apr 30, 2024

Looks much better. Waiting to test this in the lab before I approve it

@noam987
Copy link
Contributor

noam987 commented May 4, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@noam987
Copy link
Contributor

noam987 commented May 4, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@noam987
Copy link
Contributor

noam987 commented May 5, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@noam987
Copy link
Contributor

noam987 commented May 14, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ion098 ion098 changed the title Print stack addresses to brain screen in unwind.c ✨ Print stack trace to brain screen on data abort Jun 8, 2024
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.

None yet

2 participants