-
Notifications
You must be signed in to change notification settings - Fork 384
Add bundled pretty-printers for LLDB #2928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
debugger/src/main/kotlin/org/rust/debugger/prettyPrinters/lldb_pretty_printer.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to upstream pretty printer changes?
debugger/src/main/kotlin/org/rust/debugger/prettyPrinters/lldb_pretty_printer.py
Outdated
Show resolved
Hide resolved
debugger/src/main/kotlin/org/rust/debugger/prettyPrinters/lldb_pretty_printer.py
Outdated
Show resolved
Hide resolved
debugger/src/main/kotlin/org/rust/debugger/prettyPrinters/lldb_pretty_printer.py
Outdated
Show resolved
Hide resolved
Flake8's output:
|
@matklad yep, we are going to do it |
@mchernyavsky I think the warning about 80 symbols per line doesn't really make sense. Looks like we are not going to modify this code via console editors so we can easily use restriction in 120 symbols |
Let's move lldb_pretty_printer.py from src/main/kotiln to src/main/resources. Kotlin directory should contains only kotlin sources |
c8da71c
to
cbcab57
Compare
debugger/src/main/kotlin/org/rust/debugger/UpdatePrettyPrintersComponent.kt
Outdated
Show resolved
Hide resolved
37cf907
to
530667a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation doesn't work for me now. But I'm absolutely sure that some previous version worked pretty well on my mac.
Could you check it?
|
||
private fun getSourceCode(): String { | ||
val resourceStream = LLDBJetbrainsPrettyPrinter::class.java.classLoader.getResourceAsStream("$PP_RESOURCE_DIR/$LLDB_PP") | ||
return resourceStream.bufferedReader().use { it.readText() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readText
potentially throws IOException
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.components.ApplicationComponent | ||
|
||
class UpdatePrettyPrintersComponent : ApplicationComponent, Disposable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnpackPrettyPrintersComponent
looks more suitable here
// NOP | ||
} | ||
|
||
override fun dispose() = disposeComponent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that we don't need to implement Disposable
and implement custom disposeComponent
.
debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugRunner.kt
Outdated
Show resolved
Hide resolved
@@ -18,21 +18,28 @@ class RsDebuggerSettingsConfigurable( | |||
private val isRendersEnabledCheckbox: JBCheckBox = JBCheckBox("Enable Rust library renders") | |||
private var isRendersEnabled: Boolean by CheckboxDelegate(isRendersEnabledCheckbox) | |||
|
|||
private val isBundledPrintersEnabledCheckbox: JBCheckBox = JBCheckBox("Enable bundled IntelliJ Rust pretty-printers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's shorten label to Enable bundled pretty-printers
@Undin thank you for the review! Now it should work fine again. |
a034e3e
to
a60eb7d
Compare
debugger/src/main/kotlin/org/rust/debugger/runconfig/RsLocalDebugProcess.kt
Outdated
Show resolved
Hide resolved
Initially, I was going to use my pretty-printers along with the original ones by using regular expressions (non-trivial regexes for my printers and trivial Now, instead of regexes, I use two lookups (synthetic and summary) to determine which pretty-printer should be used for a given value. |
88a9e37
to
6dfe25a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it already works better than default lldb pretty printers 😄
debugger/src/main/kotlin/org/rust/debugger/settings/RsDebuggerSettingsConfigurable.kt
Outdated
Show resolved
Hide resolved
debugger/src/main/kotlin/org/rust/debugger/runconfig/RsLocalDebugProcess.kt
Outdated
Show resolved
Hide resolved
import javax.swing.JComponent | ||
|
||
class RsDebuggerSettingsConfigurable( | ||
private val settings: RsDebuggerSettings | ||
) : SearchableConfigurable { | ||
|
||
private val isRendersEnabledCheckbox: JBCheckBox = JBCheckBox("Enable Rust library renders") | ||
private var isRendersEnabled: Boolean by CheckboxDelegate(isRendersEnabledCheckbox) | ||
private val isLLDB = CPPToolchains.getInstance().defaultToolchain?.debuggerKind?.isLLDB() == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we can't just read toolchain type here because
RsDebuggerSettingsConfigurable
is not instantiated on each opening of the corresponding ui panel in settings- A user can change default toolchain and we should modify our ui on each change
Let's subscribe on CPPToolchainsConfigurable.TOPIC
and do the corresponding changes in ui on toolchain change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to unsubscribe in disposeUIResources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using CPPToolchainsConfigurable.TOPIC
is a rather tricky business, because of the lifecycle of the configurables. I'd suggest not to go that way.
If you absolutely have to separate GDB/LLDB settings, it will be much easier to show both settings groups (for GDB and for LLDB)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amakeev Oh, as you are much more aware of CLion related things, let's do it in this way!
If you absolutely have to separate GDB/LLDB settings
Maybe there is a better solution, but the current one allows us to release own pretty printers partially. Also, we still use formatters from rustup distribution as defaut variant for now.
We'll merge these settings and make bundled printers default when we implement all basic features available with formatters from rustup distribution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case: you're comment about A user can change default toolchain
is totally valid. I meant that making the correct listener between two configurables is not straightforward.
|
||
private val dataFormattersLabel = Label("Data formatters") | ||
|
||
private val dataFormatters = ComboBox<DataFormatters>().apply { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's better to separate properties for gdb and lldb toolchains. At least, until we have bundled pretty printers for gdb
de8cd52
to
add99ce
Compare
debugger/src/main/kotlin/org/rust/debugger/settings/RsDebuggerSettingsConfigurable.kt
Outdated
Show resolved
Hide resolved
debugger/src/main/kotlin/org/rust/debugger/settings/RsDebuggerSettingsConfigurable.kt
Outdated
Show resolved
Hide resolved
376cfa4
to
23a9b43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
830c251
to
bb5d390
Compare
@Undin thank you for attention! Now scalar types render correctly. |
bors r+ |
2928: Add bundled pretty-printers for LLDB r=Undin a=ortem Current version of [LLDB pretty-printer for Rust](https://github.com/rust-lang/rust/blob/master/src/etc/lldb_rust_formatters.py) is very primitive. For example, it doesn't support children-based representation of data (synthetic children). I started to develop a new LLDB pretty-printer for Rust. This PR adds: * `Vec`: size as summary and elements as synthetic children; * `String` and `&str`: value as summary, also supports UTF-8; * Regular structures, arrays, and slices: LLDB already supports it. <img width="438" alt="screen shot 2018-10-31 at 14 28 36" src="https://user-images.githubusercontent.com/4854600/47785295-554f9580-dd19-11e8-94ae-dffe1f930e6e.png"> <img width="394" alt="screen shot 2018-10-31 at 14 28 50" src="https://user-images.githubusercontent.com/4854600/47785297-554f9580-dd19-11e8-8821-e941d004091a.png"> <img width="451" alt="screen shot 2018-10-31 at 14 09 52" src="https://user-images.githubusercontent.com/4854600/47784453-b75acb80-dd16-11e8-83db-7e2313fd1cf3.png"> Co-authored-by: ortem <[email protected]>
Current version of LLDB pretty-printer for Rust is very primitive. For example, it doesn't support children-based representation of data (synthetic children).
I started to develop a new LLDB pretty-printer for Rust. This PR adds:
Vec
: size as summary and elements as synthetic children;String
and&str
: value as summary, also supports UTF-8;