[LLDB] Fix TestConvenienceVariables.test AArch64/WindowsThis patch fixes TestConvenienceVariables.test for AArch64 Windows.Clang/LLD was unable to find printf apparently available as a macrodefin
[LLDB] Fix TestConvenienceVariables.test AArch64/WindowsThis patch fixes TestConvenienceVariables.test for AArch64 Windows.Clang/LLD was unable to find printf apparently available as a macrodefinition in stdio.h.
show more ...
[lldb][bindings] Implement __repr__ instead of __str__When using the `script` Python repl, SB objects are printed in a way that givesthe user no information. The simplest example is:```(lldb) s
[lldb][bindings] Implement __repr__ instead of __str__When using the `script` Python repl, SB objects are printed in a way that givesthe 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 theyimplement `__str__`, a more detailed output can be had by `print`ing theobject, 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 toremember to wrap in `print()`. If that isn't enough motivation, consider thecase where your Python expression results in a list of SB objects, in that caseyou'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 sothat they could be `eval`'d, however for typical lldb usage, I can't think of amotivating 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 SBobject, 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
[lldb/Commands] Prevent crash due to reading memory from page zero.Adds a check to ensure that a process exists before attempting to getits ABI to prevent lldb from crashing due to trying to read
[lldb/Commands] Prevent crash due to reading memory from page zero.Adds a check to ensure that a process exists before attempting to getits ABI to prevent lldb from crashing due to trying to read from page zero.Differential revision: https://reviews.llvm.org/D127016
[lldb] Remove reproducer replay functionalityThis is part of a bigger rework of the reproducer feature. See [1] formore details.[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/01704
[lldb] Remove reproducer replay functionalityThis is part of a bigger rework of the reproducer feature. See [1] formore details.[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
[lldb] make it easier to find LLDB's pythonIt is surprisingly difficult to write a simple python script thatcan reliably `import lldb` without failing, or crashing. I'mcurrently resorting to co
[lldb] make it easier to find LLDB's pythonIt is surprisingly difficult to write a simple python script thatcan reliably `import lldb` without failing, or crashing. I'mcurrently 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.pathThis 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: JDevlieghereDifferential Revision: https://reviews.llvm.org/D112973
[lldb] fix --source-quietlyJim 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
[lldb] fix --source-quietlyJim 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 afterWell, 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 itto actually suppress echoing while executing the initializationcommands.Reviewed By: jinghamDifferential Revision: https://reviews.llvm.org/D112988
[lldb] Skip TestError.test with reproducersThis tests the driver, which is bypassed by the reproducer duringreplay.
[lldb] report an error if a CLI option lacks an argumentDifferential Revision: https://reviews.llvm.org/D84955
[lldb/Interpreter] Support color in CommandReturnObjectColor the error: and warning: part of the CommandReturnObject output,similar to how an error is printed from the driver when colors areenabl
[lldb/Interpreter] Support color in CommandReturnObjectColor the error: and warning: part of the CommandReturnObject output,similar to how an error is printed from the driver when colors areenabled.Differential revision: https://reviews.llvm.org/D81058
[lldb/Test] Add test for man page and lldb --help output
[lldb/Test] Support arbitrary file extensions in TestPositionalArgs.testOn Windows the line must match: Use 'lldb.exe --help' for a complete list of options.
[lldb/Driver] Print snippet before exiting with unknown argument.Print a little snippet before exiting when passed unrecognizedarguments. The goal is twofold: - Point users to lldb --help. - Ma
[lldb/Driver] Print snippet before exiting with unknown argument.Print a little snippet before exiting when passed unrecognizedarguments. The goal is twofold: - Point users to lldb --help. - Make it clear that we exited the debugger.
[lldb/Driver] Error out when encountering unknown argumentsThere appears to be consensus in D80165 that this is the desiredbehavior and I personally agree.Differential revision: https://reviews.
[lldb/Driver] Error out when encountering unknown argumentsThere appears to be consensus in D80165 that this is the desiredbehavior and I personally agree.Differential revision: https://reviews.llvm.org/D80226
[lldb/Test] Skip TestPositionalArgs with lldb-repro
[lldb/Driver] Fix handling on positional argumentsBefore the transition to libOption it was possible to specify argumentsfor the inferior without -- as long as they didn't start with a dash.For
[lldb/Driver] Fix handling on positional argumentsBefore the transition to libOption it was possible to specify argumentsfor 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-argThis patch fixes that behavior, documents it and adds a test to coverthe different combinations.Differential revision: https://reviews.llvm.org/D80165
[lldb/Driver] Exit with a non-zero exit code in case of error in batch mode.We have the option to stop running commands in batch mode when an erroroccurs. When that happens we should exit the driv
[lldb/Driver] Exit with a non-zero exit code in case of error in batch mode.We have the option to stop running commands in batch mode when an erroroccurs. When that happens we should exit the driver with a non-zero exitcode.Differential revision: https://reviews.llvm.org/D78825
Revert "[TestConvienceVariable] Clean the directory before running the test."This reverts commit 9bce9d2d65e2462140597f71a8247750b837094c, asit breaks the bots.
[TestConvienceVariable] Clean the directory before running the test.
[lldb/Reproducer] Mark some driver tests as unsupported for lldb-reproThese test are checking for diagnostics printed by the driver. Duringreplay we only replay the SB API calls made by the drive
[lldb/Reproducer] Mark some driver tests as unsupported for lldb-reproThese test are checking for diagnostics printed by the driver. Duringreplay we only replay the SB API calls made by the driver, so it'sexpected that these messages aren't displayed.
[lldb/Test] Try to appease the Windows botIn TestConvenienceVariables I changed %t from a file to a directory.This tripped up mkdir which can't deal with an existing file at thegiven location. In
[lldb/Test] Try to appease the Windows botIn TestConvenienceVariables I changed %t from a file to a directory.This tripped up mkdir which can't deal with an existing file at thegiven location. In order to solve this issue on the bots I added an`rm -rf %t` statement, but now the Windows bot complains that "Thisfunction is not supported on this system".If you never ran the test suite wit this temporary workaround, the testmight fail. If this happens please remove what %t expands to in the litoutput and rerun the test.
[lldb/Test] Remove old binary created by TestConvenienceVariablesOn a dirty build directory the new mkdir fails because the file alreadyexists and is not a directory.
[lldb/Test] Make TestConvenienceVariables more strictThis test was passing even when the output of lldb.target was empty.I've made the test more strict by checking explicitly for the targetname a
[lldb/Test] Make TestConvenienceVariables more strictThis test was passing even when the output of lldb.target was empty.I've made the test more strict by checking explicitly for the targetname and by using CHECK-NEXT lines.
[lldb/lit] Introduce %clang_host substitutionsSummary:This patch addresses an ambiguity in how our existing tests invoke thecompiler. Roughly two thirds of our current "shell" tests invoke theco
[lldb/lit] Introduce %clang_host substitutionsSummary:This patch addresses an ambiguity in how our existing tests invoke thecompiler. Roughly two thirds of our current "shell" tests invoke thecompiler to build the executables for the host. However, there is alsoa significant number of tests which don't build a host binary (becausethey 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 %clangsubstitutions. However, most of these arguments only really make sensefor the host compilation. So far, this has worked mostly ok, because thearguments we were adding were not conflicting with the target-hardcodingtests (though they did provoke an occasional "argument unused" warning).However, this started to break down when we wanted to usetarget-hardcoding clang-cl tests (D69031) because clang-cl has asubstantially different command line, and it was getting very confusedby some of the arguments we were adding on non-windows hosts.This patch avoid this problem by creating separate %clang(xx,_cl)_hostsubstutitions, which are specifically meant to be used for compilinghost binaries. All funny host-specific options are moved there. Toensure that the regular %clang substitutions are not used for compilinghost binaries (skipping the extra arguments) I employ a littlehac^H^H^Htrick -- I add an invalid --target argument to the %clangsubstitution, which means that one has to use an explicit --target inorder for the compilation to succeed.Reviewers: JDevlieghere, aprantl, mstorsjo, espindolaSubscribers: emaste, arichardson, MaskRay, jfb, lldb-commitsTags: #lldbDifferential Revision: https://reviews.llvm.org/D69619
Re-land "[test] Split LLDB tests into API, Shell & Unit"The original patch got reverted because it broke `check-lldb` on a cleanbuild. This fixes that.llvm-svn: 374201
Revert [test] Split LLDB tests into API, Shell & Unitas it appears to have broken check-lldb.This reverts r374184 (git commit 22314179f0660c172514b397060fd8f34b586e82)llvm-svn: 374187
12