summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/FormatManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Data formatters: Look through array element typedefsJaroslav Sevcik2020-01-101-1/+23
| | | | | | | | | | | | | | | | | Summary: Motivation: When formatting an array of typedefed chars, we would like to display the array as a string. The string formatter currently does not trigger because the formatter lookup does not resolve typedefs for array elements (this behavior is inconsistent with pointers, for those we do look through pointee typedefs). This patch tries to make the array formatter lookup somewhat consistent with the pointer formatter lookup. Reviewers: teemperor, clayborg Reviewed By: teemperor, clayborg Subscribers: clayborg, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D72133
* Remove TypeValidators (NFC in terms of the testsuite)Adrian Prantl2019-12-111-30/+0
| | | | | | | | This is a half-implemented feature that as far as we can tell was never used by anything since its original inclusion in 2014. This patch removes it to make remaining the code easier to understand. Differential Revision: https://reviews.llvm.org/D71310
* [FormatManager] Move Language lookup into the obviously non-cached part (NFC)Adrian Prantl2019-12-101-16/+16
| | | | | | | | | | | | | | This refactoring makes the lookup caching easier to reason about. This has no observable effect although it does slightly change what is being cached. - Before this patch a negative lookup in the LanguageCategory would be cached, but a positive wouldn't. - After this patch LanguageCategory lookups aren't cached by FormatManager, period. (LanguageCategory has its own FormatCache for this!) Differential Revision: https://reviews.llvm.org/D71289
* Do not cache hardcoded formats in FormatManagerAdrian Prantl2019-12-101-12/+18
| | | | | | | | | | | | | | The cache in FormatCache uses only a type name as key. The hardcoded formats, synthetic children, etc inspect an entire ValueObject to determine their eligibility, which isn't modelled in the cache. This leads to bugs such as the one in this patch (where two similarly named types in different files have different hardcoded summary providers). The problem is exaggerated in the Swift language plugin due to the language's dynamic nature. rdar://problem/57756763 Differential Revision: https://reviews.llvm.org/D71233
* Replace redundant code in FormatManager and FormatCache with templates (NFC)Adrian Prantl2019-12-101-245/+36
| | | | | | | | | | | | | | | This is a preparatory patch for an upcoming bugfix. FormatManager and friends have four identical implementations of many accessor functions to deal with the four types of shared pointers in the FormatCache. This patch replaces these implementations with templates. While this patch drastically reduces the amount of source code and its maintainablity, it doesn't actually improve code size. I'd argue, this is still an improvement. rdar://problem/57756763 Differential Revision: https://reviews.llvm.org/D71231
* [FormatManager] GetCandidateLanguages shouldn't know about ValueObject.Davide Italiano2019-12-091-3/+3
| | | | | | | | | | Reviewers: jingham, teemperor, JDevlieghere, aprantl Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71236
* [FormatManager] Provide a single entrypoint for GetCandidateLanguages().Davide Italiano2019-12-091-5/+1
|
* Code cleanup: Change FormattersContainer::KeyType from SP to rvalueJan Kratochvil2019-09-041-6/+3
| | | | | | | | | | | 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
* [FormatManage] Fix the format info orderJonas Devlieghere2019-08-221-2/+3
| | | | | | | The format info entries need to match the order of the enum entries. This should fix the two failing data-formatter tests. llvm-svn: 369617
* [FormatManager] Add static_assert to keep formats in sync.Jonas Devlieghere2019-08-221-1/+5
| | | | | | | | This adds a static assert that ensures that there's a format info entry for every format enum value. This should prevent others from making the same mistake I made and Jason kindly fixed in r369611. (Thanks!) llvm-svn: 369614
* The g_format_infos table needs to be updated in concert with theJason Molenda2019-08-221-0/+1
| | | | | | | | | enum Format entries; else we can crash in a place like FormatManager::GetFormatAsCString(). We should add bounds checks to prevent this more reliably, but for tonight I'm just adding this entry to keep an address-sanitizer test run working. llvm-svn: 369611
* Revert "[CompilerType] Simplify the interface a bit more.."Davide Italiano2019-08-061-8/+12
| | | | | | | | There's actually a test downstream that fails with this. I think we can still get rid of it, but I need to do some work there first. llvm-svn: 367963
* [CompilerType] Simplify the interface a bit more..Davide Italiano2019-08-061-12/+8
| | | | | | | | | | | | | | | | | | | | | | Summary: .. removing IsMeaninglessWithoutTypeResolution(). I'm fairly confident this was introduced to support swift, where static types [without dynamic counterpart] don't carry a lot of value. Since then, the formatters and dynamic type resolution has been rewritten, and we employ different solutions. This function is unused here too, so let's get read of it. <rdar://problem/36377967> Reviewers: shafik, JDevlieghere, alex, compnerd, teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65782 llvm-svn: 367957
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-241-88/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* [lldb] NFC modernize codebase with modernize-use-nullptrKonrad Kleine2019-05-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [DataFormatters] Remove LLDB_DISABLE_PYTHON from FormatManager.Davide Italiano2019-03-151-6/+0
| | | | | | And DataVisualization. One step closer. llvm-svn: 356225
* [DataFormatters] Delete unused code. Not even exposed in the API.Davide Italiano2019-03-141-14/+0
| | | | | | | I stumbled upon this while removing LLDB_DISABLE_PYTHON when not needed. llvm-svn: 356176
* Pass ConstString by value (NFC)Adrian Prantl2019-03-061-2/+2
| | | | | | | | | | | | | | | | | My apologies for the large patch. With the exception of ConstString.h itself it was entirely produced by sed. ConstString has exactly one const char * data member, so passing a ConstString by reference is not any more efficient than copying it by value. In both cases a single pointer is passed. But passing it by value makes it harder to accidentally return the address of a local object. (This fixes rdar://problem/48640859 for the Apple folks) Differential Revision: https://reviews.llvm.org/D59030 llvm-svn: 355553
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* Simplify Boolean expressionsJonas Devlieghere2018-12-151-7/+7
| | | | | | | | | | | 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
* Remove header grouping comments.Jonas Devlieghere2018-11-111-4/+0
| | | | | | | | 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
* Reflow paragraphs in comments.Adrian Prantl2018-04-301-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
* Move Log from Core -> Utility.Zachary Turner2017-03-031-1/+1
| | | | | | | | | All references to Host and Core have been removed, so this class can now safely be lowered into Utility. Differential Revision: https://reviews.llvm.org/D30559 llvm-svn: 296909
* Clean up debug loggingPavel Labath2017-02-131-36/+20
| | | | | | | | | | | | | | | | | | | | | Summary: We've had two ways to print a "debug" log message. - Log::GetDebug() was testing a Stream flag which was never set. - Log::Debug() was checking for the presence of "log enable --debug" flag. Given that these two were used very rarely and we already have a different way to specify "I want a more verbose log", I propose to remove these two functions and migrate the callers to LLDB_LOGV. This commit does that. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D29823 llvm-svn: 294939
* Don't allow direct access to StreamString's internal buffer.Zachary Turner2016-11-161-3/+2
| | | | | | | | | | | | | | | This is a large API change that removes the two functions from StreamString that return a std::string& and a const std::string&, and instead provide one function which returns a StringRef. Direct access to the underlying buffer violates the concept of a "stream" which is intended to provide forward only access, and makes porting to llvm::raw_ostream more difficult in the future. Differential Revision: https://reviews.llvm.org/D26698 llvm-svn: 287152
* Make lldb::Regex use StringRef.Zachary Turner2016-09-211-2/+2
| | | | | | | | | | 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
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-1036/+920
| | | | | | | | | | | | | | | | | | | | | | | *** 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
* remove use of Mutex in favour of std::{,recursive_}mutexSaleem Abdulrasool2016-05-181-18/+18
| | | | | | | | | | This is a pretty straightforward first pass over removing a number of uses of Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there are interfaces which take Mutex::Locker & to lock internal locks. This patch cleans up most of the easy cases. The only non-trivial change is in CommandObjectTarget.cpp where a Mutex::Locker was split into two. llvm-svn: 269877
* Fix a bug where language categories would hold on to their caches even after ↵Enrico Granata2015-12-151-4/+16
| | | | | | changes llvm-svn: 255603
* Reapply r253423 and r253424 (which cleanup the data formatters iteration ↵Enrico Granata2015-11-181-15/+0
| | | | | | model, as well as the type X list commands), along with a change by Zachary Turner to bypass a MSVC bug with SFINAE llvm-svn: 253493
* Revert 2 commits breaking the MSVC buildTamas Berghammer2015-11-181-0/+15
| | | | | | | | | | Revert "Remove a few vestigial typedefs from the old world" This reverts commit 05872cda2a00fbd988c4fc761b1f87fe9edce224. Revert "Cleanup the type X list commands to use the new ForEach goodness" This reverts commit 85b1d83819a22cdc9ef12f58fd4fa92b473a4f81. llvm-svn: 253455
* Cleanup the type X list commands to use the new ForEach goodnessEnrico Granata2015-11-181-15/+0
| | | | llvm-svn: 253423
* The existing logic to loop over formatters is very pre-C++11, using void* ↵Enrico Granata2015-11-141-0/+15
| | | | | | | | | batons, and function pointers, and raw memory allocations instead of safer more modern constructs This is a first pass at a cleanup of that code, modernizing the "type X clear" commands, and providing the basic infrastructure I plan to use all over More cleanup will come over the next few days llvm-svn: 253125
* Extend the TypeSystem's ShouldPrintAsOneLiner implementation so that the ↵Enrico Granata2015-11-091-1/+18
| | | | | | ValueObject itself also gets a say in the process; NFC llvm-svn: 252516
* Rationalization of includes in the data formatters codeEnrico Granata2015-10-201-4/+3
| | | | llvm-svn: 250798
* Introduce the concept of a type that is meaningless without dynamic ↵Enrico Granata2015-10-201-18/+12
| | | | | | | | resolution, which are essentially placeholder types meant to appease a language's type system but do not offer any actual information to the debugger, unless further resolved This is currently meant for data formatters to know to ignore such types in caching and lookup llvm-svn: 250767
* Resubmit: RenderScript command for printing allocation contents Ewan Crawford2015-10-161-0/+2
| | | | | | | | | Previous commit r250281 broke TestDataFormatterSmartArray.py Resolved in in this patch by adding the new enum eFormatVectorOfFloat16 to FormatManager. Differential Revision: http://reviews.llvm.org/D13730 llvm-svn: 250499
* Create a logging category that is specific to data formatters activityEnrico Granata2015-10-061-4/+4
| | | | llvm-svn: 249433
* Introduce a FormattersMatchData class which contains all the information ↵Enrico Granata2015-10-061-68/+60
| | | | | | | | that data formatters need in one place, and also allows for lazy computation of expensive chunks of information if need be This is a NFC commit that is essentially plumbing the new currency through the system llvm-svn: 249366
* Fix covered-switch-default warning in FormatManager.Bruce Mitchener2015-09-231-1/+0
| | | | | | | | | | | | | | | | Summary: The default case doesn't need to be here as the switch covers all possible values. If there's a new "lazy bool" value added in the future, the compiler would start to warn about the new case not being covered. Reviewers: granata.enrico, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13084 llvm-svn: 248365
* Allow CompilerType to express a vote on whether oneliner printing should happenEnrico Granata2015-09-231-0/+17
| | | | llvm-svn: 248363
* Add {TypeSystem|CompilerType}::GetTypeForFormatters()Enrico Granata2015-09-231-1/+1
| | | | | | | | | Different type system may have different notions of attributes of a type that do not matter for data formatters matching purposes For instance, in the case of clang types, we remove some qualifiers (e.g. "volatile") as it doesn't make much sense to differentiate volatile T from T in the data formatters This new API allows each type system to generate, if needed, a type that does not have those unwanted attributes that the data formatters can then consume to generate matches llvm-svn: 248359
* TypeSystem is now a plugin interface and removed any "ClangASTContext ↵Greg Clayton2015-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | &Class::GetClangASTContext()" functions. This cleans up type systems to be more pluggable. Prior to this we had issues: - Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()" - Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem - Cleaned up Module so that it no longer has dedicated type system member variables: lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module. lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module. Now we have a type system map: typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap; TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module - Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract: class CompilerType { ... //---------------------------------------------------------------------- // Return a new CompilerType that is a L value reference to this type if // this type is valid and the type system supports L value references, // else return an invalid type. //---------------------------------------------------------------------- CompilerType GetLValueReferenceType () const; //---------------------------------------------------------------------- // Return a new CompilerType that is a R value reference to this type if // this type is valid and the type system supports R value references, // else return an invalid type. //---------------------------------------------------------------------- CompilerType GetRValueReferenceType () const; //---------------------------------------------------------------------- // Return a new CompilerType adds a const modifier to this type if // this type is valid and the type system supports const modifiers, // else return an invalid type. //---------------------------------------------------------------------- CompilerType AddConstModifier () const; //---------------------------------------------------------------------- // Return a new CompilerType adds a volatile modifier to this type if // this type is valid and the type system supports volatile modifiers, // else return an invalid type. //---------------------------------------------------------------------- CompilerType AddVolatileModifier () const; //---------------------------------------------------------------------- // Return a new CompilerType adds a restrict modifier to this type if // this type is valid and the type system supports restrict modifiers, // else return an invalid type. //---------------------------------------------------------------------- CompilerType AddRestrictModifier () const; //---------------------------------------------------------------------- // Create a typedef to this type using "name" as the name of the typedef // this type is valid and the type system supports typedefs, else return // an invalid type. //---------------------------------------------------------------------- CompilerType CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const; }; Other changes include: - Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);" - Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed llvm-svn: 247953
* DataFormatters: Rename clang_type to compiler_type.Bruce Mitchener2015-09-171-15/+15
| | | | | | | | | | Reviewers: granata.enrico Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D12930 llvm-svn: 247915
* Add the ability for formatter categories to be bound to one or more languagesEnrico Granata2015-09-171-2/+2
| | | | | | What that does is it restricts formatters in those categories to only match to types coming from "compatible" source languages llvm-svn: 247872
* Move hardcoded formatters from the FormatManager to the Language pluginsEnrico Granata2015-09-161-91/+41
| | | | llvm-svn: 247831
* Move Objective-C data formatters to the Objective-C language plugin where ↵Enrico Granata2015-09-141-314/+6
| | | | | | they belong llvm-svn: 247627
* Introduce the notion of an escape helper. Different languages have different ↵Enrico Granata2015-09-091-0/+6
| | | | | | | | notion of what to print in a string and how to escape non-printable things. The escape helper is where this notion is provided to LLDB This is NFC, other than a code re-org llvm-svn: 247200
* Data formatter candidate matches can be generated in a number of ways; ↵Enrico Granata2015-09-091-31/+12
| | | | | | | | | | language-based dynamic type discovery being one of them (for instance, this is what takes an 'id' and discovers that it truly is an __NSArrayI, so it should probably use the NSArray formatter) This used to be hardcoded in the FormatManager, but in a pluginized world that is not the right way to go So, move this step to the Language plugin such that appropriate language plugins for a type get a say about adding candidates to the formatters lookup tables llvm-svn: 247112
* Move the C++ data formatters to the C++ language pluginEnrico Granata2015-09-041-186/+34
| | | | llvm-svn: 246873
OpenPOWER on IntegriCloud