XCode不会在#include CPP文件中破坏 [英] XCode doesn't break in #include'd CPP files

查看:296
本文介绍了XCode不会在#include CPP文件中破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果包括来自另一个CPP文件的CPP文件,XCode拒绝在包含的CPP文件中的任何断点处中断。我要提出一个与苹果公司的错误,但只是想提到这里,以防其他人遇到这个,并可能找到方法。



有很多好的原因,你可能想包括CPP文件从CPP文件,我不会在这里。



示例:一个非常简单的iPhone项目



main.mm

  extern void FunctionInSource1(int a); 

int main(int argc,char * argv [])
{
FunctionInSource1(1);

return 0;
}

source1.cpp
$ b

  #includesource2.cpp

void FunctionInSource1(int a)
{
int b = a;

FunctionInSource2(b);

return;
}

source2.cpp
$ b

  void FunctionInSource2(int b)
{
int c = b;

c = c + 1;

return;
}

main.mm和source1.cpp是目标的成员,设置为构建。 source2.cpp不是目标的成员,除非通过其包含在source1.cpp中,否则不会被编译。



在source2.cpp中任何位置设置断点都无法触发。任何地方的断点工作正常。 N.B.你仍然可以从source1.cpp进入source2.cpp,例如,不能直接在source2.cpp中断开



如果任何人想出一个解决方案,我会非常高兴听到。



最大

解决方案

在Apple开发者论坛上的回复我现在已经解决了这个问题。



编译器内嵌这些文件,默认情况下LLDB不打破内联文件。



编辑(或创建)〜/ .lldbinit 文件,以强制它断开您需要向.lldbinit文件添加设置。并添加以下行:

 设置设置target.inline-breakpoint-strategy总是



这么简单!


If you include a CPP file from another CPP file, XCode refuses to break at any breakpoints in the included CPP file. I'm going to raise a bug with Apple but just wanted to mention it here in case others have come across this and have maybe found ways around it.

There are very good reasons that you may want to include CPP files from CPP files which I won't go into here. Suffice to say, I can't simple re-arrange the project to compile the included files directly.

Example: A very simple iPhone project

main.mm

extern void FunctionInSource1( int a );

int main(int argc, char * argv[])
{
    FunctionInSource1( 1 );

    return 0;
}

source1.cpp

#include "source2.cpp"

void FunctionInSource1( int a )
{
    int b = a;

    FunctionInSource2( b );

    return;
}

source2.cpp

void FunctionInSource2( int b )
{
    int c = b;

    c = c + 1;

    return;
}

main.mm and source1.cpp are members of the target, i.e. they are set to build. source2.cpp is NOT a member of the target and is NOT compiled except through its inclusion in source1.cpp

Setting a breakpoint anywhere in source2.cpp fails to trigger. Breakpoints anywhere else work fine. N.B. You can still step into source2.cpp from source1.cpp for example, just not break directly in source2.cpp

If anyone has come up with a solution I'd be very happy to hear about it.

Max

解决方案

Thanks to a reply over on the Apple developer forums I have now solved this problem.

The compiler is in-lining these files and by default LLDB doesn't break on in-lined files. To force it to break you need to add a setting to your .lldbinit file.

Edit (or create) the file ~/.lldbinit and add the following line:

settings set target.inline-breakpoint-strategy always

It's as simple as that!

这篇关于XCode不会在#include CPP文件中破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆