使用Linux中的Netbeans调试具有GUI前端的C ++源代码

时间:2014-09-09 09:39:32

标签: c++ linux debugging user-interface netbeans

我有一个C ++开源代码,包含许多文件中的数千行代码,这些代码可以帮助运行机器人手抓取模拟器工具。它有一个前端GUI,可以选择导入各种机器人手和对象,并抓取对它们执行的操作。虽然我已经理解了一些正在使用的概念,并通过浏览来理解一些源文件,但我无法得到整个过程如何工作的要点。我想弄清楚通过按下特定的gui按钮,调用哪些文件和函数。有没有办法从开始调试软件gui代码?

我对自己编写的小代码的写入技术和步骤调试技术有所了解,但对于拥有数百个带有大量对象的文件的代码来说,这样做太混乱了。

此外,调试菜单有两个我可以使用的选项,1-Debug Project:这样做时,用户界面窗口会绕过我放置的断点打开。 2-步进:它始终在Disassembly(main)中开始,并且步骤over,out不再变灰,我可以使用它们。那是代码的汇编语言吗?是否有更简单的方法来调试它?

任何形式的指导和帮助都将受到赞赏。

编辑:下面列出的是开源代码的主要文件,由于声誉较低而无法发布带有断点的快照,并在评论中提及它们。

/*! \file
\brief Program execution starts here.  Server is started, main window is built, 
and the interactive loop is started.

The main call returns an exit code as indicated by the graspit GUI (0 by default)
to provide feedback to calling program, if desired.
 */

#define GRASPITDBG

#include <iostream>
#include <graspitApp.h>
#include "graspitGUI.h"
#include "graspitServer.h"
#include "mainWindow.h"

#ifdef Q_WS_WIN
#include <windows.h>
#include <wincon.h>
#endif

int main(int argc, char **argv) {
#ifdef GRASPITDBG
#ifdef Q_WS_WIN
    AllocConsole();
    freopen("conin$", "r", stdin);
    freopen("conout$", "w", stdout);
    freopen("conout$", "w", stderr);
    //ios::sync_with_stdio();
#endif
#endif
    //*******placed breakpoint1
    GraspItApp app(argc, argv); //shows the GraspIt! logo splash screen in the 
                                //center of  the screen.

    if (app.splashEnabled()) {
        app.showSplash();
        QApplication::setOverrideCursor(Qt::waitCursor);
    }

    //******* placed breakpoint2

    GraspItGUI gui(argc, argv); // Implements the graspit user interface.
                                // Responsible for    creating both MainWindow and IVmgr.

    //This is the GraspIt TCP server. It can be used to connect to GraspIt from
    //external programs, such as Matlab.
    //On some machines, the Q3Socket segfaults at exit, so this is commented out by
    //default
    //GraspItServer server(4765);

    app.setMainWidget(gui.getMainWindow()->mWindow);
    QObject::connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));

    if (app.splashEnabled()) {
        app.closeSplash();
        QApplication::restoreOverrideCursor();
    }

    if (!gui.terminalFailure()) {
        gui.startMainLoop();
    }
    return gui.getExitCode();
}

1 个答案:

答案 0 :(得分:0)

GUI按钮通常与回调函数相关联。 我会找出哪个函数与感兴趣的按钮相关联,并在那里设置断点并开始调试。

[审核您的代码后添加了编辑]

如果代码中指示的断点不起作用,则NetBeans项目可能已经以某种方式损坏。 An example, FYI

我曾遇到过同样的问题,但原因不同(NetBeans + CMAKE设置不匹配)。

如果断点有效,那么..

让我们看看GraspItGUI,例如,如果你在GraspItGUI.cpp的第86行设置断点(如果版本与此link相同),那么恰好是第一个if - GraspItGUI::GraspItGUI的陈述,程序应该在此时停止。

相关问题