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

🚨🔊 Add a better Data Abort Handler #112

Merged
merged 27 commits into from
Sep 2, 2019

Conversation

edjubuh
Copy link
Member

@edjubuh edjubuh commented Feb 17, 2019

Summary:

Dunno how to be concise yet. But this makes the data abort handler do something interesting.

  • We have our own error box on the V5 that reports the proper PC and also current task name (because we can)
  • We still background process and printfs work, so I print registers of the state that caused the abort and stack trace of the running task
    • This required adding unwind tables. Some additional adjustments will need to be made once ✨ Add 🔥/❄ linking #89 lands to ensure that the unwinder can find both hot and cold tables.

There will need to be additional work in the CLI to create a frontend for doing addr2line and objdump to make it a bit easier to see where things went wrong.

Motivation:

I'm tired of guessing why the MEMORY ERROR 0000000 box pops up because the 0000000 is meaningless.

References (optional):

Closes #150

Test Plan:

  • int x = *(int*)0; printf("%d\n" ,x); and get this output

@edjubuh edjubuh added p: normal Normal priority enhancement This builds on top of an existing feature labels Feb 17, 2019
@edjubuh edjubuh added this to the 3.1.7 milestone Feb 17, 2019
@edjubuh edjubuh changed the title Add a better Add a better Data Abort Handler Feb 17, 2019
@Octogonapus
Copy link
Contributor

Octogonapus commented Feb 17, 2019

I have been seeing a lot of people ask for memory usage. Is it possible to get the current heap/task stack memory usage? That might also be something we want to display.

@edjubuh
Copy link
Member Author

edjubuh commented Feb 17, 2019

I have been seeing a lot of people ask for memory usage. Is it possible to get the current heap/task stack memory usage? That might also be something we want to display.

Stack usage is a bit philosophical. Do you want to see current task stack usage or peak stack usage or perhaps average stack usage? Current task stack usage at the time of the abort is easy since we know the current SP and where the top of the stack is (since we have access to the TCB). Peak stack usage is a more expensive to compute and perfect if you're trying to fool it, but FreeRTOS does have a facility. We don't currently measure any sort of average stack usage. Average stack usage could be probed periodically on every context switch and do a rolling average on that, but that seems like a lot of work for little tangible benefit.

@edjubuh
Copy link
Member Author

edjubuh commented Feb 17, 2019

I have been seeing a lot of people ask for memory usage. Is it possible to get the current heap/task stack memory usage? That might also be something we want to display.

Heap usage can be done by users today with mallinfo. I'll add that to the printf'd abort report

@Octogonapus
Copy link
Contributor

that seems like a lot of work for little tangible benefit

I agree. Just reporting whatever the stack usage happens to be at abort time is probably good enough for now.

@edjubuh edjubuh changed the title Add a better Data Abort Handler 🚨🔊 Add a better Data Abort Handler Feb 17, 2019
@edjubuh edjubuh added this to In progress in 3.1.7 Feb 18, 2019
@HotelCalifornia HotelCalifornia added the in progress This is currently being worked on label Feb 18, 2019
@edjubuh edjubuh marked this pull request as ready for review February 20, 2019 00:39
@edjubuh
Copy link
Member Author

edjubuh commented Mar 7, 2019

From some initial testing from @baylessj, we've discovered that many (if not all) of the FILE* family of functions (fopen, fputs) are marked as cantunwind. Investigating further.

@edjubuh
Copy link
Member Author

edjubuh commented Mar 7, 2019

Turns out there's no unwinding information in newlib/libc.a that ships in the GNU Toolchain whatsoever... I'm trying to figure out if that was intentional.

arm-none-eabi-readelf -u /usr/arm-none-eabi/lib/libc.a | less

@edjubuh edjubuh self-assigned this Mar 7, 2019
PROS Non-Versioned Kernel Development automation moved this from Reviewer Approved to In Review Aug 8, 2019
@HotelCalifornia HotelCalifornia moved this from In Review to In Progress in PROS Non-Versioned Kernel Development Aug 20, 2019
src/system/hot.c Outdated
@@ -71,6 +76,7 @@ void invoke_install_hot_table() {
// printf("%s %p %p %x %x\n", __FUNCTION__, (void*)install_hot_table, (void*)HOT_TABLE, MAGIC_ADDR[0], MAGIC_ADDR[1]);
if(vexSystemLinkAddrGet() == (uint32_t)0x03800000 && MAGIC_ADDR[0] == MAGIC0 && MAGIC_ADDR[1] == MAGIC1) {
install_hot_table(HOT_TABLE);

This comment was marked as resolved.

@HotelCalifornia HotelCalifornia added enhancement This builds on top of an existing feature feature A brand new feature and removed enhancement This builds on top of an existing feature labels Sep 2, 2019
missed this in #155, but these two functions are moved to their own file for the same reason as __malloc_lock/__malloc_unlock were-- to follow the override scheme that newlib expects. found the right filename from here: https://newlib.sourceware.narkive.com/aXWplROp/queries-concerning-rtos-protection-in-newllib
.arclint Outdated Show resolved Hide resolved
PROS Non-Versioned Kernel Development automation moved this from In Progress to Reviewer Approved Sep 2, 2019
Copy link
Contributor

@HotelCalifornia HotelCalifornia left a comment

Choose a reason for hiding this comment

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

this looks good to me, now that it works and compiles and all that 😄

@HotelCalifornia HotelCalifornia merged commit 6394b23 into develop Sep 2, 2019
PROS Non-Versioned Kernel Development automation moved this from Reviewer Approved to Done Sep 2, 2019
@HotelCalifornia HotelCalifornia mentioned this pull request Sep 3, 2019
1 task
HotelCalifornia added a commit that referenced this pull request Sep 15, 2019
* Better errno for registry validation failure, update vision sensor errnos

Summary:
  - Changed port number validation to return ENXIO when outside the domain of port numbers
  - Changed port validation to return ENODEV when the requested device doesn't match the actual device
  - Vision Sensor read/get functions consistently use EAGAIN when the libv5rts tells us it couldn't get data
  - Remove docstrings for EACCES since it is practically impossible to get that errno (we wait for mutex indefinitely)

Test Plan:
TBD

* ✨ Add Makefile-variable for excluding libraries from cold image (#121)

#### Summary:
Someone want to enable 🔥/❄ function but he doesn't want to include all libraries in the cold image. So he adds this feature here. you can edit `EXCLUDE_COLD_LIBRARIES` to exclude the library. The library will be compiled every time you use `make` command. (🔥🔥🔥)

#### Motivation:
Add it.

##### References (optional):
lazy to make an issue. 404 not found.

#### Test Plan:
- [x] Make a library for testing
- [x] Make a new project and apply the testing library
- [x] Compile with  🔥/❄ function (use `make all`)
- [x] Upload and test if the library is running?
- [x] Exclude the library
- [x] Compile with  🔥/❄ function (use `make all`)
- [x] Upload and test if the library is running?
- [x] Change something in the project
- [x] Compile with  🔥/❄ function  (use `make`)
- [x] Upload and test if the library is running?
- [x] delete variable `EXCLUDE_COLD_LIBRARIES`
- [x] Compile with  🔥/❄ function (use `make all`)
- [x] Upload and test if the library is running?

* Update vdml_vision.c

* Update vdml_vision.c

* Update vdml_vision.c

* Update Copyright info to current year

* 🐛 Fix cold libraries variable assignment (#129)

* Apply suggestions from code review

Co-Authored-By: edjubuh <edjubuh@elliotjb.com>

* Fix whitespace

* Fix up errno when mismatch/not connected

* Fix up errno when mismatch/not connected for ADI

* Fix up errno when mismatched/not connected for ADI round 2

* Fix up errno when mismatched/not connected for ADI round 3

* ✨ Improve Makefile compile speed (#123)

#### Summary:
Someone doesn't want to waste his time. So he adds this code to make compile-job faster. The compiler now doesn't need to remove and create `temp.log` every time it compiles a file. 

#### Motivation:
Add it.

##### References (optional):
close #103 

#### Test Plan:
- [x] Call `make all`
- [x] Call `make`
- [x] Try to compile with no error
- [x] Try to compile with warning
- [x] Try to compile with error

#### Commits:

* ✨ Improve Makefile compile speed

* Use only variables; use printf

* Keep changes from #119

* Do not treat strings as escaped

* Migate kernel makefile to test_output_2 (#130)

#### Summary:
Migrate kernel makefile to `test_output_2` and make make make again.

#### Motivation:
It's broken because `@cd` isn't a command. `@` was supposed to suppress echoing the whole command, but `test_output` has changed.

##### References (optional):
#123 

#### Test Plan:
- [X] It build

* Fix incorrect port type (#139)

#### Summary:
Fix incorrect port type in some motor functions

#### Motivation:
They were different from everywhere else with seemingly no reason.

#### Test Plan:

- [x] Still compiles

* Add alternate generic serial API and fix generic serial filesystem driver (#141)

* Add alternate serial API

* Fix generic serial files

* Add serial tests

* Fix dev_read_r and dev_write_r starving tasks

* Revert DEVCTL_SET_BAUDRATE to maintain compatibility

* Update generic serial test

* Modify blocking serial sleep time

* Move serial include

* Change serial telemetry function names

* 🐛 Update vision_read_by_sig to be less funky (#124)

* Update vision_read_by_sig to properly transform all coordinates and
respect array boundaries

Summary:
- We weren't properly respecting array boundaries on read_by_sig, now we
are

Test Plan:
- [x] @kdcrafter tested in T659 and throughout Worlds

* Update vdml_vision.c

* 🚨 Make things work with GCC 8.3 (#155)

* add __sync_synchronize stub

* catch exception by reference to suppress new warning

* move mlock functions to their own file to fix newlib

* 🔧 Enable hot/cold by default (#154)

* 🏗 Combine template source files (#152)

* Rename main.c to startup.c

* Combine initialize, autonomous, and opcontrol into main

* Patch Makefile

* Patch template-Makefile

* Don't change USE_PACKAGE in this PR

* 🐛 Fix multiple ADI bugs and inconsistencies (#151)

* Fix IntelliSense error

* Note possible hack with registry pad

* Note possible issue with claim_port

* Cleanup ADI C API

* Remove config clear from ADI destructor

* Move ADI config to initilizer list

* Fix double normalization of ultrasonic port

* Partially Revert "Remove config clear from ADI destructor"

This partially reverts commit 6a562ef.

* Declare ADIPort destructor as default

* Revert "Note possible hack with registry pad"

This reverts commit 866067b.

* Change claim_port note

* ⬆️ Upgrade LVGL to 5.3 (#144)

* [wip] rollback point

* finish upgrade\? doubt it

* update lv_conf

* make everything compile

- still need to test for some regressions
- still need to test some 5.3 features

* initialize LVGL before system daemon

* make non-monospaced font the default again

* limit LLEMU screen to 33 monospace chars

* clean versions

* add comment about system_daemon_initialize

* 🤫 Suppress ignored qualifiers when including lvgl (#147)

* 🔧 Add default `.gitignore` to template (#156)

* 🚸 Add alternate constructor for pros::Task (#158)

* Alternate Task contructor: ommission of prio and stack_depth while still allowing access to name

* Delegation of truncated constructor to the normal constructor

* 💚 Update toolchain installation for azure (#163)

* update toolchain installation for azure

the PPA was hanging, and it installs an old version anyway

* Update azure-pipelines.yml

Co-Authored-By: Elliot Berman <berman5@purdue.edu>

* 🚨🔊 Add a better Data Abort Handler (#112)

* Add WIP of a better DataAbortHandler

* More WIP

* Cleanup

* refactor some things

* Refactor, clean up, and documentation

* More comments

* Update unwind.c

* Tweak printfs

* Add custom build of newlib

* Include libc/libm in template

* Exclude libc/libm from being included in cold image

* check whether pc is in the hot zone

* test unwind with hot/cold linking

* Add support for unwinding through hot code

* Clean up for PR

* Undo USE_PACKAGE:=1

* remove leftover include

* move __env_lock/__env_unlock to src/system/envlock.c

missed this in #155, but these two functions are moved to their own file for the same reason as __malloc_lock/__malloc_unlock were-- to follow the override scheme that newlib expects. found the right filename from here: https://newlib.sourceware.narkive.com/aXWplROp/queries-concerning-rtos-protection-in-newllib

* lint files

* Update .arclint whitespace

* 🐛 Add default LLEMU init code back to main.cpp (#165)

* 🐛 adddefault LLEMU init code back to main.cpp

* add documentation comment for callback function

* Bump to 3.2.0

* 🔧 Recompile on header change (#167)

* implemented header dependency tracking

* Added dependency folder to the makefile

* fix bug in making c folders

* Renamed POSTCOMPILE

* Undo unwanted changes

* Modify template gitignore

* Ignore clean errors

* 🐛 Return proper error code for VDML functions that return floating point numbers (#160)

* 🐛 Fix problem of return PROS_ERR_F error code

* 🐛 Improve condition statement and comment VDML function


🤫 forgot to change

* 🐛 Undo claim_port_try code to avoid warning




🐛 Undo claim_port_try code to avoid warning

* 🐛 Fix motor PID functions bug (#162)
@HotelCalifornia HotelCalifornia deleted the feature/better-abort-handler branch September 13, 2020 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A brand new feature in progress This is currently being worked on p: normal Normal priority
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

C++ exceptions not working with hot/cold linking
4 participants