From eb0f29223a059f67a033928e4135eaf675951c56 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 18 Jun 2020 09:44:13 -0400 Subject: [PATCH] add docs to gdb-filter.py turn off thread logging in gdb make sure everything runs in gdb when running test add note in contrib/format.sh about a GNU-ism --- .drone.jsonnet | 13 ++++++------- contrib/ci/gdb-filter.py | 37 +++++++++++++++++++++++++------------ contrib/format.sh | 2 ++ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 61936b011..9f89e89e6 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -45,8 +45,8 @@ local debian_pipeline(name, image, (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + (if lto then '' else '-DWITH_LTO=OFF ') + cmake_extra, - 'ninja clean && ninja -v', - './test/testAll --gtest_color=yes', + 'ninja -v', + '../contrib/ci/drone-gdb.sh ./test/testAll --gtest_color=yes', '../contrib/ci/drone-gdb.sh ./test/catchAll --use-colour yes', ] + extra_cmds, } @@ -85,8 +85,8 @@ local windows_cross_pipeline(name, image, (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + (if lto then '' else '-DWITH_LTO=OFF ') + "-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON" + - cmake_extra, - 'ninja clean && ninja -v', + cmake_extra, + 'ninja -v', ] + extra_cmds, } ], @@ -156,9 +156,8 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra 'mkdir build', 'cd build', 'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fcolor-diagnostics -DCMAKE_BUILD_TYPE='+build_type+' ' + - (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + - cmake_extra, - 'ninja clean && ninja -v', + (if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + cmake_extra, + 'ninja -v', './test/testAll --gtest_color=yes', './test/catchAll --use-colour yes', ] + extra_cmds, diff --git a/contrib/ci/gdb-filter.py b/contrib/ci/gdb-filter.py index 94921e288..d5ddf8ae0 100644 --- a/contrib/ci/gdb-filter.py +++ b/contrib/ci/gdb-filter.py @@ -1,23 +1,36 @@ def exit_handler (event): + """ + write exit code of the program running in gdb to a file called exit.out.txt + """ code = 1 if hasattr(event, "exit_code"): code = event.exit_code with open("exit.out.txt", 'w') as f: f.write("{}".format(code)) +def gdb_execmany(*cmds): + """ + run multiple gdb commands + """ + for cmd in cmds: + gdb.execute(cmd) + def crash_handler (event): - if (isinstance(event, gdb.SignalEvent)): - log_file_name = "crash.out.txt" - gdb.execute("set logging file " + log_file_name ) - gdb.execute("set logging on") - gdb.execute("set logging redirect on") - gdb.execute("thread apply all bt full") - gdb.execute("q") + """ + handle a crash from the program running in gdb + """ + if isinstance(event, gdb.SignalEvent): + log_file_name = "crash.out.txt" + # poop out log file for stack trace of all threads + gdb_execmany("set logging file {}".format(log_file_name), "set logging on", "set logging redirect on", "thread apply all bt full") + # quit gdb + gdb.execute("q") +# set up event handlers to catch shit gdb.events.stop.connect(crash_handler) - gdb.events.exited.connect(exit_handler) -gdb.execute("set confirm off") -gdb.execute("set pagination off") -gdb.execute("r") -gdb.execute("q") + +# run settings setup +gdb_execmany("set confirm off", "set pagination off", "set print thread-events off") +# run program and exit +gdb_execmany("r", "q") diff --git a/contrib/format.sh b/contrib/format.sh index 463f2c835..6cb8b0ff8 100755 --- a/contrib/format.sh +++ b/contrib/format.sh @@ -1,3 +1,5 @@ #!/usr/bin/env bash + +# TODO: readlink -e is a GNU-ism cd "$(readlink -e $(dirname $0)/../)" clang-format-9 -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$') &> /dev/null