summaryrefslogtreecommitdiff
path: root/lldb/source/DataFormatters/FormattersHelpers.cpp
AgeCommit message (Collapse)Author
2025-06-02[lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)Pavel Labath
The problem was in calling GetLoadAddress on a value in the error state, where `ValueObject::GetLoadAddress` could end up accessing the uninitialized "address type" by-ref return value from `GetAddressOf`. This probably happened because each function expected the other to initialize it. We can guarantee initialization by turning this into a proper return value. I've added a test, but it only (reliably) crashes if lldb is built with ubsan.
2025-05-08[lldb][DataFormatters] Change ExtractIndexFromString to return std::optional ↵Charles Zablit
(#138297) This PR is in continuation of https://github.com/llvm/llvm-project/pull/136693.
2023-05-01Re-land "[lldb] Make the libcxx unique_ptr prettyprinter support custom ↵Jorge Gorbe Moya
deleters." This reverts commit 45351120105a7257ccb1e38ec1b1f8a452269da2.
2023-05-01Revert "[lldb] Make the libcxx unique_ptr prettyprinter support custom ↵Jorge Gorbe Moya
deleters." This reverts commit d366da97bd24ddfb91c9f260fa0aaf105d947652.
2023-05-01[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.Jorge Gorbe Moya
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
2023-04-12[lldb] Change formatter helper function parameter list to remove ConstStringAlex Langford
All of these functions take a ConstString for the type_name, but this isn't really needed for two reasons: 1.) This parameter is always constructed from a static c-string constant. 2.) They are passed along to to `AddTypeSummary` as a StringRef anyway. Differential Revision: https://reviews.llvm.org/D148050
2022-10-10[NFCI] More TypeCategoryImpl refactoring.Jorge Gorbe Moya
The main aim of this patch is to delete the remaining instances of code reaching into the internals of `TypeCategoryImpl`. I made the following changes: - Add some more methods to `TieredFormatterContainer` and `TypeCategoryImpl` to expose functionality that is implemented in `FormattersContainer`. - Add new overloads of `TypeCategoryImpl::AddTypeXXX` to make it easier to add formatters to categories without reaching into the internal `FormattersContainer` objects. - Remove the `GetTypeXXXContainer` and `GetRegexTypeXXXContainer` accessors from `TypeCategoryImpl` and update all call sites to use the new methods instead. Differential Revision: https://reviews.llvm.org/D135399
2021-11-18[lldb] (Partially) enable formatting of utf strings before the program is ↵Pavel Labath
started The StringPrinter class was using a Process instance to read memory. This automatically prevented it from working before starting the program. This patch changes the class to use the Target object for reading memory, as targets are always available. This required moving ReadStringFromMemory from Process to Target. This is sufficient to make frame/target variable work, but further changes are necessary for the expression evaluator. Preliminary analysis indicates the failures are due to the expression result ValueObjects failing to provide an address, presumably because we're operating on file addresses before starting. I haven't looked into what would it take to make that work. Differential Revision: https://reviews.llvm.org/D113098
2020-03-23[DataFormatters] Add formatter for libc++ std::unique_ptrshafik
This adds a formatter for libc++ std::unique_ptr. I also refactored GetValueOfCompressedPair(...) out of LibCxxList.cpp since I need the same functionality and it made sense to share it. Differential Revision: https://reviews.llvm.org/D76476
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-09-04Code cleanup: Change FormattersContainer::KeyType from SP to rvalueJan Kratochvil
There is now std::shared_ptr passed around which is expensive for manycore CPUs. Most of the times (except for 3 cases) it is now just std::moved with no CPU locks needed. It also makes it possible to sort the keys (which is now not needed much after D66398). Differential revision: https://reviews.llvm.org/D67049 llvm-svn: 370863
2019-05-23[lldb] NFC modernize codebase with modernize-use-nullptrKonrad Kleine
Summary: NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]] This commit is the result of modernizing the LLDB codebase by using `nullptr` instread of `0` or `NULL`. See https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html for more information. This is the command I ran and I to fix and format the code base: ``` run-clang-tidy.py \ -header-filter='.*' \ -checks='-*,modernize-use-nullptr' \ -fix ~/dev/llvm-project/lldb/.* \ -format \ -style LLVM \ -p ~/llvm-builds/debug-ninja-gcc ``` NOTE: There were also changes to `llvm/utils/unittest` but I did not include them because I felt that maybe this library shall be updated in isolation somehow. NOTE: I know this is a rather large commit but it is a nobrainer in most parts. Reviewers: martong, espindola, shafik, #lldb, JDevlieghere Reviewed By: JDevlieghere Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits Tags: #lldb, #llvm Differential Revision: https://reviews.llvm.org/D61847 llvm-svn: 361484
2019-03-14[Python] Start eradicating unneeded LLDB_DISABLE_PYTHON guards.Davide Italiano
While we don't have a bot, I'm testing by hand that this configuration compiles. We'll probably set up one once I'm done flensing. llvm-svn: 356171
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
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
2017-02-02Move classes from Core -> Utility.Zachary Turner
This moves the following classes from Core -> Utility. ConstString Error RegularExpression Stream StreamString The goal here is to get lldbUtility into a state where it has no dependendencies except on itself and LLVM, so it can be the starting point at which to start untangling LLDB's dependencies. These are all low level and very widely used classes, and previously lldbUtility had dependencies up to lldbCore in order to use these classes. So moving then down to lldbUtility makes sense from both the short term and long term perspective in solving this problem. Differential Revision: https://reviews.llvm.org/D29427 llvm-svn: 293941
2016-09-21Make lldb::Regex use StringRef.Zachary Turner
This updates getters and setters to use StringRef instead of const char *. I tested the build on Linux, Windows, and OSX and saw no build or test failures. I cannot test any BSD or Android variants, however I expect the required changes to be minimal or non-existant. llvm-svn: 282079
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
2016-04-08Remove even more of the data formatters that silently run codeEnrico Granata
Fixes <rdar://problem/25629755> llvm-svn: 265849
2016-03-12This change introduces a "ExpressionExecutionThread" to the ThreadList. Jim Ingham
Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on behalf of the expression parser was using the currently selected thread. But sometimes, e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread we're running on, we instead set the context for the interpreter, and explicitly pass that to other callers. That wasn't getting communicated to these utility expressions, so they would run on some other thread instead, and that could cause a variety of subtle and hard to reproduce problems. I also went through the commands and cleaned up the use of GetSelectedThread. All those uses should have been trying the thread in the m_exe_ctx belonging to the command object first. It would actually have been pretty hard to get misbehavior in these cases, but for correctness sake it is good to make this usage consistent. <rdar://problem/24978569> llvm-svn: 263326
2015-11-13Upstream some data formatter related cleanupsEnrico Granata
llvm-svn: 253093
2015-10-20Rationalization of includes in the data formatters codeEnrico Granata
llvm-svn: 250798
2015-10-07Introduce a variant of GetSummaryAsCString() that takes a LanguageType ↵Enrico Granata
argument, and use it when crafting summaries by running selectors This is the first in a series of commits that are meant to teach LLDB how to properly handle multi-language formatting of values llvm-svn: 249503
2015-09-25Fix evaluation of unicode character arrays (char16_t[] and char32_t[])Dawn Perchik
Suppose we have the UTF-16 string: char16_t[] s = u"hello"; Before this patch, evaluating the string in lldb would get: (char16_t [6]) $0 = ([0] = U+0068 u'h', [1] = U+0065 u'e', [2] = U+006c u'l', [3] = U+006c u'l', [4] = U+006f u'o', [5] = U+0000 u'\0') After applying the patch, we now get: (char16_t [6]) $0 = u"hello" Patch from evgeny.leviant@gmail.com Reviewed by: granata.enrico Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13053 llvm-svn: 248555
2015-09-17Add the ability for formatter categories to be bound to one or more languagesEnrico Granata
What that does is it restricts formatters in those categories to only match to types coming from "compatible" source languages llvm-svn: 247872
2015-09-04Nuke CXXFormatterFunctions.cpp - split the contents of it across different ↵Enrico Granata
files, so that things are better organized along the C++/ObjC line This is preparatory work for moving these formatters into language categories llvm-svn: 246827
2015-09-02Move the functions that FormatManager uses to actually load formatters into ↵Enrico Granata
their own file These are useful helpers over the low-level API of the FormattersContainer, and since we're actually going to start moving formatters into plugins, it makes sense to simplify things llvm-svn: 246612