繁体   English   中英

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

[英]Debugging a C++ source code that has a GUI front end using Netbeans in Linux

我有一个C ++开源代码,其中包含成千上万行代码,这些文件包含在多个文件中,可帮助运行机器人手抓握模拟器工具。 它具有一个前端GUI,可以选择导入各种机械手和物体并掌握在其上执行的动作。 尽管我已经了解了所使用的一些概念,并通过略读了了一些源文件,但是我无法大致了解整个过程的工作原理。 我想通过按特定的gui按钮来找出正在调用的文件和功能。 有没有一种方法可以从头开始调试软件GUI代码?

我对自己编写的小代码具有写技术和逐步调试技术的知识,但是对于具有数百个带有杂乱对象的文件的代码而言,这样做太令人困惑了。

另外,调试菜单有两个可用的选项,即1-Debug Project:在执行此操作时,用户界面窗口将打开,绕过我放置的断点。 2步进入:它总是从反汇编开始(主),而步入,退出不再是灰色的,我可以使用它们。 这是代码的汇编语言吗? 有没有更简单的调试方法?

任何形式的指导和帮助将不胜感激。

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

/*! \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();
}

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

[在查看您的代码后添加了EDIT]

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

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

如果断点在工作,那么..

让我们来看看GraspItGUI ,例如,如果你在该行的86设置断点GraspItGUI.cpp (如果版本是一样的,因为这链接 ),这恰好是第一if语句来的GraspItGUI::GraspItGUI ,程序应到此为止。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM