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

Debug build flag + change to sleep behavior in debug mode #4097

Merged
merged 4 commits into from
Apr 18, 2017

Conversation

bulislaw
Copy link
Member

Description

  • Introduce new macro MBED_DEBUG that's only defined for debug profile. Right now NDEBUG is defined only for release profile, which makes it impossible to separate develop and debug builds features.
  • Profile used by online IDE is develop, we probably don't want disable sleep for profile which people actually may use in 'production'. This PR makes sleep a noop only for the debug builds.

Status

READY

CC: @theotherjimmy @0xc0170

@bulislaw
Copy link
Member Author

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1809

Build failed!

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

No tools changes, so they look fine.

@bridadan
Copy link
Contributor

bridadan commented Apr 3, 2017

FYI @bulislaw Looks like there's a build failure on this one

@bulislaw
Copy link
Member Author

bulislaw commented Apr 4, 2017

One of the board was still declaring sleep rather than hal_sleep, fixed now.

/morph test-nightly

@bulislaw
Copy link
Member Author

bulislaw commented Apr 4, 2017

retest uvisor

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

+1

we might want to document this also in the mbed_sleep.h - why NDEBUG is not the way to go as mentioned in the first description here (develop has been the default profile). To answer any questions NDEBUG vs MBED_DEBUG?

@bulislaw
Copy link
Member Author

bulislaw commented Apr 4, 2017

I think we should document it, but it should be in some generic place, where we document macros, rather than for sleep specific. I don't think we have anything close to that.

@mazimkhan
Copy link

@Patater can you please check. All uvisor enabled profiles fail tests.

@mbed-bot
Copy link

mbed-bot commented Apr 4, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1823

Build failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 4, 2017

Still maxim failure for sleep:

06:32:38         [DEBUG] Link: /home/jenkins/bin/ARM_Compiler_5.06u3/bin/armlink --via /home/jenkins/mbed_jenkins/workspace/bm_wrap/1912/mbed-os/BUILD/tests/MAX32630FTHR/ARM/./TESTS/mbed_drivers/ticker/.link_files.txt
06:32:38         [DEBUG] Return: 1
06:32:38         [DEBUG] Errors: Error: L6218E: Undefined symbol sleep (referred from sleep.o).
06:32:38         [DEBUG] Errors: Finished: 0 information, 0 warning and 1 error messages.

@bulislaw
Copy link
Member Author

bulislaw commented Apr 4, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Apr 4, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1824

All builds and test passed!

@Patater
Copy link
Contributor

Patater commented Apr 4, 2017

I used git bisect on the commits in this PR, manually clearing all the pyc files between builds as otherwise the uVisor tests would still fail after going back to older commits.

Indeed commit the commit "Disable sleep and deepsleep when MBED_DEBUG macro is defined" causes the uVisor release-mode tests to fail. I'm not sure why, as it doesn't appear like that commit should have any effect on the uVisor tests passing or not, but it does.

Maybe the TARGET_DEBUG and TARGET_RELEASE feature is not working any longer after the addition of something after -g in the debug profile? Although if that were the case, I'd expect the uVisor tests to fail after the "Introduce MBED_DEBUG macro for debug build profile" commit.

@bulislaw
Copy link
Member Author

bulislaw commented Apr 5, 2017

It's weird because sleep behavior is not changed for 'release' or 'debug' profiles, only the 'develop' profile changes.

@Patater
Copy link
Contributor

Patater commented Apr 5, 2017

I debugged a bit further. Previously (before "Disable sleep and deepsleep when MBED_DEBUG macro is defined"), in uVisor-enabled release builds, the rtos idle thread never tried entering sleep Now, an attempt to enter sleep is made in uVisor-enabled release builds, but how sleep is being entered is faulting. The fault is due to attempting to read and write to the SCR register (in SMC_SetPowerModeVlpw) from unprivileged code.

In uVisor-enabled debug builds, no attempt to enter sleep is made, so hal_sleep isn't called and no failure happens.

@bulislaw
Copy link
Member Author

bulislaw commented Apr 5, 2017

Ah right so you use mbed OS develop profile and uVisor release build, in this case yes the behaviour changed. But that means the bug was there, it was just hidden by the sleep not being there for default profile. I've changed it for two reasons, one is that many people use online ide therefore their boards wouldn't sleep at all, second, I was afraid we will hide bugs as most people will use and deploy develop profile. I'm guessing that's exactly what we hit, do you know what's going wrong with the sleep?

@Patater
Copy link
Contributor

Patater commented Apr 5, 2017

Where can I read more about this "develop" and "default" profiles? I thought we only have "release" and "debug". Maybe this is another dimension.

Yes, this bug was present in the past; your PR doesn't introduce it, only expose it. We never ran our tests with a version of mbed OS that actually attempted to sleep.

@bulislaw
Copy link
Member Author

bulislaw commented Apr 5, 2017

@Patater
Copy link
Contributor

Patater commented Apr 5, 2017

The default profile is "develop" with the CLI tools. I had assumed it was "release". So, yes, I am running the "develop" profile and mistakenly calling it the "release" profile.

What tests does mbed OS have to ensure that sleep is being entered appropriately? I'll run blinky with a debugger attached and see if we ever call hal_sleep before and after your PR with both the "release" and "develop" profiles.

Could your PR update https://github.com/ARMmbed/mbed-os/tree/master/tools/profiles to mention that develop now enters sleep?

@bridadan
Copy link
Contributor

bridadan commented Apr 7, 2017

@bulislaw could you resolve the conflict?

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 10, 2017

@bulislaw Can you please rebase (remove the merge commit) ?

@bulislaw
Copy link
Member Author

@0xc0170 done

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 10, 2017

/morph test-nightly

@bridadan
Copy link
Contributor

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1867

Example Build failed!

@bulislaw
Copy link
Member Author

@bridadan that failure looks like CI issue, maybe it run out of license or something like that? no much info

@bridadan
Copy link
Contributor

@bulislaw I've seen this issue crop up a few times and it's always on IAR, but I have trouble reproducing it. I'll punch it one more time.

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1885

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 12, 2017

Different error (not related I believe for this patch)

/morph test-nightly

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1890

All builds and test passed!

@theotherjimmy
Copy link
Contributor

This contains a fix for a bug that is blocking export builds. Merging.

@sg-
Copy link
Contributor

sg- commented Apr 19, 2017

which makes it impossible to separate develop and debug builds features.
I'm not totally sold on this one.

  • The reason for debug was to disable optimizations and enable single step debug builds.
  • The reason for release was to shrink the code.
  • The reason for develop was to maintain the legacy settings

Given this takes a new macro and uVisor exclusion to resolve it seems fishy. What problem is this actually solving?

This contains a fix for a bug that is blocking export builds. Merging.

This is not a good reason to merge. That change is a fix unrelated to this PR therefore should not have been part of this PR. It would have been better sent as its own PR

@sg-
Copy link
Contributor

sg- commented Apr 19, 2017

Going even further back 6a045a4 we seem to have added NDEBUG where version supported to work didnt make any efforts for release builds. https://github.com/ARMmbed/mbed-os/tree/db49c1edebc3516ee61197641f7cfbdeaea5482f

I'm thinking this should be reverted and NDEBUG removed if it fixes an issue we broke between mbed OS 5 and mbed OS 2. Unless there is another reason for this but it all seems like something we may want, haven't documented therefore is very confusing.

@bulislaw
Copy link
Member Author

Main reason for this PR is confusing behavior, the original change was assuming that people actually will user release builds for 'release'. As it seems not only they can't while using online compiler, but usually don't when they use CLI. We got couple of people asking about the sleep not working and I agree it should be on in the default profile. At the same time it feels like sleep it should be disabled in debug mode, not to mention it breaks local file system (if we care about it).

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.

8 participants