gpt4 book ai didi

c++ - LLDB 没有在正确的行设置断点

转载 作者:行者123 更新时间:2023-11-30 03:46:55 25 4
gpt4 key购买 nike

这应该有助于说明问题。我本来是想在Xcode中设置断点的,但是观察到在LLDB的命令行中设置断点时出现了同样的问题:

(lldb) list /Users/jim/Code/breakout-juce/Source/BalLGame.h:300
300 }
301 }
302
303 void handleCollision(const Object & other) override
304 {
305 if (other.getComponentID() == "paddle")
306 {
307 auto & paddle = dynamic_cast<const Paddle&>(other);
308
309 auto positionInPaddle = paddle.getLocalPoint(this, getLocalBounds().getCentre());
310 auto normal = paddle.getNormal(positionInPaddle.getX());

现在让我在第 305 行设置一个断点。

(lldb) break set -f /Users/jim/Code/breakout-juce/Source/BalLGame.h -l 305
Breakpoint 4: where = Buzz`Ball::getDamage() const + 12 at BalLGame.h:341, address = 0x00000001000018ac

但是该死的 - 它现在在第 341 行。

这是第 341 行:

(lldb) list /Users/jim/Code/breakout-juce/Source/BalLGame.h:340
340
341 int getDamage() const { return damage; }
342
343 void tick() override
344 {
345 setBounds(getBounds().translated(getDirectionVector().x, getDirectionVector().y));
346 angle += deltaAngle;
347 }
348
349 bool isKilled() override { return killed; }
350

我们有调试符号:

(lldb) script lldb.target.module['/Users/jim/Code/breakout-juce/Builds/MacOSX/build/Debug/Buzz.app/Contents/MacOS/Buzz'].GetNumCompileUnits()
19

有什么想法接下来要检查什么吗?这是一个调试版本...我刚刚升级到最新的 Xcode 版本,但它在 Xcode 6 中也以完全相同的方式失败。

附言。以下是可爱的编译器选项:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-回溯限制=0 -std=c++11 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wnon-virtual-dtor - Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value - Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion - Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -D_DEBUG=1 -DDEBUG=1 -DJUCER_XCODE_MAC_F6D2F4CF=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX =0x10000 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version -min=10.10 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wno-sign-conversion -iquote/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/Buzz-generated-files.hmap -I/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/Buzz-own-target -headers.hmap -I/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/Buzz-all-target-headers.hmap -iquote/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/Buzz-project-headers.hmap -I/Users/jim/Code/breakout-juce/Builds/MacOSX/build/Debug/include -I../../JuceLibraryCode -I../../../juce/modules -I/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/构建/中间体/Buzz.build/Debug/Buzz.build/DerivedSources/x86_64 -I/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/DerivedSources -Wreorder -F/Users/jim/Code/breakout-juce/Builds/MacOSX/build/Debug -MMD -MT dependencies -MF/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/中间体/Buzz.build/Debug/Buzz.build/Objects-normal/x86_64/BalLGame.d --serialize-diagnostics/Users/jim/Library/Developer/Xcode/DerivedData/Buzz-gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/调试/Buzz.build/Objects-normal/x86_64/BalLGame.dia -c/Users/jim/Code/breakout-juce/Source/BalLGame.cpp -o/Users/jim/Library/Developer/Xcode/DerivedData/Buzz- gymosgfspfkofkhbahhngwelyhbv/Build/Intermediates/Buzz.build/Debug/Buzz.build/Objects-normal/x86_64/BalLGame.o

最佳答案

如果您在不生成任何可执行代码的源代码行上设置断点(例如注释、#ifdef 输出行、从未使用过的非导出函数),lldb 将移动断点到生成可执行代码的下一个源代码行,它很可能位于不同的函数中。

无法从您的源剪辑中确定,但如果 getDamage 是 handleCollision 之后的下一个函数,那么如果没有为 handleCollision 发出代码,则断点运动将得到解释。如果你这样做:

(lldb) image lookup -n ClassName::handleCollision

或者如果你想咨询 lldb 之外的东西:

$ nm <Binary> | grep handleCollision

他们是否表明该功能实际上有一个符号?

关于c++ - LLDB 没有在正确的行设置断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33914208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com