diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-04-28 16:47:58 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-05 01:59:41 +0000 |
commit | e50713104e08b09df23399f1f0e8b34bb0d33d4a (patch) | |
tree | 0aa7c334526773a33fa3b9a5b9e281ae6a5379a0 /util/gdbinit | |
parent | 4574908d30b789e049ade2dee80678b8da4f2c6b (diff) | |
download | chrome-ec-e50713104e08b09df23399f1f0e8b34bb0d33d4a.tar.gz |
util: Add support for flashing and debugging unit tests with gdb
BRANCH=none
BUG=none
TEST=On machine with dragonclaw attached to J-Trace:
JLink_Linux_V670e_x86_64/JLinkGDBServerCLExe
-select USB -device STM32F412CG -endian little -if SWD
-speed auto -noir -noLocalhostOnly
make BOARD=bloonchipper tests -j
BOARD=bloonchipper GDBSERVER=segger BIN_NAME=sha256
gdb --ex "target remote 127.0.0.1:2331"
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I6a130c9d4d676d017969aac579d43f995b4dad09
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172060
Reviewed-by: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Craig Hesling <hesling@chromium.org>
Diffstat (limited to 'util/gdbinit')
-rw-r--r-- | util/gdbinit | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/util/gdbinit b/util/gdbinit index f82afa699d..154eefc7ad 100644 --- a/util/gdbinit +++ b/util/gdbinit @@ -39,6 +39,12 @@ import os BOARD = os.getenv('BOARD', '') GDBSERVER = os.getenv('GDBSERVER', 'openocd') USING_CLION = distutils.util.strtobool(os.getenv('USING_CLION', 'FALSE')) +# BIN_NAME can be changed to be the name of a unit test, such as "sha256" +BIN_NAME = os.getenv('BIN_NAME', 'ec') + +BIN_DIR = '' +if BIN_NAME != 'ec': + BIN_DIR = BIN_NAME if GDBSERVER == "openocd": DEFAULT_GDB_PORT = '3333' @@ -61,7 +67,7 @@ if not os.path.isdir(EC_DIR): post_remote_hook=''' define target hookpost-remote echo \ Flashing EC binary - load {EC_DIR}/build/{BOARD}/ec.obj + load {EC_DIR}/build/{BOARD}/{BIN_DIR}/{BIN_NAME}.obj echo \ Resetting target monitor reset echo \ Halting target @@ -69,7 +75,7 @@ define target hookpost-remote echo \ Setting breakpoint on main b main end\n -'''.format(BOARD=BOARD, EC_DIR=EC_DIR) +'''.format(BOARD=BOARD, EC_DIR=EC_DIR, BIN_DIR=BIN_DIR, BIN_NAME=BIN_NAME) gdb.execute('set $BOARD = "%s"'%BOARD) gdb.execute('set $GDBSERVER = "%s"'%GDBSERVER) @@ -84,8 +90,8 @@ if BOARD != "": # When using gdb from CLion, this kills gdb. if not USING_CLION: gdb.execute('file ' + os.path.join(build, 'ec.obj')) - gdb.execute('add-symbol-file ' + os.path.join(build, 'RO/ec.RO.elf')) - gdb.execute('add-symbol-file ' + os.path.join(build, 'RW/ec.RW.elf')) + gdb.execute('add-symbol-file ' + os.path.join(build, BIN_DIR, 'RO', BIN_NAME + '.RO.elf')) + gdb.execute('add-symbol-file ' + os.path.join(build, BIN_DIR, 'RW', BIN_NAME + '.RW.elf')) if GDBSERVER == "openocd": gdb.execute('set $GDBSERVER_OPENOCD = 1') |