简体   繁体   English

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

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

I have a C++ open source code comprising of thousands of lines of code in a number of files that help run a robotic hand grasping simulator tool. 我有一个C ++开源代码,其中包含成千上万行代码,这些文件包含在多个文件中,可帮助运行机器人手抓握模拟器工具。 It has a front end GUI with option to import a variety of robotic hands and objects and grasping actions performed on them. 它具有一个前端GUI,可以选择导入各种机械手和物体并掌握在其上执行的动作。 Although I have understood some of the concepts being used, and understood some source files by skimming through, but I am unable to get a gist of how the process works as a whole. 尽管我已经了解了所使用的一些概念,并通过略读了了一些源文件,但是我无法大致了解整个过程的工作原理。 I want to figure out that by pressing a specific gui button, which files and functions are being called. 我想通过按特定的gui按钮来找出正在调用的文件和功能。 Is there a way to start debugging the software gui code from start? 有没有一种方法可以从头开始调试软件GUI代码?

I have knowledge of write technique and step debugging technique for small codes that I write by myself, but doing so for a code that have hundreds of files with hundereds of objects is way too confusing. 我对自己编写的小代码具有写技术和逐步调试技术的知识,但是对于具有数百个带有杂乱对象的文件的代码而言,这样做太令人困惑了。

Also, the debugging menu has two options that I can use, 1-Debug Project: While doing so, the user interface window opens bypassing the breakpoints that I have placed. 另外,调试菜单有两个可用的选项,即1-Debug Project:在执行此操作时,用户界面窗口将打开,绕过我放置的断点。 2- step into: It always starts in Disassembly (main) and the step over,out are not grayed anymore and I can use them. 2步进入:它总是从反汇编开始(主),而步入,退出不再是灰色的,我可以使用它们。 Is that the assembly language of the code? 这是代码的汇编语言吗? Is there a simpler way to debug it? 有没有更简单的调试方法?

Any kind of guidance and help would be appreciated. 任何形式的指导和帮助将不胜感激。

EDIT: Listed below is the main file of the open source code, cant post a snapshot with breakpoints because of lesser reputation, mentioning them in comments. 编辑:下面列出的是开放源代码的主文件,由于信誉较差而无法发布带有断点的快照,并在注释中提及它们。

/*! \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 buttons are usually associated with callback functions. GUI按钮通常与回调函数关联。 I would find out which function is associated with the button-of-interest and set a breakpoint there and start debugging. 我将找出与感兴趣的按钮相关联的功能,并在那里设置断点并开始调试。

[EDIT added after Reviewing your code] [在查看您的代码后添加了EDIT]

If the breakpoints indicated in your code are not working, then the NetBeans project might have been corrupted somehow. 如果代码中指示的断点不起作用,则说明NetBeans项目可能已经以某种方式损坏。 An example, FYI 例如,FYI

I once had the same problem but with different reason (NetBeans + CMAKE setting mismatch). 我曾经遇到过同样的问题,但是原因不同(NetBeans + CMAKE设置不匹配)。

If the breakpoints are working then.. 如果断点在工作,那么..

Let's see GraspItGUI , for example, if you have set a breakpoint at the line 86 of GraspItGUI.cpp (if the version is the same as this link ) which happens to be the first if -statement of GraspItGUI::GraspItGUI , the program should stop at this point. 让我们来看看GraspItGUI ,例如,如果你在该行的86设置断点GraspItGUI.cpp (如果版本是一样的,因为这链接 ),这恰好是第一if语句来的GraspItGUI::GraspItGUI ,程序应到此为止。

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

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