Skip to content

mbed fault handler: fix mbed_fault_context parameter #11272

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

Merged
merged 2 commits into from
Aug 23, 2019

Conversation

andrewc-arm
Copy link
Contributor

@andrewc-arm andrewc-arm commented Aug 21, 2019

Description

Why required

Without this fix, when void mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in) is called, mbed_fault_context_in is in **mbed_fault_context_t type which is unnecessarily doubly pointered. Also, it's unintuitive, most users will expect to simply static cast the void pointer argument to *mbed_fault_context_t instead of **mbed_fault_context_t.

What's the change

The except.S Fault_Handler assembly code will prepare mbed_fault_context_in argument as *mbed_fault_context_t type instead of **mbed_fault_context_t type.

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 21, 2019

Can you rework the commit message, shall be something like: mbed fault handler: fix mbed_fault_context parameter and second paragraph containing info about the fix - what is it fixing and why

@andrewc-arm andrewc-arm changed the title Fixes the bug of having &mbed_fault_context in mbed_fault_handler() mbed fault handler: fix mbed_fault_context parameter Aug 21, 2019
@kjbracey
Copy link
Contributor

kjbracey commented Aug 21, 2019

If you're going to change this, it's a behaviour change, so you should at least change the parameter to be mbed_fault_context_t * to show what it actually is. (Maybe const, if the handler isn't supposed to modify it).

This isn't public API anyway, I believe, and it doesn't currently use that parameter, so I'd be inclined to just stop passing that parameter at all - save an instruction.

While here, remove the unnecessary cast at

mbed_fault_context_t *const mbed_fault_context = (mbed_fault_context_t *) &fault_context;

Is there a reason this change is happening?

@andrewc-arm
Copy link
Contributor Author

andrewc-arm commented Aug 21, 2019

Is there a reason this change is happening?

I was making stack dump feature for my customers and found that parameter was returning misleading information. It took me quite sometime to figure out the right values.

I agree with const mbed_fault_context_t *. It would really help users to understand what it is instead searching through the code/assembly. I will change them. For the mbed_fault_handler override, they can make use of the argument well.

@ciarmcom ciarmcom requested review from a team August 21, 2019 09:00
@ciarmcom
Copy link
Member

@andrewc-arm, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Looks fine to me, but it is an API change, so not sure it would be appropriate for a patch release. But I don't feel that strongly.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 21, 2019

@andrewc-arm Lets take it to 5.14. If this is API change, should be "functional change" in PR type above and contain "release notes" details as well.

@andrewc-arm
Copy link
Contributor Author

Sure. Thanks for making better software.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 22, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Aug 22, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants