diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2023-04-03 15:04:44 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-03 19:38:59 +0000 |
commit | 5a655201cd33da08e5956f29e3315381b3c1bfaa (patch) | |
tree | 26ef727d60b0c51cb50618bfa20d7b8edc977c0c /docs/zephyr | |
parent | 77c838c7b8ed56c92aa1ed6bf8c5df4447253e30 (diff) | |
download | chrome-ec-5a655201cd33da08e5956f29e3315381b3c1bfaa.tar.gz |
doc: zephyr_troubleshooting: add some notes about tests and gdb
Add a note about recompiling tests without rerunning twister and using
gdb on a test generated binary.
BRANCH=none
BUG=none
TEST=checked the page on gitiles
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Iaaa18d18e4be79d95793932f2848245571484b96
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4393513
Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'docs/zephyr')
-rw-r--r-- | docs/zephyr/zephyr_troubleshooting.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/zephyr/zephyr_troubleshooting.md b/docs/zephyr/zephyr_troubleshooting.md index 57284bfc79..aa6980a9d5 100644 --- a/docs/zephyr/zephyr_troubleshooting.md +++ b/docs/zephyr/zephyr_troubleshooting.md @@ -190,3 +190,38 @@ $3 = 0x100ba480 "tach@400e1000" ``` If the symbol has been optimized, try rebuilding with `CONFIG_LTO=n`. + + +## Using GDB for debugging unit tests + +Unit tests running on `native_posix` produce an executable file that can be +rebuilt directly with ninja to save time, and run with GDB to help out +debugging. This can be found after a twister run in the `twister-out` +directory. For example: + +``` +$ ./twister -v -T zephyr/test/hooks +... +INFO - 1/1 native_posix hooks.default PASSED (native 0.042s) +... + +# Modify the test code + +$ ninja -C twister-out/native_posix/hooks.default +... +[7/7] Linking C executable zephyr/zephyr.elf + +$ ./twister-out/native_posix/hooks.default/zephyr/zephyr.elf +... +PROJECT EXECUTION SUCCESSFUL + +$ gdb ./twister-out/native_posix/hooks.default/zephyr/zephyr.elf +Reading symbols from ./twister-out/native_posix/hooks.default/zephyr/zephyr.elf... +(gdb) b main +Breakpoint 1 at 0x80568a9: file boards/posix/native_posix/main.c, line 112. +(gdb) run +Starting program: /mnt/host/source/src/platform/ec/twister-out/native_posix/hooks.default/zephyr/zephyr.elf +Breakpoint 1, main (argc=-17520, argv=0xffffbc24) at boards/posix/native_posix/main.c:112 +112 posix_init(argc, argv); +... +``` |