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

Don't know how to break on specific Swift function in LLDB

    XMLWordPrintable

    Details

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

      Description

      Let's take the following (silly) example program

      public struct Foo<T> {
          public init() {}
          public func functionIWantToBreakOnAnnoyinglyOverloaded(int: Int, string: String, closure: (Int, String) -> T) -> T {
              return closure(int, string)
          }
      
          public func functionIWantToBreakOnAnnoyinglyOverloaded(int: Int, float: Float, closure: (Int, Float) -> T) -> T {
              return closure(int, float)
          }
      }
      
      print(Foo<String>().functionIWantToBreakOnAnnoyinglyOverloaded(int: 1, string: "2") { i, s in
          return "\(i)\(s)"
      })
      
      print(Foo<String>().functionIWantToBreakOnAnnoyinglyOverloaded(int: 1, float: 2.3) { i, s in
          return "\(i)\(s)"
      })
      

      Let's assume I want to break on some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int: Swift.Int, float: Swift.Float, closure: (Swift.Int, Swift.Float) -> A) -> A only (and not the other one). And let's also assume I don't want to do this using file/line.

      The only way I know is to do break set -n functionIWantToBreakOnAnnoyinglyOverloaded which sets breakpoints on all such functions (can be many if the name is say write or something common). After setting all these breakpoints, I can do break disable 1.1 etc to disable some instances.

      LLDB shows

      (lldb) break list
      Current breakpoints:
      1: name = 'functionIWantToBreakOnAnnoyinglyOverloaded', locations = 2, resolved = 2, hit count = 1
        1.1: where = some`some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int: Swift.Int, float: Swift.Float, closure: (Swift.Int, Swift.Float) -> A) -> A, address = 0x0000000100001730, resolved, hit count = 0 
        1.2: where = some`some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int: Swift.Int, string: Swift.String, closure: (Swift.Int, Swift.String) -> A) -> A, address = 0x00000001000016e0, resolved, hit count = 1 
      

      I tried the following and they all don't work:

      (lldb) break set -n 'some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int: Swift.Int, float: Swift.Float, closure: (Swift.Int, Swift.Float) -> A) -> A'
      Breakpoint 2: no locations (pending).
      WARNING:  Unable to resolve breakpoint to any actual locations.
      (lldb) break set -n 'some`some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int: Swift.Int, float: Swift.Float, closure: (Swift.Int, Swift.Float) -> A) -> A'
      Breakpoint 3: no locations (pending).
      WARNING:  Unable to resolve breakpoint to any actual locations.
      (lldb) break set -n some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int:float:closure)
      Breakpoint 4: no locations (pending).
      WARNING:  Unable to resolve breakpoint to any actual locations.
      (lldb) break set -n 'some.Foo.functionIWantToBreakOnAnnoyinglyOverloaded(int:float:closure)'
      Breakpoint 5: no locations (pending).
      WARNING:  Unable to resolve breakpoint to any actual locations.
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            jw Johannes Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: