# Trying to solve Alamofire's lldb woes

**URL:** <https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801>\
**Category:** LLDB\
**Created:** [March 25, 2020, 8:36pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801 "2020-03-25T20:36:44Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [March 25, 2020, 8:36pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/1 "2020-03-25T20:36:44Z")

</div>

For years now lldb has been unable to print Alamofire's `*Response` type in completion handlers, even when other values in other completion handlers are okay. Naturally this makes debugging while developing Alamofire quite frustrating. I'd like some help narrowing down the cause so I can either make a better bug report to get it fixed or look into fixing it myself.

The issues is trivially reproducible. Clone Alamofire, place a break point in a completion handler of one of our tests, and run the test. Attempting to print the response will produce this error:

```swift
error: Couldn't materialize: can't get size of type
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

```

Of course I can `frame variable` or `ex debugPrint(response)` to see the value, but this affects both `po` and the variable view, so it would be much more convenient to actually be able to print.

I've tried all of the workaround I could find online, including:

- Ensuring optimizations are turned off.
- Turning optimizations on just to see.
- Setting the Debug Information Format to DWARF or DWARF with dSYM file.
- Toggling various combinations of sanitizers and other settings in the scheme.

Nothing has made any difference, so what are my next steps to try and debug this?

---

<div class="post-metadata">

**Author:** ![dcci](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dcci/32/1673_2.png) [@dcci](https://forums.swift.org/u/dcci)\
**Post date:** [March 25, 2020, 8:51pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/2 "2020-03-25T20:51:12Z")

</div>

I'm motivated to help you fixing this, as I understand your frustration. Ideally a smaller, self contained testcase would help. As in, something I can run myself from the command line that reproduces this bug. Can you try?

---

<div class="post-metadata">

**Author:** ![dcci](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dcci/32/1673_2.png) [@dcci](https://forums.swift.org/u/dcci)\
**Post date:** [March 25, 2020, 8:53pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/3 "2020-03-25T20:53:32Z")

</div>

It's also interesting that `frame var` works for you, but the variable view doesn't, as they use the same underlying mechanism to resolve types.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [March 25, 2020, 8:58pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/4 "2020-03-25T20:58:35Z")

</div>

Sorry, it doesn't look like `frame var` actually works, as it just has this for the response:

```swift
(Alamofire.AFDataResponse<Any>) resp = {
  request = nil
}

```

This is odd, as the request has far more properties, and the `request` property isn't `nil`, as can be seen by manually printing the value:

```swift
(lldb) e debugPrint(resp)
[Request]: GET https://httpbin.org/get
[Request Body]: 
None
[Response]: 
[Status Code]: 200
[Headers]:
Access-Control-Allow-Origin: *
Content-Length: 432
Content-Type: application/json
Date: Wed, 25 Mar 2020 20:55:05 GMT
Server: gunicorn/19.9.0
access-control-allow-credentials: true
[Response Body]: 
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "br;q=1.0, gzip;q=0.9, deflate;q=0.8", 
    "Accept-Language": "en-US;q=1.0", 
    "Host": "httpbin.org", 
    "User-Agent": "Unknown/Unknown (com.apple.dt.xctest.tool; build:16091; macOS 10.15.4) Alamofire/5.0.5", 
    "X-Amzn-Trace-Id": "Root=1-5e7bc529-c49fdc85edf9c9986b493081"
  }, 
  "origin": "108.64.179.78", 
  "url": "https://httpbin.org/get"
}

[Data]: 432 bytes
[Network Duration]: 0.30299103260040283s
[Serialization Duration]: 0.0028259754180908203s
[Result]: success({
    args = {
    };
    headers = {
        Accept = "*/*";
        "Accept-Encoding" = "br;q=1.0, gzip;q=0.9, deflate;q=0.8";
        "Accept-Language" = "en-US;q=1.0";
        Host = "httpbin.org";
        "User-Agent" = "Unknown/Unknown (com.apple.dt.xctest.tool; build:16091; macOS 10.15.4) Alamofire/5.0.5";
        "X-Amzn-Trace-Id" = "Root=1-5e7bc529-c49fdc85edf9c9986b493081";
    };
    origin = "108.64.179.78";
    url = "https://httpbin.org/get";
})
() $R1 = {}

```

I can try to produce a smaller test case, but completion handlers usually work.

---

<div class="post-metadata">

**Author:** ![dcci](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dcci/32/1673_2.png) [@dcci](https://forums.swift.org/u/dcci)\
**Post date:** [March 25, 2020, 9:08pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/5 "2020-03-25T21:08:28Z")

</div>

Can you provide the definition of `Response` and `Request`?  
I would like to see if there's anything particular with them [e.g. resilient types]. Other than that, I guess I should just try to find the time to sit down and debug this.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [March 25, 2020, 9:10pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/6 "2020-03-25T21:10:29Z")

</div>

[DataRequest](https://github.com/Alamofire/Alamofire/blob/master/Source/Request.swift#L981) - Note: this is a subclass.

[DataResponse](https://github.com/Alamofire/Alamofire/blob/master/Source/Response.swift#L33)

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [March 25, 2020, 9:26pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/7 "2020-03-25T21:26:24Z")

</div>

Is there any way I could help in debugging this? Perhaps gathering diagnostic info from Xcode or lldb while I'm debugging?

---

<div class="post-metadata">

**Author:** ![dcci](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dcci/32/1673_2.png) [@dcci](https://forums.swift.org/u/dcci)\
**Post date:** [March 25, 2020, 9:27pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/8 "2020-03-25T21:27:52Z")

</div>

I think the best you can do -- if you can, is provide a smaller testcase where this reproduces. [hopefully, a single file]

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 24, 2020, 12:23am UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/9 "2020-06-24T00:23:32Z")

</div>

I was never able to reproduce this in a small sample, but my testing in Xcode 12 seems to indicate the issue may have been fixed by the enhancements to lldb in that version. For the first time in literally years I can use the debugger in Alamofire's completion handlers!

---

<div class="post-metadata">

**Author:** ![rog](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rog/32/3351_2.png) [@rog](https://forums.swift.org/u/rog)\
**Post date:** [June 25, 2020, 9:03pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/10 "2020-06-25T21:03:25Z")

</div>

Hi @Jon_Shier I was super excited to see this message, installed Xcode 12 to test it with our project target but for us debug is completely broken. Could you please let me know how you've been able to confirm that the Alamofire debugging issues have been fixed on Xcode 12?

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 25, 2020, 9:04pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/11 "2020-06-25T21:04:49Z")

</div>

I only tested that debugging Alamofire itself from within its test cases works. If you're still having trouble debugging Alamofire while its integrated into your project, you should report that issue to Apple. I'll do some additional testing to confirm.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 25, 2020, 9:07pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/12 "2020-06-25T21:07:56Z")

</div>

I've confirmed that debugging works in a simple project that integrates Alamofire using CocoaPods.

---

<div class="post-metadata">

**Author:** ![rog](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rog/32/3351_2.png) [@rog](https://forums.swift.org/u/rog)\
**Post date:** [June 25, 2020, 9:16pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/13 "2020-06-25T21:16:01Z")

</div>

Thanks for checking, in my case it is just no output at all unfortunately!

 ![image](https://global.discourse-cdn.com/swift/original/2X/7/78466bff25c5fc6da06d728d75e87eba7272c4b1.png)

I should add this is not Alamofire related though, it happens to anything that I try to inspect. Will file a radar!

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 25, 2020, 9:18pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/14 "2020-06-25T21:18:53Z")

</div>

I can confirm this behavior: `po response` prints the response properly, while `frame variable` has a broken `result` value.

Edit: It's also strange it says the `request` value is `nil`. That seems unlikely if you have a `response` value.

---

<div class="post-metadata">

**Author:** ![rog](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rog/32/3351_2.png) [@rog](https://forums.swift.org/u/rog)\
**Post date:** [June 25, 2020, 9:26pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/15 "2020-06-25T21:26:13Z")

</div>

You know I hadn't even noticed that until you mentioned. That's really strange!

---

<div class="post-metadata">

**Author:** ![Jumhyn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jumhyn/32/3891_2.png) [@Jumhyn](https://forums.swift.org/u/Jumhyn)\
**Post date:** [June 25, 2020, 9:43pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/16 "2020-06-25T21:43:35Z")

</div>

I'm _guessing_ that the issue where `request` is reported as `nil` is a manifestation of [SR-12724](https://bugs.swift.org/browse/SR-12724).

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 25, 2020, 9:49pm UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/17 "2020-06-25T21:49:15Z")

</div>

That may also explain `result`'s `<invalid> (0x0)` value, as a `nil` `Result` would be invalid.

---

<div class="post-metadata">

**Author:** ![phoneyDev](https://avatars.discourse-cdn.com/v4/letter/p/49beb7/32.png) [@phoneyDev](https://forums.swift.org/u/phoneyDev)\
**Post date:** [June 26, 2020, 12:02am UTC](https://forums.swift.org/t/trying-to-solve-alamofires-lldb-woes/34801/18 "2020-06-26T00:02:10Z")

</div>

Basically almost all types from Foundation don't work. And `po` usually works and `frame v` usually doesn't work.

[https://bugs.swift.org/browse/SR-12444](https://bugs.swift.org/browse/SR-12444)
