summaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Python
AgeCommit message (Collapse)Author
2022-03-25[lldb/crashlog] Parse thread fields and pass it to crashlog scripted processMed Ismail Bennani
Previously, the ScriptedThread used the thread index as the thread id. This patch parses the crashlog json to extract the actual thread "id" value, and passes this information to the Crashlog ScriptedProcess blueprint, to create a higher fidelity ScriptedThreaad. It also updates the blueprint to show the thread name and thread queue. Finally, this patch updates the interactive crashlog test to reflect these changes. rdar://90327854 Differential Revision: https://reviews.llvm.org/D122422 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-16[lldb/crashlog] Create artificial frames for non-crashed scripted threadsMed Ismail Bennani
This patch pipes down the `-a|--load-all` crashlog command option to the Scripted Process initializer to load all the images used by crashed process instead of only loading the images related to the crashed thread. This allows us to recreate artificial frames also for the non-crashed scripted threads. rdar://90396265 Differential Revision: https://reviews.llvm.org/D121826 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-10[lldb/crashlog] Make interactive mode display more user-friendlyMed Ismail Bennani
This patch makes the crashlog interactive mode show the scripted process status with the crashed scripted thread backtrace after launching it. rdar://89634338 Differential Revision: https://reviews.llvm.org/D121038 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-02-25[lldb/crashlog] Fix scripted_crashlog_json.test failureMed Ismail Bennani
This patch should fix the test failure on scripted_crashlog_json.test. The failure is happening because crash reporter will obfuscate the executable path in the crashlog, if it is located inside the user's home directory and replace it with `/USER/*/` as a placeholder. To fix that, we can patch the placeholder with the executable path before loading the crashlog in lldb. This also fixes a bug where we would create another target when loading the crashlog in a scripted process, even if lldb already had a target for it. Now, crashlog will only create a target if there is none in lldb. Differential Revision: https://reviews.llvm.org/D120598 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-02-16[lldb/test] Disable scripted_crashlog_json.test on non darwin aarch64 systemsMed Ismail Bennani
This patch adds requirement for the `scripted_crashlog_json` test to make sure it only runs on apple silicon systems. This should fix the following green dragon failure: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41454 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-02-16[lldb/crashlog] Add CrashLogScriptedProcess & remove interactive modeMed Ismail Bennani
This patch introduces a new type of ScriptedProcess: CrashLogScriptedProcess. It takes advantage of lldb's crashlog parsers and Scripted Processes to reconstruct a static debugging session with symbolicated stackframes, instead of just dumping out everything in the user's terminal. The crashlog command also has an interactive mode that only provide a very limited experience. This is why this patch removes all the logic for this interactive mode and creates CrashLogScriptedProcess instead. This will fetch and load all the libraries that were used by the crashed thread and re-create all the frames artificially. rdar://88721117 Differential Revision: https://reviews.llvm.org/D119501 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-02-07[lldb] Print message after loading 'crashlog' commandDave Lee
Previously, importing `crashlog` resulted in a message being printed. The message was about other commands (those in heap.py), not `crashlog`. The changes in D117237 made it so that the heap.py messages were printed only when importing `lldb.macosx.heap`, not when importing `lldb.macosx.crashlog`. Some users may see no output and think `crashlog` wasn't successfully loaded. This ensures users see that `crashlog` is loaded. rdar://88283132 Differential Revision: https://reviews.llvm.org/D119155
2022-01-31[lldb] Use the build's python interpreter in the shell testsJonas Devlieghere
Make sure that the shell tests use the same python interpreter as the rest of the build instead of picking up `python` from the PATH. It would be nice if we could use the _disallow helper, but that triggers on invocations that specify python as the scripting language.
2022-01-31[lldb] Support Rosetta registers in crashlog.pyJonas Devlieghere
Rosetta crashlogs can have their own thread register state. Unlike the other registers which ware directly listed under "threadState", the Rosetta registers are nested under their own key in the JSON, as illustrated below: { "threadState": { "rosetta": { "tmp2": { "value": 4935057216 }, "tmp1": { "value": 4365863188 }, "tmp0": { "value": 18446744073709551615 } } } }
2021-10-09Revert a LIT typo fix in a RUN lineQiu Chaofan
Commit 573531f changes the behavior of the test, revert it back.
2021-10-09Fix typo of colon to semicolon in lit testsQiu Chaofan
2021-10-07[lldb] Parse and display reporting errors from JSON crashlogsJonas Devlieghere
JSON crashlogs have an optional field named reportNotes that contains any potential errors encountered by the crash reporter when generating the crashlog. Parse and display them in LLDB. Differential revision: https://reviews.llvm.org/D111339
2021-10-07[lldb] Support missing threadState in JSON crashlogsJonas Devlieghere
Gracefully deal with JSON crashlogs that don't have thread state available and print an error saying as much: "No thread state (register information) available". rdar://83955858 Differential revision: https://reviews.llvm.org/D111341
2021-10-05[lldb] Improve meta data stripping from JSON crashlogsJonas Devlieghere
JSON crashlogs normally start with a single line of meta data that we strip unconditionally. Some producers started omitting the meta data which tripped up crashlog. Be more resilient by only removing the first line when we know it really is meta data. rdar://82641662
2021-07-09[lldb] Drop REQUIRES where redundant because of lit.local.cfgJonas Devlieghere
2021-07-09[lldb] Use custom script instead of lldb.macosx.crashlog in testJonas Devlieghere
I'm not entirely sure this is the problem, but the Windows bot doesn't seem to like this test. Let's do something similar to command_import.test which doesn't have that issue.
2021-07-09[lldb] Add the ability to silently import scripted commandsJonas Devlieghere
Add the ability to silence command script import. The motivation for this change is being able to add command script import -s lldb.macosx.crashlog to your ~/.lldbinit without it printing the following message at the beginning of every debug session. "malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help. In addition to forwarding the silent option to LoadScriptingModule, this also changes ScriptInterpreterPythonImpl::ExecuteOneLineWithReturn and ScriptInterpreterPythonImpl::ExecuteMultipleLines to honor the enable IO option in ExecuteScriptOptions, which until now was ignored. Note that IO is only enabled (or disabled) at the start of a session, and for this particular use case, that's done when taking the Python lock in LoadScriptingModule, which means that the changes to these two functions are not strictly necessary, but (IMO) desirable nonetheless. Differential revision: https://reviews.llvm.org/D105327
2021-04-22[lldb] Update register state parsing for JSON crashlogsJonas Devlieghere
- The register encoding state in the JSON crashlog format changes. Update the parser accordingly. - Print the register state when printing the symbolicated thread.
2021-04-22[lldb] Include thread name in crashlog.py outputJonas Devlieghere
Update the JSON parser to include the thread name in the Thread object. rdar://76677320
2021-03-09[lldb] Update crashlog script for JSON changesJonas Devlieghere
Update the crashlog script for changes to the JSON schema. rdar://75122914 Differential revision: https://reviews.llvm.org/D98219
2021-02-17[lldb] Improve error message for modules with dots or dashesJonas Devlieghere
LLDB does not like to import Python files with dashes or dots in their name. While the former are technically allowed, it is discouraged. Dots are allowed for subpackages but not in module names. This patch improves the user experience by printing a useful error. Before this patch: error: module importing failed: SyntaxError('invalid syntax', ('<string>', 1, 11, 'import foo-bar\n')) After this patch: error: module importing failed: Python discourages dashes in module names: foo-bar rdar://74263511 [1] https://www.python.org/dev/peps/pep-0008/#package-and-module-names Differential revision: https://reviews.llvm.org/D96833
2020-12-07[LLDB] fix error message for one-line breakpoint scriptsPedro Tammela
LLDB is ignoring compilation errors for one-line breakpoint scripts. This patch fixes the issues and now the error message of the ScriptInterpreter is shown to the user. I had to remove a new-line character for the Lua interpreter since it was duplicated. Differential Revision: https://reviews.llvm.org/D92729
2020-12-02[LLDB/Python] Fix segfault on Python scripted entrypointsPedro Tammela
The code that gets the ScriptInterpreter was not considering the case that it receives a Lua interpreter. Differential Revision: https://reviews.llvm.org/D92249
2020-11-19[lldb] Fix another Python2/3 string<->bytes type error in patch-crashlog.pyRaphael Isemann
2020-11-18[lldb] Python3 byte<->string issue in patch-crashlog.pyRaphael Isemann
2020-11-16[crashlog] Improve patch-crashlog.py scriptJonas Devlieghere
Compute the real addresses and offsets for the json crashlog test.
2020-11-16[crashlog] Implement parser for JSON encoded crashlogsJonas Devlieghere
Add a parser for JSON crashlogs. The CrashLogParser now defers to either the JSONCrashLogParser or the TextCrashLogParser. It first tries to interpret the input as JSON, and if that fails falling back to the textual parser. Differential revision: https://reviews.llvm.org/D91130
2020-11-05[lldb] Remove Crashlog/interactive.testJonas Devlieghere
This test requires running under the Python we built against (which is easy) and setting up the PYTHONPATH (which is not worth it for this simple test).
2020-11-03[crashlog] Move crash log parsing into its own classJonas Devlieghere
Move crash log parsing out of the CrashLog class and into its own class and add more tests. Differential revision: https://reviews.llvm.org/D90664
2020-10-27[lldb] Support Python imports relative the to the current file being sourcedJonas Devlieghere
Make it possible to use a relative path in command script import to the location of the file being sourced. This allows the user to put Python scripts next to LLDB command files and importing them without having to specify an absolute path. To enable this behavior pass `-c` to `command script import`. The argument can only be used when sourcing the command from a file. rdar://68310384 Differential revision: https://reviews.llvm.org/D89334
2020-09-15[lldb] Add -l/--language option to script commandJonas Devlieghere
Make it possible to run the script command with a different language than currently selected. $ ./bin/lldb -l python (lldb) script -l lua >>> io.stdout:write("Hello, World!\n") Hello, World! When passing the language option and a raw command, you need to separate the flag from the script code with --. $ ./bin/lldb -l python (lldb) script -l lua -- io.stdout:write("Hello, World!\n") Hello, World! Differential revision: https://reviews.llvm.org/D86996
2020-06-16[lldb/Python] Fix the infinitely looping Python prompt bugJonas Devlieghere
Executing commands below will get you bombarded by a wall of Python command prompts (>>> ). $ echo 'foo' | ./bin/lldb -o script $ cat /tmp/script script print("foo") $ lldb --source /tmp/script The issue is that our custom input reader doesn't handle EOF. According to the Python documentation, file.readline always includes a trailing newline character unless the file ends with an incomplete line. An empty string signals EOF. This patch raises an EOFError when that happens. [1] https://docs.python.org/2/library/stdtypes.html#file.readline Differential revision: https://reviews.llvm.org/D81898
2020-05-29[lldb/Bindings] Raise exception when using properties that rely on lldb.targetJonas Devlieghere
Several SBAddress properties use the lldb.target or lldb.process convenience variables which are only set under the interactive script interpreter. Unfortunately, users have been using these properties in Python script and commands. This patch raises a Python exception to force users to use GetLoadAddress instead. Differential revision: https://reviews.llvm.org/D80848
2020-01-27[lldb/Test] Use lit.local.cfg to mark whole directory as (un)supported.Jonas Devlieghere
Mark the whole Python or Lua test directory as unsupported when the corresponding language is not available.
2020-01-22[lldb/Test] Skip script interpreter tests reading from stdin for lldb-reproJonas Devlieghere
The reproducers currently only shadow the command interpreter. It would be possible to make it work for the Lua interpreter which uses the IOHandlerEditline under the hood, but the Python one runs a REPL in Python itself so there's no (straightforward) way to shadow that. Given that we already capture any API calls, this isn't super high on my list of priorities.
2019-12-21[lldb/Commands] Honor the scripting language passedJonas Devlieghere
This ensures that breakpoint command honors the scripting language passed with `-s`. Currently the argument ignores the actual language and only uses it to differentiate between lldb and script commands.
2019-12-18[lldb/test] Move script interpreter testsJonas Devlieghere
Create a new test for lldb launched without a script interpreter and move it under a new `ScriptInterpreter` directory. Also move crashlog.test there for consistency.