summaryrefslogtreecommitdiff
path: root/lldb/tools/driver/Driver.cpp
AgeCommit message (Collapse)Author
2025-11-19[lldb][windows] add color to the Python.dll not found error (#168718)Charles Zablit
Make the `Python.dll not found` error message stand out more by using the `llvm::WithColor::error()` method. --- ### Example #### Before <img width="782" height="431" alt="Screenshot 2025-11-19 at 15 50 22" src="https://github.com/user-attachments/assets/93960c50-cbf2-41f7-aba3-2f2a8af916cc" /> #### After <img width="780" height="430" alt="Screenshot 2025-11-19 at 15 54 28" src="https://github.com/user-attachments/assets/f7f4954b-0ce3-4a4b-b9af-5af876032573" /> rdar://165047059
2025-11-03[lldb][windows] print an error if python.dll is not in the DLL search path ↵Charles Zablit
(#164893) This is a follow up to https://github.com/llvm/llvm-project/pull/162509. Using the `SearchPathW` API, we can ensure that the correct version of Python is installed before `liblldb` is loaded (and `python.dll` subsequently). If it's not, we try to add it to the search path with the methods introduced in https://github.com/llvm/llvm-project/pull/162509. If that fails or if that method is `#ifdef`'d out, we print an error which will appear before lldb crashes due to the missing dll. Before https://github.com/llvm/llvm-project/pull/162509, when invoked from Powershell, lldb would silently crash (no error message/crash report). After https://github.com/llvm/llvm-project/pull/162509, it crashes without any indications that the root cause is the missing python.dll. With this patch, we print the error before crashing.
2025-10-27Avoid stalls when MainLoop::Interrupt fails to wake up the MainLoop (#164905)jimingham
Turns out there's a bug in the current lldb sources that if you fork, set the stdio file handles to close on exec and then exec lldb with some commands and the `--batch` flag, lldb will stall on exit. The first cause of the bug is that the Python session handler - and probably other places in lldb - think 0, 1, and 2 HAVE TO BE the stdio file handles, and open and close and dup them as needed. NB: I am NOT trying to fix that bug. I'm not convinced running the lldb driver headless is worth a lot of effort, it's just as easy to redirect them to /dev/null, which does work. But I would like to keep lldb from stalling on the way out when this happens. The reason we stall is that we have a MainLoop waiting for signals, and we try to Interrupt it, but because stdio was closed, the interrupt pipe for the MainLoop gets the file descriptor 0, which gets closed by the Python session handler if you run some script command. So the Interrupt fails. We were running the Write to the interrupt pipe wrapped in `llvm::cantFail`, but in a no asserts build that just drops the error on the floor. So then lldb went on to call std::thread::join on the still active MainLoop, and that stalls I made Interrupt (and AddCallback & AddPendingCallback) return a bool for "interrupt success" instead. All the places where code was requesting termination, I added checks for that failure, and skip the std::thread::join call on the MainLoop thread, since that is almost certainly going to stall at this point. I didn't do the same for the Windows MainLoop, as I don't know if/when the WSASetEvent call can fail, so I always return true here. I also didn't turn the test off for Windows. According to the Python docs all the API's I used should work on Windows... If that turns out not to be true I'll make the test Darwin/Unix only.
2025-10-09[lldb][windows] fix undeclared identifier error (#162705)Charles Zablit
This patch fixes the `'LLDB_PYTHON_DLL_RELATIVE_PATH': undeclared identifier` error introduced by https://github.com/llvm/llvm-project/pull/162509.
2025-10-09[lldb][windows] add support for out of PATH python.dll resolution (#162509)Charles Zablit
This patch adds the `LLDB_PYTHON_DLL_RELATIVE_PATH` Cmake variable which is the relative path to the directory containing `python.dll`. The path is relative to the directory containing `lldb.exe`. If this variable is set and the resolved path points to an existing directory, we call `SetDllDirectoryW` to add `python.dll` to the list of DLL search paths. This, combined with `liblldb.dll` being delay loaded, allows to package `python.dll` with the `llvm` installer.
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
2025-04-10[lldb] Handle signals in a separate thread in the driver (#134956)Jonas Devlieghere
Handle signals in a separate thread in the driver so that we can stop worrying about signal safety of functions in libLLDB that may get called from a signal handler.
2024-12-16[lldb] Unify window resizing logic in command line driverJonas Devlieghere
Unify the logic for window resizing in the command line driver. This was prompted by the Windows bot not knowing about the ws_col field.
2024-12-16[lldb] Use the terminal height for paging editline completions (#119914)Jonas Devlieghere
Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. This builds on the improvements of #116456.
2024-12-11Rework the `Option` library to reduce dynamic relocations (#119198)Chandler Carruth
Apologies for the large change, I looked for ways to break this up and all of the ones I saw added real complexity. This change focuses on the option's prefixed names and the array of prefixes. These are present in every option and the dominant source of dynamic relocations for PIE or PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which has a huge number of options. This PR addresses this by building a string table and a prefixes table that can be referenced with indices rather than pointers that require dynamic relocations. This removes almost 7k dynmaic relocations from the `clang` binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For busy-boxing use cases where many different option tables are linked into the same binary, the savings add up a bit more. The string table is a straightforward mechanism, but the prefixes required some subtlety. They are encoded in a Pascal-string fashion with a size followed by a sequence of offsets. This works relatively well for the small realistic prefixes arrays in use. Lots of code has to change in order to land this though: both all the option library code has to be updated to use the string table and prefixes table, and all the users of the options library have to be updated to correctly instantiate the objects. Some follow-up patches in the works to provide an abstraction for this style of code, and to start using the same technique for some of the other strings here now that the infrastructure is in place.
2024-09-27[lldb] Inline expression evaluator error visualization (#106470)Adrian Prantl
This patch is a reworking of Pete Lawrence's (@PortalPete) proposal for better expression evaluator error messages: https://github.com/llvm/llvm-project/pull/80938 Before: ``` $ lldb -o "expr a+b" (lldb) expr a+b error: <user expression 0>:1:1: use of undeclared identifier 'a' a+b ^ error: <user expression 0>:1:3: use of undeclared identifier 'b' a+b ^ ``` After: ``` (lldb) expr a+b ^ ^ │ ╰─ error: use of undeclared identifier 'b' ╰─ error: use of undeclared identifier 'a' ``` This eliminates the confusing `<user expression 0>:1:3` source location and avoids echoing the expression to the console again, which results in a cleaner presentation that makes it easier to grasp what's going on. You can't see it here, bug the word "error" is now also in color, if so desired. Depends on https://github.com/llvm/llvm-project/pull/106442.
2024-09-27Revert "[lldb] Inline expression evaluator error visualization (#106470)"Adrian Prantl
This reverts commit 49372d1cccf50f404d52d40ae4b663db5604eb2c.
2024-09-27[lldb] Inline expression evaluator error visualization (#106470)Adrian Prantl
This patch is a reworking of Pete Lawrence's (@PortalPete) proposal for better expression evaluator error messages: https://github.com/llvm/llvm-project/pull/80938 Before: ``` $ lldb -o "expr a+b" (lldb) expr a+b error: <user expression 0>:1:1: use of undeclared identifier 'a' a+b ^ error: <user expression 0>:1:3: use of undeclared identifier 'b' a+b ^ ``` After: ``` (lldb) expr a+b ^ ^ │ ╰─ error: use of undeclared identifier 'b' ╰─ error: use of undeclared identifier 'a' ``` This eliminates the confusing `<user expression 0>:1:3` source location and avoids echoing the expression to the console again, which results in a cleaner presentation that makes it easier to grasp what's going on. You can't see it here, bug the word "error" is now also in color, if so desired. Depends on https://github.com/llvm/llvm-project/pull/106442.
2024-05-07[lldb] Request crash report when prompting for a bug report on Darwin (#91371)Jonas Devlieghere
On Darwin platforms, the system will generate a crash report in ~/Library/Logs/DiagnosticReports/ when a process crashes. These reports are much more useful than the "pretty backtraces" printed by LLVM and are preferred when filing bug reports on Darwin.
2024-03-05[lldb] Print a message when background tasks take a while to complete (#82799)Jonas Devlieghere
When terminating the debugger, we wait for all background tasks to complete. Given that there's no way to interrupt those treads, this can take a while. When that happens, the debugger appears to hang at exit. The above situation is unfortunately not uncommon when background downloading of dSYMs is enabled (`symbols.auto-download background`). Even when calling dsymForUUID with a reasonable timeout, it can take a while to complete. This patch improves the user experience by printing a message from the driver when it takes more than one (1) second to terminate the debugger.
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.
2024-01-16[lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug ↵Zequan Wu
reporting. (#78210) This allows release teams to customize the bug report url for lldb. It also removes unnecessary constructions of `llvm::PrettyStackTraceProgram` as it's already constructed inside `llvm::InitLLVM`.
2023-08-25[lldb] Qualify `auto` in the lldb driver (NFC)Jonas Devlieghere
The LLVM coding guidelines say to "[u]se auto & for values and auto * for pointers unless you need to make a copy."
2023-08-15Reapply "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner
This reverts commit 4e3b89483a6922d3f48670bb1c50a37f342918c6, with fixes for places I'd missed updating in lld and lldb. I've also renamed OptionVisibility::Default to "DefaultVis" to avoid ambiguity since the undecorated name has to be available anywhere Options.inc is included. Original message follows: This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-04[llvm] Extract common `OptTable` bits into macrosJan Svoboda
All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157028
2023-07-05[lldb] Deprecate SBHostOS threading functionalityAlex Langford
For some context, Raphael tried to this before: https://reviews.llvm.org/D104231 These methods are not tested at all, and in some cases, are not even fully implemented (e.g. SBHostOS::ThreadCreated). I'm not convinced it's possible to use these correctly from Python, and I'm not aware of any users of these methods. It's difficult to remove these methods wholesale, but we can start with deprecating them. A possible follow-up to this change (which may require an RFC to get more buy in from the community) is to gut these functions entirely. That is, remove the implementations and replace them either with nothing or have them dump out a message to stderr saying not to use these. Differential Revision: https://reviews.llvm.org/D153900
2023-01-12[OptTable] Precompute OptTable prefixes union table through tablegenserge-sans-paille
This avoid rediscovering this table when reading each options, providing a sensible 2% speedup when processing and empty file, and a measurable speedup on typical workloads, see: This is optional, the legacy, on-the-fly, approach can still be used through the GenericOptTable class, while the new one is used through PrecomputedOptTable. https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u Differential Revision: https://reviews.llvm.org/D140800
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2022-12-27[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This a recommit of e953ae5bbc313fd0cc980ce021d487e5b5199ea4 and the subsequent fixes caa713559bd38f337d7d35de35686775e8fb5175 and 06b90e2e9c991e211fecc97948e533320a825470. The above patchset caused some version of GCC to take eons to compile clang/lib/Basic/Targets/AArch64.cpp, as spotted in aa171833ab0017d9732e82b8682c9848ab25ff9e. The fix is to make BuiltinInfo tables a compilation unit static variable, instead of a private static variable. Differential Revision: https://reviews.llvm.org/D139881
2022-12-25Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵Vitaly Buka
builtin and call information" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4 (part 2)" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4" GCC build hangs on this bot https://lab.llvm.org/buildbot/#/builders/37/builds/19104 compiling CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.d The bot uses GNU 11.3.0, but I can reproduce locally with gcc (Debian 12.2.0-3) 12.2.0. This reverts commit caa713559bd38f337d7d35de35686775e8fb5175. This reverts commit 06b90e2e9c991e211fecc97948e533320a825470. This reverts commit e953ae5bbc313fd0cc980ce021d487e5b5199ea4.
2022-12-24Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4serge-sans-paille
Option tables are no longer null-terminated. This is a follow-up to https://reviews.llvm.org/D139881
2022-12-24[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 that into account a GGC issue (probably https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92181) when dealing with intiailizer_list and constant expressions. Workaround this by avoiding initializer list, at the expense of a temporary plain old array. Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille
builtin and call information" There are still remaining issues with GCC 12, see for instance https://lab.llvm.org/buildbot/#/builders/93/builds/12669 This reverts commit 5ce4e92264102de21760c94db9166afe8f71fcf6.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 with a change to llvm/utils/TableGen/OptParserEmitter.cpp to cope with GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille
builtin and call information" Failing builds: https://lab.llvm.org/buildbot#builders/9/builds/19030 This is GCC specific and has been reported upstream: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 This reverts commit 719d98dfa841c522d8d452f0685e503538415a53.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139881
2022-12-08Store OptTable::Info::Name as a StringRefserge-sans-paille
This is a recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e, with a few cleanups. This avoids implicit conversion to StringRef at several points, which in turns avoid redundant calls to strlen. As a side effect, this greatly simplifies the implementation of StrCmpOptionNameIgnoreCase. It also eventually gives a consistent, humble speedup in compilation time (timing updated since original commit). https://llvm-compile-time-tracker.com/compare.php?from=de4b6a1bc64db33643f001ad45fae7b92b4a4688&to=c23a93d1292052b4be2fbe8c586fa31143d0c7ed&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139274
2022-10-31[lldb] Add diagnosticsJonas Devlieghere
Around this time last year, I said on the mailing list [1] that I wanted to to transform the reproducers into something that resembles a sysdiagnose on Apple platforms: a collection of files containing a variety of information to help diagnose bugs or troubleshoot issues. This patch adds that framework. Based on lessons learned from the reproducers, I've intentionally tried to keep it small and simple. Different parts of LLDB can register callbacks (this is necessary for layering purposes) that will get called when the diagnostics should be generated. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html Differential revision: https://reviews.llvm.org/D134991
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-03-26[lldb] Fix building for mingw after changes to sigtstp_handlerMartin Storsjö
Some signal handlers were set up within an !_MSC_VER condition, i.e. omitted in MSVC builds but included in mingw builds. Previously sigtstp_handler was defined in all builds, but since 4bcadd66864bf4af929ac8753a51d7ad408cdef0 / D120320 it's only defined non platforms other than Windows. Change the condition to !_WIN32 for consistency between the MSVC and mingw builds, fixing the build for mingw. Differential Revision: https://reviews.llvm.org/D122486
2022-03-09[lldb/driver] Fix SIGTSTP handlingPavel Labath
Our SIGTSTP handler was working, but that was mostly accidental. The reason it worked is because lldb is multithreaded for most of its lifetime and the OS is reasonably fast at responding to signals. So, what happened was that the kill(SIGTSTP) which we sent from inside the handler was delivered to another thread while the handler was still set to SIG_DFL (which then correctly put the entire process to sleep). Sometimes it happened that the other thread got the second signal after the first thread had already restored the handler, in which case the signal handler would run again, and it would again attempt to send the SIGTSTP signal back to itself. Normally it didn't take many iterations for the signal to be delivered quickly enough. However, if you were unlucky (or were playing around with pexpect) you could get SIGTSTP while lldb was single-threaded, and in that case, lldb would go into an endless loop because the second SIGTSTP could only be handled on the main thread, and only after the handler for the first signal returned (and re-installed itself). In that situation the handler would keep re-sending the signal to itself. This patch fixes the issue by implementing the handler the way it supposed to be done: - before sending the second SIGTSTP, we unblock the signal (it gets automatically blocked upon entering the handler) - we use raise to send the signal, which makes sure it gets delivered to the thread which is running the handler This also means we don't need the SIGCONT handler, as our TSTP handler resumes right after the entire process is continued, and we can do the required work there. I also include a test case for the SIGTSTP flow. It uses pexpect, but it includes a couple of extra twists. Specifically, I needed to create an extra process on top of lldb, which will run lldb in a separate process group and simulate the role of the shell. This is needed because SIGTSTP is not effective on a session leader (the signal gets delivered, but it does not cause a stop) -- normally there isn't anyone to notice the stop. Differential Revision: https://reviews.llvm.org/D120320
2022-03-03[lldb] Remove reproducer_handler from the driverJonas Devlieghere
2022-02-28[Support] Allow the ability to change WithColor's auto detection functionJonas Devlieghere
WithColor has an "auto detection mode" which looks whether the corresponding whether the corresponding cl::opt is enabled or not. While this is great when opting into cl::opt, it's not so great for downstream users of this utility, which might have their own competing options to enable or disable colors. The WithColor constructor takes a color mode, but the big benefit of the class are its static error and warning helpers and default error handlers. In order to allow users of this utility to enable or disable colors globally, this patch adds the ability to specify a global auto detection function. By default, the auto detection function behaves the way that it does today. The benefit of this patch lies in that it can be overwritten. In addition to a ability to change the auto detection function, I've also made it possible to get your hands on the default auto detection function, so you swap it back if if you so desire. This patch allow downstream users (like LLDB) to globally disable colors with its own command line flag. Differential revision: https://reviews.llvm.org/D120593
2022-02-28Revert "[Support] Allow the ability to change WithColor's auto detection ↵Jonas Devlieghere
function" This reverts commit a83cf7a84628a9e3a24cfd33c69f786cf74df4ec because it breaks a bunch of build bots.
2022-02-28[Support] Allow the ability to change WithColor's auto detection functionJonas Devlieghere
WithColor has an "auto detection mode" which looks whether the corresponding whether the corresponding cl::opt is enabled or not. While this is great when opting into cl::opt, it's not so great for downstream users of this utility, which might have their own competing options to enable or disable colors. The WithColor constructor takes a color mode, but the big benefit of the class are its static error and warning helpers and default error handlers. In order to allow users of this utility to enable or disable colors globally, this patch adds the ability to specify a global auto detection function. By default, the auto detection function behaves the way that it does today. The benefit of this patch lies in that it can be overwritten. In addition to a ability to change the auto detection function, I've also made it possible to get your hands on the default auto detection function, so you swap it back if if you so desire. This patch allow downstream users (like LLDB) to globally disable colors with its own command line flag. Differential revision: https://reviews.llvm.org/D120593
2022-02-18[lldb] Add support for a "global" lldbinit filePavel Labath
This patch adds introduces a new kind of an lldbinit file. Unlike the lldbinit in the home directory (useful for customizing lldb to the needs of a particular user), or the cwd lldbinit file (useful for project-specific settings), this file can be used to customize an entire lldb installation to a particular environment. The feature is enabled at build time, by setting the LLDB_GLOBAL_INIT_DIRECTORY variable to a path to a directory which should contain an "lldbinit" file. Lldb will then load the file at startup, if it exists, and if automatic init loading has not been disabled. Relative paths will be resolved (at runtime) relative to the location of the lldb library (liblldb or LLDB.framework). The system-wide lldbinit file will be loaded first, before any $HOME/.lldbinit and $CWD/.lldbinit files are processed, so that those can override any system-wide settings. More information can be found on the RFC thread at <https://discourse.llvm.org/t/rfc-system-wide-lldbinit/59933>. Differential Revision: https://reviews.llvm.org/D119831
2022-01-05[lldb] Create a property to store the REPL languageJonas Devlieghere
Until the introduction of the C++ REPL, there was always a single REPL language. Several places relied on this assumption through repl_languages.GetSingularLanguage. Now that this is no longer the case, we need a way to specify a selected/preferred REPL language. This patch does that with the help of a debugger property, taking inspiration from how we store the scripting language. Differential revision: https://reviews.llvm.org/D116697
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-12-17[lldb] Remove --reproducer-finalize and associated 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-24Fixed use of -o and -k in LLDB under Windows when statically compiled with ↵Levon Ter-Grigoryan
vcruntime. Right now if the LLDB is compiled under the windows with static vcruntime library, the -o and -k commands will not work. The problem is that the LLDB create FILE* in lldb.exe and pass it to liblldb.dll which is an object from CRT. Since the CRT is statically linked each of these module has its own copy of the CRT with it's own global state and the LLDB should not share CRT objects between them. In this change I moved the logic of creating FILE* out of commands stream from Driver class to SBDebugger. To do this I added new method: SBError SBDebugger::SetInputStream(SBStream &stream) Command to build the LLDB: cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx" -DLLVM_USE_CRT_RELEASE="MT" -DLLVM_USE_CRT_MINSIZEREL="MT" -DLLVM_USE_CRT_RELWITHDEBINFO="MT" -DP YTHON_HOME:FILEPATH=C:/Python38 -DCMAKE_C_COMPILER:STRING=cl.exe -DCMAKE_CXX_COMPILER:STRING=cl.exe ../llvm Command which will fail: lldb.exe -o help See discord discussion for more details: https://discord.com/channels/636084430946959380/636732809708306432/854629125398724628 This revision is for the further discussion. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104413
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
2021-07-13[lldb] Fix editline unicode on LinuxJan Kratochvil
Based on: [lldb-dev] proposed change to remove conditional WCHAR support in libedit wrapper https://lists.llvm.org/pipermail/lldb-dev/2021-July/016961.html There is already setlocale in lldb/source/Core/IOHandlerCursesGUI.cpp but that does not apply for Editline GUI editing. Unaware how to make automated test for this, it requires pty. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D105779
2021-06-24[OptTable] Rename PrintHelp to printHelpFangrui Song
To be consistent with other member functions and match the coding standard.
2021-05-26[lldb][NFC] Use C++ versions of the deprecated C standard library headersRaphael Isemann
The C headers are deprecated so as requested in D102845, this is replacing them all with their (not deprecated) C++ equivalent. Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D103084