mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
core: add build target for debug unix build
This commit is contained in:
parent
75ddedb0b0
commit
42f1af3aa4
@ -123,6 +123,9 @@ build_unix: res ## build unix port
|
||||
build_unix_frozen: res build_cross ## build unix port with frozen modules
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
|
||||
|
||||
build_unix_debug: res ## build unix port
|
||||
$(SCONS) --max-drift=1 CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_ASAN=1 TREZOR_EMULATOR_DEBUGGABLE=1
|
||||
|
||||
build_cross: ## build mpy-cross port
|
||||
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
|
||||
|
||||
|
@ -314,21 +314,31 @@ env.Replace(
|
||||
LINK='ld',
|
||||
SIZE='size',
|
||||
STRIP='strip',
|
||||
OBJCOPY='objcopy', )
|
||||
OBJCOPY='objcopy',
|
||||
COPT=os.getenv('OPTIMIZE', '-Os'), )
|
||||
|
||||
if env.get('ENV').get('DEBUG_BUILD', 0):
|
||||
import platform
|
||||
platsys = platform.system()
|
||||
env.Replace(
|
||||
OPTIMIZE='-O0',
|
||||
LINKFLAGS='-Wl,-no_pie' if platsys == "Darwin" else '-Wl,-no-pie'
|
||||
if ARGUMENTS.get('TREZOR_EMULATOR_ASAN', 0):
|
||||
asan_flags=(
|
||||
' -fsanitize=address'+
|
||||
' -fsanitize-blacklist=asan_blacklist.txt'+
|
||||
' -fno-omit-frame-pointer'+
|
||||
' -fno-optimize-sibling-calls'
|
||||
)
|
||||
env.Replace(
|
||||
CC=os.getenv('CC') or 'clang',
|
||||
LINK=os.getenv('LINK') or 'clang',
|
||||
CFLAGS=asan_flags,
|
||||
LINKFLAGS=' -Wl,-no_pie' + asan_flags, )
|
||||
|
||||
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', 0):
|
||||
env.Replace(
|
||||
COPT=' -O0 -ggdb',
|
||||
STRIP='true', )
|
||||
|
||||
env.Replace(
|
||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||
|
||||
env.Replace(
|
||||
COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
|
||||
CCFLAGS='$COPT '
|
||||
'-g3 '
|
||||
'-std=gnu99 -Wall -Werror -Wuninitialized -Wno-missing-braces '
|
||||
|
@ -73,3 +73,21 @@ You must not use both on the same test.
|
||||
|
||||
[pytest-random-order]: https://pypi.org/project/pytest-random-order/
|
||||
[REGISTERED_MARKERS]: ../REGISTERED_MARKERS
|
||||
|
||||
## Extended testing and debugging
|
||||
|
||||
### Building for debugging (Emulator only)
|
||||
|
||||
Build the debuggable unix binary so you can attach the gdb or lldb.
|
||||
This removes optimizations and reduces address space randomizaiton.
|
||||
|
||||
```sh
|
||||
make build_unix_debug
|
||||
```
|
||||
|
||||
The final executable is significantly slower due to ASAN(Address Sanitizer) integration.
|
||||
If you wan't to catch some memory errors use this.
|
||||
|
||||
```sh
|
||||
time ASAN_OPTIONS=verbosity=1:detect_invalid_pointer_pairs=1:strict_init_order=true:strict_string_checks=true TREZOR_PROFILE="" pipenv run make test_emu
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user