<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:&#39;Andale Mono&#39;;font-size:12px">Process 13833 stopped</span><br></div><div>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">* thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -&gt; ManagedBufferPointer&lt;A, B&gt; [inlined] Swift._roundUp (Swift.Int, toAlignment : Swift.Int) -&gt; Swift.Int at Builtin.swift:72, queue = &#39;com.apple.main-thread&#39;, stop reason = step in</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">    frame #0: 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -&gt; ManagedBufferPointer&lt;A, B&gt; [inlined] Swift._roundUp (Swift.Int, toAlignment : Swift.Int) -&gt; Swift.Int at Builtin.swift:72 [opt]</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><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:&#39;Andale Mono&#39;"><span style="">   70  <span class="" style="white-space:pre">        </span>internal func _roundUp(_ offset: Int, toAlignment alignment: Int) -&gt; Int {</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">   71  <span class="" style="white-space:pre">        </span>  _sanityCheck(offset &gt;= 0)</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">-&gt; 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:&#39;Andale Mono&#39;"><span style="">   73  <span class="" style="white-space:pre">        </span>}</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">   74  <span class="" style="white-space:pre">        </span></span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><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:&#39;Andale Mono&#39;"><span style="">(lldb) fr v</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) po offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">error: &lt;EXPR&gt;:3:1: error: use of unresolved identifier &#39;offset&#39;</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">^~~~~~</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) fr v offset</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">error: no variable named &#39;offset&#39; found in this frame</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) s</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">Process 13833 stopped</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">* thread #1: tid = 0x3a6ffe, 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -&gt; ManagedBufferPointer&lt;A, B&gt; [inlined] Swift._roundUpImpl (Swift.UInt, toAlignment : Swift.Int) -&gt; Swift.UInt at Builtin.swift:58, queue = &#39;com.apple.main-thread&#39;, stop reason = step in</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">    frame #0: 0x00000001000c3603 libswiftCore.dylib`ManagedBufferPointer.init(_uncheckedBufferClass : AnyObject.Type, minimumCapacity : Int) -&gt; ManagedBufferPointer&lt;A, B&gt; [inlined] Swift._roundUpImpl (Swift.UInt, toAlignment : Swift.Int) -&gt; Swift.UInt at Builtin.swift:58 [opt]</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><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:&#39;Andale Mono&#39;"><span style="">   56  <span class="" style="white-space:pre">        </span>  // Note, given that offset is &gt;= 0, and alignment &gt; 0, we don&#39;t</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><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:&#39;Andale Mono&#39;"><span style="">-&gt; 58  <span class="" style="white-space:pre">        </span>  let x = offset + UInt(bitPattern: alignment) &amp;- 1</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">   59  <span class="" style="white-space:pre">        </span>  // Note, as alignment is a power of 2, we&#39;ll use masking to efficiently</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><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:&#39;Andale Mono&#39;"><span style="">   61  <span class="" style="white-space:pre">        </span>  return x &amp; ~(UInt(bitPattern: alignment) &amp;- 1)</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) fr v</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) fr v -R</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) fr v aligment</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">error: no variable named &#39;aligment&#39; found in this frame</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">(lldb) fr v alignment</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:&#39;Andale Mono&#39;"><span style="">error: no variable named &#39;alignment&#39; found in this frame</span></p></div></div>