bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
760 stars 303 forks source link

Clion: gdb report missing file for cc_test #6509

Open fzjalfred opened 3 months ago

fzjalfred commented 3 months ago

Description of the bug:

run button for all the targets works well. But gdb button works only for cc_binary. cc_test will report a missing file issue, even for the path the binary of gdbserver exists.

Here are the clion cmds for both cc_binary debug and cc_test debug:

##cc_binary works well:
bazel run --tool_tag=ijwb:CLion --override_repository=intellij_aspect=/root/.local/share/JetBrains/CLion2024.1/clwb/aspect "--run_under='bash' '/root/.local/share/JetBrains/CLion2024.1/clwb/gdb/gdbserver' '/root/.cache/JetBrains/RemoteDev/dist/4c7a0de431e93_CLion-2024.1.4/bin/gdb/linux/x64/bin/gdbserver' --once localhost:5006 --target" --compilation_mode=dbg --strip=never --dynamic_mode=off --fission=yes --curses=no --color=yes --progress_in_terminal_title=no -- //demo:demo

##cc_test fail:
bazel test --tool_tag=ijwb:CLion --override_repository=intellij_aspect=/root/.local/share/JetBrains/CLion2024.1/clwb/aspect "--run_under='bash' '/root/.local/share/JetBrains/CLion2024.1/clwb/gdb/gdbserver' '/root/.cache/JetBrains/RemoteDev/dist/4c7a0de431e93_CLion-2024.1.4/bin/gdb/linux/x64/bin/gdbserver' --once localhost:5006 --target" --compilation_mode=dbg --strip=never --dynamic_mode=off --test_timeout=3600 --nocache_test_results --test_strategy=exclusive --test_sharding_strategy=disabled --fission=yes --curses=no --color=yes --progress_in_terminal_title=no --runs_per_test=1 --flaky_test_attempts=1 --build_event_binary_file=/tmp/intellij-bep-6c8e1be5-e99b-4784-8e3c-b1866455f6ad --nobuild_event_binary_file_path_conversion -- //demo:main_test

I am using remote development ssh connecting to a VM and install the bazel plugin.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD.bazel:

cc_binary(
    name = "demo",
    srcs = [
        "main.cpp",
    ],
    visibility = ["//visibility:public"],
    deps = [
    ],
)

cc_test(
    name = "main_test",
    srcs = [
        "main.cpp",
    ],
)

main.cpp:

#include <iostream>

int main() {
    std::cout<<"HelloWorld!"<<std::endl;
    return 0;
}

Which Intellij IDE are you using? Please provide the specific version.

CLion 2024.1.4 Build #JBC-241.18034.45, built on June 18, 2024 Licensed to Huawei Technologies Co., Ltd. Runtime version: 17.0.11+1-b1207.24 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11.0 Controller in Remote Development GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 16 Registry: debugger.attach.dialog.enabled=true run.processes.with.pty=TRUE ide.experimental.ui=true rdclient.backend.actionHandlers=false

What programming languages and tools are you using? Please provide specific versions.

c++14 bazel-6.1.0

What Bazel plugin version are you using?

Bazel for CLion 2024.06.04.0.2-api-version-241

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

Running debug binary
Command: bazel test --tool_tag=ijwb:CLion --override_repository=intellij_aspect=/root/.local/share/JetBrains/CLion2024.1/clwb/aspect "--run_under='bash' '/root/.local/share/JetBrains/CLion2024.1/clwb/gdb/gdbserver' '/root/.cache/JetBrains/RemoteDev/dist/4c7a0de431e93_CLion-2024.1.4/bin/gdb/linux/x64/bin/gdbserver' --once localhost:5006 --target" --compilation_mode=dbg --strip=never --dynamic_mode=off --test_timeout=3600 --nocache_test_results --test_strategy=exclusive --test_sharding_strategy=disabled --fission=yes --curses=no --color=yes --progress_in_terminal_title=no --runs_per_test=1 --flaky_test_attempts=1 --build_event_binary_file=/tmp/intellij-bep-208fb490-ef51-42db-94e2-b3bc5d958bf0 --nobuild_event_binary_file_path_conversion -- //demo:main_test

FAIL: //demo:main_test (see /data/.cache/fa4dd86d997067b45e4b2569754c7bfa/execroot/_main/bazel-out/k8-dbg/testlogs/demo/main_test/test.log)
Target //demo:main_test up-to-date:
  bazel-bin/demo/main_test
INFO: Elapsed time: 0.463s, Critical Path: 0.27s
INFO: 2 processes: 2 remote.
INFO: Build completed, 1 test FAILED, 2 total actions
//demo:main_test                                                         FAILED in 0.0s
  /data/.cache/fa4dd86d997067b45e4b2569754c7bfa/execroot/_main/bazel-out/k8-dbg/testlogs/demo/main_test/test.log

Executed 1 out of 1 test: 1 fails remotely.
INFO: Build Event Protocol files produced successfully.

Process finished with exit code 3

exited with error code 127

Generated test.log (if the file is not UTF-8, then this may be unreadable):
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //demo:main_test
-----------------------------------------------------------------------------
bash: /root/.local/share/JetBrains/CLion2024.1/clwb/gdb/gdbserver: No such file or directory