summaryrefslogtreecommitdiffstats
path: root/lldb/source
Commit message (Collapse)AuthorAgeFilesLines
* build: reduce CMake handling for zlibSaleem Abdulrasool2020-01-012-3/+3
| | | | | | | | | Rather than handling zlib handling manually, use `find_package` from CMake to find zlib properly. Use this to normalize the `LLVM_ENABLE_ZLIB`, `HAVE_ZLIB`, `HAVE_ZLIB_H`. Furthermore, require zlib if `LLVM_ENABLE_ZLIB` is set to `YES`, which requires the distributor to explicitly select whether zlib is enabled or not. This simplifies the CMake handling and usage in the rest of the tooling.
* [lldb][NFC] Simplify CompilerType constructors/destructors and fix unused ↵Raphael Isemann2020-01-012-8/+0
| | | | | | | | | variable warning CompilerType has no virtual functions and no statements in its constructors, so we can simplify this code. This also allows Clang to emit unused variable warnings for CompilerType, so I also removed one unused variable that otherwise causes -Werror builds to fail.
* [NFC] Fixes -Wrange-loop-analysis warningsMark de Wever2020-01-013-3/+3
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71857
* [lldb][NFC] Make some checks more readable in Variable::PrivateAutoCompleteRaphael Isemann2020-01-011-3/+3
|
* [lldb][NFC] Simplify ClangASTContext::GetTypeForDeclRaphael Isemann2019-12-302-20/+9
| | | | Also removes the GetASTContext call from this code.
* [lldb][NFC] Make integer types functions in ClangASTContext not staticRaphael Isemann2019-12-291-45/+32
| | | | | | These functions need a ClangASTContext instance that we would otherwise recalculate by calling GetASTContext (which is no longer necessary with this patch).
* [lldb][NFC] Delete static versions of ClangASTContext::CreateFunctionTypeRaphael Isemann2019-12-292-12/+12
| | | | We can always call the member function version of this function.
* [lldb][NFC] Remove most GetASTContext calls in AST metadata codeRaphael Isemann2019-12-292-25/+18
|
* [lldb][NFC] Remove GetASTContext call in ClangPersistentVariablesRaphael Isemann2019-12-283-27/+36
| | | | | | | | We try to build a CompilerType from the persistent decls so we need a ClangASTContext. With this patch the ClangPersistentVariables store the associated ClangASTContext of the persistent decls (which is always the scratch ClangASTContext) and no longer call GetASTContext to map back from clang::ASTContext to ClangASTContext.
* [lldb][NFC] Remove GetASTContext call in ClangDeclVendorRaphael Isemann2019-12-285-22/+20
| | | | | | | | Instead of returning NamedDecls and then calling GetASTContext to find back the ClangASTContext we used can just implement the FindDecl variant that returns CompilerDecls (and implement the other function by throwing away the ClangASTContext part of the compiler decl).
* [lldb][NFC] Move lock scope where it should beginTatyana Krasnukha2019-12-261-9/+10
|
* [lldb][NFC] Use ClangASTContext in AppleObjCRuntime interfacesRaphael Isemann2019-12-265-61/+46
| | | | | | | This code actually needs a ClangASTContext but instead takes a clang::ASTContext and then retrieves the original ClangASTContext via the global map of ClangASTContexts. Let's change it so that it takes a ClangASTContext which is simpler and faster.
* [lldb] Remove some calls to GetASTContextRaphael Isemann2019-12-263-36/+21
| | | | | | | GetASTContext is really expensive to call as it makes use of the global mapping from ASTContext to ClangASTContext. This replaces all calls where we already have the ClangASTContext around and don't need to call GetASTContext again.
* [lldb][NFC] Use StringRef in ↵Raphael Isemann2019-12-252-46/+40
| | | | ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize
* [lldb] Adapt for NetBSD-9.99.30 ptrace(2) API changesKamil Rytarowski2019-12-242-2/+21
| | | | | | | | Switch from PT_LWPINFO to PT_LWPSTATUS/PT_LWPNEXT. Keep compat support for < 9.99.30. No functional change intended.
* [lldb][NFC] Move ClangASTContext::m_scratch_ast_source_up to the appropriate ↵Raphael Isemann2019-12-241-8/+13
| | | | | | | | | class m_scratch_ast_source_up is only used by ClangASTContextForExpressions so it should also be declared only in that class. Also make all other members of ClangASTContext private and move the initialization code for ClangASTContextForExpressions into the constructor.
* [lldb][NFC] Remove ClangExternalASTSourceCommonRaphael Isemann2019-12-246-58/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | ClangExternalASTSourceCommon's purpose is to store a map from Decl*/Type* to ClangASTMetadata. Usually this data is accessed via the ClangASTContext interface which then grabs the current ExternalASTSource of its ASTContext, tries to cast it to ClangExternalASTSourceCommon and then accesses the metadata map. If the casting fails the setter does nothing and the getter returns a nullptr as if there was no known metadata for a type/decl. This system breaks as soon as any non-LLDB ExternalASTSource is added via a multiplexer to our existing ExternalASTSource (in which case we suddenly loose all out metadata as the casting always fails with an ExternalASTSource that is not inheriting from ClangExternalASTSourceCommon). This patch moves the metadata map to the ClangASTContext. This gets rid of all the fragile casting, the requirement that every ExternalASTSource in LLDB has to inherit from ClangExternalASTSourceCommon and simplifies the metadata implementation to a simple map lookup. As ClangExternalASTSourceCommon had no other purpose than storing metadata, this patch deletes this class and replaces all uses with clang::ExternalASTSource. No other code changes in this commit beside the AppleObjCDeclVendor which was the only code that did not use the ClangASTContext interface but directly accessed the ClangExternalASTSourceCommon.
* Revert "[lldb] Don't process symlinks deep inside DWARFUnit"Jonas Devlieghere2019-12-232-12/+20
| | | | | This temporarily reverts commit 3cfb6677b2aa20f782d9bb0f7958e61f5a976c16 because it breaks TestCompDirSymLink.py on macOS.
* [lldb] Remove DWARFUnit::AppendDIEsWithTagPavel Labath2019-12-233-24/+6
| | | | | | | This function is not very useful, as it's forcing a materialization of the returned DIEs, and calling it is not substantially simpler than just iterating over the DIEs manually. Delete it, and rewrite the single caller.
* [lldb/DWARF] Fix hostname-stripping logicPavel Labath2019-12-231-0/+2
| | | | | | | | | | | | | | This bit of code is trying to strip everything up to the first colon from all debug info paths, as dwarf2 recommends this syntax for storing the compilation host name. However, this code was too eager, and it ended up stripping the entire compilation directory, if it did not contain a forward slash (or a "x:\"). Normally this does not matter, as all absolute paths will contain one of these patterns, but this does not have to be the case in case the debug info is produced by "clang -fdebug-compilation-dir", which can end up producing a relative compilation directory with no slashes (this is one of the techniques for producing "relocatable" debug info).
* [lldb][NFC] Remove unused callback functionality from ClangASTContextRaphael Isemann2019-12-231-5/+0
|
* [lldb][NFC] Simplify ClangExternalASTSourceCallbacksRaphael Isemann2019-12-232-78/+18
| | | | | | | | | | | | | | | This class is only used by the ClangASTContext so we might as well simplify this whole logic by just passing a ClangASTContext instead of a list of callbacks and a void* pointer. If we ever need this to support other classes then we can define some interface that ClangASTContext implements but for now this isn't needed. I also removed any code for m_callback_find_by_name as this was always a nullptr in LLDB and removed all overriden implementations that just redefined the default no-op implementation that the ExternalASTSource provides. Also removed the assert.h workarounds.
* [lldb][NFC] Remove unused 'type' parameter in ↵Raphael Isemann2019-12-232-23/+6
| | | | | | ClangExpressionDeclMap::FindGlobalVariable We never pass something else than a nullptr as the 'type' so the related code in this function is never reached.
* [lldb][NFC] Remove wrong and unused ClangASTContext::CopyDecl methodRaphael Isemann2019-12-231-16/+0
|
* [lldb][NFC] Delete all 'else return ...' in CompilerDeclContext.cppRaphael Isemann2019-12-231-8/+4
|
* [lldb] Add sanity check to CreateDeclContext and fixed illformed ↵Raphael Isemann2019-12-232-1/+5
| | | | | | | | | | | | | | | | | | | | | CompilerContext in ClangExpressionDeclMap. This adds a check that the ClangASTContext actually fits to the DeclContext that we want to create a CompilerDeclContext for. If the ClangASTContext (and its associated ASTContext) does not fit to the DeclContext (that is, the DeclContext wasn't created by the ASTContext), all computations using this malformed CompilerDeclContext will yield unpredictable results. Also fixes the only place that actually hits this assert which is the construction of a CompilerDeclContext in ClangExpressionDeclMap where we pass an unrelated ASTContext instead of the ASTContext of the current expression. I had to revert my previous change to DWARFASTParserClangTests.cpp back to using the unsafe direct construction of CompilerDeclContext as this assert won't work if the DeclContext we pass isn't a valid DeclContext in the first place.
* [lldb] Don't process symlinks deep inside DWARFUnitPavel Labath2019-12-232-20/+12
| | | | | | | | | | | | | | | | | | | | | | Summary: This code is handling debug info paths starting with /proc/self/cwd, which is one of the mechanisms people use to obtain "relocatable" debug info (the idea being that one starts the debugger with an appropriate cwd and things "just work"). Instead of resolving the symlinks inside DWARFUnit, we can do the same thing more elegantly by hooking into the existing Module path remapping code. Since llvm::DWARFUnit does not support any similar functionality, doing things this way is also a step towards unifying llvm and lldb dwarf parsers. Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71770
* [lldb] Fix a -Wreturn-type gcc warning in ScriptInterpreter.cppPavel Labath2019-12-231-0/+1
|
* [lldb][NFC] Simplify ClangASTContext::GetTranslationUnitDeclRaphael Isemann2019-12-231-7/+1
| | | | | | | | | | | | | | | | | These two functions are just calling their equivalent function in ASTContext and implicitly convert the result to a DeclContext* (a parent class of TranslationUnitDecl). This leads to the absurd situation that we had to cast the result of GetTranslationUnitDecl to a TranslationUnitDecl*. The only reason we did this implicit conversion to the parent class was that the void* conversion for the CompilerDeclContext constructor was sound (which otherwise would receive a Decl* pointer when called with a TranslationUnitDecl*). Now that the CompilerDeclContext constructor is type safe we can properly implement these functions by actually returning the right type. Also deletes the static inconvenience method that was not used anywhere.
* [lldb][NFC] Make CompilerDeclContext construction type safeRaphael Isemann2019-12-236-18/+17
| | | | | | | | | | | | | | | The CompilerDeclContext constructor takes a void* pointer which means that all callers of this constructor need to first explicitly convert all pointers to clang::DeclContext*. This causes that we for example can't just pass a TranslationUnitDecl* to the constructor without first casting it to its parent class (as it inherits from both Decl and DeclContext so the void* pointer is actually a Decl*). This patch introduces a utility function in the ClangASTContext which gets rid of the requirement to cast all pointers to clang::DeclContext. Also moves all constructor calls to use this function instead which is NFC (beside the change in DWARFASTParserClangTests.cpp).
* [lldb/ScriptInterpreter] Remove can_reload which is always true (NFC)Jonas Devlieghere2019-12-226-25/+11
| | | | | | The `-r` option for `command script import` is there for legacy compatibility, however the can_reload flag is always set to true. This patch removes the flag and any code that relies on it being false.
* [lldb/ScriptInterpreter] Unify error message for command script importJonas Devlieghere2019-12-222-7/+8
| | | | | Rather than checking for Python explicitly, let the script interpreter handle things and print an error if the functionality is not supported.
* [lldb] Remove unused CompilerDeclContext::IsStructUnionOrClassRaphael Isemann2019-12-222-14/+0
|
* [lldb/ScriptInterpreter] Fix stale/bogus error messagesJonas Devlieghere2019-12-211-2/+2
| | | | | Fix the nonsensical error messages for when breakpoint and watchpoint callbacks are not supported.
* [lldb/Commands] Honor the scripting language passed (2/2)Jonas Devlieghere2019-12-211-14/+26
| | | | | | This ensures that watchpoint command honors the scripting language passed with `-s`. Currently the argument ignores the actual language and only uses it to differentiate between lldb and script commands.
* [lldb/Lua] Add missing boiler plate to ScriptInterpreter.Jonas Devlieghere2019-12-212-14/+11
| | | | | | - Fix enum entry order. - Fix missing enum case in CommandObjectBreakpointCommand. - Add Lua entry to swtich in LanguageToString and simplify the code.
* [lldb/Commands] Use the default scripting langauge for BP functionsJonas Devlieghere2019-12-211-1/+4
| | | | | When a function is used as a breakpoint command, use to the debugger's default scripting language, unless a language is explicitly specified.
* [lldb/Commands] Honor the scripting language passedJonas Devlieghere2019-12-211-2/+2
| | | | | | This ensures that breakpoint command honors the scripting language passed with `-s`. Currently the argument ignores the actual language and only uses it to differentiate between lldb and script commands.
* [lldb/Commands] Fix bogus enum entry and add Lua (NFC)Jonas Devlieghere2019-12-211-5/+12
| | | | | Fixes a bogus enum value for the scripting language options, adds an entry for Lua and refactored the code to use an exhaustive switch.
* [lldb/Core] Support asking the debugger for a specific script interpreterJonas Devlieghere2019-12-211-7/+11
| | | | | | | | | Rather than holding on to one script interpreter, it should be possible to request a script interpreter for a specific scripting language. The GetScriptInterpreter method now takes an optional scripting language argument. (NFC)
* [Lldb/Lua] Persist Lua state across script interpreter calls.Jonas Devlieghere2019-12-214-9/+21
| | | | | | Don't create a new lua state on every operation. Share a single state across the lifetime of the script interpreter. Add simple locking to prevent two threads from modifying the state concurrently.
* [lldb][NFC] Return a reference from ClangASTContext::getASTContext and ↵Raphael Isemann2019-12-2112-623/+576
| | | | | | | | | | | 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/Lua] Generate Lua BindingsJonas Devlieghere2019-12-213-0/+26
| | | | | | | | | | | This patch uses SWIG to generate the Lua bindings for the SB API. It covers most of the API, but some methods require a type map similar to Python. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html Differential revision: https://reviews.llvm.org/D71235
* [lldb][NFC] Remove all ASTContext getter wrappers from ClangASTContextRaphael Isemann2019-12-214-102/+57
| | | | | | | | | | | | 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] Fix -Wstringop-truncation in PythonReadline.cppPavel Labath2019-12-211-1/+1
| | | | | The size is known and the truncation is deliberate -- use memcpy instead of strncpy.
* [lldb] Fix ARM32 inferior callsJan Kratochvil2019-12-216-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | echo -e '#include <unistd.h>\nint main(void){\nsync();return 0;}'|./bin/clang -g -x c -;./bin/lldb -o 'file ./a.out' -o 'b main' -o r -o 'p (void)sync()' Actual: error: Expression can't be run, because there is no JIT compiled function Expected: <nothing, sync() has been executed> This patch has been checked by: D71707: clang-tidy: new bugprone-pointer-cast-widening https://reviews.llvm.org/D71707 Casting from 32-bit `void *` to `uint64_t` requires an intermediate `uintptr_t` cast otherwise the pointer gets sign-extended: echo -e '#include <stdio.h>\n#include <stdint.h>\nint main(void){void *p=(void *)0x80000000;unsigned long long ull=(unsigned long long)p;unsigned long long ull2=(unsigned long long)(uintptr_t)p;printf("p=%p ull=0x%llx ull2=0x%llx\\n",p,ull,ull2);return 0;}'|gcc -Wall -m32 -x c -;./a.out <stdin>: In function ‘main’: <stdin>:3:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] p=0x80000000 ull=0xffffffff80000000 ull2=0x80000000 With debug output: Actual: IRMemoryMap::WriteMemory (0xb6ff8640, 0xffffffffb6f82158, 0x112) went to [0xb6ff8640..0xb6ff86b3) Code can be run in the target. Found function, has local address 0xffffffffb6f84000 and remote address 0xffffffffffffffff Couldn't disassemble function : Couldn't find code range for function _Z12$__lldb_exprPv Sections: [0xb6f84000+0x3c]->0xb6ff9020 (alignment 4, section ID 0, name .text) ... HandleCommand, command did not succeed error: Expression can't be run, because there is no JIT compiled function Expected: IRMemoryMap::WriteMemory (0xb6ff8640, 0xb6faa15c, 0x128) went to [0xb6ff8640..0xb6ff86c3) IRExecutionUnit::GetRemoteAddressForLocal() found 0xb6fac000 in [0xb6fac000..0xb6fac040], and returned 0xb6ff9020 from [0xb6ff9020..0xb6ff9060]. Code can be run in the target. Found function, has local address 0xb6fac000 and remote address 0xb6ff9020 Function's code range is [0xb6ff9020+0x40] ... Function data has contents: 0xb6ff9020: 10 4c 2d e9 08 b0 8d e2 08 d0 4d e2 00 40 a0 e1 ... Function disassembly: 0xb6ff9020: 0xe92d4c10 push {r4, r10, r11, lr} Differential revision: https://reviews.llvm.org/D71498
* [lldb] Expose more optional dependencies through GetBuildConfiguration()Jonas Devlieghere2019-12-201-0/+12
| | | | | Expose all the externally-observable optional dependencies through SBDebugger::GetBuildConfiguration().
* Re-land "[lldb/CMake] Change how we deal with optional dependencies"Jonas Devlieghere2019-12-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently there has been some discussion about how we deal with optional dependencies in LLDB. The approach in LLVM is to make things work out of the box. If the dependency isn't there, we move on silently. That's not true for LLDB. Unless you explicitly disable the dependency with LLDB_ENABLE_*, you'll get a configuration-time error. The historical reason for this is that LLDB's dependencies have a much broader impact, think about Python for example which is required to run the test suite. The current approach can be frustrating from a user experience perspective. Sometimes you just want to ensure LLDB builds with a change in clang. This patch changes the optional dependencies (with the exception of Python) to a new scheme. The LLDB_ENABLE_* now takes three values: On, Off or Auto, with the latter being the default. On and Off behave the same as today, forcing the dependency to be enabled or disabled. If the dependency is set to On but is not found, it results in a configuration time warning. For Auto we detect if the dependency is there and either enable or disable it depending on whether it's found. Differential revision: https://reviews.llvm.org/D71306 PS: The reason Python isn't included yet is because it's so pervasive that I plan on doing that in a separate patch.
* Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysrootAdrian Prantl2019-12-201-1/+1
| | | | | | | | | | | | This is a purely cosmetic change that is NFC in terms of the binary output. I bugs me that I called the attribute DW_AT_LLVM_isysroot since the "i" is an artifact of GCC command line option syntax (-isysroot is in the category of -i options) and doesn't carry any useful information otherwise. This attribute only appears in Clang module debug info. Differential Revision: https://reviews.llvm.org/D71722
* [lldb/Lua] Implement a Simple Lua Script Interpreter PrototypeJonas Devlieghere2019-12-204-12/+120
| | | | | | | | | | | | | | | This implements a very elementary Lua script interpreter. It supports running a single command as well as running interactively. It uses editline if available. It's still missing a bunch of stuff though. Some things that I intentionally ingored for now are that I/O isn't properly hooked up (so every print goes to stdout) and the non-editline support which is not handling a bunch of corner cases. The latter is a matter of reusing existing code in the Python interpreter. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html Differential revision: https://reviews.llvm.org/D71234
OpenPOWER on IntegriCloud