kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'feature/silent_assertions' into 'master'
Add "silent" assertion option See merge request !984pull/585/merge
commit
399ec29a68
37
Kconfig
37
Kconfig
|
@ -47,14 +47,39 @@ config OPTIMIZATION_LEVEL_RELEASE
|
|||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS
|
||||
prompt "Enable assertions"
|
||||
bool
|
||||
default y
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Enable assertions.
|
||||
Assertions can be:
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
If disabled, -DNDEBUG is added to CFLAGS.
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
endmenu # Optimization level
|
||||
|
||||
|
|
|
@ -11,4 +11,4 @@ COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib
|
|||
|
||||
COMPONENT_ADD_LINKER_DEPS := $(LIBC_PATH) $(LIBM_PATH)
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS := include platform_include
|
||||
COMPONENT_ADD_INCLUDEDIRS := platform_include include
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
/* This header file wraps newlib's own unmodified assert.h and adds
|
||||
support for silent assertion failure.
|
||||
*/
|
||||
#pragma once
|
||||
#include <sdkconfig.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include_next <assert.h>
|
||||
|
||||
#if defined(CONFIG_OPTIMIZATION_ASSERTIONS_SILENT) && !defined(NDEBUG)
|
||||
#undef assert
|
||||
#define assert(__e) ((__e) ? (void)0 : abort())
|
||||
#endif
|
|
@ -239,7 +239,7 @@ else
|
|||
OPTIMIZATION_FLAGS = -Og
|
||||
endif
|
||||
|
||||
ifeq ("$(CONFIG_OPTIMIZATION_ASSERTIONS)", "")
|
||||
ifeq ("$(CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED)", "y")
|
||||
CPPFLAGS += -DNDEBUG
|
||||
endif
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue