<div dir="ltr">Thank you Michael this really helps a lot, i really appreciate your help.<div>Here is the bug i filed. <a href="https://bugs.swift.org/browse/SR-2494">https://bugs.swift.org/browse/SR-2494</a> .</div><div>Also as a side question, this is my current method of trying to debug the Standard Library, was wondering is there a better way to debug other than build toolchain and debug through command line?</div><div><br></div><div>Cheers</div><div><br></div><div>Dave</div><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 25, 2016 at 11:31 PM, Michael Gottesman <span dir="ltr"><<a href="mailto:mgottesman@apple.com" target="_blank">mgottesman@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">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><br></div><div>If you want to have a debug stdlib, you need to make sure that the cmake flag -DSWIFT_STDLIB_BUILD_TYPE=<wbr>Debug is set. (And probably you also want) -DSWIFT_STDLIB_ASSERTIONS=<wbr>true.</div><div><br></div><div>Now you are not going to be able to get that from build-toolchain without modification. A few thoughts:</div><div><br></div><div>1. I would file a bug on <a href="http://bugs.swift.org" target="_blank">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>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-<wbr>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><br></div><div>Michael</div><div><br><div><blockquote type="cite"><div><div class="h5"><div>On Aug 26, 2016, at 12:36 AM, David Liu via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div>Hi all, can any one here give me some pointers on debugging the standard library?</div><div>I may be compiling the toolchain incorrectly when i step through the code variables on the stack frame are not available. </div><div>I think its due to this message when i start the REPL</div><div>`libswiftCore.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.`</div><div>I am using the /utils/build-toolchain command and did not touch the presets.ini file.</div><div>Any help is appreciated!</div><div><br></div><div>Thanks in advance</div><div><br></div><div>Dave</div><div><br></div><div><span style="font-family:'Andale Mono';font-size:12px">Process 13833 stopped</span><br></div><div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>* thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`<wbr>ManagedBufferPointer.init(_<wbr>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'"><span> frame #0: 0x00000001000c3603 libswiftCore.dylib`<wbr>ManagedBufferPointer.init(_<wbr>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'"><span> 69 <span style="white-space:pre-wrap">        </span>@_versioned</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 70 <span style="white-space:pre-wrap">        </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'"><span> 71 <span style="white-space:pre-wrap">        </span> _sanityCheck(offset >= 0)</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>-> 72 <span style="white-space:pre-wrap">        </span> return Int(_roundUpImpl(UInt(<wbr>bitPattern: offset), toAlignment: alignment))</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 73 <span style="white-space:pre-wrap">        </span>}</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 74 <span style="white-space:pre-wrap">        </span></span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 75 <span style="white-space:pre-wrap">        </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'"><span>(lldb) fr v</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>(lldb) po offset</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>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'"><span>offset</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>^~~~~~</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>(lldb) fr v offset</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>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'"><span>(lldb) s</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>Process 13833 stopped</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>* thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`<wbr>ManagedBufferPointer.init(_<wbr>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'"><span> frame #0: 0x00000001000c3603 libswiftCore.dylib`<wbr>ManagedBufferPointer.init(_<wbr>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'"><span> 55 <span style="white-space:pre-wrap">        </span> _sanityCheck(_isPowerOf2(<wbr>alignment))</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 56 <span style="white-space:pre-wrap">        </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'"><span> 57 <span style="white-space:pre-wrap">        </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'"><span>-> 58 <span style="white-space:pre-wrap">        </span> let x = offset + UInt(bitPattern: alignment) &- 1</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 59 <span style="white-space:pre-wrap">        </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'"><span> 60 <span style="white-space:pre-wrap">        </span> // get the aligned value</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span> 61 <span style="white-space:pre-wrap">        </span> return x & ~(UInt(bitPattern: alignment) &- 1)</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>(lldb) fr v</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>(lldb) fr v -R</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>(lldb) fr v aligment</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>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'"><span>(lldb) fr v alignment</span></div><div style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span>error: no variable named 'alignment' found in this frame</span></div></div></div></div></div>
______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>