简体   繁体   English

使用基于Eclipse的IDE调试C ++时出现问题

[英]Problem debugging C++ with an Eclipse based IDE

This is a weird question in that I'm not sure where to start looking. 这是一个奇怪的问题,因为我不确定从哪里开始寻找。

First of all, I haven't done any C++ programming for the last 10 years so it could be me thats forgotten a few things. 首先,过去十年来我没有进行过任何C ++编程,因此可能是我忘记了一些东西。 Secondly, the IDE I'm using is Eclipse based (which I've never used) and customized for Samsung bada based mobile development (it kicks off an emulator for debugging purposes) 其次,我使用的IDE是基于Eclipse的(我从未使用过),并且针对基于Samsung bada的移动开发进行了自定义(它启动了用于调试目的的仿真器)

I'm posting my code samples as images because the StackOverflow WYSIWYG editor seems to have a problem parsing C++. 我将代码示例发布为图像,因为StackOverflow WYSIWYG编辑器似乎在解析C ++时遇到问题。

[EDIT] Due to complaints I've edited my question to remove the images. [编辑]由于投诉,我已编辑问题以删除图像。 Hope that helps :) 希望有帮助:)

I have the following header file... 我有以下头文件...

#include <FApp.h>
#include <FBase.h>
#include <FGraphics.h>
#include <FSystem.h>
#include <FMedia.h>

using namespace Osp::Media;
using namespace Osp::Graphics;

class NineAcross :
    public Osp::App::Application,
    public Osp::System::IScreenEventListener
{
    public:

    static Osp::App::Application* CreateInstance(void);

    public:
    NineAcross();
    ~NineAcross();

    public:     
    bool OnAppInitializing(Osp::App::AppRegistry& appRegistry);

    private:
    Image *_problematicDecoder;
};

...and the following cpp file... ...以及以下cpp文件...

#include "NineAcross.h"

using namespace Osp::App;
using namespace Osp::Base;
using namespace Osp::System;
using namespace Osp::Graphics;
using namespace Osp::Media;

NineAcross::NineAcross()
{
}

NineAcross::~NineAcross()
{
}

Application*  NineAcross::CreateInstance(void)
{
    // Create the instance through the constructor.
    return new NineAcross();
}

bool NineAcross::OnAppInitializing(AppRegistry& appRegistry)
{

    Image *workingDecoder;      
    workingDecoder->Construct();

       _problematicDecoder->Construct();

    return true;
}

Now, in my cpp file, if I comment out the line that reads _problematicDecoder->Construct(); 现在,在我的cpp文件中,如果我注释掉读取_problematicDecoder-> Construct();的行; ...I'm able to set a breakpoint and happily step over the call to Constuct() on workingDecoder . ...我可以设置一个断点,并愉快地跳过对workingDecoder的Constuct ()的调用。 However, as soon as I uncomment the line that reads _problematicDecoder->Construct(); 但是,只要取消注释该行, 便会读取_problematicDecoder-> Construct();。 ... I end up with the IDE telling me... ...最后,IDE告诉我...

"No source available for "Osp::Media::Image::Construct()" “没有可用于“ Osp :: Media :: Image :: Construct()”的源”

In other words, why can I NOT debug this code when I reference Image *image from a header file? 换句话说,当我从头文件中引用Image * image时,为什么不能调试此代码?

Any ideas? 有任何想法吗?

Thanks :-) 谢谢 :-)

This usually means you're stepping through some code which you do not posses its source. 这通常意味着您正在逐步浏览一些没有源代码的代码。 I assume here that Osp::Media::Image is a class supplied by Samsung or similar for which you do not have the cpp file. 我在这里假设Osp::Media::Image是Samsung或类似公司提供的类,您没有该类的cpp文件。 So this means the debugger can't show you the current code line while you're at a function of Osp::Media::Image . 因此,这意味着当您使用Osp::Media::Image函数时,调试器无法向您显示当前代码行。

Alternatively, there's a good chance you do have all of the source code for this class, but Eclipse doesn't know where it is. 另外,您很有可能拥有该类的所有源代码,但是Eclipse不知道它在哪里。 In this case you can add the correct directories under the Debug Configurations window. 在这种情况下,您可以在“调试配置”窗口下添加正确的目录。

Ok, problem solved. 好,问题解决了。

The idea is to first new up an instance of Image like so... 这个想法是首先像这样新建一个Image实例。

_decoder = new Osp::Media::Image(); _decoder =新的Osp :: Media :: Image();

And then do _decoder->Construct(). 然后执行_decoder-> Construct()。

Funny enough, this seems blatantly obvious to me now coming from the C# world, though why the code I posted for workingDecoder works is still somewhat mysterious to me. 有趣的是,对于我来说,这似乎是显而易见的,现在我来自C#世界,尽管我为workingDecoder发布的代码为什么对我来说仍然有些神秘。 The fact the sample projects pre-loaded with the bada IDE don't seem to make a call to new() leads me to believe that perhaps those samples are outdated our out of synch. 预装了bada IDE的示例项目似乎并未调用new(),这一事实使我相信这些示例可能已经过时了。

Either that or I really AM wildly out of the C++ loop. 要么,要么我真的很疯狂地脱离了C ++循环。

Anyway thanks so much for the effort guys. 无论如何,非常感谢你们的努力。

Appreciated :) 感激:)

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

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