<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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 = )].<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Now you are not going to be able to get that from build-toolchain without modification. A few thoughts:</div><div class=""><br class=""></div><div class="">1. I would file a bug on <a href="http://bugs.swift.org" class="">bugs.swift.org</a> 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.</div><div class="">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.</div><div class=""><br class=""></div><div class="">Michael</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 26, 2016, at 12:36 AM, David Liu via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi all, can any one here give me some pointers on debugging the standard library?</div><div class="">I may be compiling the toolchain incorrectly when i step through the code variables on the stack frame are not available. </div><div class="">I think its due to this message when i start the REPL</div><div class="">`libswiftCore.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.`</div><div class="">I am using the /utils/build-toolchain command and did not touch the presets.ini file.</div><div class="">Any help is appreciated!</div><div class=""><br class=""></div><div class="">Thanks in advance</div><div class=""><br class=""></div><div class="">Dave</div><div class=""><br class=""></div><div class=""><span style="font-family:'Andale Mono';font-size:12px" class="">Process 13833 stopped</span><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">* 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</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 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]</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 69 <span class="" style="white-space:pre">        </span>@_versioned</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 70 <span class="" style="white-space:pre">        </span>internal func _roundUp(_ offset: Int, toAlignment alignment: Int) -> Int {</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 71 <span class="" style="white-space:pre">        </span> _sanityCheck(offset >= 0)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">-> 72 <span class="" style="white-space:pre">        </span> return Int(_roundUpImpl(UInt(bitPattern: offset), toAlignment: alignment))</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 73 <span class="" style="white-space:pre">        </span>}</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 74 <span class="" style="white-space:pre">        </span></span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 75 <span class="" style="white-space:pre">        </span>// This function takes a raw pointer and returns a typed pointer. It implicitly</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) po offset</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">error: <EXPR>:3:1: error: use of unresolved identifier 'offset'</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">offset</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">^~~~~~</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v offset</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">error: no variable named 'offset' found in this frame</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) s</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">Process 13833 stopped</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">* 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</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 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]</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 55 <span class="" style="white-space:pre">        </span> _sanityCheck(_isPowerOf2(alignment))</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 56 <span class="" style="white-space:pre">        </span> // Note, given that offset is >= 0, and alignment > 0, we don't</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 57 <span class="" style="white-space:pre">        </span> // need to underflow check the -1, as it can never underflow.</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">-> 58 <span class="" style="white-space:pre">        </span> let x = offset + UInt(bitPattern: alignment) &- 1</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 59 <span class="" style="white-space:pre">        </span> // Note, as alignment is a power of 2, we'll use masking to efficiently</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 60 <span class="" style="white-space:pre">        </span> // get the aligned value</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class=""> 61 <span class="" style="white-space:pre">        </span> return x & ~(UInt(bitPattern: alignment) &- 1)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v -R</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v aligment</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">error: no variable named 'aligment' found in this frame</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">(lldb) fr v alignment</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono';" class=""><span style="" class="">error: no variable named 'alignment' found in this frame</span></div></div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>