aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Python/Crashlog
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>
2024-10-31[lldb] Remove lldb-repro utilityJonas Devlieghere1-3/+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-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-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-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere1-18/+19
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-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>
2022-06-10[lldb/crashlog] Show help when the command is called without any argumentMed Ismail Bennani1-0/+9
This patch changes the `crashlog` command behavior to print the help message if no argument was provided with the command. rdar://94576026 Differential Revision: https://reviews.llvm.org/D127362 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-20[lldb] Disable scripted_crashlog_json.test on Apple SiliconJonas Devlieghere1-0/+3
Disable scripted_crashlog_json.test on Apple Silicon until Ismail has bandwidth to investigate. rdar://93655633
2022-03-25[lldb/crashlog] Parse thread fields and pass it to crashlog scripted processMed Ismail Bennani1-6/+13
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 Bennani3-85/+486
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 Bennani1-4/+12
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 Bennani2-6/+7
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 Bennani1-0/+2
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 Bennani2-0/+85
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 Lee3-0/+6
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 Devlieghere3-4/+4
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 Devlieghere2-0/+12
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-07[lldb] Parse and display reporting errors from JSON crashlogsJonas Devlieghere2-1/+7
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 Devlieghere2-0/+115
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 Devlieghere2-0/+12
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