Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (72 loc) · 2.46 KB

File metadata and controls

83 lines (72 loc) · 2.46 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) 2016-2017, Niklas Hauser
* Copyright (c) 2017, Sascha Schade
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------
#include <modm/board.hpp>
#include <modm/architecture/interface/assert.hpp>
#include <string>
using namespace std::string_literals;
using namespace Board;
static modm::Abandonment
test_assertion_handler(const modm::AssertionInfo &info)
{
if (not strncmp(info.name, "io.", 3)) {
MODM_LOG_ERROR << "Ignoring all io.* assertions!" << modm::endl;
return modm::Abandonment::Ignore;
}
return modm::Abandonment::DontCare;
}
MODM_ASSERTION_HANDLER(test_assertion_handler);
static modm::Abandonment
core_assertion_handler(const modm::AssertionInfo &info)
{
if (info.name == "nvic.undef"s) {
MODM_LOG_ERROR.printf("Ignoring undefined IRQ handler %d!\n", info.context);
return modm::Abandonment::Ignore;
}
if ((info.name == "new"s) or (info.name == "malloc"s)) {
MODM_LOG_ERROR.printf("Ignoring '%s' of size 0x%x!\n", info.name, info.context);
return modm::Abandonment::Ignore;
}
return modm::Abandonment::DontCare;
}
MODM_ASSERTION_HANDLER(core_assertion_handler);
// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
MODM_LOG_INFO << "\n=== RESTART ===\n" << modm::flush;
// trigger an IRQ with undefined handler
NVIC_EnableIRQ(OTG_FS_WKUP_IRQn);
NVIC_SetPendingIRQ(OTG_FS_WKUP_IRQn);
// trigger an out of memory
// we definitely don't have 32MB RAM on this board
// returns NULL, asserts in debug mode
volatile void * ptr = malloc(1 << 25);
// returns NULL, asserts in debug mode
ptr = new (std::nothrow) uint8_t[1 << 25];
// always asserts
ptr = new uint8_t[1 << 25];
(void) ptr;
// does not fail, should not be optimized away
volatile bool true_condition = true;
modm_assert(true_condition, "can.init",
"Can::init() function has timed out!");
// only fails for debug builds, but is ignored anyways
modm_assert_continue_fail_debug(false, "io.tx",
"The IO transmit buffer is full!");
MODM_LOG_ERROR << modm::flush;
// "accidentally" return from main, without even returning properly!
// This should be caught by the debug assert main.exit!
// while (true)
// {};
// return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.