Skip to content

nrf: Enable source line on tracebacks. Improve run-tests. #6395

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

Closed
wants to merge 1 commit into from

Conversation

mzdaniel
Copy link
Contributor

@mzdaniel mzdaniel commented Sep 2, 2020

Improve traceback debugging on nrf targets with enough flash, adding missing source line info and improve run-tests to properly handle opt_level and opt_level_lineno tests.

It will be nice to add line number on tracebacks for nrf targets. This is an important REPL and debugging feature, specially if the board has enough room to acommodate it. This feature adds 204 extra bytes to the firmware. AFAICT, this is a standard feature for all targets with flash >= 1M throught the entire repository and for most targets with exception of minimal, bare-arm and pic16bit.

Currently, run-tests fails on opt_level_lineno for nrf52840 and other nrf targets. This PR adds a feature check to fix the issue.

@glenrub: Other features on the nrf family were also checked, UBINASCII (772 bytes), SYS_STDFILES (268 bytes) and ARRAY_SLICE_ASSIGN (176 bytes) before defining MICROPY_ENABLE_SOURCE_LINE on nrf52832 and conditionally defining it on nrf51822. We certainly can revert the changes on nrf52832 and nrf51822 if 204 extra bytes is too much for them.

Here are the tests performed

nrf/mpconfigport.h (as on master):
#define MICROPY_ENABLE_SOURCE_LINE (0)

make BOARD=particle_xenon

arm-none-eabi-size build-particle_xenon/firmware.elf
text data bss dec hex filename
153308 48 4552 157908 268d4 build-particle_xenon/firmware.elf

MPY: soft reboot
MicroPython v1.12-700-g0e6ef4035 on 2020-09-01; XENON with NRF52840
Type "help()" for more information.

cd tests; ./run-tests --target nrf --device /dev/ttyACM0

534 tests performed (14756 individual testcases)
533 tests passed
226 tests skipped
1 tests failed: opt_level_lineno


nrf/mpconfigdevice_nrf52840.h (with this PR):
#define MICROPY_ENABLE_SOURCE_LINE (1)

make BOARD=particle_xenon

arm-none-eabi-size build-particle_xenon/firmware.elf
text data bss dec hex filename
153512 48 4552 158112 269a0 build-particle_xenon/firmware.elf

MPY: soft reboot
MicroPython v1.12-701-gae8394d81 on 2020-09-01; XENON with NRF52840
Type "help()" for more information.

cd tests; ./run-tests --target nrf --device /dev/ttyACM0

535 tests performed (14760 individual testcases)
535 tests passed
225 tests skipped

@mzdaniel
Copy link
Contributor Author

mzdaniel commented Aug 6, 2021

Rebased on top of master as 2021-08-05

@mzdaniel mzdaniel force-pushed the nrf_traceback_lineno branch from 48ad869 to 83ac2e0 Compare August 6, 2021 01:33
@codecov-commenter
Copy link

codecov-commenter commented Aug 6, 2021

Codecov Report

Merging #6395 (3e5127c) into master (f834fef) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6395   +/-   ##
=======================================
  Coverage   98.29%   98.29%           
=======================================
  Files         154      154           
  Lines       20015    20015           
=======================================
  Hits        19674    19674           
  Misses        341      341           
Impacted Files Coverage Δ
py/runtime.c 99.24% <0.00%> (-0.16%) ⬇️
py/objtype.c 100.00% <0.00%> (ø)
py/objenumerate.c 100.00% <0.00%> (ø)
py/parse.c 100.00% <0.00%> (+0.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f834fef...3e5127c. Read the comment docs.

Copy link
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

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

Thanks for this, and sorry it got lost in the PR queue. It's a good change, definitely very useful to have line numbers in a traceback.

@@ -59,3 +59,11 @@
#define MICROPY_PY_UBINASCII (1)
#endif
#endif

#ifndef MICROPY_ENABLE_SOURCE_LINE
Copy link
Member

Choose a reason for hiding this comment

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

It's good to keep these config options in the same order as what appears in py/mpconfig.h, in which case this one should go before MICROPY_PY_ARRAY_SLICE_ASSIGN (and after MICROPY_VFS). Same goes for all additions in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, good to know. Done

@@ -0,0 +1,6 @@
import sys
Copy link
Member

Choose a reason for hiding this comment

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

I can't see this file being used by tests/run-tests.py, I don't think it does anything having it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I wasnt sure about how do we want to add new user facing tests to the project. I included it for completeness

Copy link
Member

@dpgeorge dpgeorge Aug 8, 2021

Choose a reason for hiding this comment

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

There are 2 ways to skip tests:

  1. provide a feature check test (like here)
  2. explicitly check for the feature as part of the test and skip it if the feature is not supported

Usually (1) is used when the feature is complicated to test for, or if lots of tests rely on it. For one-off tests, option (2) is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate your comments and took note. I'm taking the test out for now and the PR looks in good shape.

@mzdaniel mzdaniel force-pushed the nrf_traceback_lineno branch 2 times, most recently from 3e5127c to ab4238e Compare August 8, 2021 21:25
@mzdaniel mzdaniel force-pushed the nrf_traceback_lineno branch from ab4238e to 240c395 Compare August 8, 2021 21:28
@dpgeorge
Copy link
Member

dpgeorge commented Aug 9, 2021

Thanks for updating. Rebased and merged in 8645b7c

@dpgeorge dpgeorge closed this Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants