Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11661

Source path remapping to find source code in LLDB debugging fails when using a UUID property list in a dSYM to specify a source path mapping

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Component/s: LLDB for Swift
    • Labels:
      None

      Description

      Starting in the development snapshot toolchain from 10/3/19, LLDB incorrectly applies the source location mapping specified in a UUID plist in a dSYM using DBGSourcePathRemapping dictionary and/or DBGBuildSourcePath & DBGSourcePath. When remapping a relative source path, everything except the path's basename is discarded and the basename is appended to the entire prefix provided in the plist. This results in using the wrong paths for source code while debugging in LLDB: Xcode shows assembly instead of source code, breakpoints set in source code in Xcode are never hit, LLDB cannot display source code for the current frame, etc.

      I created an iOS app using Xcode's "Single view app" template to demonstrate the issue, which is attached. I made 2 changes to the project's configuration:

      • Set debugging to use dSYM instead of just DWARF, to generate a dSYM.
      • Added -debug-prefix-map ${PROJECT_DIR} . to the other Swift flags, to use relative paths for sources in the debug info.

      This app has the following directory structure:

      • SimpleApp/
        • AppDelegate.swift
        • Other unimportant files 

       

      In the dSYM, I created a UUID plist and added the following to remap the relative paths back to absolute paths on my system (the path is specific to where you place the project):

      <key>DBGSourcePathRemapping</key>
      <dict>
      <key>.</key>
      <string>/Users/dylansturg/playgrounds/SimpleApp/</string>
      </dict>

      After generating the dSYM, I used dwarfdump to check the paths used to reference AppDelegate.swift, and correctly found ./SimpleApp/AppDelegate.swift.

      When I debug the resulting app in LLDB, it's unable to find the source code. I used source info command to see if LLDB was finding the right file:

      (lldb) source info

      Lines found in module `SimpleApp

      [0x0000000106b65b45-0x0000000106b65b70): /Users/dylansturg/playgrounds/SimpleApp/AppDelegate.swift:12:55

      The correct path is /Users/dylansturg/playgrounds/SimpleApp/SimpleApp/AppDelegate.swift. The incorrect path is missing the directories before the basename of the file, but those directories were included in the path that I found in the debug info.

      I used LLDB's target.source-map setting to apply the remapping, and that worked correctly on all tested toolchains. Apparently that setting is applied differently than the same remapping specified in the UUID plist in the dSYM.

       

      I verified that this same setup works correctly when I use the default toolchain of Xcode 11.1 and the development snapshot from 9/30. I believe this a regression introduced sometime between the snapshot of 9/30 and the snapshot of 10/3. I verified that this issue is reproducible on the latest snapshot as of the time of filing (10/21).

        Attachments

          Activity

            People

            Assignee:
            aprantl Adrian Prantl
            Reporter:
            dylansturg Dylan Sturgeon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: