summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility
Commit message (Collapse)AuthorAgeFilesLines
...
* [lldb] Remove redundant argument lists in CompletionRequestRaphael Isemann2019-09-241-6/+4
| | | | | | | | | | | We currently have two lists in the CompletionRequest that we inherited from the old API: The complete list of arguments ignoring where the user requested completion and the list of arguments that stops at the cursor. Having two lists of arguments is confusing and can lead to subtle errors, so let's remove the complete list until we actually need it. llvm-svn: 372692
* [lldb] Add completion support for log enable/disable/listRaphael Isemann2019-09-241-7/+31
| | | | | | | | | | | | | | Reviewers: #lldb, JDevlieghere Reviewed By: JDevlieghere Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67903 llvm-svn: 372691
* [LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in ↵Martin Storsjo2019-09-231-2/+2
| | | | | | | | | | | general These ifdefs contain code that isn't specific to MSVC but useful for any windows target, like MinGW. Differential Revision: https://reviews.llvm.org/D67893 llvm-svn: 372592
* [LLDB] Remove a stray semicolon. NFC.Martin Storsjo2019-09-231-1/+1
| | | | | | This fixes build warnings with at least GCC. llvm-svn: 372588
* [lldb] Make cursor index in CompletionRequest unsignedRaphael Isemann2019-09-231-23/+17
| | | | | | | | | | | | The fact that index==-1 means "no arguments" is not obvious and only used in one place from what I can tell. Also fixes several warnings about using the cursor index as if it was a size_t when comparing. Not fully NFC as we now also correctly update the partial argument list when injecting the fake empty argument in the CompletionRequest constructor. llvm-svn: 372566
* [lldb][NFC] Remove argument prefix checking boilerplate when adding completionsRaphael Isemann2019-09-231-11/+2
| | | | llvm-svn: 372561
* [NFC] Move dumping into GDBRemotePacketJonas Devlieghere2019-09-161-0/+17
| | | | | | | | This moves the dumping logic from the GDBRemoteCommunicationHistory class into the GDBRemotePacket so that it can be reused from the reproducer command object. llvm-svn: 372028
* [Reproducer] Move GDB Remote Packet into Utility. (NFC)Jonas Devlieghere2019-09-133-46/+89
| | | | | | | | | | | | | | To support dumping the reproducer's GDB remote packets, we need the (de)serialization logic to live in Utility rather than the GDB remote plugin. This patch renames StreamGDBRemote to GDBRemote and moves the relevant packet code there. Its uses in the GDBRemoteCommunicationHistory and the GDBRemoteCommunicationReplayServer are updated as well. Differential revision: https://reviews.llvm.org/D67523 llvm-svn: 371907
* [lldb][NFC] Remove ArgEntry::ref memberRaphael Isemann2019-09-131-7/+6
| | | | | | | | | | | The StringRef should always be identical to the C string, so we might as well just create the StringRef from the C-string. This might be slightly slower until we implement the storage of ArgEntry with a string instead of a std::unique_ptr<char[]>. Until then we have to do the additional strlen on the C string to construct the StringRef. llvm-svn: 371842
* [lldb][NFC] Simplify Args::ReplaceArgumentAtIndexRaphael Isemann2019-09-131-9/+2
| | | | | | | | | This code is not on any performance critical path that would justify this shortening optimization. It also makes it possible to turn 'ref' into a function (as this is the only place where we modify this ArgEntry member). llvm-svn: 371836
* [NFC] Sort source files in Utility/CMakeLists.txtJonas Devlieghere2019-09-121-3/+3
| | | | llvm-svn: 371784
* [Reproducer] Move the command loader into the reproducer (NFC)Jonas Devlieghere2019-09-111-0/+34
| | | | | | | | This just moves the CommandLoader utility into the reproducer namespace and makes it accessible outside the API layer. This is setting things up for a bigger change. llvm-svn: 371689
* [Reproducer] Move GDB Remote Provider into Reproducer (NFC)Jonas Devlieghere2019-09-111-2/+14
| | | | | | | | | | | | | | Originally the idea was for providers to be defined close to where they are used. While this helped designing the providers in such a way that they don't depend on each other, it also means that it's not possible to access them from a central place. This proved to be a problem for some providers and resulted in them living in the reproducer class. The ProcessGDBRemote provider is the last remaining exception. This patch makes things consistent and moves it into the reproducer like the other providers. llvm-svn: 371685
* Implement DW_OP_convertAdrian Prantl2019-09-101-0/+45
| | | | | | | | | | | | | | | | | | | | | | 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
* [lldb][NFC] Remove Args::StripSpacesRaphael Isemann2019-09-061-23/+0
| | | | | | This just reimplemented llvm::StringRef::[r/l]trim(). llvm-svn: 371181
* [lldb][NFC] Remove unused Args::GetArgumentQuoteCharAtIndexRaphael Isemann2019-09-061-6/+0
| | | | llvm-svn: 371176
* ProcessInstanceInfo: Fix dumping of invalid user idsPavel Labath2019-08-261-11/+26
| | | | | | | Don't attempt to print invalid user ids. Previously, these would come out as UINT32_MAX, or as an assertion failure. llvm-svn: 369906
* [lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some codeRaphael Isemann2019-08-261-2/+2
| | | | llvm-svn: 369880
* [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and ↵Raphael Isemann2019-08-222-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove any undocumented/redundant return values Summary: We still have some leftovers of the old completion API in the internals of LLDB that haven't been replaced by the new CompletionRequest. These leftovers are: * The return values (int/size_t) in all completion functions. * Our result array that starts indexing at 1. * `WordComplete` mode. I didn't replace them back then because it's tricky to figure out what exactly they are used for and the completion code is relatively untested. I finally got around to writing more tests for the API and understanding the semantics, so I think it's a good time to get rid of them. A few words why those things should be removed/replaced: * The return values are really cryptic, partly redundant and rarely documented. They are also completely ignored by Xcode, so whatever information they contain will end up breaking Xcode's completion mechanism. They are also partly impossible to even implement as we assign negative values special meaning and our completion API sometimes returns size_t. Completion functions are supposed to return -2 to rewrite the current line. We seem to use this in some untested code path to expand the history repeat character to the full command, but I haven't figured out why that doesn't work at the moment. Completion functions return -1 to 'insert the completion character', but that isn't implemented (even though we seem to activate this feature in LLDB sometimes). All positive values have to match the number of results. This is obviously just redundant information as the user can just look at the result list to get that information (which is what Xcode does). * The result array that starts indexing at 1 is obviously unexpected. The first element of the array is reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is that we calculate this to make the life of the API caller easier, but obviously forcing people to have 1-based indices is not helpful (or even worse, forces them to manually copy the results to make it 0-based like Xcode has to do). * The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The idea is that we let the top-level API know that we just provided a full completion. Interestingly we `WordComplete` is just a single bool that somehow represents all N completions. And we always provide full completions in LLDB, so in theory it should always be true. The only use it currently serves is providing redundant information about whether we have a single definitive completion or not (which we already know from the number of results we get). This patch essentially removes `WordComplete` mode and makes the result array indexed from 0. It also removes all return values from all internal completion functions. The only non-redundant information they contain is about rewriting the current line (which is broken), so that functionality was moved to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)` to do the same. For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we didn't even implement them in the Editline handler (e.g. -1). I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code, but I would prefer doing this in follow-up NFC commits Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: arphaman, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66536 llvm-svn: 369624
* [NFC] Remove unused function GetHexWithFixedSizeJonas Devlieghere2019-08-211-28/+0
| | | | | | | | The implementation of this function was obviously incorrect, as the result variable was never used. This led me to check if it was actually used anywhere, which came back negative. llvm-svn: 369492
* [NFC] Remove lldb_utility namespace.Jonas Devlieghere2019-08-211-1/+1
| | | | | | | While generating the Doxygen I noticed this lone namespace that has one class and one function in it. This moves them into lldb_private. llvm-svn: 369485
* [lldb] Use the new Regex::isValid() with no parameterJan Kratochvil2019-08-201-4/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D66463 llvm-svn: 369398
* [lldb] D66174 `RegularExpression` cleanupJan Kratochvil2019-08-201-10/+7
| | | | | | | | | | I find as a good cleanup to drop the Compile method. As I do not find TIMTOWTDI as an advantage and there is already constructor parameter to compile the regex. Differential Revision: https://reviews.llvm.org/D66392 llvm-svn: 369352
* [lldb][NFC] Remove StringList::AutoCompleteRaphael Isemann2019-08-191-23/+0
| | | | | | | We don't need this very specific function in StringList that we only call once in LLDB. llvm-svn: 369242
* [lldb][NFC] Address review comments to StringList for-loop supportRaphael Isemann2019-08-191-0/+1
| | | | llvm-svn: 369237
* [Utility] Reimplement RegularExpression on top of llvm::RegexJonas Devlieghere2019-08-161-129/+18
| | | | | | | | | | | | | | | Originally I wanted to remove the RegularExpression class in Utility and replace it with llvm::Regex. However, during that transition I noticed that there are several places where need the regular expression string. So instead I propose to keep the RegularExpression class and make it a thin wrapper around llvm::Regex. This patch also removes the workaround for empty regular expressions. The result is that we are now (more or less) POSIX conformant. Differential revision: https://reviews.llvm.org/D66174 llvm-svn: 369153
* [lldb][NFC] Allow for-ranges on StringListRaphael Isemann2019-08-162-6/+3
| | | | llvm-svn: 369113
* Fix variable mismatch between signature and bodyJonas Devlieghere2019-08-151-3/+3
| | | | | | | I updated the signature to conform to the LLDB coding style but accidentally forgot to update the function body. llvm-svn: 368962
* [NFC] Fix documentation for some utility classes.Jonas Devlieghere2019-08-151-1/+1
| | | | | | This fixes a few warnings emitted when compiling with -Wdocumentation. llvm-svn: 368959
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-142-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* [lldb][NFC] Assert on invalid cursors positions when creating CompletionRequestRaphael Isemann2019-08-091-0/+1
| | | | | | Before we just triggered undefined behavior on invalid positions. llvm-svn: 368444
* [Utility] Remove unused function 'GetMatchSpanningIndices'Jonas Devlieghere2019-08-081-17/+0
| | | | llvm-svn: 368243
* Remove unused function 'SetMangledCounterparts' (NFC)Jonas Devlieghere2019-08-061-17/+0
| | | | | | This function is not referenced. llvm-svn: 367975
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-3/+3
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [CompletionRequest] Remove unimplemented members.Jonas Devlieghere2019-07-311-4/+1
| | | | | | | | | | Completion requests have two fields that are essentially unimplemented: `m_match_start_point` and `m_max_return_elements`. This would've been okay, if it wasn't for the fact that this caused a bunch of useless parameters to be passed around. Occasionally there would be a comment or assert saying that they are not supported. This patch removes them. llvm-svn: 367385
* [StringList] Change LongestCommonPrefix APIJonas Devlieghere2019-07-311-4/+3
| | | | | | | | | When investigating a completion bug I got confused by the API. LongestCommonPrefix finds the longest common prefix of the strings in the string list. Instead of returning that string through an output argument, just return it by value. llvm-svn: 367384
* [Support] move FileCollector from LLDB to llvm/SupportAlex Lorenz2019-07-242-183/+0
| | | | | | | | | The file collector class is useful for creating reproducers, not just for LLDB, but for other tools as well in LLVM/Clang. Differential Revision: https://reviews.llvm.org/D65237 llvm-svn: 366956
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-243-42/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [Logging] Replace LogIfAnyCategoriesSet with LLDB_LOG.Jonas Devlieghere2019-07-221-10/+0
| | | | | | | | This patch removes any remaining instances of LogIfAnyCategoriesSet and replaces them with the LLDB_LOG macro. This in turn made it possible to make Log::VAPrintf and Log::VAError private. llvm-svn: 366768
* [LLDBAssert] Use unreachable instead of assert(0)Jonas Devlieghere2019-07-051-2/+2
| | | | | | As per Davide's suggestion offline. llvm-svn: 365250
* lldb_assert: abort when assertions are enabled.Jonas Devlieghere2019-07-051-0/+6
| | | | | | | | | | | | | | | | | | | | We had a long discussion in D59911 about lldb_assert and what it means. The result was the assert manifesto on lldb.llvm.org. > LLDB provides lldb_assert() as a soft alternative to cover the middle > ground of situations that indicate a recoverable bug in LLDB. In a > Debug configuration lldb_assert() behaves like assert(). In a Release > configuration it will print a warning and encourage the user to file a > bug report, similar to LLVM’s crash handler, and then return > execution. However, currently lldb_assert doesn't behave they way it's being described there: it doesn't abort in a debug/assert build. This patch fixes that by adding a call to assert() in lldb_assert(). Differential revision: https://reviews.llvm.org/D64267#1571962 llvm-svn: 365246
* [Reproducers] Copy over access/modification time in the FileCollector.Jonas Devlieghere2019-06-261-0/+31
| | | | | | | | Copy over access and modification time for the files included in the reproducer. This is needed to pass tests that check the integrity of object files based on their time stamp. llvm-svn: 364457
* Fix a dangling StringRef in FileCollectorPavel Labath2019-06-191-1/+1
| | | | | | FileSpec::GetPath returns a temporary std::string. llvm-svn: 363770
* [Reproducers] Make reproducer relocatableJonas Devlieghere2019-06-181-2/+5
| | | | | | | | | | | | | | Before this patch, reproducers weren't relocatable. The reproducer contained hard coded paths in the VFS mapping, as well in the yaml file listing the different input files for the command interpreter. This patch changes that: - Use relative paths for the DataCollector. - Use an overlay prefix for the FileCollector. Differential revision: https://reviews.llvm.org/D63467 llvm-svn: 363697
* [Reproducers] Remove call to lldb_private::GetVersion()Jonas Devlieghere2019-06-131-2/+1
| | | | | | | | Utility doesn't link against lldbBase so we cannot call GetVersion in keep. I already added a string member m_version to deal with that, but the call was still there. llvm-svn: 363228
* [Reproducers] Include lldb version in the reproducer rootJonas Devlieghere2019-06-131-4/+17
| | | | | | | | | | | Generally, reproducers are rev-locked to the version of LLDB, so it's valuable to have the LLDB version in the reproducer. For now I just want the information to be present, without enforcing it, but I envision emitting a warning during replay in the future. Differential revision: https://reviews.llvm.org/D63229 llvm-svn: 363225
* [Reproducers] Simplify providers with nested Info struct (NFC)Jonas Devlieghere2019-06-121-6/+6
| | | | | | | | | This replaces the `info` typedef with a nested struct named Info. This means we now have FooProvider and FooProvider::Info, instead of two related but separate classes FooProvider and FooInfo. This change is mostly cosmetic. llvm-svn: 363211
* Create a generic handler for Xfer packetsAntonio Afonso2019-06-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the first of a few patches I have to improve the performance of dynamic module loading on Android. In this first diff I'll describe the context of my main motivation and will then link to it in the other diffs to avoid repeating myself. ## Motivation I have a few scenarios where opening a specific feature on an Android app takes around 40s when lldb is attached to it. The reason for that is because 40 modules are dynamicly loaded at that point in time and each one of them is taking ~1s. ## The problem To learn about new modules we have a breakpoint on a linker function that is called twice whenever a module is loaded. One time just before it's loaded (so lldb can check which modules are loaded) and another right after it's loaded (so lldb can check again which ones are loaded and calculate the diference). It's figuring out which modules are loaded that is taking quite some time. This is currently done by traversing the linked list of loaded shared libraries that the linker maintains in memory. Each item in the linked list requires its own `x` packet sent to the gdb server (this is android so the network also plays a part). In my scenario there are 400+ loaded libraries and even though we read 0x800 worth of bytes at a time we still make ~180 requests that end up taking 150-200ms. We also do this twice, once before the module is loaded (state = eAdd) and another right after (state = eConsistent) which easly adds up to ~400ms per module. ## A solution **Implement `xfer:libraries-svr4` in lldb-server:** I noticed in the code that loads the new modules that it had support for the `xfer:libraries-svr4` packet (added ~4 years ago to support the ds2 debug server) but we didn't support it in lldb-server. This single packet returns an xml list of all the loaded modules by the process. The advantage is that there's no more need to make 180 requests to read the linked list. Additionally this new requests takes around 10ms. **More efficient usage of the `xfer:libraries-svr4` packet in lldb:** When `xfer:libraries-svr4` is available the Process class has a `LoadModules` function that requests this packet and then loads or unloads modules based on the current list of loaded modules by the process. This is the function that is used by the DYLDRendezvous class to get the list of loaded modules before and after the module is loaded. However, this is really not needed since the LoadModules function already loaded or unloaded the modules accordingly. I changed this strategy to call LoadModules only once (after the process has loaded the module). **Bugs** I found a few issues in lldb while implementing this and have submitted independent patches for them. I tried to devide this into multiple logical patches to make it easier to review and discuss. ## Tests I wanted to put these set of diffs up before having all the tests up and running to start having them reviewed from a techical point of view. I'm also having some trouble making the tests running on linux so I need more time to make that happen. # This diff The `xfer` packages follow the same protocol, they are requested with `xfer:<object>:<read|write>:<annex>:<offset,length>` and a return that starts with `l` or `m` depending if the offset and length covers the entire data or not. Before implementing the `xfer:libraries-svr4` I refactored the `xfer:auxv` to generically handle xfer packets so we can easly add new ones. The overall structure of the function ends up being: * Parse the packet into its components: object, offset etc. * Depending on the object do its own logic to generate the data. * Return the data based on its size, the requested offset and length. Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: mgorny, krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62499 llvm-svn: 362982
* Fix lit tests on Windows related to CR+LFAdrian McCarthy2019-06-071-1/+2
| | | | | | | | | | | | | | | | | | | | | Problem discovered in the breakpoint lit test, but probably exists in others. lldb-test splits lines on LF. Input files that are CR+LF separated (as is common on Windows) then resulted in commands being sent to LLDB that ended in CR, which confused the command interpreter. This could be fixed at different levels: 1. Treat '\r' like a tab or space in the argument splitter. 2. Fix the line splitters (plural) in lldb-test. 3. Normalize the test files to LF only. If we did only 3, I'd expect similar problems to recur, so this patch does 1 and 2. I may also do 3 in a separate patch later, but that's tricky because I believe we have some input files that MUST use CR+LF. Differential Revision: https://reviews.llvm.org/D62759 llvm-svn: 362844
* [lldb-server] Support 'g' packetsPavel Labath2019-05-301-3/+1
| | | | | | | Differential Revision: https://reviews.llvm.org/D62221 Patch by Guilherme Andrade <guiandrade@google.com>. llvm-svn: 362063
OpenPOWER on IntegriCloud