summaryrefslogtreecommitdiff
path: root/lldb/test/Shell/Driver
AgeCommit message (Collapse)Author
2025-10-13[lldb] Don't emit .lldbinit warning as an error (#163265)Jonas Devlieghere
Actually emit a warning, rather than an error, when there's an .lldbinit file in the current directly. Currently, the message is prepended by "error" which looks rather odd, as the warning refers to itself as a warning.
2025-06-03[lldb] Emit an error when using --wait-for without a name or pid (#142424)Jonas Devlieghere
Emit an error when using --wait-for without a name and correct the help output to specify a name must be provided, rather than a name or PID. Motivated by https://discourse.llvm.org/t/why-is-wait-for-not-attaching/86636
2024-10-31[lldb] Remove lldb-repro utilityJonas Devlieghere
Remove lldb-repro which was used to run the test suite against a reproducer. The corresponding functionality has been removed from LLDB so there's no need for the tool anymore.
2024-08-20[lldb][test] Change unsupported cat -e to cat -v to work with lit internal ↵Connie Zhu
shell (#104878) This patch changes the test that uses the `cat -e` option to `cat -v` so that the test can be run using lit's internal shell. For `cat`, the `-v` option prints non-printing characters in ^ and M- notation, while the `-e` option adds `$` to the end of lines in addition to printing non-printing characters in ^ and M- notation. This is an alternative patch to https://github.com/llvm/llvm-project/pull/102061, opting to rewrite the test that uses `cat -e` instead of extending support to the `-e` option. Fixes https://github.com/llvm/llvm-project/issues/102377
2024-02-28[lldb] Remove -d(ebug) mode from the lldb driver (#83330)Jonas Devlieghere
The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. Since then, we were never check if the option is set. We were incorrectly toggling the internal variable (m_debug_mode) based on OPT_no_use_colors instead. Given that the functionality doesn't seem particularly useful and nobody noticed it has been broken for 5 years, I'm just removing the flag.
2023-03-07[lldb] Respect empty arguments in target.run-argsAlex Langford
Currently empty arguments are not respected. They are silently dropped in two places: (1) when extracting them from the target.run-args setting and (2) when constructing the lldb-argdumper invocation. (1) is actually a regression from a few years ago. We did not always drop empty arguments. See 31d97a5c8ab78c619deada0cdb1fcf64021d25dd. rdar://106279228 Differential Revision: https://reviews.llvm.org/D145450
2022-09-26[lldb] Fix CommandInterpreter::DidProcessStopAbnormally() with multiple threadsMartin Storsjö
If a process has multiple threads, the thread with the stop info might not be the first one in the thread list. On Windows, under certain circumstances, processes seem to have one or more extra threads that haven't been launched by the executable itself, waiting in NtWaitForWorkViaWorkerFactory. If the main (stopped) thread isn't the first one in the list (the order seems nondeterministic), DidProcessStopAbnormally() would return false prematurely, instead of inspecting later threads. The main observable effect of DidProcessStopAbnormally() erroneously returning false, is when running lldb with multiple "-o" parameters to specify multiple commands to execute on the command line. After an abnormal stop, lldb would stop executing "-o" parameters and execute "-k" parameters instead - but due to this issue, it would instead keep executing "-o" parameters as if there was no abnormal stop. (If multiple parameters are specified via a script file via the "-s" option, all of the commands in that file are executed regardless of whether there's an abnormal stop inbetween.) Differential Revision: https://reviews.llvm.org/D134037
2022-09-19[lldb] Remove LLDB reproducersJonas Devlieghere
This patch removes the remaining reproducer code. The SBReproducer class remains for ABI stability but is just an empty shell. This completes the removal process outlined on the mailing list [1]. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2022-07-13[LLDB] Fix TestConvenienceVariables.test AArch64/WindowsMuhammad Omair Javaid
This patch fixes TestConvenienceVariables.test for AArch64 Windows. Clang/LLD was unable to find printf apparently available as a macro definition in stdio.h.
2022-06-11[lldb][bindings] Implement __repr__ instead of __str__Dave Lee
When using the `script` Python repl, SB objects are printed in a way that gives the user no information. The simplest example is: ``` (lldb) script lldb.debugger <lldb.SBDebugger; proxy of <Swig Object of type 'lldb::SBDebugger *' at 0x1097a5de0> > ``` This output comes from the Python repl printing the `repr()` of an object. None of the SB classes implement `__repr__`, and all print like the above. However, many (most?, all?) SB classes implement `__str__`. Because they implement `__str__`, a more detailed output can be had by `print`ing the object, for example: ``` (lldb) script print(lldb.debugger) Debugger (instance: "debugger_1", id: 1) ``` For convenience, this change switches all SB classes that implement to `__str__` to instead implement `__repr__`. **The result is that `str()` and `repr()` will produce the same output**. This is because `str` calls `__repr__` for classes that have no `__str__` method. The benefit being that when writing a `script` invocation, you don't need to remember to wrap in `print()`. If that isn't enough motivation, consider the case where your Python expression results in a list of SB objects, in that case you'd have to `map` or use a list comprehension like `[str(x) for x in <expr>]` in order to see the details of the objects in the list. For reference, the docs for `repr` say: > repr(object) > Return a string containing a printable representation of an object. For > many types, this function makes an attempt to return a string that would > yield an object with the same value when passed to eval(); otherwise, the > representation is a string enclosed in angle brackets that contains the > name of the type of the object together with additional information often > including the name and address of the object. A class can control what this > function returns for its instances by defining a __repr__() method. and the docs for `__repr__` say: > object.__repr__(self) > Called by the repr() built-in function to compute the “official” string > representation of an object. If at all possible, this should look like a > valid Python expression that could be used to recreate an object with the > same value (given an appropriate environment). If this is not possible, a > string of the form <...some useful description...> should be returned. The > return value must be a string object. If a class defines __repr__() but not > __str__(), then __repr__() is also used when an “informal” string > representation of instances of that class is required. > > This is typically used for debugging, so it is important that the > representation is information-rich and unambiguous. Even if it were convenient to construct Python expressions for SB classes so that they could be `eval`'d, however for typical lldb usage, I can't think of a motivating reason to do so. As it stands, the only action the docs say to do, that this change doesn't do, is wrap the `repr` string in `<>` angle brackets. An alternative implementation is to change lldb's python repl to apply `str()` to the top level result. While this would work well in the case of a single SB object, it doesn't work for a list of SB objects, since `str([x])` uses `repr` to convert each list element to a string. Differential Revision: https://reviews.llvm.org/D127458
2022-06-08[lldb/Commands] Prevent crash due to reading memory from page zero.Chelsea Cassanova
Adds a check to ensure that a process exists before attempting to get its ABI to prevent lldb from crashing due to trying to read from page zero. Differential revision: https://reviews.llvm.org/D127016
2021-12-17[lldb] Remove reproducer replay functionalityJonas Devlieghere
This is part of a bigger rework of the reproducer feature. See [1] for more details. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2021-11-10[lldb] make it easier to find LLDB's pythonLawrence D'Anna
It is surprisingly difficult to write a simple python script that can reliably `import lldb` without failing, or crashing. I'm currently resorting to convolutions like this: def find_lldb(may_reexec=False): if prefix := os.environ.get('LLDB_PYTHON_PREFIX'): if os.path.realpath(prefix) != os.path.realpath(sys.prefix): raise Exception("cannot import lldb.\n" f" sys.prefix should be: {prefix}\n" f" but it is: {sys.prefix}") else: line1, line2 = subprocess.run( ['lldb', '-x', '-b', '-o', 'script print(sys.prefix)'], encoding='utf8', stdout=subprocess.PIPE, check=True).stdout.strip().splitlines() assert line1.strip() == '(lldb) script print(sys.prefix)' prefix = line2.strip() os.environ['LLDB_PYTHON_PREFIX'] = prefix if sys.prefix != prefix: if not may_reexec: raise Exception( "cannot import lldb.\n" + f" This python, at {sys.prefix}\n" f" does not math LLDB's python at {prefix}") os.environ['LLDB_PYTHON_PREFIX'] = prefix python_exe = os.path.join(prefix, 'bin', 'python3') os.execl(python_exe, python_exe, *sys.argv) lldb_path = subprocess.run(['lldb', '-P'], check=True, stdout=subprocess.PIPE, encoding='utf8').stdout.strip() sys.path = [lldb_path] + sys.path This patch aims to replace all that with: #!/usr/bin/env lldb-python import lldb ... ... by adding the following features: * new command line option: --print-script-interpreter-info. This prints language-specific information about the script interpreter in JSON format. * new tool (unix only): lldb-python which finds python and exec's it. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D112973
2021-11-02[lldb] fix --source-quietlyLawrence D'Anna
Jim says: lldb has a -Q or --source-quietly option, which supposedly does: --source-quietly Tells the debugger to execute this one-line lldb command before any file has been loaded. That seems like a weird description, since we don't generally use source for one line entries, but anyway, let's try it: > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q "script print('I should be quiet')" a.out -O "script print('I should be before')" -o "script print('I should be after')" (lldb) script print('I should be before') I should be before (lldb) target create "script print('I should be quiet')" error: unable to find executable for 'script print('I should be quiet')' That was weird. The first real -O gets sourced but not quietly, then the argument to the -Q gets treated as the target. > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q a.out -O "script print('I should be before')" -o "script print('I should be after')" (lldb) script print('I should be before') I should be before (lldb) target create "a.out" Current executable set to '/tmp/a.out' (x86_64). (lldb) script print('I should be after') I should be after Well, that's a little better, but the -Q option seems to have done nothing. --- This fixes the description of --source-quietly, as well as causing it to actually suppress echoing while executing the initialization commands. Reviewed By: jingham Differential Revision: https://reviews.llvm.org/D112988
2020-08-17[lldb] Skip TestError.test with reproducersJonas Devlieghere
This tests the driver, which is bypassed by the reproducer during replay.
2020-07-31[lldb] report an error if a CLI option lacks an argumentLuboš Luňák
Differential Revision: https://reviews.llvm.org/D84955
2020-06-09[lldb/Interpreter] Support color in CommandReturnObjectJonas Devlieghere
Color the error: and warning: part of the CommandReturnObject output, similar to how an error is printed from the driver when colors are enabled. Differential revision: https://reviews.llvm.org/D81058
2020-06-01[lldb/Test] Add test for man page and lldb --help outputJonas Devlieghere
2020-05-20[lldb/Test] Support arbitrary file extensions in TestPositionalArgs.testJonas Devlieghere
On Windows the line must match: Use 'lldb.exe --help' for a complete list of options.
2020-05-20[lldb/Driver] Print snippet before exiting with unknown argument.Jonas Devlieghere
Print a little snippet before exiting when passed unrecognized arguments. The goal is twofold: - Point users to lldb --help. - Make it clear that we exited the debugger.
2020-05-20[lldb/Driver] Error out when encountering unknown argumentsJonas Devlieghere
There appears to be consensus in D80165 that this is the desired behavior and I personally agree. Differential revision: https://reviews.llvm.org/D80226
2020-05-18[lldb/Test] Skip TestPositionalArgs with lldb-reproJonas Devlieghere
2020-05-18[lldb/Driver] Fix handling on positional argumentsJonas Devlieghere
Before the transition to libOption it was possible to specify arguments for the inferior without -- as long as they didn't start with a dash. For example, the following invocations should all behave the same: $ lldb inferior inferior-arg $ lldb inferior -- inferior-arg $ lldb -- inferior inferior-arg This patch fixes that behavior, documents it and adds a test to cover the different combinations. Differential revision: https://reviews.llvm.org/D80165
2020-05-05[lldb/Driver] Exit with a non-zero exit code in case of error in batch mode.Jonas Devlieghere
We have the option to stop running commands in batch mode when an error occurs. When that happens we should exit the driver with a non-zero exit code. Differential revision: https://reviews.llvm.org/D78825
2020-02-07Revert "[TestConvienceVariable] Clean the directory before running the test."Davide Italiano
This reverts commit 9bce9d2d65e2462140597f71a8247750b837094c, as it breaks the bots.
2020-02-07[TestConvienceVariable] Clean the directory before running the test.Davide Italiano
2020-01-22[lldb/Reproducer] Mark some driver tests as unsupported for lldb-reproJonas Devlieghere
These test are checking for diagnostics printed by the driver. During replay we only replay the SB API calls made by the driver, so it's expected that these messages aren't displayed.
2020-01-07[lldb/Test] Try to appease the Windows botJonas Devlieghere
In TestConvenienceVariables I changed %t from a file to a directory. This tripped up mkdir which can't deal with an existing file at the given location. In order to solve this issue on the bots I added an `rm -rf %t` statement, but now the Windows bot complains that "This function is not supported on this system". If you never ran the test suite wit this temporary workaround, the test might fail. If this happens please remove what %t expands to in the lit output and rerun the test.
2020-01-07[lldb/Test] Remove old binary created by TestConvenienceVariablesJonas Devlieghere
On a dirty build directory the new mkdir fails because the file already exists and is not a directory.
2020-01-07[lldb/Test] Make TestConvenienceVariables more strictJonas Devlieghere
This test was passing even when the output of lldb.target was empty. I've made the test more strict by checking explicitly for the target name and by using CHECK-NEXT lines.
2019-10-31[lldb/lit] Introduce %clang_host substitutionsPavel Labath
Summary: This patch addresses an ambiguity in how our existing tests invoke the compiler. Roughly two thirds of our current "shell" tests invoke the compiler to build the executables for the host. However, there is also a significant number of tests which don't build a host binary (because they don't need to run it) and instead they hardcode a certain target. We also have code which adds a bunch of default arguments to the %clang substitutions. However, most of these arguments only really make sense for the host compilation. So far, this has worked mostly ok, because the arguments we were adding were not conflicting with the target-hardcoding tests (though they did provoke an occasional "argument unused" warning). However, this started to break down when we wanted to use target-hardcoding clang-cl tests (D69031) because clang-cl has a substantially different command line, and it was getting very confused by some of the arguments we were adding on non-windows hosts. This patch avoid this problem by creating separate %clang(xx,_cl)_host substutitions, which are specifically meant to be used for compiling host binaries. All funny host-specific options are moved there. To ensure that the regular %clang substitutions are not used for compiling host binaries (skipping the extra arguments) I employ a little hac^H^H^Htrick -- I add an invalid --target argument to the %clang substitution, which means that one has to use an explicit --target in order for the compilation to succeed. Reviewers: JDevlieghere, aprantl, mstorsjo, espindola Subscribers: emaste, arichardson, MaskRay, jfb, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D69619
2019-10-09Re-land "[test] Split LLDB tests into API, Shell & Unit"Jonas Devlieghere
The original patch got reverted because it broke `check-lldb` on a clean build. This fixes that. llvm-svn: 374201
2019-10-09Revert [test] Split LLDB tests into API, Shell & UnitAdrian Prantl
as it appears to have broken check-lldb. This reverts r374184 (git commit 22314179f0660c172514b397060fd8f34b586e82) llvm-svn: 374187
2019-10-09[test] Split LLDB tests into API, Shell & UnitJonas Devlieghere
LLDB has three major testing strategies: unit tests, tests that exercise the SB API though dotest.py and what we currently call lit tests. The later is rather confusing as we're now using lit as the driver for all three types of tests. As most of this grew organically, the directory structure in the LLDB repository doesn't really make this clear. The 'lit' tests are part of the root and among these tests there's a Unit and Suite folder for the unit and dotest-tests. This layout makes it impossible to run just the lit tests. This patch changes the directory layout to match the 3 testing strategies, each with their own directory and their own configuration file. This means there are now 3 directories under lit with 3 corresponding targets: - API (check-lldb-api): Test exercising the SB API. - Shell (check-lldb-shell): Test exercising command line utilities. - Unit (check-lldb-unit): Unit tests. Finally, there's still the `check-lldb` target that runs all three test suites. Finally, this also renames the lit folder to `test` to match the LLVM repository layout. Differential revision: https://reviews.llvm.org/D68606 llvm-svn: 374184