summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
AgeCommit message (Collapse)Author
2024-11-21[lldb] Refactor UserExpression::Evaluate to only have one error channel. ↵Adrian Prantl
(#117186) Prior to this patch, the function returned an exit status, sometimes a ValueObject with an error and a Status object. This patch removes the Status object and ensures the error is consistently returned as the error of the ValueObject.
2024-09-27[lldb] Store expression evaluator diagnostics in an llvm::Error (NFC) (#106442)Adrian Prantl
…NFC] This patch is the first patch in a series reworking of Pete Lawrence's (@PortalPete) amazing proposal for better expression evaluator error messages (https://github.com/llvm/llvm-project/pull/80938) This patch is preparatory patch for improving the rendering of expression evaluator diagnostics. Currently diagnostics are rendered into a string and the command interpreter layer then textually parses words like "error:" to (sometimes) color the output accordingly. In order to enable user interfaces to do better with diagnostics, we need to store them in a machine-readable fromat. This patch does this by adding a new llvm::Error kind wrapping a DiagnosticDetail struct that is used when the error type is eErrorTypeExpression. Multiple diagnostics are modeled using llvm::ErrorList. Right now the extra information is not used by the CommandInterpreter, this will be added in a follow-up patch!
2024-09-05[lldb] Make deep copies of Status explicit (NFC) (#107170)Adrian Prantl
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
2023-09-11[lldb] Correctly invalidate unloaded image tokens (#65945)David Spickett
Some functions in Process were using LLDB_INVALID_ADDRESS instead of LLDB_INVALID_TOKEN. The only visible effect of this appears to be that "process unload <tab>" would complete to 0 even after the image was unloaded. Since the command is checking for LLDB_INVALID_TOKEN. Everything else worked somehow. I've added a check to the existing load unload tests anyway. The tab completion cannot be checked as is, but when I make them more strict in a later patch it will be tested.
2023-09-01[lldb] Fix duplicate word typos; NFCFangrui Song
Those fixes were taken from https://reviews.llvm.org/D137338
2023-07-03[lldb][NFCI] Change return type of GetProcessPluginNameAlex Langford
Instead of just returning a raw `const char *`, I think llvm::StringRef would make more sense. Most of the time that we use the return value of `GetProcessPluginName` we're passing it to `CreateProcess` which takes a StringRef anyway. Differential Revision: https://reviews.llvm.org/D153825
2023-01-13Revert "[lldb] Add Debugger & ScriptedMetadata reference to ↵Med Ismail Bennani
Platform::CreateInstance" This reverts commit 2d53527e9c64c70c24e1abba74fa0a8c8b3392b1.
2023-01-12[lldb] Add Debugger & ScriptedMetadata reference to Platform::CreateInstanceMed Ismail Bennani
This patch is preparatory work for Scripted Platform support and does multiple things: First, it introduces new options for the `platform select` command and `SBPlatform::Create` API, to hold a reference to the debugger object, the name of the python script managing the Scripted Platform and a structured data dictionary that the user can use to pass arbitrary data. Then, it updates the various `Create` and `GetOrCreate` methods for the `Platform` and `PlatformList` classes to pass down the new parameter to the `Platform::CreateInstance` callbacks. Finally, it updates every callback to reflect these changes. Differential Revision: https://reviews.llvm.org/D139249 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2023-01-09Return a shared_ptr from ScratchTypeSystemClang::GetForTarget()Adrian Prantl
The current interface theoretically could lead to a use-after-free when a client holds on to the returned pointer. Fix this by returning a shared_ptr to the scratch typesystem. rdar://103619233 Differential Revision: https://reviews.llvm.org/D141100
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-07-06[lldb] Stop passing both i386 and i686 in parallel as architectures on WindowsMartin Storsjö
When an object file returns multiple architectures, it is treated as a fat binary - which really isn't the case of i386 vs i686 where the object file actually has one architecture. This allows getting rid of hardcoded architecture triples in PlatformWindows. The parallel i386 and i686 architecture strings stem from 5e6f45201f0b62c1e7a24fc396f3ea6e10dc880d / D7120 and ad587ae4ca143d388c0ec4ef2faa1b5eddedbf67 / D4658. Differential Revision: https://reviews.llvm.org/D128617
2022-04-16Windows: correct iteration of additional search pathsSaleem Abdulrasool
This adjusts the path iteration - `paths` is a null-terminated sequence of C strings, creating an array from a single contiguous buffer. We would previously continue to iterate indefinitely as we did not check if we had encountered the terminator. Found by inspection.
2022-04-13[lldb] Remove the global platform listPavel Labath
This patch moves the platform creation and selection logic into the per-debugger platform lists. I've tried to keep functional changes to a minimum -- the main (only) observable difference in this change is that APIs, which select a platform by name (e.g., Debugger::SetCurrentPlatform) will not automatically pick up a platform associated with another debugger (or no debugger at all). I've also added several tests for this functionality -- one of the pleasant consequences of the debugger isolation is that it is now possible to test the platform selection and creation logic. This is a product of the discussion at <https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>. Differential Revision: https://reviews.llvm.org/D120810
2022-03-09Revert "[lldb] Remove the global platform list"Pavel Labath
It makes module dependencies loopier. This reverts commits 49cffe3c7fab74252d4b6a073303c803dc1659f0 and ffb9429b6f3c29ab4687b96fd85374924c98ad16.
2022-03-09[lldb] Remove the global platform listPavel Labath
This patch moves the platform creation and selection logic into the per-debugger platform lists. I've tried to keep functional changes to a minimum -- the main (only) observable difference in this change is that APIs, which select a platform by name (e.g., Debugger::SetCurrentPlatform) will not automatically pick up a platform associated with another debugger (or no debugger at all). I've also added several tests for this functionality -- one of the pleasant consequences of the debugger isolation is that it is now possible to test the platform selection and creation logic. This is a product of the discussion at <https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>. Differential Revision: https://reviews.llvm.org/D120810
2022-02-22[lldb] Fix race condition between lldb-vscode and stop hooks executorIlya Nozhkin
The race is between these two pieces of code that are executed in two separate lldb-vscode threads (the first is in the main thread and another is in the event-handling thread): ``` // lldb-vscode.cpp g_vsc.debugger.SetAsync(false); g_vsc.target.Launch(launch_info, error); g_vsc.debugger.SetAsync(true); ``` ``` // Target.cpp bool old_async = debugger.GetAsyncExecution(); debugger.SetAsyncExecution(true); debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx, options, result); debugger.SetAsyncExecution(old_async); ``` The sequence that leads to the bug is this one: 1. Main thread enables synchronous mode and launches the process. 2. When the process is launched, it generates the first stop event. 3. This stop event is catched by the event-handling thread and DoOnRemoval is invoked. 4. Inside DoOnRemoval, this thread runs stop hooks. And before running stop hooks, the current synchronization mode is stored into old_async (and right now it is equal to "false"). 5. The main thread finishes the launch and returns to lldb-vscode, the synchronization mode is restored to asynchronous by lldb-vscode. 6. Event-handling thread finishes stop hooks processing and restores the synchronization mode according to old_async (i.e. makes the mode synchronous) 7. And now the mode is synchronous while lldb-vscode expects it to be asynchronous. Synchronous mode forbids the process to broadcast public stop events, so, VS Code just hangs because lldb-vscode doesn't notify it about stops. So, this diff makes the target intercept the first stop event if the process is launched in the synchronous mode, thus preventing stop hooks execution. The bug is only present on Windows because other platforms already intercept this event using their own hijacking listeners. So, this diff also fixes some problems with lldb-vscode tests on Windows to make it possible to run the related test. Other tests still can't be enabled because the debugged program prints something into stdout and LLDB can't intercept this output and redirect it to lldb-vscode properly. Reviewed By: jingham Differential Revision: https://reviews.llvm.org/D119548
2021-12-08Silence format string warning harder.Benjamin Kramer
This can be unsigned long or unsigned long long depending on where it's compiled. Use the ugly portable way. PlatformWindows.cpp:397:63: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long')
2021-12-08lldb: silence a warning on the Windows error path (NFCI)Saleem Abdulrasool
This corrects the printf specifier for the `error_code` parameter that was reported by @thakis.
2021-12-04[lldb] Fix a warningKazu Hirata
This patch fixes: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp:386:13: error: comparison between NULL and non-pointer ('lldb::addr_t' (aka 'unsigned long') and NULL) [-Werror,-Wnull-arithmetic]
2021-12-04Windows: support `DoLoadImage`Saleem Abdulrasool
This implements `DoLoadImage` and `UnloadImage` in the Windows platform plugin modelled after the POSIX platform plugin. This was previously unimplemented and resulted in a difficult to decipher error without any logging. This implementation is intended to support enables the use of LLDB's Swift REPL on Windows. Paths which are added to the library search path are persistent and applied to all subsequent loads. This can be adjusted in the future by storing all the cookies and restoring the path prior to returning from the helper. However, the dynamic path count makes this a bit more challenging. Reviewed By: @JDevlieghere Differential Revision: https://reviews.llvm.org/D77287
2021-11-17[lldb] Port PlatformWindows, PlatformOpenBSD and PlatformRemoteGDBServer to ↵Pavel Labath
GetSupportedArchitectures
2021-10-26[lldb] Remove ConstString from Platform plugin namesPavel Labath
2021-10-24Use llvm::any_of and llvm::none_of (NFC)Kazu Hirata
2021-10-18[lldb] Return StringRef from PluginInterface::GetPluginNamePavel Labath
There is no reason why this function should be returning a ConstString. While modifying these files, I also fixed several instances where GetPluginName and GetPluginNameStatic were returning different strings. I am not changing the return type of GetPluginNameStatic in this patch, as that would necessitate additional changes, and this patch is big enough as it is. Differential Revision: https://reviews.llvm.org/D111877
2021-09-22[lldb] [Windows] Fix continuing from breakpoints and singlestepping on ↵Martin Storsjö
ARM/AArch64 Based on suggestions by Eric Youngdale. This fixes https://llvm.org/PR51673. Differential Revision: https://reviews.llvm.org/D109777
2021-09-16[lldb] Make Platform::DebugProcess take a Target referencePavel Labath
instead of a pointer. There are just two callers of this function, and both of them have a valid target pointer, so there's no need for all implementations to concern themselves with whether the pointer is null.
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
2020-12-12[lldb] "target create" shouldn't save target if the command failedTatyana Krasnukha
TargetList::CreateTarget automatically adds created target to the list, however, CommandObjectTargetCreate does some additional preparation after creating a target and which can fail. The command should remove created target if it failed. Since the function has many ways to return, scope guard does this work safely. Changes to the TargetList make target adding and selection more transparent. Other changes remove unnecessary SetSelectedTarget after CreateTarget. Differential Revision: https://reviews.llvm.org/D93052
2020-11-23[lldb] Prevent 'process connect' from using local-only pluginsMichał Górny
Add a 'can_connect' parameter to Process plugin initialization, and use it to filter plugins to these capable of remote connections. This is used to prevent 'process connect' from picking up a plugin that can only be used locally, e.g. the legacy FreeBSD plugin. Differential Revision: https://reviews.llvm.org/D91810
2020-10-09[lldb] Delete copy operations on PluginInterface classPavel Labath
This is a polymorphic class, copying it is a bad idea. This was not a problem because most classes inheriting from it were deleting their copy operations themselves. However, this enables us to delete those explicit deletions, and ensure noone forgets to add them in the future.
2020-05-13[lldb] Merge PlatformXXX::ResolveExecutablePavel Labath
The near-identical implementations of this function for posix-y platforms were merged in r293910. PlatformWindows was left out of this merge because at the time we did not have a suitable base class to sink the code into. That is no longer true, so this commit finishes the job by moving the code into RemoteAwarePlatform::ResolveExecutable.
2020-02-14[lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)Jonas Devlieghere
Rename LLDB_PLUGIN to LLDB_PLUGIN_DEFINE as Pavel suggested in D73067 to avoid name conflict.
2020-02-10[LLDB] Fix GCC warnings about extra semicolons. NFC.Martin Storsjö
2020-02-07[lldb/Plugins] Use external functions to (de)initialize pluginsJonas Devlieghere
This is a step towards making the initialize and terminate calls be generated by CMake, which in turn is towards making it possible to disable plugins at configuration time. Differential revision: https://reviews.llvm.org/D74245
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-04-10[NFC] Remove ASCII lines from commentsJonas Devlieghere
A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
2019-04-10[lldb-server] Introduce Socket::Initialize and Terminate to simply WSASocket ↵Aaron Smith
setup Reviewers: zturner, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D60440 llvm-svn: 358044
2019-02-14[lldb-server] Add remote platform capabilities for WindowsAaron Smith
Summary: Implement a few routines for Windows to support some basic process interaction and file system operations. Reviewers: zturner, llvm-commits, labath, jingham Reviewed By: labath Subscribers: emaste, jdoerfert, Hui, labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D56232 llvm-svn: 354010
2019-02-12Extract common PlatformPOSIX/Windows code into a separate classPavel Labath
Summary: The two classes contained a lot of duplicated code, but there wasn't a good place to factor it to. It couldn't be the base Platform class, since we also have platforms which are only remote (such as PlatformGDBRemoteServer), and so it did not make sense for those to have an m_remote_platform member. This patch creates a new class, RemoteAwarePlatform, which can serve as a base class for platforms which can both serve as a host, and forward actions to a remote system. It is motivated partly by D56232 (which was about to add a bunch of additional duplicated methods), and partly by my own need to modify a function which happens to be implemented in both places identically. The patch moves the methods which are trivially identical in the two classes into the common base class, there were one or two more methods which could probably be merged into one, but this wasn't completely trivial, so I did not attempt to do that now. Reviewers: jingham, zturner, clayborg, asmith Subscribers: emaste, mgorny, Hui, lldb-commits Differential Revision: https://reviews.llvm.org/D58052 llvm-svn: 353812
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-07ProcessLaunchInfo: remove Debugger referencePavel Labath
Summary: The Debuffer object was being used in "GetListenerForProcess" to provide a default listener object if one was not specified in the launch_info object. Since all the callers of this function immediately passed the result to Target::CreateProcess, it was easy to move this logic there instead. This brings us one step closer towards being able to move the LaunchInfo classes to the Host layer (which is there the launching code that consumes them lives). Reviewers: zturner, jingham, teemperor Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D56174 llvm-svn: 350510
2018-12-15Simplify Boolean expressionsJonas Devlieghere
This patch simplifies boolean expressions acorss LLDB. It was generated using clang-tidy with the following command: run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD Differential revision: https://reviews.llvm.org/D55584 llvm-svn: 349215
2018-11-11Remove header grouping comments.Jonas Devlieghere
This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
2018-11-01[FileSystem] Move path resolution logic out of FileSpecJonas Devlieghere
This patch removes the logic for resolving paths out of FileSpec and updates call sites to rely on the FileSystem class instead. Differential revision: https://reviews.llvm.org/D53915 llvm-svn: 345890
2018-11-01[FileSystem] Remove Exists() from FileSpecJonas Devlieghere
This patch removes the Exists method from FileSpec and updates its uses with calls to the FileSystem. Differential revision: https://reviews.llvm.org/D53845 llvm-svn: 345854
2018-11-01[FileSystem] Remove ResolveExecutableLocation() from FileSpecJonas Devlieghere
This patch removes the ResolveExecutableLocation method from FileSpec and updates its uses with calls to the FileSystem. Differential revision: https://reviews.llvm.org/D53834 llvm-svn: 345853
2018-11-01[FileSystem] Remove GetPermissions() and Readable() from FileSpecJonas Devlieghere
This patch removes the GetPermissions and GetReadable methods from FileSpec and updates its uses with calls to the FileSystem. Differential revision: https://reviews.llvm.org/D53831 llvm-svn: 345843
2018-09-20[NFC] Turn "load dependent files" boolean into an enumJonas Devlieghere
This is an NFC commit to refactor the "load dependent files" parameter from a boolean to an enum value. We want to be able to specify a default, in which case we decide whether or not to load the dependent files based on whether the target is an executable or not (i.e. a dylib). This is a dependency for D51934. Differential revision: https://reviews.llvm.org/D51859 llvm-svn: 342633