简体   繁体   中英

LLDB is not setting breakpoints at the correct line

This should server to illustrate the problem. I was originally trying to set the breakpoints in Xcode, but observed that the same problem happened when I set them on the command line of 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());

Now let me set a breakpoint at line 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

But bugger - it's now at line 341.

Here is line 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 

And we have debugging symbols:

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

Any ideas what to check next? It's a debug build...I've just upgraded to the latest Xcode version, but it was failing in Xcode 6 as well in exactly the same way.

PS. Here are the lovely compiler options:

/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-backtrace-limit=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/Bui ld/Intermediates/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/Intermediates/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/Debug/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

If you set a breakpoint on a line of source code that doesn't generate any executable code (eg a comment, a #ifdef'ed out line, an non-exported function that never gets used) lldb will move the breakpoint to the next source line that generates executable code, which may well be in a different function.

Can't tell for sure from your source clips, but if getDamage is the next function after handleCollision, then the breakpoint motion would be explained if no code was emitted for handleCollision. If you do:

(lldb) image lookup -n ClassName::handleCollision

or if you want to consult something outside lldb:

$ nm <Binary> | grep handleCollision

do they show there is actually a symbol for that function?

尝试将Xcode升级到最新版本,如果您使用Xcode 7.1或更低版本,则可能是我在使用Xcode 7.1.1时遇到了许多错误,并且没有任何问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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