[swift-users] libswiftCore.dylib was compiled with optimization - stepping may behave oddly;
Michael Gottesman
mgottesman at apple.com
Fri Aug 26 01:31:23 CDT 2016
If you are using the build-toolchain command, the stdlib will be built with optimizations enabled [as one would hope when you compile a toolchain = )].
If you want to have a debug stdlib, you need to make sure that the cmake flag -DSWIFT_STDLIB_BUILD_TYPE=Debug is set. (And probably you also want) -DSWIFT_STDLIB_ASSERTIONS=true.
Now you are not going to be able to get that from build-toolchain without modification. A few thoughts:
1. I would file a bug on bugs.swift.org saying that you want the ability to tell build-toolchain to build a debug standard library. I think that is a reasonable request. Please respond to this thread with the URL.
2. Notice that the build-toolchain script has a build-script invocation inside of it. There is an option to build-script called something along the lines of --expand-build-script-command-line perhaps? Look for expand in the --help. You can add that to the script to grab the internal build-script invocation. Then add to the end of that invocation the option: --debug-swift-stdlib --swift-stdlib-assertions. Keep in mind that this is just from memory so you may need to munge it a little bit.
Michael
> On Aug 26, 2016, at 12:36 AM, David Liu via swift-users <swift-users at swift.org> wrote:
>
> Hi all, can any one here give me some pointers on debugging the standard library?
> I may be compiling the toolchain incorrectly when i step through the code variables on the stack frame are not available.
> I think its due to this message when i start the REPL
> `libswiftCore.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.`
> I am using the /utils/build-toolchain command and did not touch the presets.ini file.
> Any help is appreciated!
>
> Thanks in advance
>
> Dave
>
> Process 13833 stopped
> * thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -> ManagedBufferPointer<A, B> [inlined] Swift._roundUp (Swift.Int, toAlignment : Swift.Int) -> Swift.Int at Builtin.swift:72, queue = 'com.apple.main-thread', stop reason = step in
> frame #0: 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -> ManagedBufferPointer<A, B> [inlined] Swift._roundUp (Swift.Int, toAlignment : Swift.Int) -> Swift.Int at Builtin.swift:72 [opt]
> 69 @_versioned
> 70 internal func _roundUp(_ offset: Int, toAlignment alignment: Int) -> Int {
> 71 _sanityCheck(offset >= 0)
> -> 72 return Int(_roundUpImpl(UInt(bitPattern: offset), toAlignment: alignment))
> 73 }
> 74
> 75 // This function takes a raw pointer and returns a typed pointer. It implicitly
> (lldb) fr v
> (lldb) po offset
> error: <EXPR>:3:1: error: use of unresolved identifier 'offset'
> offset
> ^~~~~~
> (lldb) fr v offset
> error: no variable named 'offset' found in this frame
> (lldb) s
> Process 13833 stopped
> * thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -> ManagedBufferPointer<A, B> [inlined] Swift._roundUpImpl (Swift.UInt, toAlignment : Swift.Int) -> Swift.UInt at Builtin.swift:58, queue = 'com.apple.main-thread', stop reason = step in
> frame #0: 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -> ManagedBufferPointer<A, B> [inlined] Swift._roundUpImpl (Swift.UInt, toAlignment : Swift.Int) -> Swift.UInt at Builtin.swift:58 [opt]
> 55 _sanityCheck(_isPowerOf2(alignment))
> 56 // Note, given that offset is >= 0, and alignment > 0, we don't
> 57 // need to underflow check the -1, as it can never underflow.
> -> 58 let x = offset + UInt(bitPattern: alignment) &- 1
> 59 // Note, as alignment is a power of 2, we'll use masking to efficiently
> 60 // get the aligned value
> 61 return x & ~(UInt(bitPattern: alignment) &- 1)
> (lldb) fr v
> (lldb) fr v -R
> (lldb) fr v aligment
> error: no variable named 'aligment' found in this frame
> (lldb) fr v alignment
> error: no variable named 'alignment' found in this frame
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160826/cc6b22da/attachment.html>
More information about the swift-users
mailing list