-
Notifications
You must be signed in to change notification settings - Fork 3k
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
platform: make C++ allocation wrappers log the correct caller address #5456
Conversation
88add3d
to
c0b7470
Compare
@TeroJaasko Can we fix also GCC in this patch, or are there any blockers ?
I can see also IAR is fixed. In the code please can you change |
@0xc0170: GCC variant has those "struct _reent" parameters in the wrappers, eg. "__real__malloc_r(struct _reent * r, size_t size)". I have no idea where to get that from C++ side. Any pointers where to look? The IAR build does not seem to get the caller address at all, as the MBED_CALLER_ADDRESS macro is defined as NULL, see https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_toolchain.h#L314. Is there a way to get the caller address on IAR? Or should I just remove the Regarding TOOLCHAIN_ARM - which is the correct one to use instead of it? On the mbed_retarget.cpp there are __ARMCC_VERSION and __CC_ARM used in addition of TOOLCHAIN_ARM. |
Don't know from top of my head, @pan- any pointers?
Looks correct, not sure if this changes with IAR 8 update, I could not find it.
|
You may include |
@TeroJaasko Could you fix this in all 3 compilers before we merge it? |
c0b7470
to
758a026
Compare
@pan- : thanks for guidance, that seems to work. IAR 8.x version seem to mostly work also if I use "#define MBED_CALLER_ADDR() ((void *)__get_LR())". I don't have IAR 7 installed, so if possible, could you take the ball on the IAR support? |
@TeroJaasko Could you please rebase this to remove the conflict ? |
758a026
to
a1bd296
Compare
@adbridge : done. At same time, removed also the pointless "if (ptr)"'s from the operator delete wrappers as they were removed from the original versions. |
I restarted jenkins CI (network failure there) @TeroJaasko what is outstanding here?
IAR support (version 7.x) ? |
As far as I know, the IAR target has never been able to print the caller address at all, just zeros. If you want to fix also IAR as part of this PR, please do so. |
Summarize: ARMCC and GCC fixed, IAR does not provide caller address thus no change there. This fix is ready for review |
The C++ "operator new" and "operator delete" (and their array variants) were logging the the caller address wrong. In practice if one used "operator new", the logged caller address pointed to mbed_retarget.cpp, not to the client. Fix this by exposing the alloc wrappers to the the retarget. Note: this fixes only the ARMCC variants, as the GCC ones have different different API and implementation.
Fix the caller address logging on the GCC compilation too. Previously the code logged the caller address as C++ wrapper, not the actual caller of the C++ operator new or delete.
a1bd296
to
b81be1e
Compare
CI build pointed out that I had broken the non-tracing IAR build. Fixed it and force pushed. |
/morph build |
Build : SUCCESSBuild number : 834 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 496 |
Test : SUCCESSBuild number : 674 |
@TeroJaasko Did you intend on adding any additional documentation? |
@cmonr : I have nothing to add here. |
Description
The C++ "operator new" and "operator delete" (and their array
variants) were logging the the caller address wrong. In practice
if one used "operator new", the logged caller address pointed
to mbed_retarget.cpp, not to the client. Fix this by exposing
the alloc wrappers to the the retarget.
Note: this fixes only the ARMCC variants, as the GCC ones have
different different API and implementation.
Related mbed-os issue: #5221
Status
IN DEVELOPMENT, GCC should also be fixed.
Migrations
NO
Related PRs
Todos
Deploy notes
Note: the GCC target is equally broken, but this PR is not fixing that.
Steps to test or reproduce
Test code