XCode不会破坏#include'dCPP文件

MrM*_*axP 6 c++ xcode breakpoints include

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

您可能希望在CPP文件中包含CPP文件有很好的理由,我不会在此处介绍.可以说,我不能简单地重新安排项目直接编译包含的文件.

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

main.mm

extern void FunctionInSource1( int a );

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

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

source1.cpp

#include "source2.cpp"

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

    FunctionInSource2( b );

    return;
}
Run Code Online (Sandbox Code Playgroud)

source2.cpp

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

    c = c + 1;

    return;
}
Run Code Online (Sandbox Code Playgroud)

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

在source2.cpp中的任何位置设置断点都无法触发.其他地方的断点工作正常.NB你仍然可以从source1.cpp步入source2.cpp,例如,不要直接在source2.cpp中断

如果有人提出解决方案,我会很高兴听到它.

马克斯

MrM*_*axP 14

感谢Apple开发人员论坛上的回复,我现在已经解决了这个问题.

编译器内嵌这些文件,默认情况下,LLDB不会破坏内联文件.要强制它中断,您需要为.lldbinit文件添加设置.

编辑(或创建)〜/ .lldbinit文件并添加以下行:

settings set target.inline-breakpoint-strategy always
Run Code Online (Sandbox Code Playgroud)

就这么简单!