From 2b40e65c33c65acb58faab0b0db2a1f10f6c4164 Mon Sep 17 00:00:00 2001 From: Artem Serov Date: Mon, 14 Mar 2022 22:11:11 +0000 Subject: Support running dalvikvm under gdb on host. Supports debugging dalvikvm on host (host & simulator modes); adds '--gdb' CLI option. Also adds a check that debugging is only enabled for run-tests as gtests are not yet supported by ./art scripts. Note: --gdb and --gdb-dex2oat could be used together. Test: ./scripts/tests/test_art_host.sh --64bit --gdb --single-test 530-checker-peel-unroll Test: ./scripts/tests/test_art_host.sh --64bit --gdb --gdb-dex2oat --single-test 530-checker-peel-unroll Test: ./scripts/tests/test_art_simulator.sh --gdb --single-test 530-checker-peel-unroll Change-Id: I310a1ceb5fc44e2e2bd35468e94214a577fad93f --- tests/test_art_host.sh | 16 +++++++++++++--- tests/test_art_simulator.sh | 16 +++++++++++++--- utils/utils_run.sh | 10 ++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/test_art_host.sh b/tests/test_art_host.sh index 20223804..537f7b4a 100755 --- a/tests/test_art_host.sh +++ b/tests/test_art_host.sh @@ -37,6 +37,7 @@ declare -A options_format=( ["64bit"]="false" ["default"]="p:set_defaults_wrapper()" ["dump-cfg"]="" + ["gdb"]="false" ["gdb-dex2oat"]="false" ["gdb-dex2oat-args"]="" ["gcstress"]="false" @@ -93,9 +94,17 @@ validate_options() { exit 1 fi - if [[ "${options["gdb-dex2oat"]}" == "true" ]] && [[ -z "${options["single-test"]}" ]]; then - log E "Can only run the debugger on dex2oat for a single test." - exit 1 + if [[ "${options["gdb"]}" == "true" || "${options["gdb-dex2oat"]}" == "true" ]]; then + if [[ -z "${options["single-test"]}" ]]; then + log E "Can only run the debugger for a single test." + exit 1 + fi + + local -r test_name="${options["single-test"]}" + if is_single_test_gtest "${test_name}"; then + log E "Can't run the debugger for a gtest." + exit 1 + fi fi } @@ -132,6 +141,7 @@ usage() { generation." log I " --dump-cfg - dump .cfg to the specified host full path. Only runs for a" log I " single test" + log I " --gdb - Run dalvikvm under gdb. Only runs for a single test." log I " --gdb-dex2oat - Run dex2oat under lldb. Only runs for a single test." log I " --gdb-dex2oat-args - Use LLDB with arguments to debug the compiler (dex2oat) Each argument needs to be separated by a semicolon." diff --git a/tests/test_art_simulator.sh b/tests/test_art_simulator.sh index 320c4a94..473b54bb 100755 --- a/tests/test_art_simulator.sh +++ b/tests/test_art_simulator.sh @@ -64,6 +64,7 @@ usage() { generation." log I " --dump-cfg - dump .cfg to the specified host full path. Only runs for a" log I " single test" + log I " --gdb - Run dalvikvm under gdb. Only runs for a single test." log I " --gdb-dex2oat - Run dex2oat under lldb. Only runs for a single test." log I " --gdb-dex2oat-args - Use LLDB with arguments to debug the compiler (dex2oat) Each argument needs to be separated by a semicolon." @@ -82,6 +83,7 @@ declare -A options_format=( ["sve"]="false" ["s"]="r:&sve" ["dump-cfg"]="" + ["gdb"]="false" ["gdb-dex2oat"]="false" ["gdb-dex2oat-args"]="" ["gcstress"]="false" @@ -107,9 +109,17 @@ validate_options() { exit 1 fi - if [[ "${options["gdb-dex2oat"]}" == "true" ]] && [[ -z "${options["single-test"]}" ]]; then - log E "Can only run the debugger on dex2oat for a single test." - exit 1 + if [[ "${options["gdb"]}" == "true" || "${options["gdb-dex2oat"]}" == "true" ]]; then + if [[ -z "${options["single-test"]}" ]]; then + log E "Can only run the debugger for a single test." + exit 1 + fi + + local -r test_name="${options["single-test"]}" + if is_single_test_gtest "${test_name}"; then + log E "Can't run the debugger for a gtest." + exit 1 + fi fi } diff --git a/utils/utils_run.sh b/utils/utils_run.sh index bf068771..bf346e04 100644 --- a/utils/utils_run.sh +++ b/utils/utils_run.sh @@ -55,9 +55,19 @@ run_test_with_python_runner() { if ${local_options["gcstress"]}; then test_command+=" --gcstress" fi + if [[ -n "${local_options["dump-cfg"]}" ]]; then test_command+=" --dump-cfg ${local_options["dump-cfg"]}" fi + + if ${local_options["gdb"]}; then + if [[ "${test_environment}" == "target" ]]; then + log E "The --gdb option is only available for host." + return 1 + fi + test_command+=" --gdb" + fi + if ${local_options["gdb-dex2oat"]}; then if [[ "${test_environment}" == "target" ]]; then log E "The --gdb-dex2oat option is only available for host." -- cgit v1.2.3