Help with lldb's `po` command

I'm viewing a variable and the result is getting truncated:

what do I do to show in non truncated?

help po will tell you, that po is abbreviation of expression -O --. The -O will Display using a language-specific description API, if possible..

Use expression without -O, following example:

(lldb) e -l swift -- let $x = NSView()
(lldb) e -l swift -O -- $x
<NSView: 0x100604080>

(lldb) e -l swift -- $x
(NSView) $R1 = 0x0000000100604080 {
  baseNSResponder@0 = {
    baseNSObject@0 = {
      isa = NSView
    }
    _nextResponder = 0x0000000000000000
    _dependencyInfo = 0x0000600001708000
    _respondersWeAreNextFor = 0x0000000000000000
  }
  _trackingAreaHelper = 0x0000600000c08000
  _frameMatrix = 0x0000000000000000
  _superview = 0x0000000000000000
  _dragTypes = 0x0000000000000000
  _viewRoot = 0x0000000000000000
  _subviews = 0x0000000000000000
  _layer = 0x0000000000000000
  _window = 0x0000000000000000
  _needsGeometryInWindowDidChangeNotificationCount = 0
  _geometryInWindowSensitiveSubviews = 0x0000000000000000
  _bindingAdaptor = 0x0000000000000000
  _menu = 0x0000000000000000
  _layoutAux = 0x0000000000000000
  _animator = 0x0000000000000000
  _animationsDictionary = 0x0000000000000000
  _alphaValue = 1
  _contentFilters = 0x0000000000000000
  _backgroundFilters = 0x0000000000000000
  _compositingFilter = 0x0000000000000000
  _shadow = 0x0000000000000000
  _userInterfaceItemIdentifierInternalNumber = 0
  _layoutTransactionSeed = 0
  _userInterfaceItemIdentifier = 0x0000000000000000
  _clipPath = 0x0000000000000000
  _updateLayerHandler = 0x0000000000000000
  _cachedEffectiveAppearance = 0x0000000000000000
  _contentStyle = 0x0000000000000000
  _cachedEffectiveContentStyle = 0x0000000000000000
  _cornerRadius = 0
  _backgroundColor = 0x0000000000000000
  _idleTimerMonitor = 0x0000000000000000
  _viewController = 0x0000000000000000
  _gestureRecognizers = 0x0000000000000000
  _ancestorWithLayerForLastLayerGeometryUpdate = 0x0000000000000000
  _antialiasThresholdChangedNotificationToken = 8589934593
  _drawingCalloutDependencyContexts = 0x0000000000000000
}

3 Likes

Try using xpc_copy_description to get the full char *

1 Like

Ah. Sounds like XPC doesn't provide a non-truncated description for that type then. You'll probably have to DIY it.

1 Like

I am totally up to DIY-ing that debugging call myself. Before I spend hours on it – that's an iOS project, so, to begin with, what do I import to use XPC functions? :thinking: Or do I just read memory from some offset and unsafeBitCast it to what I think it should be until it works? :rofl: (I know I could do it, just before spending a few hours on that would like to double check if there's an easier solution).

If you put lldb in objc mode (e.g. expression -l objc …) you can just call the C interface (xpc_data_get_bytes_ptr) and then do something like memory read -c3334 <that address> --force. Maybe with some -f and -s sprinkled in there for formatting/grouping, check the help on memory read.

1 Like

Will try that, thank you. It's not particularly helpful that OS kills my process (a service extension) quite quickly, within a minute or so, so I can't spend in debugger too long.

Hurray,

So the relevant xpc dictionary variable is in x20:

(lldb) po $x20
<OS_xpc_dictionary: dictionary[0x10440e8e0]: { refcnt = 1, xrefcnt = 1, subtype = 1, count = 5, transport = 0, dest port = 0x5223, dest msg id = 0x5223, transaction = 1, voucher = 0x10440aef0 } <dictionary: 0x10440e8e0> { count = 5, transaction: 1, voucher = 0x10440aef0, contents =
	"f" => <uint64: 0xb6d3d23e734eb797>: 33
	"root" => <data: 0x1091043f0>: { length = 3334 bytes, contents = 0x62706c6973743137a0050d0000000000007f113564696452... }
	"proxynum" => <uint64: 0xb6d3d23e734eb697>: 1
	"replysig" => <string: 0x1091041c0> { length = 31, contents = "v16@?0@"UNNotificationContent"8" }
	"sequence" => <uint64: 0xb6d3d23e734eb697>: 1
}>

From there get 0x1091043f0 where the data is and its length: 3334. Then:

(lldb) expression (void*)xpc_data_get_bytes_ptr(0x109104440)
(void *) $5 = 0x000000010a008240

and finally pass the gathered numbers into this line:

(lldb) memory read --size 1 --count 3334 --force 0x000000010a008240

Here's the result:

0x10a008240: 62 70 6c 69 73 74 31 37 a0 05 0d 00 00 00 00 00  bplist17........
......
0x10a008f30: 65 6e 74 00 b0 7d 64 65 73 74 69 6e 61 74 69 6f  ent..}destinatio
0x10a008f40: 6e 73 00 11 1f e0 

Thanks guys.

4 Likes