aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/completion
AgeCommit message (Collapse)AuthorFilesLines
2025-09-04[lldb] Add more command option mnemonics (#155705)Jonas Devlieghere1-6/+6
Add a bunch of mnemonics to the command options now that they're highlighted in the help output. This uncovered two issues: - We had an instance where we weren't applying the ANSI formatting. - We had a place where we were now incorrectly computing the column width. Both are fixed by this PR.
2025-05-11[lldb] Fix term settings completion tests (#139447)Emmanuel Ferdman1-6/+6
# PR Summary Small PR - Several test functions for `term-width/height` completions had identical names, causing silent overriding. This gives them distinct _width/_height suffixes to ensure all tests run. Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-12-16[lldb] Use the terminal height for paging editline completions (#119914)Jonas Devlieghere1-3/+12
Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. This builds on the improvements of #116456.
2024-10-15[lldb] Support tests with nested make invocations on Windows 1/2 (#112342)Stefan Gränitz1-1/+1
In recent PR https://github.com/llvm/llvm-project/pull/111531 for Windows support, we enabled tests that require the `make` tool. On Windows, default install directories likely contain spaces, in this case e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically handled well by CMake, so that today invocations from `dotest.py` don't cause issues. However, we also have nested invocations from a number of Makefiles themselves. These still failed if the path to the `make` tool contains spaces. This patch attempts to fix the functionalities/completion test by adding quotes in the respective Makefile. If it keeps passing on the bots, we can roll out the fix to all affected tests.
2024-08-27[lldb] Add frame recognizers for libc++ `std::invoke` (#105695)Adrian Vogelsgesang1-1/+1
With this commit, we also hide the implementation details of `std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more regular expressions. The regular expression passed into `AddRecognizer` became problematic, as it was evaluated on the demangled name. Those names also included result types for C++ symbols. For `std::__invoke` the return type is a huge `decltype(...)`, making the regular expresison really hard to write. Instead, I added support to `AddRecognizer` for matching on the demangled names without result type and argument types. By hiding the implementation details of `invoke`, also the back traces for `std::function` become even nicer, because `std::function` is using `__invoke` internally. Co-authored-by: Adrian Prantl <aprantl@apple.com>
2024-06-28[lldb][test] Remove duplicate testcase names in API test-suite (#97043)Michael Buch1-6/+0
In one of my recent PRs I mistakenly had two test-cases with the same name, preventing one of them to run. Since it's an easy mistake to make (e.g., copy pasting existing test-cases), I ran following sanity-check script over `lldb/test/API`, which found couple of tests which were losing coverage because of this (or in some cases simply had duplicate tests): ``` import ast import sys filename = sys.argv[1] print(f'Checking {filename}...') tree = ast.parse(open(filename, 'r').read()) for node in ast.walk(tree): if not isinstance(node, ast.ClassDef): continue func_names = [] for child in ast.iter_child_nodes(node): if isinstance(child, ast.FunctionDef): func_names.append(child.name) seen_func_names = set() duplicate_func_names = [] for name in func_names: if name in seen_func_names: duplicate_func_names.append(name) else: seen_func_names.add(name) if len(duplicate_func_names) != 0: print(f'Multiple func names found:\n\t{duplicate_func_names}\n\tclass {node.name}\n\tfile: {filename}') ``` This patch fixes these cases.
2024-05-30[lldb] Attempt to fix TestCompletion on macosPavel Labath1-2/+4
Macos will automatically load dependent modules when creating a target, resulting in more modules than the test expects.
2024-05-30[lldb] Fix module name tab completion (#93458)Pavel Labath1-0/+35
Module names can be matched either by a full path or just their basename. The completion machinery tried to do both, but had several bugs: - it always inserted the basename as a completion candidate, even if the string being completed was a full path - due to FileSpec canonicalization, it lost information about trailing slashes (it treated "lib/<TAB>" as "lib<TAB>", even though it's clear the former was trying to complete a directory name) - due to both of the previous issues, the completion candidates could end up being shorter than the string being completed, which caused crashes (string out of range errors) when attempting to substitute the results. This patch rewrites to logic to remove these kinds of issues: - basename and full path completion are handled separately - full path completion is attempted always, basename only if the input string does not contain a slash - the code remembers both the canonical and original spelling or the completed argument. The canonical arg is used for matching, while the original spelling is used for completion. This way "/foo///.//b<TAB>" can still match "/foo/bar", but it will complete to "/foo///.//bar".
2024-05-17[lldb] Avoid modifying the source tree in TestCompletion.pyPavel Labath1-8/+10
This was a side-effect of the "optimization" in #92281. Deoptimize the code slightly.
2024-05-15[lldb] Fixed the TestCompletion test running on a remote target (#92281)Dmitry Vasilyev1-3/+10
Install the image to the remote target if necessary.
2024-02-29[LLDB] Fix test failure introduced by #83234 (#83406)Sudharsan Veeravalli1-1/+1
Missed adding a . in the test check
2024-02-29[LLDB] Fix crash when using tab completion on class variables (#83234)Sudharsan Veeravalli2-6/+13
We weren't checking to see if the partial_path was empty before adding completions and this led to crashes when the class object and a variable both start with the same substring. Fixes [#81536](https://github.com/llvm/llvm-project/issues/81536) --------- Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
2024-02-20Remove the "generic" register completion test. (#82445)jimingham1-21/+0
For reasons that are not clear to me, on arm64, the alias registers are listed in list of register info's we do completion against, but for x86_64 they are not. Maybe this is a difference in how the dynamic register builders work for the two systems. Anyway, it doesn't look possible to make a generic one.
2024-02-20Add the RegisterCompleter to eArgTypeRegisterName in g_argument_table (#82428)jimingham1-0/+21
This is a follow-on to: https://github.com/llvm/llvm-project/pull/82085 The completer for register names was missing from the argument table. I somehow missed that the only register completer test was x86_64, so that test broke. I added the completer in to the right slot in the argument table, and added a small completions test that just uses the alias register names. If we end up having a platform that doesn't define register names, we'll have to skip this test there, but it should add a sniff test for register completion that will run most everywhere.
2023-09-13[lldb] Treat user aliases the same as built-ins when tab completing (#65974)David Spickett1-11/+7
Previously we would check all built-ins first for suggestions, then check built-ins and aliases. This meant that if you had an alias brkpt -> breakpoint, "br" would complete to "breakpoint". Instead of giving you the choice of "brkpt" or "breakpoint".
2023-09-12Reland "[lldb] Improve completion tests (#65973)"David Spickett1-12/+4
This reverts commit 8012518f600bebaa4ed99a57d553eeea25c2d0c9. The x86 register write test had one that expected "\$rax" so on. As these patterns were previously regex, the $ had to be escaped. Now they are just plain strings to this is not needed.
2023-09-11Revert "[lldb] Improve completion tests (#65973)"David Spickett1-3/+11
This reverts commit 2378ba632e5cdc761584a4154449833ac0f86384. I need to fix the x86 specific register tests.
2023-09-11[lldb] Improve completion tests (#65973)David Spickett1-11/+3
* Assert no completions for tests that should not find completions. * Remove regex mode from complete_from_to, which was unused. This exposed bugs in 2 of the tests, target stop-hook and process unload. These were fixed in previous commits but couldn't be tested properly until this patch.
2023-09-08[lldb] Add test to document alias tab completion behaviour (#65760)David Spickett1-0/+19
While looking at https://github.com/llvm/llvm-project/issues/49528 I found that, happily, aliases can now be tab completed. However, if there is a built-in match that will always be taken. Which is a bit surprising, though logical if we don't want people really messing up their commands I guess. Meaning "b" tab completes to our built-in breakpoint alias, before it looks at any of the aliases. "bf" doesn't match "b", so it looks through the aliases. I didn't find any tests for this in the obvious places, so this adds some.
2023-08-04[lldb] Fix Python test formatting (NFC)Jonas Devlieghere1-1/+1
All Python files in the LLVM repository were reformatted with Black [1]. Files inside the LLDB subproject were reformatted in 2238dcc39358. This patch updates a handful of tests that were added or modified since then and weren't formatted with Black. [1] https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257
2023-07-17Fix the root directory completion test.Jim Ingham1-1/+1
It was implicitly assumning that "/" would have no files in it, only directories. That's not true, for instance on macOS if you've navigated to the root directory in the Finder... Since we're assuming everything we check against is a directory, then we need to filter the completion for that coming in.
2023-07-10[lldb] Prevent crash when completing ambiguous subcommandsJonas Devlieghere1-0/+8
Fix a crash when trying to complete an ambiguous subcommand. Take `set s tar` for example: for the subcommand `s` there's ambiguity between set and show. Pressing TAB after this input currently crashes LLDB. The problem is that we're trying to complete `tar` but give up at `s` because of the ambiguity. LLDB doesn't expect the completed string to be shorter than the current string and crashes when trying to eliminate the common prefix. rdar://111848598 Differential revision: https://reviews.llvm.org/D154643
2023-07-06[lldb] Fix crash when completing register names after program exitDavid Spickett1-4/+16
Previously the following would crash: (lldb) run Process 2594053 launched: '/tmp/test.o' (aarch64) Process 2594053 exited with status = 0 (0x00000000) (lldb) register read <tab> As the completer assumed that the execution context would always have a register context. After a program has finished, it does not. Split out the generic parts of the test from the x86 specific tests, and added "register info" to both. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D154413
2023-06-06[lldb] Disable some tests on windowsMed Ismail Bennani1-0/+1
This patch skips both `test_completion_target_create_from_root_dir` introduced in `e896612` and `target-label.test` introduced in `1e82b20` since I don't have a windows machine to try to accomodate the filesystem path style differences for these tests to pass. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06[lldb/Commands] Fix disk completion from root directoryMed Ismail Bennani1-0/+13
This patch should fix path completion starting from the root directory. To do so, this patch adds a special case when setting the search directory when the completion buffer points to the root directory. Differential Revision: https://reviews.llvm.org/D152013 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06[lldb/Commands] Add support to auto-completion for user commandsMed Ismail Bennani2-0/+43
This patch should allow the user to set specific auto-completion type for their custom commands. To do so, we had to hoist the `CompletionType` enum so the user can access it and add a new completion type flag to the CommandScriptAdd Command Object. So now, the user can specify which completion type will be used with their custom command, when they register it. This also makes the `crashlog` custom commands use disk-file completion type, to browse through the user file system and load the report. Differential Revision: https://reviews.llvm.org/D152011 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere2-366/+412
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
2023-03-06[lldb] Add variable completion to dwim-printDave Lee1-29/+42
Enable completion of variables for `dwim-print` command. Differential Revision: https://reviews.llvm.org/D145124
2022-09-26[lldb] Fix completion of 'settings set' valuesDave Lee1-0/+5
Some time ago, a refactor (1153dc960) broke completion for assigning settings values (`settings set`). This was most annoying for enum settings, where you'd have to get the valid enum names separately. This restores the logic in the post-refactor completion function, as well as adding a test to catch future regressions. Differential Revision: https://reviews.llvm.org/D134515
2022-07-12[LLDB] Catagory decorator for watchpoint test in TestCompletion.pyMuhammad Omair Javaid1-0/+1
This patch adds watchpoint catagory decorator to watchpoint dependent tests in TestCompletion.py.
2022-06-27Have CommandObjectParsed check for "commands that take no arguments".Jim Ingham1-1/+1
This is currently being done in an ad hoc way, and so for some commands it isn't being checked. We have the info to make this check, since commands are supposed to add their arguments to the m_arguments field of the CommandObject. This change uses that info to check whether the command received arguments in error. A handful of commands weren't defining their argument types, I also had to fix them. And a bunch of commands were checking for arguments by hand, so I removed those checks in favor of the CommandObject one. That also meant I had to change some tests that were checking for the ad hoc error outputs. Differential Revision: https://reviews.llvm.org/D128453
2022-06-17[lldb][tests] Automatically call compute_mydir (NFC)Dave Lee1-2/+0
Eliminate boilerplate of having each test manually assign to `mydir` by calling `compute_mydir` in lldbtest.py. Differential Revision: https://reviews.llvm.org/D128077
2022-06-08[lldb] Add assertState function to the API test suiteJonas Devlieghere1-1/+1
Add a function to make it easier to debug a test failure caused by an unexpected state. Currently, tests are using assertEqual which results in a cryptic error message: "AssertionError: 5 != 10". Even when a test provides a message to make it clear why a particular state is expected, you still have to figure out which of the two was the expected state, and what the other value corresponds to. We have a function in lldbutil that helps you convert the state number into a user readable string. This patch adds a wrapper around assertEqual specifically for comparing states and reporting better error messages. The aforementioned error message now looks like this: "AssertionError: stopped (5) != exited (10)". If the user provided a message, that continues to get printed as well. Differential revision: https://reviews.llvm.org/D127355
2022-03-03Revert "[lldb] Correct case in description of breakpoint --on-catch/throw"David Spickett1-6/+6
This reverts commit 6b3b3ef344504334f43afe76c805d2e6e7b587e9. Jim Ingham informed me that the upper case is a hint to the option name, like you might see in a menu to show you what the shortcut is.
2022-03-03[lldb] Correct case in description of breakpoint --on-catch/throwDavid Spickett1-6/+6
Somehow we ended up with catcH/throW.
2021-10-18Add a "command container" hierarchy to allow users to add container nodes.Jim Ingham1-1/+1
The point is to allow users with a related set of script based commands to organize their commands in a hierarchy in the command set, rather than having to have only top-level commands. Differential Revision: https://reviews.llvm.org/D110298
2021-10-15[lldb] Harden TestCompletion against new settings in 'target.process'Raphael Isemann1-1/+1
This test starts failing when people add a setting starting with `target.process.t` which of course can easily happen. Make it a bit more resistant by only requiring that `target.process.thr` has a unique completion.
2021-10-01[lldb] Simplify TestCompletion.pyPavel Labath1-1/+1
2021-09-30[lldb] Remove support for replaying the test suite from a reproducerJonas Devlieghere1-1/+0
This patch removes the infrastructure to replay the test suite from a reproducer, as well as the modifications made to the individual tests.
2021-07-22[lldb] Fix TestCompletion by using SIGPIPE instead of SIGINT as test signalRaphael Isemann1-2/+2
The test I added in commit 078003482e90ff5c7ba047a3d3152f0b0c392b31 was using SIGINT for testing the tab completion. The idea is to have a signal that only has one possible completion and I ended up picking SIGIN -> SIGINT for the test. However on non-Linux systems there is SIGINFO which is a valid completion for `SIGIN' and so the test fails there. This replaces SIGIN -> SIGINT with SIGPIP -> SIGPIPE completion which according to LLDB's signal list in Host.cpp is the only valid completion.
2021-07-22[lldb] Fix that `process signal` completion always returns all signalsRaphael Isemann1-0/+2
`CompletionRequest::AddCompletion` adds the given string as completion of the current command token. `CompletionRequest::TryCompleteCurrentArg` only adds it if the current token is a prefix of the given string. We're using `AddCompletion` for the `process signal` handler which means that `process signal SIGIN` doesn't get uniquely completed to `process signal SIGINT` as we unconditionally add all other signals (such as `SIGABRT`) as possible completions. By using `TryCompleteCurrentArg` we actually do the proper filtering which will only add `SIGINT` (as that's the only signal with the prefix 'SIGIN' in the example above). Reviewed By: mib Differential Revision: https://reviews.llvm.org/D105028
2020-12-20[lldb] [test] Update test status for NetBSDMichał Górny1-0/+1
2020-11-10[lldb] [test] Rename '.categories' to 'categories'Michał Górny1-0/+0
Make category-specifying files visible. There is really no good reason to keep them hidden, and having them visible increases the chances that someone will actually spot them. Differential Revision: https://reviews.llvm.org/D91065
2020-09-22[lldb] Skip test_common_completion_process_pid_and_name with reproducersJonas Devlieghere1-0/+1
This test launches a subprocess which will have a different PID during capture and replay.
2020-08-31[lldb] tab completion for class `CommandObjectTypeFormatterDelete`Gongyu Deng1-0/+21
1. Added a dedicated completion to class `CommandObjectTypeFormatterDelete` which can be used by these commands: `type filter/format/summary/synthetic delete`; 2. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D84142
2020-08-31[lldb][NFC] Remove trailing whitespace in TestCompletionRaphael Isemann1-7/+7
2020-08-31[lldb] Fix TestCompletion's pid completion failing randomlyRaphael Isemann1-3/+3
TestCompletion is randomly failing on some bots. The error message however states that the computed completions actually do contain the expected pid we're looking for, so there shouldn't be any test failure. The reason for that turns out to be that complete_from_to is actually used for testing two different features. It can be used for testing what the common prefix for the list of completions is and *also* for checking all the possible completions that are returned for a command. Which one of the two things should be checked can't be defined by a parameter to the function, but is instead guessed by the test method instead based on the results that were returned. If there is a common prefix in all completions, then that prefix is searched and otherwise all completions are searched. For TestCompletion's pid test this behaviour leads to the strange test failures. If all the pid's that our test LLDB can see have a common prefix (e.g., it can only see pids [123, 122, 10004, 10000] -> common prefix '1'), then complete_from_to check that the common prefix contains our pid, which is always fails ('1' doesn't contain '123' or any other valid pid). If there isn't a common prefix (e.g., pids are [123, 122, 10004, 777]) then complete_from_to will check the list of completions instead which works correctly. This patch is fixing this by adding a simple check method that doesn't have this behaviour and is simply searching the returned list of completions. This should get the bots green while I'm working on a proper fix that fixes complete_from_to.
2020-08-25[lldb] Don't depend on psutil in TestCompletion.pyRaphael Isemann1-4/+14
psutil isn't reall a dependency of the test suite so this shouldn't be unconditionally be imported here. Instead just check for the process name by looking for the "a.out" string to get the bots green again.
2020-08-24[lldb] type category name common completionGongyu Deng1-0/+6
1. Added a new common completion TypeCategoryNames to provide a list of category names for completion; 2. Applied the completion to these commands: type category delete/enable/disable/list/define; 3. Added a related test case; 4. Bound the completion to the arguments of the type 'eArgTypeName'. Reviewed By: teemperor, JDevlieghere Differential Revision: https://reviews.llvm.org/D84124
2020-08-24[lldb] common completion for process pids and process namesGongyu Deng2-9/+36
1. Added two common completions: `ProcessIDs` and `ProcessNames`, which are refactored from their original dedicated option completions; 2. Removed the dedicated option completion functions of `process attach` and `platform process attach`, so that they can use arg-type-bound common completions instead; 3. Bound `eArgTypePid` to the pid completion, `eArgTypeProcessName` to the process name completion in `CommandObject.cpp`; 4. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D80700