配置netbeans 8.0 gdb以使用gradle cpp插件

r.p*_*ski 12 c++ debugging gdb netbeans gradle

最近我使用Netbeans 8.0(C++)从Windows 7中的Visual Studio切换到Ubuntu.从那时起,我从NetBeans调试我的应用程序时遇到了很大的问题(gdb工作得很好).我用gradle编写了hello world c ++来演示我的问题.我花了很多时间但没有任何重大进展.

Gradle项目

build.gradle:

apply plugin: 'cpp'

executables {
    helloWorld
}
binaries.all {
     cppCompiler.args "-g"
}
Run Code Online (Sandbox Code Playgroud)

main.cpp中:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int a = 10;
    int b = 12;
    int c = a + b;
    puts("Hello World!!!");
    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

然后我构建并运行gdb:

robert-Aspire-S3:~/NetBeansProjects/helloWorld$ gradle helloWorldExecutable
robert-Aspire-S3:~/NetBeansProjects/helloWorld$ gdb ./build/binaries/helloWorldExecutable/helloWorld                     
....
Reading symbols from ./build/binaries/helloWorldExecutable/helloWorld...done.
(gdb) b 5
Breakpoint 1, main () at /home/robert/NetBeansProjects/helloWorld/src/helloWorld/cpp/main.cpp:5
5           int a = 10;
(gdb) n                                                                                                                         
6           int b = 12;
(gdb) print a
$1 = 10
(gdb) n
7           int c = a + b;
(gdb) c
Continuing.
Hello World!!!
[Inferior 1 (process 3693) exited normally]
Run Code Online (Sandbox Code Playgroud)

下一步是从Netbeans 8.0附加到gdb进程.我还在第5行的NetBeans中放置了断点,希望我能获得gdb输出. 附加gdb 来自NetBeans的断点

可悲的是,Netbeans没有在编辑区打破断点,我不知道为什么.我还打开了Debbuger控制台,并粘贴了日志(pastebin)以获取更多信息.

C++应用程序

当我从NetBeans向导创建标准C/C++应用程序并尝试调试时,一切正常. Cpp调试器

对于那个会话,我也上传了日志.

我发现日志有一点不同:

  • Gradle cpp: 10-file-symbol-file "/usr/bin/gdb"
  • NetBeans cpp: 10-file-exec-and-symbols "/home/robert/NetBeansProjects/CppApplication_1/dist/Debug/GNU-Linux-x86/cppapplication_1"

那么这一行有gradle是一个问题吗?如果是,我该如何解决?任何人都可以帮助我附加NetBeans可视化调试器来gradle cpp项目吗?感谢帮助.

Jit*_*yan 0

我认为问题出在 build.gradle 中,所以你必须检查 gradle 程序中使用的语法。http://gradle.org/getting-started-native/该站点包含一些示例。阅读它解决您的问题。