Skip to content

Change behaviour of mbed_asert to use mbed_error instead of mbed_die #8255

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 6 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions platform/mbed_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <string.h>
#include "platform/mbed_assert.h"
#include "device.h"

#include "platform/mbed_interface.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_error.h"

void mbed_assert_internal(const char *expr, const char *file, int line)
{
core_util_critical_section_enter();
mbed_error_printf("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
mbed_die();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this function no longer need mbed_die()?

@deepikabhavnani @SenRamakri

Copy link
Contributor

Choose a reason for hiding this comment

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

Nvm, looked over the PR again and it looks ok.

Copy link

@deepikabhavnani deepikabhavnani Oct 9, 2018

Choose a reason for hiding this comment

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

mbed_die is called but after error processing, just like any other error, next addition to removal is mbed_error()

WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)

mbed_error(MBED_ERROR_ASSERTION_FAILED, expr, 0, file, line);
}

4 changes: 4 additions & 0 deletions platform/mbed_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
mbed_error_printf("MessageQueue: 0x%X, ", ctx->error_value);
break;

case MBED_ERROR_CODE_ASSERTION_FAILED:
mbed_error_printf("Assertion failed: ", ctx->error_value);
Copy link
Contributor

@kjbracey kjbracey Oct 9, 2018

Choose a reason for hiding this comment

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

This still has the stray ctx->error_value.

(You should ideally be getting a warning about that, but unfortunately there's no format checking directives on mbed_error_printf. I am intending to add some to all the local printf-type functions).

break;

default:
//Nothing to do here, just print the error info down
break;
Expand Down
3 changes: 2 additions & 1 deletion platform/mbed_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */

MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */

//Everytime you add a new system error code, you must update
//Error documentation under Handbook to capture the info on
//the new error status/codes
Expand Down