-
Notifications
You must be signed in to change notification settings - Fork 3k
Adding debugger awarness with Keil MDK #8887
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
How does this interact with #7244? If that still applies, this will cost a lot of ROM in ARMCC? Presumably nothing you could do about the underlying issue, but maybe you could restrict the section attribute to |
c00d9a4
to
3254fe9
Compare
Tested blinky example with and without change to see the impact on ROM size, please see the results below: Without Fix
With Fix
|
@kjbracey-arm - Having just the control block in BSS section resolves the issue, i.e. we are not putting the main thread stack in .bss here. https://github.com/ARMmbed/mbed-os/pull/8887/files#diff-91e672466b09fb21b174f0f44e07b8aaL31 hence the size impact is not much. On another thought can we do same do Idle / timer threads?
|
We could make such a local change to RTX, #7244 closed with a change not happening upstream, and not making a local change either, but we could still do something locally. And just removing the area directive from the stacks altogether seems plausible - if we have no special handling for the .bss.os area in our linker maps. If this PR was a net ROM reduction by taking the stacks out of ROM and putting this control block in, @bulislaw couldn't complain. |
I am not sure of any special handling for .bss.os. |
@JonatanAntoni - Please review and share your thoughts on this PR |
Hi @deepikabhavnani, this looks meaningful to me. The relevant part for RTX5 awareness in MDK (and potentially other IDEs) is to place all the object control blocks to their specific memory sections. This applies to all RTOS objects (not only threads) when control blocks are allocated manually (from RTX point of view). Cheers, |
@JonatanAntoni does this mean that threads created by using the |
I have never tried to debug a mbed application using MDK, but I assume it won't show up. The RTOS-awareness (generally speaking component awareness) in MDK is generated using a generic Software Component View Description. The section names are used as a common entry point for control block look up. Control blocks spread randomly over the memory cannot be found.
--keep is not needed for Arm Compiler 6 but for Arm Compiler 5. The symbol Cheers, |
Testing PR with CI. |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
03bdb0d
to
c75ac42
Compare
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Conflicts :-( |
Main thread in Mbed OS is statically allocated and was not available in call stack of Keil MDK. The RTX5 kernel requires statically allocated thread information objects that are placed into a specific section to enable RTOS thread awareness in Keil MDK. This fix is to keep main thread in specific section of memory.
In case of ARM compiler, idle and timer thread stack though assigned to `.bss.os` section since not zero initialized are part of `data` section. In this commit, we are moving stacks of idle and timer thread to bss section and thereby saving ROM space.
3aa5ea6
to
4ca0122
Compare
4ca0122
to
347acd1
Compare
Rebased and conflicts resolved. Changing label from |
@deepikabhavnani Nothing hard, but we definitely prefer if PRs for minior releases come in a bit later than right after a minor release is made, if that makes sense. Lowers the risk that early 5.x.{1,2,3} patch releases will be troublesome. |
CI started |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
Client test got stuck, restarted |
👍 This helps, will consider this when adding changes for minor release. Else can we add and park those changes ? |
I just found out the proposed "patch" has only been applied to the "_main_obj" thread. Actually all internal RTX5 threads defined and created by mbedOS need to have such a patch. |
@chentang16 - Yes the patch is applied to main thread, for other threads it will be change in design since we allocate dynamic memory for thread stack. Issue can be closed for Keil MDK debugger but it will remain open in Mbed OS |
Yes, this just handles the static built-in threads. It's unclear what the path forward here is. Mbed OS is currently permitting general allocation, including thread control blocks and stacks even being on the heap, rather than being restricted to static allocation. If MDK can only debug threads allocated via fixed static memory, it's never going to be able to handle the general case, as represented by our I don't understand what MDK actually does with the special area names - if you were to just stick |
"custom control block" plays the key role here in the MDK debugger, as explained here http://www.keil.com/support/docs/4026.htm |
Is the requirement that the section be an array of the raw RTX control blocks? I imagine it is, which would mean putting an entire Other debuggers like pyOCD manage full OS awareness without any special handling, as they can follow the linked lists of the RTX kernel data structures. I can see some robustness advantages to MDK's approach - it would handle OS data structure corruption better - but it does seem limiting. But if MDK is a hybrid, where it's following the linked lists and only using the section address as a sanity-check for values, then putting the |
Description
Main thread in Mbed OS is statically allocated and was not available in call stack of Keil MDK. The RTX5 kernel requires statically allocated thread information objects that are placed into a specific section to enable RTOS thread awareness in Keil MDK. This fix is to keep main thread in specific section of memory.
Issue: #8793
Pull request type