summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Expression
Commit message (Collapse)AuthorAgeFilesLines
* Fix a buffer-size bug when the first DW_OP_piece is undefinedAdrian Prantl2020-02-191-0/+5
| | | | | | | | | | | | | | and document the shortcomings of LLDB's partially defined DW_OP_piece handling. This would manifest as "DW_OP_piece for offset foo but top of stack is of size bar". rdar://problem/46262998 Differential Revision: https://reviews.llvm.org/D72880 (cherry picked from commit f55ab6f90b7317a6bb85303a6102702bdae1199e)
* Add testing for DW_OP_piece and fix a bug with small Scalar values.Adrian Prantl2020-02-191-1/+22
| | | | | | | | | | | | By switching to Scalars that are backed by explicitly-sized APInts we can avoid a bug that increases the buffer reserved for a small piece to the next-largest host integer type. This manifests as "DW_OP_piece for offset foo but top of stack is of size bar". Differential Revision: https://reviews.llvm.org/D72879 (cherry picked from commit 7b0d58e339b271e3b1d9dc14b781b57fa0262e3a)
* [lldb] Add a SubsystemRAII that takes care of calling Initialize and ↵Raphael Isemann2019-12-234-29/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Terminate in the unit tests Summary: Many of our tests need to initialize certain subsystems/plugins of LLDB such as `FileSystem` or `HostInfo` by calling their static `Initialize` functions before the test starts and then calling `::Terminate` after the test is done (in reverse order). This adds a lot of error-prone boilerplate code to our testing code. This patch adds a RAII called SubsystemRAII that ensures that we always call ::Initialize and then call ::Terminate after the test is done (and that the Terminate calls are always in the reverse order of the ::Initialize calls). It also gets rid of all of the boilerplate that we had for these calls. Per-fixture initialization is still not very nice with this approach as it would require some kind of static unique_ptr that gets manually assigned/reseted from the gtest SetUpTestCase/TearDownTestCase functions. Because of that I changed all per-fixture setup to now do per-test setup which can be done by just having the SubsystemRAII as a member of the test fixture. This change doesn't influence our normal test runtime as LIT anyway runs each test case separately (and the Initialize/Terminate calls are anyway not very expensive). It will however make running all tests in a single executable slightly slower. Reviewers: labath, JDevlieghere, martong, espindola, shafik Reviewed By: labath Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71630
* [lldb][NFC] Return a reference from ClangASTContext::getASTContext and ↵Raphael Isemann2019-12-211-1/+1
| | | | | | | | | | | remove dead nullptr checks ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a while that the ASTContext is not a nullptr. This causes that we still have a lot of code that is doing nullptr checks on the result of getASTContext() which is all unreachable code. This patch changes the return value to a reference to make it clear this can't be a nullptr and deletes all the nullptr checks.
* [lldb][NFC] Remove all ASTContext getter wrappers from ClangASTContextRaphael Isemann2019-12-211-1/+1
| | | | | | | | | | | | Their naming is misleading as they only return the ClangASTContext-owned variables. For ClangASTContext instances constructed for a given clang::ASTContext they silently generated duplicated instances (e.g., a second IdentifierTable) that were essentially unusable. This removes all these getters as they are anyway not very useful in comparison to just calling the clang::ASTContext getters. The initialization code has been moved to the CreateASTContext initialization method so that all code for making our own clang::ASTContext is in one place.
* [lldb][NFC] Remove redundant ASTContext args to CopyDecl/DeportDeclRaphael Isemann2019-12-201-5/+1
| | | | | | We already pass a Decl here and the additional ASTContext needs to match the Decl. We might as well just pass the Decl and then extract the ASTContext from that.
* [lldb][NFC] Move utility functions from ClangASTImporter and ↵Raphael Isemann2019-12-201-20/+7
| | | | ClangExpressionDeclMap to own header
* [lldb][NFC] Add unit test for persistent variable lookup with ↵Raphael Isemann2019-12-181-13/+100
| | | | | | | | | ClangExpressionDeclMap This adds a unit test for looking up persistent declarations in the scratch AST context. Also adds the `GetPersistentDecl` hook to the ClangExpressionDeclMap that this unit test can emulate looking up persistent variables without having a lldb_private::Target.
* [lldb][NFC] Allow creating ClangExpressionDeclMap and ClangASTSource without ↵Raphael Isemann2019-12-172-0/+60
| | | | | | | | | | a Target and add basic unit test The ClangExpressionDeclMap should be testable from a unit test. This is currently impossible as they have both dependencies on Target/ExecutionContext from their constructor. This patch allows constructing these classes without an active Target and adds the missing tests for running without a target that we can do at least a basic lookup test without crashing.
* whitespace cleanupAdrian Prantl2019-10-211-1/+1
| | | | llvm-svn: 375465
* Factor out common test functionality into a helper class. (NFC)Adrian Prantl2019-10-211-81/+91
| | | | llvm-svn: 375464
* [lldb][NFC] Use unique_ptr in DiagnosticManager to express ownershipRaphael Isemann2019-10-101-28/+44
| | | | llvm-svn: 374289
* [lldb] Also force posix paths in CppModuleConfigurationTestRaphael Isemann2019-09-241-1/+1
| | | | llvm-svn: 372737
* [lldb] Decouple importing the std C++ module from the way the program is ↵Raphael Isemann2019-09-242-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compiled Summary: At the moment, when trying to import the `std` module in LLDB, we look at the imported modules used in the compiled program and try to infer the Clang configuration we need from the DWARF module-import. That was the initial idea but turned out to cause a few problems or inconveniences: * It requires that users compile their programs with C++ modules. Given how experimental C++ modules are makes this feature inaccessible for many users. Also it means that people can't just get the benefits of this feature for free when we activate it by default (and we can't just close all the associated bug reports). * Relying on DWARF's imported module tags (that are only emitted by default on macOS) means this can only be used when using DWARF (and with -glldb on Linux). * We essentially hardcoded the C standard library paths on some platforms (Linux) or just couldn't support this feature on other platforms (macOS). This patch drops the whole idea of looking at the imported module DWARF tags and instead just uses the support files of the compilation unit. If we look at the support files and see file paths that indicate where the C standard library and libc++ are, we can just create the module configuration this information. This fixes all the problems above which means we can enable all the tests now on Linux, macOS and with other debug information than what we currently had. The only debug information specific code is now the iteration over external type module when -gmodules is used (as `std` and also the `Darwin` module are their own external type module with their own files). The meat of this patch is the CppModuleConfiguration which looks at the file paths from the compilation unit and then figures out the include paths based on those paths. It's quite conservative in that it only enables modules if we find a single C library and single libc++ library. It's still missing some test mode where we try to compile an expression before we actually activate the config for the user (which probably also needs some caching mechanism), but for now it works and makes the feature usable. Reviewers: aprantl, shafik, jdoerfert Reviewed By: aprantl Subscribers: mgorny, abidh, JDevlieghere, lldb-commits Tags: #c_modules_in_lldb, #lldb Differential Revision: https://reviews.llvm.org/D67760 llvm-svn: 372716
* [lldb][NFC] Sort files in unittests/Expression/CMakeLists.txtRaphael Isemann2019-09-111-1/+1
| | | | llvm-svn: 371614
* Implement DW_OP_convertAdrian Prantl2019-09-101-4/+290
| | | | | | | | | | | | | | | | | | | | | | This patch adds basic support for DW_OP_convert[1] for integer types. Recent versions of LLVM's optimizer may insert this opcode into DWARF expressions. DW_OP_convert is effectively a type cast operation that takes a reference to a base type DIE (or zero) and then casts the value at the top of the DWARF stack to that type. Internally this works by changing the bit size of the APInt that is used as backing storage for LLDB's DWARF stack. I managed to write a unit test for this by implementing a mock YAML object file / module that takes debug info sections in yaml2obj format. [1] Typed DWARF stack. http://www.dwarfstd.org/ShowIssue.php?issue=140425.1 <rdar://problem/48167864> Differential Revision: https://reviews.llvm.org/D67369 llvm-svn: 371532
* DWARFExpression: Simplify class interfacePavel Labath2019-08-271-2/+2
| | | | | | | | | | | | | | | | | Summary: The DWARFExpression methods have a lot of arguments. This removes two of them by removing the ability to slice the expression via two offset+size parameters. This is a functionality that it is not always needed, and when it is, we already have a different handy way of slicing a data extractor which we can use instead. Reviewers: JDevlieghere, clayborg Subscribers: aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D66745 llvm-svn: 370027
* [lldb][NFC] Add unit test for lldb_private::DiagnosticManagerRaphael Isemann2019-08-122-0/+195
| | | | llvm-svn: 368567
* DWARFExpression: Fix implementation of DW_OP_pickPavel Labath2019-04-292-0/+44
| | | | | | | | | | | | | | | | | | | | | | Summary: The DWARF spec states that the DWARF stack arguments are numbered from the top. Our implementation of DW_OP_pick was counting them from the bottom. This bug probably wasn't noticed because nobody (except my upcoming postfix-to-DWARF converter) uses DW_OP_pick, but I've cross-checked with gdb to confirm that counting from the top is the expected behavior. This patch fixes the implementation to match the spec and gdb behavior and adds a test. Reviewers: jasonmolenda, clayborg Subscribers: mgorny, aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D61182 llvm-svn: 359436
* [ExpressionParser] Add swift-lldb case for finding clang resource dirAlex Langford2019-03-261-3/+2
| | | | | | | | | | | | | | Summary: I'm adding this to reduce the difference between swift-lldb and llvm.org's lldb. Reviewers: aprantl, davide, compnerd, JDevlieghere, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D59708 llvm-svn: 357030
* [ExpressionParser] Implement ComputeClangResourceDir for WindowsAlex Langford2019-03-071-2/+5
| | | | | | | | | | | | | | | | Summary: This function is useful for expression evaluation, especially when doing swift debugging on windows. Reviewers: aprantl, labath Reviewed By: labath Subscribers: teemperor, jdoerfert, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D59072 llvm-svn: 355631
* [ExpressionParser] Test GetClangResourceDirAlex Langford2019-03-061-12/+27
| | | | | | | | | | | | | Summary: I'm doing this because I plan on implementing `ComputeClangResourceDirectory` on windows so that `GetClangResourceDir` will work. Additionally, I made test_paths make sure that the directory member of the returned FileSpec is not none. This will fail on windows since `ComputeClangResourceDirectory` isn't implemented yet. Differential Revision: https://reviews.llvm.org/D58748 llvm-svn: 355463
* 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
* Remove Go debugger pluginJonas Devlieghere2018-11-052-275/+0
| | | | | | | | | | | | | | | | | | | In January Davide sent an e-mail to the mailing list to suggest removing unmaintained language plugins such as Go and Java. The plan was to have some cool down period to allow users to speak up, however after that the plugins were never actually removed. This patch removes the Go debugger plugin. The plugin can be added again in the future if it is mature enough both in terms of testing and maintenance commitment. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html Differential revision: https://reviews.llvm.org/D54057 llvm-svn: 346157
* [FileSystem] Move path resolution logic out of FileSpecJonas Devlieghere2018-11-011-1/+1
| | | | | | | | | 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
* [FileSystem] Extend file system and have it use the VFS.Jonas Devlieghere2018-10-311-2/+9
| | | | | | | | | | | | | | | | This patch extends the FileSystem class with a bunch of functions that are currently implemented as methods of the FileSpec class. These methods will be removed in future commits and replaced by calls to the file system. The new functions are operated in terms of the virtual file system which was recently moved from clang into LLVM so it could be reused in lldb. Because the VFS is stateful, we turned the FileSystem class into a singleton. Differential revision: https://reviews.llvm.org/D53532 llvm-svn: 345783
* Really fix ClangParserTestPavel Labath2018-06-051-1/+9
| | | | | | | It turns out the test needs a fixture after all (to initialize HostInfo), so provide one that does that. llvm-svn: 334003
* Fix ClangParserTest.cppPavel Labath2018-06-051-1/+1
| | | | | | | The test does not use a test fixture, so it needs to be declared with the TEST macro. llvm-svn: 333992
* Fix Expression unittests on DarwinJonas Devlieghere2018-06-052-1/+4
| | | | | | Fixes the Expression unittests on Darwin after r333933 was landed. llvm-svn: 333974
* Remove dependency from Host to clang.Zachary Turner2018-06-042-0/+66
| | | | | | | | | | Host depended on clang because HostInfo had a function to get the directory where clang was installed. We move this over to the clang expression parser plugin where it's more at home. Differential Revision: https://reviews.llvm.org/D47384 llvm-svn: 333933
* Rename Error -> Status.Zachary Turner2017-05-121-2/+2
| | | | | | | | | | | | | | | This renames the LLDB error class to Status, as discussed on the lldb-dev mailing list. A change of this magnitude cannot easily be done without find and replace, but that has potential to catch unwanted occurrences of common strings such as "Error". Every effort was made to find all the obvious things such as the word "Error" appearing in a string, etc, but it's possible there are still some lingering occurences left around. Hopefully nothing too serious. llvm-svn: 302872
* [Windows] Remove the #include <eh.h> hack.Zachary Turner2017-03-031-7/+0
| | | | | | | | | | Prior to MSVC 2015 we had to manually include this header any time we were going to include <thread> or <future> due to a bug in MSVC's STL implementation. This has been fixed in MSVC for some time now, and we require VS 2015 minimum, so we can remove this across all subprojects. llvm-svn: 296906
* Move classes from Core -> Utility.Zachary Turner2017-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* [CMake] Update unit tests with accurate dependenciesChris Bieneman2017-02-011-0/+4
| | | | | | This is extending the updates from r293696 to the LLDB unit tests. llvm-svn: 293821
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-202/+232
| | | | | | | | | | | | | | | | | | | | | | | *** 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
* Fix build for go parser unittest.Ryan Brown2015-11-031-1/+1
| | | | llvm-svn: 252007
* Create an expression parser for Go.Ryan Brown2015-11-022-0/+253
The Go interpreter doesn't JIT or use LLVM, so this also moves all the JIT related code from UserExpression to a new class LLVMUserExpression. Differential Revision: http://reviews.llvm.org/D13073 Fix merge llvm-svn: 251820
OpenPOWER on IntegriCloud