forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 340
[lldb] Support CommandInterpreter print callbacks #9955
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
Merged
JDevlieghere
merged 9 commits into
stable/20240723
from
cherrypick-stable/20240723-74690327c8fb-c1e9b908d9c2-26c2da5a1225-dbabad0fc04e-6deee0d5b36c-906eeeda833b-97f6e533865c-53d6e59b5946
Feb 5, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's no reason these methods cannot be `const`. Currently this prevents us from passing around a const ref. This patch is in preparation for llvm#125006. (cherry picked from commit 7469032)
Per the title, the variable is unused. (cherry picked from commit c1e9b90)
(cherry picked from commit 26c2da5)
…vm#125270) Name and line number are part of different option groups and are not compatible. ``` (lldb) breakpoint set -n foo -l 10 error: invalid combination of options for the given command ``` The help output for `breakpoint set` confirms this. This patch updates the test to use two compatible options. With the improved error reporting from llvm#125125 this becomes an issue. (cherry picked from commit dbabad0)
…ting (llvm#125125) Use `llvm::Error` instead of `CommandReturnObject` for error reporting. The command return objects were populated with errors but never displayed. With this patch they're at least logged. (cherry picked from commit 6deee0d)
As suggested in llvm#125006. Depending on which PR lands first, I'll update `TestCommandInterepterPrintCallback.py` to check that the `CommandReturnObject` passed to the callback has the correct command. (cherry picked from commit 906eeed)
Xcode uses a pseudoterminal for the debugger console. - The upside of this apporach is that it means that it can rely on LLDB's IOHandlers for multiline and script input. - The downside of this approach is that the command output is printed to the PTY and you don't get a SBCommandReturnObject. Adrian added support for inline diagnostics (llvm#110901) and we'd like to access those from the IDE. This patch adds support for registering a callback in the command interpreter that gives access to the `(SB)CommandReturnObject` right before it will be printed. The callback implementation can choose whether it likes to handle printing the result or defer to lldb. If the callback indicated it handled the result, the command interpreter will skip printing the result. We considered a few other alternatives to solve this problem: - The most obvious one is using `HandleCommand`, which returns a `SBCommandReturnObject`. The problem with this approach is the multiline input mentioned above. We would need a way to tell the IDE that it should expect multiline input, which isn't known until LLDB starts handling the command. - To address the multiline issue,we considered exposing (some of the) IOHandler machinery through the SB API. To solve this particular issue, that would require reimplementing a ton of logic that already exists today in the CommandInterpeter. Furthermore that seems like overkill compared to the proposed solution. rdar://141254310 (cherry picked from commit 97f6e53)
Now that we store the command in the CommandReturnObject (llvm#125132) we can check the command in the print callback. (cherry picked from commit 53d6e59)
@swift-ci test |
@swift-ci test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Xcode uses a pseudoterminal for the debugger console.
This patch adds support for registering a callback in the command interpreter that gives access to the
(SB)CommandReturnObject
right before it will be printed. The callback implementation can choose whether it likes to handle printing the result or defer to lldb. If the callback indicated it handled the result, the command interpreter will skip printing the result.We considered a few other alternatives to solve this problem:
HandleCommand
, which returns aSBCommandReturnObject
. The problem with this approach is the multiline input mentioned above. We would need a way to tell the IDE that it should expect multiline input, which isn't known until LLDB starts handling the command.rdar://141254310