aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter
AgeCommit message (Collapse)AuthorFilesLines
2025-09-03[lldb] Mark scripted frames as synthetic instead of artificial (#153117)Med Ismail Bennani6-92/+92
This patch changes the way frames created from scripted affordances like Scripted Threads are displayed. Currently, they're marked artificial which is used usually for compiler generated frames. This patch changes that behaviour by introducing a new synthetic StackFrame kind and moves 'artificial' to be a distinct StackFrame attribut. On top of making these frames less confusing, this allows us to know when a frame was created from a scripted affordance. rdar://155949703 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-06-20[lldb/crashlog] Make registers always available & fix x29/x30 parsing (#145104)Med Ismail Bennani1-0/+80
This patch addresses 2 issues: 1. It makes registers available on non-crashed threads all the time 2. It fixes arm64 registers parsing for registers that don't use the `x` prefix (`fp` -> `x29` / `lr` -> `x30`) --------- Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-06-20[lldb] Add support for x86_64h to scripted process (#145099)Med Ismail Bennani1-1/+1
This patch adds support to the haswell sub-architecture (x86_64h) to scripted processes. rdar://147208252 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-06-18[lldb/crashlog] Make interactive mode the new default (#144839)Med Ismail Bennani5-7/+7
This patch makes interactive mode as the default when using the crashlog command. It replaces the existing `-i|--interactive` flag with a new `-m|--mode` option, that can either be `interactive` or `batch`. By default, when the option is not explicitely set by the user, the interactive mode is selected, however, lldb will fallback to batch mode if the command interpreter is not interactive or if stdout is not a tty. This also adds some railguards to prevent users from using interactive only options with the batch mode and updates the tests accordingly. rdar://97801509 Differential Revision: https://reviews.llvm.org/D141658 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-02-13[lldb] Fix Block::GetRangeIndexContainingAddress for discontinuous functions ↵Pavel Labath1-13/+26
(#124931) This is a followup to #122440, which changed function-relative calculations to use the function entry point rather than the lowest address of the function (but missed this usage). Like in #116777, the logic is changed to use file addresses instead of section offsets (as not all parts of the function have to be in the same section).
2025-01-15[lldb] Implement (SB)Function::GetInstructions for discontinuous functions ↵Pavel Labath1-0/+11
(#122933) The main change is to permit the disassembler class to process/store multiple (discontinuous) ranges of addresses. The result is not ambiguous because each instruction knows its size (in addition to its address), so we can check for discontinuity by looking at whether the next instruction begins where the previous ends. This patch doesn't handle the "disassemble" CLI command, which uses a more elaborate mechanism for disassembling and printing instructions.
2024-12-06[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examplesAdrian Prantl3-0/+206
This PR adds a proof-of-concept for a bytecode designed to ship and run LLDB data formatters. More motivation and context can be found in the formatter-bytecode.rst file and on discourse. https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696 Relanding with a fix for a case-sensitive path.
2024-12-06Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to ↵Adrian Prantl3-206/+0
examples" This reverts commit 60380cd27c6fa5ed6e39866c51b18a64bc4d566a.
2024-12-06[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examplesAdrian Prantl3-0/+206
This PR adds a proof-of-concept for a bytecode designed to ship and run LLDB data formatters. More motivation and context can be found in the formatter-bytecode.rst file and on discourse. https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696 Relanding with a fix for a case-sensitive path.
2024-12-06Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to ↵Adrian Prantl3-206/+0
examples" This reverts commit 7e3da87ca896484a11ac09df297183147154ac91. I managed to break the bots.
2024-12-06[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to ↵Adrian Prantl3-0/+206
lldb/examples (#113398) This PR adds a proof-of-concept for a bytecode designed to ship and run LLDB data formatters. More motivation and context can be found in the `formatter-bytecode.md` file and on discourse. https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696
2024-12-03Reapply "[lldb] Use the function block as a source for function ranges ↵Pavel Labath1-1/+1
(#117996)" This reverts commit 2526d5b1689389da9b194b5ec2878cfb2f4aca93, reapplying ba14dac481564000339ba22ab867617590184f4c after fixing the conflict with #117532. The change is that Function::GetAddressRanges now recomputes the returned value instead of returning the member. This means it now returns a value instead of a reference type.
2024-12-03[lldb] Expose discontinuous functions through SBFunction::GetRanges (#117532)Pavel Labath1-0/+182
SBFunction::GetEndAddress doesn't really make sense for discontinuous functions, so I'm declaring it deprecated. GetStartAddress sort of makes sense, if one uses it to find the functions entry point, so I'm keeping that undeprecated. I've made the test a Shell tests because these make it easier to create discontinuous functions regardless of the host os and architecture. They do make testing the python API harder, but I think I've managed to come up with something not entirely unreasonable.
2024-10-31[lldb] Remove lldb-repro utilityJonas Devlieghere11-21/+0
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-06-20Revert "[lldb/crashlog] Make interactive mode the new default" (#96263)Med Ismail Bennani5-7/+7
Reverts llvm/llvm-project#94575 since introduces test failure: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6166/
2024-06-20[lldb/crashlog] Make interactive mode the new default (#94575)Med Ismail Bennani5-7/+7
This patch makes interactive mode as the default when using the crashlog command. It replaces the existing `-i|--interactive` flag with a new `-m|--mode` option, that can either be `interactive` or `batch`. By default, when the option is not explicitely set by the user, the interactive mode is selected, however, lldb will fallback to batch mode if the command interpreter is not interactive or if stdout is not a tty. This also adds some railguards to prevent users from using interactive only options with the batch mode and updates the tests accordingly. rdar://97801509 Differential Revision: https://reviews.llvm.org/D141658 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-06[lldb/crashlog] Remove aarch64 requirement on crashlog tests (#94553)Med Ismail Bennani7-6/+9
This PR removes the `target-aarch64` requirement on the crashlog tests to exercice them on Intel bots and make image loading single-threaded temporarily while implementing a fix for a deadlock issue when loading the images in parallel. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-05[lldb/crashlog] Always load Application Specific Backtrace Thread images ↵Med Ismail Bennani2-2/+2
(#94259) This patch changes the crashlog image loading default behaviour to not only load images from the crashed thread but also for the application specific backtrace thread. This patch also move the Application Specific Backtrace / Last Exception Backtrace tag from the thread queue field to the thread name. rdar://128276576 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-05[lldb/crashlog] Use environment variable to manually set dsymForUUIDBinary ↵Med Ismail Bennani1-0/+2
(#94517) In lldb, users can change the `dsymForUUID` binary using the `LLDB_APPLE_DSYMFORUUID_EXECUTABLE` environment variable. This patch changes the crashlog to support the same behaviour as lldb and uses this environment variable to disable `dsymForUUID` lookups in crashlog test by having it be empty. Since CI bots shoudn't have access to images on build records, it doesn't make sense to make use of `dsymForUUID` in tests. rdar://128953725 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-03-04[lldb/crashlog] Fix breaking changes in textual report format (#83861)Med Ismail Bennani2-0/+63
This patch should address some register parsing issue in the legacy report format. rdar://107210149 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-31[lldb] Fix test failure for breakpoint_function_callback.testMed Ismail Bennani1-1/+1
This should fix the test failure in breakpoint_function_callback.test since SBStructuredData can now display the content of SBStructuredData. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-23[lldb/test] Fix `Crashlog/no-args.test` on ASAN builds (NFC)Med Ismail Bennani1-1/+1
This should fix the Sanitizer Green Dragon LLDB Bot: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/4633 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18[lldb/crashlog] Add support for Last Exception BacktraceMed Ismail Bennani3-1/+183
This patch adds support to the "Last Exception Backtrace" to the `crashlog` command. This metadata is homologous to the "Application Specific Backtrace", however the format is closer to a regular stack frame. Since the thread that "contains" the "Last Exception Backtrace" doesn't really exist, this information is displayed when requesting an extended backtrace of the crashed thread, similarly to the "Application Specific Backtrace". To achieve that, this patch includes some refactors and fixes to the existing "Application Specific Backtrace" handling. rdar://113046509 Differential Revision: https://reviews.llvm.org/D157851 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18[lldb/crashlog] Replace deprecated optparse by argparse (NFC)Med Ismail Bennani1-2/+4
This patch replace the deprecated `optparse` module used for the `crashlog`& `save_crashlog` commands with the new `argparse` from the python standard library. This provides many benefits such as showing the default values for each option in the help description, but also greatly improve the handling of position arguments. Differential Revision: https://reviews.llvm.org/D157849 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18[lldb/crashlog] Add test for 8f75c4d01eff3c65d7ae40bfd05582de7dffa590 (NFC)Med Ismail Bennani1-0/+1
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-07[lldb] Disable variable watchpoints when going out of scopeMed Ismail Bennani1-1/+1
If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). This was discovered after `watchpoint_callback.test` started failing on the green dragon bot. This patch should address that issue by setting an internal breakpoint on the return addresss of the current frame when creating a variable watchpoint. The breakpoint has a callback that will disable the watchpoint if the the breakpoint execution context matches the watchpoint execution context. This is only enabled for local variables. This patch also re-enables the failing test following e1086384e584. rdar://109574319 Differential Revision: https://reviews.llvm.org/D151366 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06[lldb] Fix "NameError: name 'self' is not defined" when using crashlog -cJonas Devlieghere1-0/+1
This fixes a regression introduced by 27f27d15f6c9 that results in a NameError: (name 'self' is not defined) when using crashlog with the -c option. rdar://110007391
2023-06-01[lldb/crashlog] Add test for non-symbolicated report crashMed Ismail Bennani1-1/+1
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-26Revert "[lldb] Disable variable watchpoints when going out of scope"Jason Molenda1-1/+1
Reverting https://reviews.llvm.org/D151366 until Ismail has a chance to look at the ubuntu CI test failures and can reland. This reverts commit 7c847ac4bd1bd8a89c7fbb4581328fa8cb0498f1.
2023-05-25[lldb] Disable variable watchpoints when going out of scopeMed Ismail Bennani1-1/+1
If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). This was discovered after `watchpoint_callback.test` started failing on the green dragon bot. This patch should address that issue by setting an internal breakpoint on the return addresss of the current frame when creating a variable watchpoint. The breakpoint has a callback that will disable the watchpoint if the the breakpoint execution context matches the watchpoint execution context. This is only enabled for local variables. This patch also re-enables the failing test following e1086384e584. rdar://109574319 Differential Revision: https://reviews.llvm.org/D151366 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere2-19/+22
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-05-24[lldb] Disable `watchpoint_callback.test` temporarily on darwinMed Ismail Bennani1-1/+1
This test started failing on the green-dragon bot, but after some investigation, it doesn't have anything to do with Lua. If we use a variable watchpoint with a condition using a scope variable, if we go out-of-scope, the watpoint remains active which can the expression evaluator to fail to parse the watchpoint condition (because of the missing varible bindings). For now, we should disable this test until we come up with a fix for it. rdar://109574319 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-19[lldb/crashlog] Load inlined symbol into interactive crashlogMed Ismail Bennani3-0/+183
Sometimes, crash reports come with inlined symbols. These provide the exact stacktrace from the user binary. However, when investigating a crash, it's very likely that the images related to the crashed thread are not available on the debugging user system or that the versions don't match. This causes interactive crashlog to show a degraded backtrace in lldb. This patch aims to address that issue, by parsing the inlined symbols from the crash report and load them into lldb's target. This patch is a follow-up to 27f27d1, focusing on inlined symbols loading from legacy (non-json) crash reports. To do so, it updates the stack frame regular expression to make the capture groups more granular, to be able to extract the symbol name, the offset and the source location if available, while making it more maintainable. So now, when parsing the crash report, we build a data structure containing all the symbol information for each stackframe. Then, after launching the scripted process for interactive mode, we write a JSON symbol file for each module, only containing the symbols that it contains. Finally, we load the json symbol file into lldb, before showing the user the process status and backtrace. rdar://97345586 Differential Revision: https://reviews.llvm.org/D146765 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-04-13[lldb] Use ObjectFileJSON to create modules for interactive crashlogsJonas Devlieghere2-0/+12
Create an artificial module using a JSON object file when we can't locate the module and dSYM through dsymForUUID (or however locate_module_and_debug_symbols is implemented). By parsing the symbols from the crashlog and making them part of the JSON object file, LLDB can symbolicate frames it otherwise wouldn't be able to, as there is no module for it. For non-interactive crashlogs, that never was a problem because we could simply show the "pre-symbolicated" frame from the input. For interactive crashlogs, we need a way to pass the symbol information to LLDB so that it can symbolicate the frames, which is what motivated the JSON object file format. Differential revision: https://reviews.llvm.org/D148172
2022-11-15[lldb/test] Fix app_specific_backtrace_crashlog.test (NFC)Med Ismail Bennani2-2/+2
This patch changes app_specific_backtrace_crashlog.test's crashlog file extension from `ips` to `txt. This should prevent the test from opening Console.app when being run. This should also fix a test failure caused by missing symbols. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-11-10[lldb/test] Fix app_specific_backtrace_crashlog.test (NFC)Med Ismail Bennani1-1/+1
This patch fixes app_specific_backtrace_crashlog.test. It was failing because one of the loaded images was built with optimization which added a new warning message between the first `CHECK` and the `CHECK-NEXT`, breaking the expected ordering. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-11-04[lldb/crashlog] Fix frame parser regex for when there is no source infoMed Ismail Bennani1-1/+1
It can happen that the originator of a crash report doesn't have access to certain images. When that's the case, ReportCrash won't show the source info in the crash report stack frames, but only the stack address and image name. This patch fixes a bug in the crashlog stackframe parser regular expression to optionally match the source info group. rdar://101934135 Differential Revision: https://reviews.llvm.org/D137466 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-11-03[lldb/crashlog] Add support for Application Specific Backtraces & InformationMed Ismail Bennani4-0/+588
For an exception crashlog, the thread backtraces aren't usually very helpful and instead, developpers look at the "Application Specific Backtrace" that was generated by `objc_exception_throw`. LLDB could already parse and symbolicate these Application Specific Backtraces for regular textual-based crashlog, so this patch adds support to parse them in JSON crashlogs, and materialize them a HistoryThread extending the crashed ScriptedThread. This patch also includes the Application Specific Information messages as part of the process extended crash information log. To do so, the ScriptedProcess Python interface has a new GetMetadata method that returns an arbitrary dictionary with data related to the process. rdar://93207586 Differential Revision: https://reviews.llvm.org/D126260 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-11-03[lldb/crashlog] Fix the image_regex_uuid to skip null UUID imagesMed Ismail Bennani1-0/+1
This patch updates the image_regex_uuid matcher to match null-UUID images in the plain text crashlog parser. It updates the regex to match one or more '?' characters or the image full path. rdar://100904019 Differential Revision: https://reviews.llvm.org/D135482 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-11[lldb/crashlog] Improve exception reporting for interactive modeMed Ismail Bennani2-8/+8
This patch improve exception reporting when loading a crash report in a scripted process. Now, we parse the `exception` dictionary from the crash report use it the create a higher fidelity `MachException` stop info. This patch also updates the test to reflect that change. rdar://97096486 Differential Revision: https://reviews.llvm.org/D131086 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-11[lldb/test] Fix interactive crashlog test failure (NFC)Med Ismail Bennani2-18/+18
This patch removes the system library names and mangled symbol from the expected output for the interactive crashlog tests. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-11[lldb] Tidy some regex in crashlog.py (NFC)Dave Lee1-7/+0
A spiritual follow up to D131032. I noticed some regex could be simplified. This does some of the following: 1. Removes unused capture groups 2. Uses non-capturing `(?:...)` groups where grouping is needed but capturing isn't 3. Removes trailing `.*` 4. Uses `\d` over `[0-9]` 5. Uses raw strings 6. Uses `{N,}` to indicate N-or-more Also improves the call site of a `re.findall`. Differential Revision: https://reviews.llvm.org/D131305
2022-08-10[lldb/crashlog] Add `-V|--version` optionMed Ismail Bennani1-0/+3
This patch introduces a new option to the crashlog command to get the the script version. Since `crashlog.py` is not actually versioned, this returns lldb's version instead. rdar://98392669 Differential Revision: https://reviews.llvm.org/D131542 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Skip null image dsym fetching on interactive modeMed Ismail Bennani1-1/+7
Sometimes, it can happen that a crash report has null images in its list of used binaries. This manifests like such: ``` 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ??? ``` When fetching debug symbols to symbolicate the crashlog stackframe, having null images causes `dsymForUUID` to hang for few seconds. This patch addresses that by skipping null images from being load by the scripted process. rdar://97419487 Differential Revision: https://reviews.llvm.org/D131038 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Add `-s|--skip-status` option to interactive modeMed Ismail Bennani1-0/+43
This patch introduces a new option for the interactive crashlog mode, that will prevent it from dumping the `process status` & `thread backtrace` output to the debugger console. This is necessary when lldb in running from an IDE, to prevent flooding the console with information that should be already present in the UI. rdar://96813296 Differential Revision: https://reviews.llvm.org/D131036 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Remove 'process_path' parsing logicMed Ismail Bennani1-2/+1
In can happen when creating stackshot crash report that that key is missing. Moreover, we try to parse that key but don't use it, or need it, since we fetch images and symbolicate the stackframes using the binaries UUIDs. This is why this patch removes everything that is related to the `process_path`/`procPath` parsing. rdar://95054188 Differential Revision: https://reviews.llvm.org/D131033 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Update frame regex matcherMed Ismail Bennani2-1/+2
This patch updates the regular expression matching stackframes in crashlog to allow addresses that are 7 characters long and more (vs. 8 characters previously). It changes the `0x[0-9a-fA-F]{7}[0-9a-fA-F]+` by `0x[0-9a-fA-F]{7,}`. rdar://97684839 Differential Revision: https://reviews.llvm.org/D131032 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Surface error using SBCommandReturnObject argumentMed Ismail Bennani1-0/+8
This patch allows the crashlog script to surface its errors to lldb by using the provided SBCommandReturnObject argument. rdar://95048193 Differential Revision: https://reviews.llvm.org/D129614 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Add '-t|--target' option to interactive modeMed Ismail Bennani1-2/+2
This patch introduces a new flag for the interactive crashlog mode, that allow the user to specify, which target to use to create the scripted process. This can be very useful when lldb already have few targets created: Instead of taking the first one (zeroth index), we will use that flag to create a new target. If the user didn't provide a target path, we will rely on the symbolicator to create a targer.If that fails and there are already some targets loaded in lldb, we use the first one. rdar://94682869 Differential Revision: https://reviews.llvm.org/D129611 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-08-09[lldb/crashlog] Fix interactive crashlog testMed Ismail Bennani5-458/+5013
This patch should fix the interactive crashlog test by checking in the binary as a yaml to regeneate the binary with the addresses and offsets when running the test. rdar://93655633 Differential Revision: https://reviews.llvm.org/D129603 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>