Swift LLDB Feature Support


(Jessie Serrino) #1

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature
requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions
through *expression*, and create variables in a global context without a *$*.
This is incredibly important, and would enable us (and other developers) to
make deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of
expressions in Swift. This would allow us to set the state for certain
variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to
the codebase, so we've been having trouble getting things kickstarted on
our end.

Thanks again,
Jessie (and Rex)

···

--
Jessie Serrino
iOS Engineer, Remind


(Jim Ingham) #2

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions through expression, and create variables in a global context without a $. This is incredibly important, and would enable us (and other developers) to make deeper, more valuable investigations into code while debugging.

Not sure what you mean by this. If you mean read a multi-line expression from a file, then that's a long-standing request, and should be pretty straight-forward to add. But you can just do:

(lldb) expr
Enter expressions, then terminate with an empty line to evaluate:
  1: //Start writing code
  2: //Some more code
  3:
(lldb)

Also, both SBFrame.EvaluateExpression and SBTarget.EvaluateExpression take in a python string, which can certainly have newlines.

So there are already ways to do this.

For the C family of languages, using the --top-level will allow you to create variables in the global context w/o $, that can be used in other expressions:

(lldb) expr --top-level -- int NoSuchVariable = 10;
(lldb) expr printf("%d\n", NoSuchVariable)
10
(int) $0 = 3

so you can already do that.

Similarly in Swift, you can do:

(lldb) repl
  1> var NoSuchVariable : Int = 10
NoSuchVariable: Int = 10
  2> ^D
(lldb) expr print("Value: \(NoSuchVariable)")
Value: 10

The bug to fix here is that --top-level isn't currently wired up for Swift. That should get wired up to do exactly what the REPL does, but just not require the interactive part.

It seems to me worthwhile to make an explicit statement that you are adding global definitions that will take their place in lookups at the global scope. And having --top-level be the one that can introduce those definitions seems a perfectly clear way to do this to me.

OTOH, if I were writing a bunch of expression code that could be injected into the target process and then run for investigation purposes from the expr command, and that code relied on some global variable state, I would personally never use variables w/o $'s in front. That way I'd never find myself in the case where some user tries to run your investigation code who has a local variable with the same name as your variables, and they'll get some weird error they won't understand because of the shadowing.

In a similar vein, we would like to be able to revert these definitions of expressions in Swift. This would allow us to set the state for certain variables, but also revert our code if anything were to go awry.

It would be pretty straight-forward to dump the whole state that you've built up in expressions. All that information is stored in the "ScratchTypeSystem" for a given language. See lldb_private::Target::GetScratchTypeSystem*. So you could just jettison that. You'd have to be careful because the ScratchTypeSystem also stores utility functions that lldb uses internally. So you'd probably need to make an internal scratch space, and use that where we make UtilityFunctions and the like. But this shouldn't be all that hard.

It would be much trickier to try to throw away individual expressions. I'm not sure the benefits of this would really be worth the trouble.

Would it be possible to have some help with this? We're relatively new to the codebase, so we've been having trouble getting things kickstarted on our end.

We are certainly available to answer questions and help you get started.

Jim

···

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org> wrote:

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-lldb-dev


(Enrico Granata) #3

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions through expression,

Good news! This is already possible:

As for the other features you suggest, I'll let someone who is more in depth with the expression evaluator go into details

and create variables in a global context without a $. This is incredibly important, and would enable us (and other developers) to make deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of expressions in Swift. This would allow us to set the state for certain variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to the codebase, so we've been having trouble getting things kickstarted on our end.

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone:️ 27683

···

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org> wrote:


(Jessie Serrino) #4

Hi Swift-LLDB,

I had something I wanted to follow up on.

I'm currently working in a mixed development environment (Obj-C & Swift),
and we're slowly migrating to Swift. I've managed to connect lldb to a
Swift only environment and use REPL to successfully inspect objects without
issue. That said, when I connect to my mixed project, it doesn't allow me
to import UIKit (see errors below):

(lldb) repl
3> import UIKit
error: Couldn't lookup symbols:
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_func4
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_token4
  __TZvOs11CommandLine11_unsafeArgvGSpGSqGSpVs4Int8___
  __TZvOs11CommandLine5_argcVs5Int32

I've appropriately set the language to Swift as follows: (lldb) settings
set target.language swift

My suspicion is that there are two UIKits (one in Objective-C and one in
Swift). Would you be able to offer me some clarity to resolve this issue?

Thank you,
Jessie

···

On Thu, Oct 6, 2016 at 10:43 AM, Enrico Granata <egranata@apple.com> wrote:

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev < > swift-lldb-dev@swift.org> wrote:

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature
requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions
through *expression*,

Good news! This is already possible:

As for the other features you suggest, I'll let someone who is more in
depth with the expression evaluator go into details

and create variables in a global context without a *$*. This is
incredibly important, and would enable us (and other developers) to make
deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of
expressions in Swift. This would allow us to set the state for certain
variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to
the codebase, so we've been having trouble getting things kickstarted on
our end.

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind
_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Thanks,
*- Enrico*
:envelope_with_arrow: egranata@.com :phone:️ 27683


(Todd Fiala) #5

Hi Jessie!

Hi Swift-LLDB,

I had something I wanted to follow up on.

I'm currently working in a mixed development environment (Obj-C & Swift), and we're slowly migrating to Swift. I've managed to connect lldb to a Swift only environment and use REPL to successfully inspect objects without issue. That said, when I connect to my mixed project, it doesn't allow me to import UIKit (see errors below):

(lldb) repl
3> import UIKit
error: Couldn't lookup symbols:
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_func4
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_token4
  __TZvOs11CommandLine11_unsafeArgvGSpGSqGSpVs4Int8___
  __TZvOs11CommandLine5_argcVs5Int32

I've appropriately set the language to Swift as follows: (lldb) settings set target.language swift

My suspicion is that there are two UIKits (one in Objective-C and one in Swift). Would you be able to offer me some clarity to resolve this issue?

I have a few bits of info I’d like to gather:

* Which version of Xcode are you using?

* Are you using a custom-built or downloaded toolchain for Swift? How about LLDB?

* What’s the output when you type “lldb --version” and “swiftc --version”?

* Can you reproduce it in a small project, and send us steps to follow?

Thanks!

-Todd

···

On Oct 19, 2016, at 6:12 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org> wrote:

Thank you,
Jessie

On Thu, Oct 6, 2016 at 10:43 AM, Enrico Granata <egranata@apple.com <mailto:egranata@apple.com>> wrote:

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>> wrote:

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions through expression,

Good news! This is already possible:

<PastedGraphic-1.png>

As for the other features you suggest, I'll let someone who is more in depth with the expression evaluator go into details

and create variables in a global context without a $. This is incredibly important, and would enable us (and other developers) to make deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of expressions in Swift. This would allow us to set the state for certain variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to the codebase, so we've been having trouble getting things kickstarted on our end.

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone:️ 27683

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-lldb-dev


(Todd Fiala) #6

Hi Jessie!

Hi Swift-LLDB,

I had something I wanted to follow up on.

I'm currently working in a mixed development environment (Obj-C & Swift), and we're slowly migrating to Swift. I've managed to connect lldb to a Swift only environment and use REPL to successfully inspect objects without issue. That said, when I connect to my mixed project, it doesn't allow me to import UIKit (see errors below):

(lldb) repl
3> import UIKit
error: Couldn't lookup symbols:
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_func4
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_token4
  __TZvOs11CommandLine11_unsafeArgvGSpGSqGSpVs4Int8___
  __TZvOs11CommandLine5_argcVs5Int32

I've appropriately set the language to Swift as follows: (lldb) settings set target.language swift

My suspicion is that there are two UIKits (one in Objective-C and one in Swift). Would you be able to offer me some clarity to resolve this issue?

I have a few bits of info I’d like to gather:

* Which version of Xcode are you using?

* Are you using a custom-built or downloaded toolchain for Swift? How about LLDB?

* What’s the output when you type “lldb --version” and “swiftc --version”?

* Can you reproduce it in a small project, and send us steps to follow?

Another question:

* When you ran the repl and import command above, what language was the top (0th) stack frame in the attached process? Was it Swift or Objective-C?

···

On Oct 20, 2016, at 7:53 AM, Todd Fiala <tfiala@apple.com> wrote:

On Oct 19, 2016, at 6:12 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>> wrote:

Thanks!

-Todd

Thank you,
Jessie

On Thu, Oct 6, 2016 at 10:43 AM, Enrico Granata <egranata@apple.com <mailto:egranata@apple.com>> wrote:

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>> wrote:

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions through expression,

Good news! This is already possible:

<PastedGraphic-1.png>

As for the other features you suggest, I'll let someone who is more in depth with the expression evaluator go into details

and create variables in a global context without a $. This is incredibly important, and would enable us (and other developers) to make deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of expressions in Swift. This would allow us to set the state for certain variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to the codebase, so we've been having trouble getting things kickstarted on our end.

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone:️ 27683

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-lldb-dev


(Todd Fiala) #7

So we don’t lose track of all this info, can you create a JIRA ticket on bugs.swift.org <http://bugs.swift.org/> to track this?

Thanks!

-Todd

···

On Oct 20, 2016, at 7:54 AM, Todd Fiala <tfiala@apple.com> wrote:

On Oct 20, 2016, at 7:53 AM, Todd Fiala <tfiala@apple.com <mailto:tfiala@apple.com>> wrote:

Hi Jessie!

On Oct 19, 2016, at 6:12 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>> wrote:

Hi Swift-LLDB,

I had something I wanted to follow up on.

I'm currently working in a mixed development environment (Obj-C & Swift), and we're slowly migrating to Swift. I've managed to connect lldb to a Swift only environment and use REPL to successfully inspect objects without issue. That said, when I connect to my mixed project, it doesn't allow me to import UIKit (see errors below):

(lldb) repl
3> import UIKit
error: Couldn't lookup symbols:
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_func4
  _globalinit_33_FD9A49A256BEB6AF7C48013347ADC3BA_token4
  __TZvOs11CommandLine11_unsafeArgvGSpGSqGSpVs4Int8___
  __TZvOs11CommandLine5_argcVs5Int32

I've appropriately set the language to Swift as follows: (lldb) settings set target.language swift

My suspicion is that there are two UIKits (one in Objective-C and one in Swift). Would you be able to offer me some clarity to resolve this issue?

I have a few bits of info I’d like to gather:

* Which version of Xcode are you using?

* Are you using a custom-built or downloaded toolchain for Swift? How about LLDB?

* What’s the output when you type “lldb --version” and “swiftc --version”?

* Can you reproduce it in a small project, and send us steps to follow?

Another question:

* When you ran the repl and import command above, what language was the top (0th) stack frame in the attached process? Was it Swift or Objective-C?

Thanks!

-Todd

Thank you,
Jessie

On Thu, Oct 6, 2016 at 10:43 AM, Enrico Granata <egranata@apple.com <mailto:egranata@apple.com>> wrote:

On Oct 5, 2016, at 5:01 PM, Jessie Serrino via swift-lldb-dev <swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>> wrote:

Hi Swift LLDB,

First of all, thanks to some of you for being so responsive!

After playing around a bit with the LLDB build, we had some feature requests for the next version of LLDB.

First and foremost, we’d like to be able to execute multi-line expressions through expression,

Good news! This is already possible:

<PastedGraphic-1.png>

As for the other features you suggest, I'll let someone who is more in depth with the expression evaluator go into details

and create variables in a global context without a $. This is incredibly important, and would enable us (and other developers) to make deeper, more valuable investigations into code while debugging.

In a similar vein, we would like to be able to revert these definitions of expressions in Swift. This would allow us to set the state for certain variables, but also revert our code if anything were to go awry.

Would it be possible to have some help with this? We're relatively new to the codebase, so we've been having trouble getting things kickstarted on our end.

Thanks again,
Jessie (and Rex)

--
Jessie Serrino
iOS Engineer, Remind

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone:️ 27683

_______________________________________________
swift-lldb-dev mailing list
swift-lldb-dev@swift.org <mailto:swift-lldb-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-lldb-dev