Commit Graph

1069 Commits

Author SHA1 Message Date
Tamas Berghammer bba2c83493 Remove the DWARFExpression -> Clang ExpressionParser dependency
It was completly unused and broke the part of the encapsulation that
common code shouldn't depend on specific plugins or language specific
features.

llvm-svn: 311000
2017-08-16 11:45:10 +00:00
Rafael Espindola 86b875fc08 Update for llvm api change.
llvm-svn: 309916
2017-08-03 02:45:01 +00:00
Zachary Turner 97206d5727 Rename Error -> Status.
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
2017-05-12 04:51:55 +00:00
Jim Ingham 56454b592d Add CopyDiagnostic to the DiagnosticManager.
From Gregor Milos (gmilos@apple.com), for:

https://reviews.llvm.org/D32078

llvm-svn: 300733
2017-04-19 18:56:44 +00:00
Michal Gorny 1052b72361 Revert r298776 - Expression: add missing linkage to RuntimeDyld ...
This needs to be addressed within LLVM itself.

llvm-svn: 299095
2017-03-30 18:24:07 +00:00
Michal Gorny a32fc333d2 Expression: add missing linkage to RuntimeDyld component
Add missing linkage from lldbExpression library to LLVMRuntimeDyld.
Otherwise the build against shared LLVM libraries fails with:

    lib64/liblldbExpression.a(IRExecutionUnit.cpp.o):IRExecutionUnit.cpp:function llvm::RTDyldMemoryManager::deregisterEHFrames(unsigned char*, unsigned long, unsigned long): error: undefined reference to 'llvm::RTDyldMemoryManager::deregisterEHFramesInProcess(unsigned char*, unsigned long)'

Differential Revision: https://reviews.llvm.org/D31367

llvm-svn: 298776
2017-03-25 18:51:29 +00:00
Bruce Mitchener ef4536c389 Fix warnings from clang build on macOS.
Reviewers: lldb-commits

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D31279

llvm-svn: 298585
2017-03-23 09:52:26 +00:00
Jason Molenda ab2dae0a9c Initialize m_allow_cxx, m_allow_objc. These ivars in the base class are not
initialized in the ctor and they're only initialized to 'true' in ClangUserExpression.cpp
when specific languages are detected so we can use uninitialized values.  This
bug has been present since the ivars were added in r144042.
<rdar://problem/31105864> 

llvm-svn: 298333
2017-03-21 02:59:15 +00:00
Zachary Turner fb1a0a0d2f Move many other files from Core -> Utility.
llvm-svn: 297043
2017-03-06 18:34:25 +00:00
Zachary Turner 666cc0b291 Move DataBuffer / DataExtractor and friends from Core -> Utility.
llvm-svn: 296943
2017-03-04 01:30:05 +00:00
Zachary Turner 9739a552c2 Fix DataExtractor failures.
Some code that doesn't get compiled on Windows had some references
that needed updating, and I missed those.

llvm-svn: 296930
2017-03-03 23:52:09 +00:00
Zachary Turner 29cb868aa4 Isolate Target-specific functionality of DataExtractor.
In an effort to move the various DataBuffer / DataExtractor
classes from Core -> Utility, we have to separate the low-level
functionality from the higher level functionality.  Only a
few functions required anything other than reading/writing
raw bytes, so those functions are separated out into a
more appropriate area.  Specifically, Dump() and DumpHexBytes()
are moved into free functions in Core/DumpDataExtractor.cpp,
and GetGNUEHPointer is moved into a static function in the
only file that it's referenced from.

Differential Revision: https://reviews.llvm.org/D30560

llvm-svn: 296910
2017-03-03 20:57:05 +00:00
Zachary Turner 6f9e690199 Move Log from Core -> Utility.
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
2017-03-03 20:56:28 +00:00
Zachary Turner 01c3243fc1 Remove dependencies from Utility to Core and Target.
With this patch, the only dependency left is from Utility
to Host.  After this is broken, Utility will finally be
standalone.

Differential Revision: https://reviews.llvm.org/D29909

llvm-svn: 295088
2017-02-14 19:06:07 +00:00
Zachary Turner bf9a77305f Move classes from Core -> Utility.
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
2017-02-02 21:39:50 +00:00
Chris Bieneman 494f277af5 [CMake] Add accurate dependency specifications
Summary:
This patch adds accurate dependency specifications to the mail LLDB libraries and tools.

In all cases except lldb-server, these dependencies are added in addition to existing dependencies (making this low risk), and I performed some code cleanup along the way.

For lldb-server I've cleaned up the LLVM dependencies down to just the minimum actually required. This is more than lldb-server actually directly references, and I've left a todo in the code to clean that up.

Reviewers: labath, zturner

Subscribers: lldb-commits, danalbert, srhines, ki.stfu, mgorny, jgosnell

Differential Revision: https://reviews.llvm.org/D29333

llvm-svn: 293686
2017-01-31 20:43:05 +00:00
David Blaikie a322f36cfd Make lldb -Werror clean for -Wstring-conversion
Also found/fixed one bug identified by this warning in
RenderScriptx86ABIFixups.cpp where a string literal was being used in an
effort to provide a name for an instruction/register, but was instead
being passed as the bool 'isVolatile' parameter.

llvm-svn: 291198
2017-01-06 00:38:06 +00:00
Pavel Labath f31c9d27a4 Silence some -Wstring-conversion warnings
lldbassert(!"foo") -> lldbassert(0 && "foo")

In one case, this actually detected a logic error in the assertion (missing !).

llvm-svn: 291102
2017-01-05 13:18:42 +00:00
Luke Drummond f5bb1d6c4e Expression evaluation for overloaded C functions (redux)
This is a redux of [Ewan's patch](https://reviews.llvm.org/D17957) , refactored
to properly substitute primitive  types using a hook in the itanium demangler,
and updated after the previous patch went stale

The new `SubsPrimitiveParmItanium` function takes a symbol name and replacement
primitive type parameter as before but parses it using the FastDemangler, which
has been modified to be able to notify clients of parse events (primitive types
at this point).

Additionally, we now use a `set` of `ConstStrings` instead of a `vector` so
that we don't try and resolve the same invalid candidate multiple times.

Differential Revision: https://reviews.llvm.org/D27223
Subscribers: lldb-commits

llvm-svn: 290117
2016-12-19 17:22:44 +00:00
Pavel Labath 43d354182f Use Timeout<> in EvaluateExpressionOptions class
llvm-svn: 288797
2016-12-06 11:24:51 +00:00
Alexander Shaposhnikov 696bd63550 [lldb] Fix typos in file headers
This diff fixes typos in file headers (incorrect file names).

Test plan:

Under llvm/tools/lldb/source:
find ./* -type f | grep -e '\(cpp\|h\)$' | while read F; do B=$(basename $F); echo $F head -n 1 $F | grep -v $B | wc -l ; done

Differential revision: https://reviews.llvm.org/D27115

llvm-svn: 287966
2016-11-26 05:23:44 +00:00
Chris Bieneman b653c4957d [CMake] NFC. Updating CMake dependency specifications
This patch updates a bunch of places where add_dependencies was being explicitly called to add dependencies on intrinsics_gen to instead use the DEPENDS named parameter. This cleanup is needed for a patch I'm working on to add a dependency debugging mode to the build system.

llvm-svn: 287408
2016-11-18 23:31:53 +00:00
Zachary Turner c156427ded Don't allow direct access to StreamString's internal buffer.
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
2016-11-16 21:15:24 +00:00
Zachary Turner e2411fabda Make DiagnosticsManager functions take StringRefs.
llvm-svn: 286730
2016-11-12 19:12:56 +00:00
Zachary Turner c5d7df9035 Convert some Expression parser functions to StringRef.
llvm-svn: 286208
2016-11-08 04:52:16 +00:00
Jim Ingham 0298082541 UserExpression::Evaluate only returns a non-empty ValueObjectSP
if it returns eExpressionCompleted.  Don't try to get the error
from the ValueObjectSP if that's not true.

I just have a report of this from the field, I don't know how
to make it fail yet.

<rdar://problem/29113004>

llvm-svn: 286170
2016-11-07 22:47:01 +00:00
Malcolm Parsons 771ef6d4f1 Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: zturner, labath

Subscribers: tberghammer, danalbert, lldb-commits
    
Differential Revision: https://reviews.llvm.org/D26233

llvm-svn: 285855
2016-11-02 20:34:10 +00:00
Pavel Labath 6b91e405e3 Use the right dwarf attributes for parsing location list entries (fixup for r285441)
Note that the parsing code here is still incorrect wrt. the new draft of the
dwarf 5 spec (seconds arguments to DW_LLE_startx_length should be uleb128, not
u32). Once we have compilers actually emitting dwarf conformant with the new
spec, we'll need to revisit this and figure out the proper behavior there.

This should unbreak the linux bot.

llvm-svn: 285562
2016-10-31 11:53:13 +00:00
Adrian Prantl e704506c93 Rename DWARF 5 constants to adapt to change in LLVM
llvm-svn: 285441
2016-10-28 20:11:27 +00:00
Sean Callanan 8f04805c9f Remove a stray dump().
<rdar://problem/28635530>

llvm-svn: 283604
2016-10-07 21:25:29 +00:00
Zachary Turner a01bccdbe6 Convert some more aliasing and CI functions to StringRef.
llvm-svn: 283386
2016-10-05 21:14:56 +00:00
Chris Bieneman e3e6474824 [CMake] LLDB/Expression needs to depend on intrinsics_gen
IRExecutionUnit.h includes Module.h, which through a long chain of includes eventually includes Attributes.gen.

This fixes a build issue reported to lldb-dev by Hal. Thanks Hal!

llvm-svn: 282803
2016-09-29 22:55:09 +00:00
Sean Callanan 5deb06eb43 Added a setting that enables saving all .o files from a given JIT expression.
This allows debugging of the JIT and other analyses of the internals of the
expression parser.  I've also added a testcase that verifies that the setting
works correctly when off and on.

llvm-svn: 282434
2016-09-26 20:18:51 +00:00
Zachary Turner 514d8cd83e Update the prompt related functions to use StringRefs.
llvm-svn: 282269
2016-09-23 18:06:53 +00:00
Sean Callanan aa4b44c662 Replaced two instances of std::function with auto.
Thanks to Zachary Turner for the suggestion.  It's distasteful that the actual
type of the lambda can't be spelled out, but it should be evident from the
definition of the lambda body.

llvm-svn: 281536
2016-09-14 20:58:31 +00:00
Sean Callanan 807ee2ff69 Cleaned up some of the "frame diagnose" code to use Operands as currency.
Also added some utility functions around Operands to make code easier and more
compact to write.

llvm-svn: 281398
2016-09-13 21:18:27 +00:00
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** 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-09-06 20:57:50 +00:00
Sean Callanan 4740a734bb Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one).  From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.

To address this, I have added new fuctionality to StackFrame to parse the 
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.

This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command.  It is also used to provide symbolic information, when
available, in the event of a crash.

The algorithm is very rudimentary, and it needs a bunch of work, including
  - better parsing for assembly, preferably with help from LLVM
  - support for non-Apple platforms
  - cleanup of the algorithm core, preferably to make it all work in terms of
    Operands instead of register/offset pairs
  - improvement of the GetExpressioPath() logic to make prettier expression
    paths, and
  - better handling of vtables.
I welcome all suggestios, improvements, and testcases.

llvm-svn: 280692
2016-09-06 04:48:36 +00:00
Lang Hames 6377aa1cb1 [lldb] Use OrcMCJITReplacement rather than MCJIT as the underlying JIT for LLDB
expression evaluation.

OrcMCJITReplacement is a reimplementation of MCJIT using ORC components, and
provides an easy upgrade path to ORC for existing MCJIT clients. There should be
no functional changes resulting from this switch.

llvm-svn: 279327
2016-08-19 21:27:16 +00:00
Sean Callanan 799a3fc60b Fixed a problem where we failed to get the size of an Objective-C type.
<rdar://problem/27897056>

llvm-svn: 279098
2016-08-18 17:45:50 +00:00
Todd Fiala e1cfbc7942 Decoupled Options from CommandInterpreter.
Options used to store a reference to the CommandInterpreter instance
in the base Options class.  This made it impossible to parse options
independent of a CommandInterpreter.

This change removes the reference from the base class.  Instead, it
modifies the options-parsing-related methods to take an
ExecutionContext pointer, which the options may inspect if they need
to do so.

Closes https://reviews.llvm.org/D23416
Reviewers: clayborg, jingham

llvm-svn: 278440
2016-08-11 23:51:28 +00:00
Jim Ingham bed6779c7a Add an "experimental" setting to disable injecting local variables into expressions.
This feature was added to solve a lookup problem in expressions when local variables
shadow ivars.  That solution requires fully realizing all local variables to evaluate
any expression, and can cause significant performance problems when evaluating 
expressions in frames that have many complex locals.

Until we get a better solution, this setting mitigates the problem when you don't
have local variables that shadow ivars.

<rdar://problem/27226122>

llvm-svn: 274783
2016-07-07 18:25:48 +00:00
Greg Clayton 63a27afae3 Added support for thread local variables on all Apple OS variants.
We had support that assumed that thread local data for a variable could be determined solely from the module in which the variable exists. While this work for linux, it doesn't work for Apple OSs. The DWARF for thread local variables consists of location opcodes that do something like:

DW_OP_const8u (x)
DW_OP_form_tls_address

or 

DW_OP_const8u (x)
DW_OP_GNU_push_tls_address

The "x" is allowed to be anything that is needed to determine the location of the variable. For Linux "x" is the offset within the TLS data for a given executable (ModuleSP in LLDB). For Apple OS variants, it is the file address of the data structure that contains a pthread key that can be used with pthread_getspecific() and the offset needed. 

This fix passes the "x" along to the thread:

virtual lldb::addr_t
lldb_private::Thread::GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr);

Then this is passed along to the DynamicLoader::GetThreadLocalData():

virtual lldb::addr_t
lldb_private::DynamicLoader::GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr);

This allows each DynamicLoader plug-in do the right thing for the current OS.

The DynamicLoaderMacOSXDYLD was modified to be able to grab the pthread key from the data structure that is in memory and call "void *pthread_getspecific(pthread_key_t key)" to get the value of the thread local storage and it caches it per thread since it never changes.

I had to update the test case to access the thread local data before trying to print it as on Apple OS variants, thread locals are not available unless they have been accessed at least one by the current thread.

I also added a new lldb::ValueType named "eValueTypeVariableThreadLocal" so that we can ask SBValue objects for their ValueType and be able to tell when we have a thread local variable.

<rdar://problem/23308080>

llvm-svn: 274366
2016-07-01 17:17:23 +00:00
Sean Callanan b37674dca0 Fixed a problem in IRMemoryMap where the flag to zero out memory was ignored.
llvm-svn: 272320
2016-06-09 22:22:40 +00:00
Sean Callanan f3df7e86b4 Updated the FindSpace() algorithm to avoid the 0 page when it's unsafe.
Previously we eliminated the randomized scheme for finding memory when the
underlying process cannot allocate memory, and replaced it with an algorithm
that starts the allocations at 00x.

This was more determinstic, but runs into problems on embedded targets where the
pages near 0x0 are in fact interesting memory.  To deal with those cases, this
patch does two things:

- It makes the default fallback be an address that is less likely than 0x0 to
  contain interesting information.

- Before falling back to this, it adds an algorithm that consults the
  GetMemoryRegionInfo() API to see if it can find an unmapped area.

This should eliminate the randomness (and unpredictable memory accesseas) of the
previous scheme while making expressions more likely to return correct results.

<rdar://problem/25545573>

llvm-svn: 272301
2016-06-09 20:22:25 +00:00
Greg Clayton 32c940de37 Now that there are no cycles that cause leaks in the disassembler/instruction classes, we can get rid of the FIXME lines that were working around this issue.
<rdar://problem/26684190>

llvm-svn: 272071
2016-06-07 23:19:00 +00:00
Stephane Sezer 04a89fd826 Fix function name lookup in IRExecutionEngine.cpp.
Summary:
Without this commit, when `log enable lldb expr` is enabled, the
disassembly of JIT'ed code is never displayed.

Reviewers: spyffe, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D20312

llvm-svn: 271863
2016-06-06 02:50:46 +00:00
Sean Callanan 34ab28a470 Fixed a problem where we couldn't call extern "C" functions.
Some compilers do not mark up C++ functions as extern "C" in the DWARF, so LLDB
has to fall back (if it is about to give up finding a symbol) to using the base
name of the function.

This fix also ensures that we search by full name rather than "auto," which
could cause unrelated C++ names to be found.  Finally, it adds a test case.

<rdar://problem/25094302>

llvm-svn: 271551
2016-06-02 17:59:47 +00:00
Saleem Abdulrasool 16ff860469 remove use of Mutex in favour of std::{,recursive_}mutex
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
2016-05-18 01:59:10 +00:00
Marianne Mailhot-Sarrasin 3fe7158174 [LLDB] Added support for PHI nodes to IR interpreter
This allows expressions such as 'i == 1 || i == 2` to be executed using the IR interpreter, instead of relying on JIT code injection (which may not be available on some platforms).

Patch by cameron314

Differential Revision: http://reviews.llvm.org/D19124

llvm-svn: 269340
2016-05-12 20:00:53 +00:00