<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>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">* 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></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 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></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 69 <span class="" style="white-space:pre">        </span>@_versioned</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 70 <span class="" style="white-space:pre">        </span>internal func _roundUp(_ offset: Int, toAlignment alignment: Int) -> Int {</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 71 <span class="" style="white-space:pre">        </span> _sanityCheck(offset >= 0)</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">-> 72 <span class="" style="white-space:pre">        </span> return Int(_roundUpImpl(UInt(bitPattern: offset), toAlignment: alignment))</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 73 <span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 74 <span class="" style="white-space:pre">        </span></span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 75 <span class="" style="white-space:pre">        </span>// This function takes a raw pointer and returns a typed pointer. It implicitly</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) po offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">error: <EXPR>:3:1: error: use of unresolved identifier 'offset'</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">^~~~~~</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">error: no variable named 'offset' found in this frame</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) s</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">Process 13833 stopped</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">* 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></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 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></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 55 <span class="" style="white-space:pre">        </span> _sanityCheck(_isPowerOf2(alignment))</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 56 <span class="" style="white-space:pre">        </span> // Note, given that offset is >= 0, and alignment > 0, we don't</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 57 <span class="" style="white-space:pre">        </span> // need to underflow check the -1, as it can never underflow.</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">-> 58 <span class="" style="white-space:pre">        </span> let x = offset + UInt(bitPattern: alignment) &- 1</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 59 <span class="" style="white-space:pre">        </span> // Note, as alignment is a power of 2, we'll use masking to efficiently</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 60 <span class="" style="white-space:pre">        </span> // get the aligned value</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style=""> 61 <span class="" style="white-space:pre">        </span> return x & ~(UInt(bitPattern: alignment) &- 1)</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v -R</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v aligment</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">error: no variable named 'aligment' found in this frame</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">(lldb) fr v alignment</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:'Andale Mono'"><span style="">error: no variable named 'alignment' found in this frame</span></p></div></div>