summaryrefslogtreecommitdiff
path: root/lldb/include
Commit message (Collapse)AuthorAgeFilesLines
* [lldb][NFCI] Qualify param type in SBDebugger::FindTargetWithProcessIDAlex Langford2023-05-171-1/+1
| | | | | | | | | We should specify that this is the pid_t as defined in the lldb namespace, not some other pid_t. This doesn't really affect builds but it makes writing tooling against the SBAPI easier. I have verified that this does not change the emitted mangled name and does not break ABI.
* [lldb][NFCI] Clean up ThreadSafeDenseMapAlex Langford2023-05-171-15/+11
| | | | | | | - Change header guard after 147a61618989 - Fix file header - Remove the `_MutexType` template parameter, I did not see this used anywhere on llvm.org or on Apple's downstream forks.
* [lldb][NFCI] Move ThreadSafeDenseMap to UtilityAlex Langford2023-05-171-0/+0
| | | | This seems better suited for Utility than Core
* [lldb] Define lldbassert based on NDEBUG instead of LLDB_CONFIGURATION_DEBUGJonas Devlieghere2023-05-161-1/+10
| | | | | | | | | | | Whether assertions are enabled or not is orthogonal to the build type which could lead to surprising behavior for lldbassert. Previously, when doing a debug build with assertions disabled, lldbassert would become a NOOP, rather than printing an error like it does in a release build. By definining lldbassert in terms of NDEBUG, it behaves like a regular assert when assertions are enabled, and like a soft assert. Differential revision: https://reviews.llvm.org/D150639
* [lldb] Fix lua build after 27b6a4e63afeAlex Langford2023-05-154-1/+17
| | | | | | | This applies the same trick for Lua that I did for python in 27b6a4e63afe. Differential Revision: https://reviews.llvm.org/D150624
* [lldb] Change definition of DisassemblerCreateInstanceAlex Langford2023-05-151-2/+2
| | | | | | | | | DissassemblerCreateInstance is a function pointer whos return type is `Disassembler *`. But Disassembler::FindPlugin always returns a DisassemblerSP, so there's no reason why we can't just create a DisassemblerSP in the first place. Differential Revision: https://reviews.llvm.org/D150235
* [lldb] Cleanup OptionValue header and implenentation (NFC)Jonas Devlieghere2023-05-141-21/+3
| | | | | Group related functions together and remove inconsistencies between them in the implementation.
* [lldb] Complete OptionValue cleanup (NFC)Jonas Devlieghere2023-05-142-52/+52
| | | | | Make the `Get.*Value` and `Set.*Value` function private and migrate the last remaining call sites to the new overloaded/templated functions.
* [lldb][NFCI] Delete commented out method OptionValueProperties::GetQualifiedNameAlex Langford2023-05-121-3/+0
|
* [lldb][NFCI] Redefine dw_attr_t typedef with llvm::dwarf::AttributeAlex Langford2023-05-121-1/+1
| | | | | | | | | Similar to dw_form_t, dw_attr_t is typedef'd to be a uint16_t. LLVM defines their type `llvm::dwarf::Attribute` as an enum backed by a uint16_t. Switching to the LLVM type buys us type checking and the requirement of explicit casts. Differential Revision: https://reviews.llvm.org/D150299
* We can't let GetStackFrameCount get interrupted or it will give theJim Ingham2023-05-112-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | wrong answer. Plus, it's useful in some places to have a way to force the full stack to be created even in the face of interruption. Moreover, most of the time when you're just getting frames, you don't need to know the number of frames in the stack to start with. You just keep calling Thread::GetStackFrameAtIndex(index++) and when you get a null StackFrameSP back, you're done. That's also more amenable to interruption if you are doing some work frame by frame. So this patch makes GetStackFrameCount always return the full count, suspending interruption. I also went through all the places that use GetStackFrameCount to make sure that they really needed the full stack walk. In many cases, they did not. For instance frame select -r 10 was getting the number of frames just to check whether cur_frame_idx + 10 was within the stack. It's better in that case to see if that frame exists first, since that doesn't force a full stack walk, and only deal with walking off the end of the stack if it doesn't... I also added a test for some of these behaviors. Differential Revision: https://reviews.llvm.org/D150236
* [lldb] Mark most SBAPI methods involving private types as protected or privateAlex Langford2023-05-1023-102/+226
| | | | | | | | | | | | | | | | | | | | | Many SB classes have public constructors or methods involving types that are private. Some are more obvious (e.g. containing lldb_private in the name) than others (lldb::FooSP is usually std::shared_pointer<lldb_private::Foo>). This commit explicitly does not address FileSP, so I'm leaving that one alone for now. Some of these were for other SB classes to use and should have been made protected/private with a friend class entry added. Some of these were public for some of the swig python helpers to use. I put all of those functions into a class and made them static methods. The relevant SB classes mark that class as a friend so they can access those private/protected members. I've also removed an outdated SBStructuredData test (can you guess which constructor it was using?) and updated the other relevant tests. Differential Revision: https://reviews.llvm.org/D150157
* [lldb][NFCI] Replace dw_form_t with llvm::dwarf::FormAlex Langford2023-05-101-1/+1
| | | | | | | | | | | | | | | | LLDB currently defines `dw_form_t` as a `uint16_t` which makes sense. However, LLVM also defines a similar type `llvm::dwarf::Form` which is an enum backed by a `uint16_t`. Switching to the llvm implementation means that we can more easily interoperate with the LLVM DWARF code. Additionally, we get some type checking out of this: I found that DWARFAttribute had a method called `FormAtIndex` that returned a `dw_attr_t`. Although `dw_attr_t` is also a `uint16_t` under the hood, the type checking benefits here are undeniable: If this had returned a something of different signedness/width, we could have had some bad bugs. Differential Revision: https://reviews.llvm.org/D150228
* [lldb][NFCI] Remove custom dwarf LEB128 typesAlex Langford2023-05-091-2/+0
| | | | | | | | | | The LEB128 type defined by the DWARF standard is explicitly a variable-length encoding of an integer. LLDB had defined `uleb128` and `sleb128` types to be 32-bit but in many places in both LLVM and LLDB we treat the maximum width of LEB128 types to be 64, so let's remove these types and be consistent. Differential Revision: https://reviews.llvm.org/D150222
* [lldb] Simplify predicates of find_if in BroadcastManagerAlex Langford2023-05-091-97/+0
| | | | | | | We had some custom classes that were used as the predicate for `std::find_if`. It would be a lot simpler if we used lambdas instead. Differential Revision: https://reviews.llvm.org/D150168
* [lldb] Replace None with std::nullopt in comments (NFC)Kazu Hirata2023-05-061-1/+1
| | | | | | | 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
* [LLDB] Add minimal support for the new Mojo languagewalter erquinigo2023-05-051-0/+3
| | | | Modular just announced a new language called Mojo. This patch adds an entry in the language list in LLDB for minimal support (e.g. being able to create a TypeSystem for this language). We will later add debug info entries when the language matures.
* [lldb] Migrate to GetPropertyAtIndexAs for ArchSpec (NFC)Jonas Devlieghere2023-05-052-3/+9
| | | | Use the templated GetPropertyAtIndexAs helper for ArchSpec.
* [lldb] Migrate to GetPropertyAtIndexAs for LanguageType (NFC)Jonas Devlieghere2023-05-051-3/+0
| | | | Use the templated GetPropertyAtIndexAs helper for LanguageType.
* Re-land "[lldb] Expose a const iterator for SymbolContextList"Alex Langford2023-05-053-3/+7
| | | | | | | Re-lands 04aa943be8ed5c03092e2a90112ac638360ec253 with modifications to fix tests. I originally reverted this because it caused a test to fail on Linux. The problem was that I inverted a condition on accident.
* [lldb] Migrate to GetPropertyAtIndexAs for FileSpecList (NFC)Jonas Devlieghere2023-05-041-1/+6
| | | | Use the templated GetPropertyAtIndexAs helper for FileSpecList.
* [lldb] Eliminate {Get,Set}PropertyAtIndexAsFileSpec (NFC)Jonas Devlieghere2023-05-042-9/+7
| | | | | This patch is a continuation of 6f8b33f6dfd0 and eliminates the {Get,Set}PropertyAtIndexAsFileSpec functions.
* [lldb] Move Core/FileSpecList -> Utility/FileSpecList (NFC)Jonas Devlieghere2023-05-047-12/+9
| | | | | There's no reason for FileSpecList to live in lldb/Core while FileSpec lives in lldb/Utility. Move FileSpecList next to FileSpec.
* [lldb] Remove SetPropertyAtIndexAsLanguage (NFC)Jonas Devlieghere2023-05-041-3/+0
| | | | After 6f8b33f6dfd0 this function has no callers anymore.
* Revert "[lldb] Expose a const iterator for SymbolContextList"Alex Langford2023-05-043-7/+3
| | | | | | | This reverts commit 04aa943be8ed5c03092e2a90112ac638360ec253. This broke the debian buildbot and I'm not sure why. Reverting so I can investigate.
* [lldb] Use templates to simplify {Get,Set}PropertyAtIndex (NFC)Jonas Devlieghere2023-05-044-47/+97
| | | | | | | | | | | Use templates to simplify {Get,Set}PropertyAtIndex. It has always bothered me how cumbersome those calls are when adding new properties. After this patch, SetPropertyAtIndex infers the type from its arguments and GetPropertyAtIndex required a single template argument for the return value. As an added benefit, this enables us to remove a bunch of wrappers from UserSettingsController and OptionValueProperties. Differential revision: https://reviews.llvm.org/D149774
* [lldb] Expose a const iterator for SymbolContextListAlex Langford2023-05-043-3/+7
| | | | | | | | | | | | | | | | | | | | There are many situations where we'll iterate over a SymbolContextList with the pattern: ``` SymbolContextList sc_list; // Fill in sc_list here for (auto i = 0; i < sc_list.GetSize(); i++) { SymbolContext sc; sc_list.GetSymbolAtContext(i, sc); // Do work with sc } ``` Adding an iterator to iterate over the instances directly means we don't have to do bounds checking or create a copy of every element of the SymbolContextList. Differential Revision: https://reviews.llvm.org/D149900
* [LLDB] Add a hook to notify REPLs that an expression was evaluatedwalter erquinigo2023-05-041-0/+18
| | | | | | REPL implementations don't have an easy way to know that an expression has been evaluated, so I'm adding a simple function for that. In the future we can add another hook for meta commands. Differential Revision: https://reviews.llvm.org/D149719
* [lldb] Make some functions useful to REPLs publicwalter erquinigo2023-05-041-6/+13
| | | | | | `StartEventHandlerThread` and `StopEventHandlerThread` are available to the SwiftREPL even though they are protected because SwiftREPL is a friend class of Debugger. I'm developing my own REPL and having access to these functions, including `FlushProcessOutput`, is desirable. Differential Revision: https://reviews.llvm.org/D149717
* [Modules] Move modulemaps to header search directories. NFC intended.Volodymyr Sapsai2023-05-032-142/+142
| | | | | | | | | | | In code we use `#include "llvm/Lib/Header.h"` which is located in "llvm/include/llvm/Lib/Header.h", so we use "llvm/include/" as a header search path. We should put modulemaps in the same directory and shouldn't rely on clang to search in immediate subdirectories. rdar://106677321 Differential Revision: https://reviews.llvm.org/D148776
* Allow scripted thread plans to modify the thread stop description whenJim Ingham2023-05-032-0/+12
| | | | they are completed.
* [lldb] Remove distribution_id from ArchSpecAlex Langford2023-05-032-17/+8
| | | | | | | | | | | | | | | The qHostInfo packet in the gdb-remote communication protocol specifies that distribution_id can be set, so lldb handles that. But we store that in the ArchSpec representing the "Host" platform (whatever platform the debug server is running on). This field is otherwise unused in ArchSpec, so it would be a lot easier if we stored that information at the gdb-remote communication layer. Sidenote: The distribution_id field is currently unused but I did not want to remove it in case some folks found it useful (e.g. in downstream forks). Differential Revision: https://reviews.llvm.org/D149697
* [lldb] Remove FileSpec::GetLastPathComponentAlex Langford2023-05-021-2/+0
| | | | | | | | As far as I can tell, this just computes the filename of the FileSpec, which is already conveniently stored in m_filename. We can use FileSpec::GetFilename() instead. Differential Revision: https://reviews.llvm.org/D149663
* [lldb] Assert on invalid index in OptionValueProperties (NFC)Jonas Devlieghere2023-05-021-2/+2
| | | | | All indexes passed to GetPropertyAtIndex are constants generated by ablegen. We should never pass an invalid index.
* [lldb] Add settings for expression evaluation memory allocations.Ilya Kuklin2023-05-022-0/+8
| | | | | | | | | | Expression evaluation allocates memory for storing intermediate data during evaluation. For it to work properly it has to be allocated within target's available address space, for example within first 0xFFFF bytes for the 16-bit MSP430. The memory for such targets can be very tightly packed, but not all targets support GetMemoryRegionInfo API to pick an unused region, like MSP430 with MSPDebug GDB server. These settings allow the programmer to manually pick precisely where and how much memory to allocate for expression evaluation in order not to overlap with existing data in process memory. Reviewed By: bulbazord Differential Revision: https://reviews.llvm.org/D149262
* [lldb] Make exe_ctx an optional argument in OptionValueProperties (NFC)Jonas Devlieghere2023-05-021-70/+64
| | | | | | The majority of call sites are nullptr as the execution context. Refactor OptionValueProperties to make the argument optional and simplify all the callers.
* [lldb] Add cstdio include to fix a595b931f1f91897317a4257df313bddfeb029a6Dmitry Chernenkov2023-05-021-0/+2
|
* [lldb] Remove unused will_modify argument (NFC)Jonas Devlieghere2023-05-025-20/+18
| | | | | | Various OptionValue related classes are passing around will_modify but the value is never used. This patch simplifies the interfaces by removing the redundant argument.
* [lldb] Refactor OptionValueProperties to return a std::optional (NFC)Jonas Devlieghere2023-05-011-12/+15
| | | | | | | | | Similar to fdbe7c7faa54, refactor OptionValueProperties to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality.
* [lldb] Refactor OptionValue to return a std::optional (NFC)Jonas Devlieghere2023-05-011-15/+8
| | | | | | | | | Refactor OptionValue to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality.
* Re-land "[lldb] Make the libcxx unique_ptr prettyprinter support custom ↵Jorge Gorbe Moya2023-05-011-2/+0
| | | | | | deleters." This reverts commit 45351120105a7257ccb1e38ec1b1f8a452269da2.
* [lldb] Change ObjectValueDictionary to use a StringMapAlex Langford2023-05-011-8/+6
| | | | | | | | | | | | | llvm has a structure for maps where the key's type is a string. Using that also means that the keys for OptionValueDictionary don't stick around forever in ConstString's StringPool (even after they are gone). The only thing we lose here is ordering: iterating over the map where the keys are ConstStrings guarantees that we iterate in alphabetical order. StringMap makes no guarantees about the ordering when you iterate over the entire map. Differential Revision: https://reviews.llvm.org/D149482
* Revert "[lldb] Make the libcxx unique_ptr prettyprinter support custom ↵Jorge Gorbe Moya2023-05-011-0/+2
| | | | | | deleters." This reverts commit d366da97bd24ddfb91c9f260fa0aaf105d947652.
* [lldb] Add debugger.external-editor settingJonas Devlieghere2023-05-012-2/+6
| | | | | | | | Add a new setting (debugger.external-editor) to specify an external editor. The setting takes precedence over the existing LLDB_EXTERNAL_EDITOR environment variable. Differential revision: https://reviews.llvm.org/D149565
* [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.Jorge Gorbe Moya2023-05-011-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The unique_ptr prettyprinter calls `GetValueOfLibCXXCompressedPair`, which looks for a `__value_` child. However, when the second value in the compressed pair is not an empty class, there are two `__value_` children because `__compressed_pair` derives twice from `__compressed_pair_elem`, one for each member of the pair. And then the lookup fails because it's ambiguous. This patch makes the following changes: - Rename `GetValueOfLibCXXCompressedPair` to `GetFirstValueOfLibCXXCompressedPair`, and add a similar function to get the second value. Put both functions in Plugin/Language/CPlusPlus/LibCxx.cpp because it seems inappropriate to have libcxx-specific helpers separate from all the libcxx-dependent code. - Read the second value of the `__ptr_` pair and display a "deleter" child in the unique_ptr synthetic child provider, when available. - Add a test case for the non-empty deleter case. Differential Revision: https://reviews.llvm.org/D148662
* Revert "Host: generalise `GetXcodeSDKPath`"Douglas Yung2023-05-012-26/+5
| | | | | | | | This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9. This breaks the build with GCC and affects at least 2 build bots: https://lab.llvm.org/buildbot/#/builders/217/builds/20568 https://lab.llvm.org/buildbot/#/builders/243/builds/5576
* [lldb] Refactor host::OpenFileInExternalEditorJonas Devlieghere2023-04-281-2/+2
| | | | | | | | | | | | | | | | | | | This patch refactors the macOS implementation of OpenFileInExternalEditor. It fixes an AppleEvent memory leak, the caching of LLDB_EXTERNAL_EDITOR and speculatively fixes a crash when CFURL is NULL (rdar://108633464). The new code also improves error handling, readability and documents calls to the CoreFoundation Launch Services APIs. A bunch of the Launch Services APIs have been deprecated (LSFindApplicationForInfo, LSOpenURLsWithRole). The preferred API is LSOpenCFURLRef but it doesn't specifying the "location" Apple Event which is used to highlight the current line and switching over would regress the existing behavior. rdar://108633464 Differential revision: https://reviews.llvm.org/D149482
* Host: generalise `GetXcodeSDKPath`Saleem Abdulrasool2023-04-282-5/+26
| | | | | | | | | | | | This generalises the GetXcodeSDKPath hook to a GetSDKRoot path which will be re-used for the Windows support to compute a language specific SDK path on the platform. Because there may be other options that we wish to use to compute the SDK path, sink the XcodeSDK parameter into a structure which can pass a disaggregated set of options. Furthermore, optionalise the parameter as Xcode is not available for all platforms. Differential Revision: https://reviews.llvm.org/D149397 Reviewed By: JDevlieghere
* [lldb] Create a way to force remove commandswalter erquinigo2023-04-261-2/+3
| | | | | | Some LLDB set ups need to hide certain commands for security reasons, so I'm adding a flag that allows removing non-user commands. Differential Revision: https://reviews.llvm.org/D149312
* [lldb] Change return type of FileSpec::GetFileNameExtensionAlex Langford2023-04-261-2/+2
| | | | | | | | | | These don't really need to be in ConstStrings. It's nice that comparing ConstStrings is fast (just a pointer comparison) but the cost of creating the ConstString usually already includes the cost of doing a StringRef comparison anyway, so this is just extra work and extra memory consumption for basically no benefit. Differential Revision: https://reviews.llvm.org/D149300