Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 beta 2 debugger not showing variable contents after call to String.componentsSeparatedByString

Tags:

swift

xcode6

For some reason LLDB is not showing me the contents of variables while I am stepping through my Swift code. The actual execution works fine, but no matter what I try I can't see the contents of my strings!

Here's what I see in the variable list:

enter image description here

At this point type contains "name" and value contains "Logan". But you wouldn't be able to tell that looking here. If I use the "quick look" button, it says the value is "(None)".

And I get this kind of gibberish when I try to po a String from the console:

(lldb) po space
error: <REPL>:1:1: error: non-nominal type '$__lldb_context' cannot be extended
extension $__lldb_context {                            
^
<REPL>:11:5: error: 'Space.Type' does not have a member named '$__lldb_wrapped_expr_0'
    $__lldb_injected_self.$__lldb_wrapped_expr_0(     
    ^     

However this varies. Sometimes I'll get something like:

class name = __NSAtom

or

Printing description of [0]:
(String) [0] = {
  core = {
    _baseAddress = Builtin.RawPointer = 0x00000001004016f0
    _countAndFlags = -4611686018427387894
    _owner = Some {
      Some = (instance_type = Builtin.RawPointer = 0x0000000100401820 -> 0x00007fff7b3d5390 (void *)0x00007fff7b3d5340: __NSCFString)
    }
  }
}

or

Printing description of declaration:
(String) declaration = <DW_OP_piece for offset 8: top of stack is not a piece>

...but never the actual contents of the string!

Update:

I've noticed the problem only seems to start occurring once a call to componentsSeparatedByString() is made in the function. (This happens right at the top so as I was stepping I didn't notice that the debugger actually does show the value until this point.) So something weird is going on with that function. I've updated the question title to reflect this new information.

Interestingly, it seems once the string has been "corrupted" by this call, you can't view it anywhere else, even when passed to a different function. And any regular string variables are not viewable either. Definitely a bug, but I wonder if there's a workaround. It's getting really hard to debug my program!

like image 642
devios1 Avatar asked Jul 04 '14 20:07

devios1


1 Answers

When I've been encountering this, I've used either NSLog("\(myThing)") in the compiled code I want to debug, or have been calling expression NSLog("\(myThing)") while in the debugger's REPL

like image 143
Dan McClain Avatar answered Oct 13 '22 22:10

Dan McClain