Xcode调试器:代码窗口与堆栈窗口不匹配

时间:2009-02-24 16:19:21

标签: xcode gcc

我正在尝试将基于SDLWxWidgets的相当大的Windows项目移植到Mac OS X.

有史以来第一次在Mac上,我可以运行我的应用程序,但调试器似乎无法正常工作。当进入我的应用程序时,堆栈视图似乎有意义,但是当我单击调试器堆栈视图中显示的其中一个函数名称时,下面的代码视图向我显示了一段完全不同的代码。

例如,我在堆栈视图中单击“main”,但下面的代码窗口从Mac OS X SDK跳转到stdexcept的第100行。

我尝试将调试器与“hello world”项目一起使用,一切正常,所以问题必须与我的项目有关。我已经在项目选项中检查了以下设置:

  

生成调试符号:1级

     

调试符号:所有符号

     

优化级别:无

     

构建变体:debug

我还确保在调试器首选项中关闭“Load Signols Lazily”。

什么可能导致调试器出现故障?

编辑:我已经根据sqook的建议将所有.cpp和.h文件转换为Unix行结尾,排除了Windows文件结尾。

第二次编辑:由于此问题仅发生在此特定项目中,因此我在此处发布了我从默认设置(标题搜索路径除外)更改的所有设置。也许其中一个可能是罪魁祸首?

    ARCHS = $(NATIVE_ARCH)
    SDKROOT = macosx10.5
    VALID_ARCHS = i386 x86_64
    BUILD_VARIANTS = normal
    MACOSX_DEPLOYMENT_TARGET = 10.4
    COPY_PHASE_STRIP = NO
    DEAD_CODE_STRIPPING = NO
    OTHER_LDFLAGS = $(OTHER_LDFLAGS_LIBBOOST) $(OTHER_LDFLAGS_QUOTED_FOR_PROJECT_1) $(OTHER_LDFLAGS_QUOTED_FOR_PROJECT_2) $(OTHER_LDFLAGS_WXWIDGETS)
    PREBINDING = NO
    PRODUCT_NAME = Gemsweeper
    FRAMEWORK_SEARCH_PATHS = $(HOME)/Library/Frameworks /Library/Frameworks $(FRAMEWORK_SEARCH_PATHS)
    HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_7) $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_6) /usr/local/include $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_1) $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_2) $(HOME)/Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL.framework/Headers $(HEADER_SEARCH_PATHS) /opt/local/var/macports/software/boost/1.37.0_0+darwin_9/opt/local/include $(HOME)/Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL.framework/Headers $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_3) $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_4) $(HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_5)
    LIBRARY_SEARCH_PATHS = /usr/local/lib /opt/local/lib
    GCC_DEBUGGING_SYMBOLS = full
    GCC_OPTIMIZATION_LEVEL = 0
    OTHER_CFLAGS = $(WX_CXX_FLAGS)
    OTHER_CPLUSPLUSFLAGS = -I/usr/local/lib/wx/include/mac-ansi-debug-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXDEBUG__ -D__WXMAC__
    GCC_PREPROCESSOR_DEFINITIONS = NO_BASS_SOUND _DEBUG XCODE __WXMAC__
    GCC_WARN_ABOUT_RETURN_TYPE = YES
    GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES
    GCC_WARN_UNUSED_VARIABLE = YES
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_1 = '/Users/adriangrigore/Documents/Gemsweeper Mac'
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_2 = "/Users/adriangrigore/Documents/Gemsweeper Mac/Finity Engine VS 2003/WxNonogram"
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_3 = "/Users/adriangrigore/Documents/Gemsweeper Mac/Finity Engine VS 2003/Finity Engine VS 2003/myunits/resmanager"
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_4 = "/Users/adriangrigore/Documents/Gemsweeper Mac/Finity Engine VS 2003/Finity Engine VS 2003/myunits"
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_5 = "/Users/adriangrigore/Documents/Gemsweeper Mac/Finity Engine VS 2003/Finity Engine VS 2003"
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_6 = "/Users/adriangrigore/Documents/Gemsweeper Mac/Finity Engine VS 2003/Finity Engine VS 2003/myunits/compiler-dependent"
    HEADER_SEARCH_PATHS_QUOTED_FOR_PROJECT_7 = '/Users/adriangrigore/Documents/Gemsweeper Mac/3rd party/AntiGrain/include'
    OTHER_LDFLAGS_LIBBOOST = /opt/local/lib/libboost_program_options-mt.a /opt/local/lib/libboost_filesystem-mt.a /opt/local/lib/libboost_serialization-mt.a /opt/local/lib/libboost_system-mt.a /opt/local/lib/libboost_thread-mt.a
    OTHER_LDFLAGS_QUOTED_FOR_PROJECT_1 = '/Users/adriangrigore/Documents/Gemsweeper Mac/3rd party/FreeImage/Dist/libfreeimage.a'
    OTHER_LDFLAGS_QUOTED_FOR_PROJECT_2 = '/Users/adriangrigore/Documents/Gemsweeper Mac/3rd party/cpuinfo-1.0/libcpuinfo.a'
    OTHER_LDFLAGS_WXWIDGETS = -L/usr/local/lib   -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL  -lwx_macd_richtext-2.8 -lwx_macd_aui-2.8 -lwx_macd_xrc-2.8 -lwx_macd_qa-2.8 -lwx_macd_html-2.8 -lwx_macd_adv-2.8 -lwx_macd_core-2.8 -lwx_base_carbond_xml-2.8 -lwx_base_carbond_net-2.8 -lwx_base_carbond-2.8

希望最后编辑:我刚刚发现问题实际上并不是与Xcode调试器绑定,而是与底层GDB有关。通过命令行调试程序时,我看到完全相同的问题。因此,我已将此问题移至 GCC debugger stack trace displays wrong file name and line number

3 个答案:

答案 0 :(得分:1)

Xcode有缺陷。非常非常马车。即使是3.x我昨晚也有同样的问题,因为它会显示超出应有的循环次数。插入一些printf()表明它是调试器IDE出错了。

但是,您可以尝试一下干净的构建。并确保您使用的是调试版本。并且所有模块都已加载。

答案 1 :(得分:1)

我也注意到了这一点,并向Apple报告了一个关于此问题的错误。他们否认了这种行为,但暗示这可能是由文件中错误的行结尾引起的。无论如何,尝试将行结尾转换为unix / mac格式,执行完全清理,然后运行它。

编辑:我应该在Xcode中指定,您可以选择保存行结束类型。您可以使用您选择的行结尾重新保存所有文件。但是,这也有点不一致(grr),所以我建议使用flip,并执行以下操作:

find /wherever -name "*.cpp" -print -exec flip -u {} \;

同样,我不能保证这会解决问题,因为我接受了Apple的建议,但仍然看到调试器在我的断点处停止了几十行。

答案 2 :(得分:0)

请参阅我的答案here。 SDL将main重新定义为SDL_main