Commit Graph

989 Commits

Author SHA1 Message Date
Hafiz Abid Qadeer b10fb96541 Provide option to set pc of the file loaded in memory.
Summary: This commit adds an option to set PC to the entry point of the file loaded using "target module load" command. In D28804, Greg asked me to separate this part under a different option.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 292989
2017-01-24 23:07:27 +00:00
Hafiz Abid Qadeer b1554311d3 Fix more unused variable warnings when asserts are disabled.
llvm-svn: 292598
2017-01-20 10:24:03 +00:00
Hafiz Abid Qadeer 4687db0e09 Provide a substitute to load command of gdb.
For bare-metal targets, lldb was missing a command like 'load' in gdb
which can be used to create executable image on the target. This was
discussed in
http://lists.llvm.org/pipermail/lldb-dev/2016-December/011752.html

This commits adds an option to "target module load" command to provide
that functionality. It does not set the PC to entry address which will
be done separately.

Reviewed in https://reviews.llvm.org/D28804

llvm-svn: 292499
2017-01-19 17:32:50 +00:00
Pavel Labath 0cfd7dc9ea Remove a couple of Stream flags
Summary:
I came across this while trying to understand what Log::Debug does. It turns out
it does not do anything, as there is no instance of someone setting a debug flag
on a stream. The same is true for the Verbose and AddPrefix flags. Removing
these will enable some cleanups in the Logging class, and it brings us closer
towards the long term goal of standardizing on llvm stream classes.

I have removed these flags and all code the code which tested for their
presence -- there wasn't much of it, mostly in SymbolFileDWARF, which is
probably going away at some point anyway.

The eBinary flag still has some users, so I am letting it life for the time
being.

Reviewers: clayborg, zturner

Subscribers: aprantl, beanz, lldb-commits

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

llvm-svn: 291895
2017-01-13 10:41:59 +00:00
Pavel Labath 4294de3aa0 Fix build for clang r291753
llvm-svn: 291756
2017-01-12 10:44:16 +00:00
Tamas Berghammer 556b1611cd Improve Type::GetTypeScopeAndBasenameHelper and add unit tests
Previously it failed to handle nested types inside templated classes
making it impossible to look up these types using the fully qualified
name.

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

llvm-svn: 291559
2017-01-10 11:13:59 +00:00
Tamas Berghammer 1c62e0356d Fix dereferencing of pointers to empty classes
llvm-svn: 291350
2017-01-07 16:39:07 +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
Zachary Turner 827d5d74a5 Add methods to enable using formatv syntax in LLDB.
This adds formatv-backed formatting functions in various
places in LLDB such as StreamString, logging, constructing
error messages, etc.  A couple of callsites are changed
from Printf style syntax to formatv style syntax to
illustrate its usage.  Additionally, a FileSpec formatter
is introduced so that FileSpecs can be formatted natively.

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

llvm-svn: 289922
2016-12-16 04:27:00 +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
Johan Engelen 0479957d1a Use Clang for D language support.
Differential revision: https://reviews.llvm.org/D24794

llvm-svn: 287917
2016-11-25 11:01:12 +00:00
Zachary Turner 72f4997cbf Fix some accidental Prints of StringRefs that snuck in.
llvm-svn: 287412
2016-11-19 00:50:29 +00:00
Zachary Turner 2a3d10ae61 Re-add the StringRef interface changes for Variable.
This concludes the changes I originally tried to make and then
had to back out.  This way if anything is still broken, it
should be easier to bisect it back to a more specific changeset.

llvm-svn: 287367
2016-11-18 19:23:39 +00:00
Zachary Turner d2daca770b Resubmit "Remove an output-parameter from Variable function".
The scanning algorithm had a few little subtleties that I
overlooked, but this patch should fix everything.

I still haven't changed the function to take a StringRef since
that has some trickle down effect and is mostly mechanical,
I just wanted to get the tricky part as isolated as possible.

llvm-svn: 287354
2016-11-18 17:55:04 +00:00
Zachary Turner 655c452534 Revert "Remove an out param from ValueObject::GetValueForExpressionPath."
This reverts commit r287315, as it introduces a bug that breaks
many things.

llvm-svn: 287320
2016-11-18 06:34:45 +00:00
Zachary Turner 82d760879f Remove an out param from ValueObject::GetValueForExpressionPath.
This argument was only used in one place in the codebase, and
it was in a non-critical log statement and can be easily
substituted for an equally meaningful field instead.  The
payoff of computing this value is not worth the added
complexity.

llvm-svn: 287315
2016-11-18 05:45:41 +00:00
Zachary Turner 4aa8753c81 Convert AutoComplete related code to StringRef.
Differential Revision: https://reviews.llvm.org/D26721

llvm-svn: 287188
2016-11-17 01:37:42 +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 c5d7df9035 Convert some Expression parser functions to StringRef.
llvm-svn: 286208
2016-11-08 04:52:16 +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
Zachary Turner 4fa098a5c0 Convert UniqueCStringMap to use StringRef.
llvm-svn: 283494
2016-10-06 21:22:44 +00:00
Francis Ricci 51019244ab Fix GetDisplayName when only a demangled name is available
Summary:
GetDisplayDemangledName will already return a ConstString() when
there is neither a mangled name or a demangled name, so we don't need to special
case here. This will fix GetDisplayName in cases where m_mangled contains
only a demangled name and not a mangled name.

Reviewers: clayborg, granata.enrico, sas

Subscribers: lldb-commits

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

llvm-svn: 283491
2016-10-06 20:41:11 +00:00
Zachary Turner 5a8ad4591b Make lldb -Werror clean on Windows.
Differential Revision: https://reviews.llvm.org/D25247

llvm-svn: 283344
2016-10-05 17:07:34 +00:00
Dawn Perchik 9d9474ba35 Fix comment - Module::PrepareForFunctionNameLookup should be Module::LookupInfo::LookupInfo.
llvm-svn: 282941
2016-09-30 20:38:33 +00:00
Sean Callanan f9c622adfc Fixed several i386 Objective-C tests by completing objects, not their pointers.
llvm-svn: 282898
2016-09-30 18:44:43 +00:00
Zachary Turner 95eae4235d Make lldb::Regex use StringRef.
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
2016-09-21 16:01:28 +00:00
Jason Molenda f81f15a706 Force the initialization of the m_type ivar in
Function::GetStartLineSourceInfo before we try to
return the start line information about a function;
this function requires it to have been initialized.

llvm-svn: 280902
2016-09-08 02:26:58 +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
Tamas Berghammer 2a2712e062 Fix build breakage caused by r280490
llvm-svn: 280492
2016-09-02 15:56:33 +00:00
Tamas Berghammer 1d1613c966 Fix 2 waring in the OCaml AST context
llvm-svn: 280490
2016-09-02 15:52:19 +00:00
Enrico Granata befba52f89 Fix a typo/thinko - this was generating the wrong kind of array
llvm-svn: 280164
2016-08-30 21:33:29 +00:00
Enrico Granata 639392fe76 Add SBType::GetArrayType() such that - given a type - one can make an array (of a given size) of that type
This is currently only implemented for the clang-based TypeSystem, but other languages are welcome to jump in!

llvm-svn: 280151
2016-08-30 20:39:58 +00:00
Saleem Abdulrasool 5cf8e59763 Symbol: add missing item in covered switch
RenderScript was missing from the covered switch.  Add it to avoid a warning of
the missing entry.  NFC.

llvm-svn: 278774
2016-08-16 04:12:36 +00:00
Pavel Labath 1ac2b20d25 Fix expression evaluation with operator new
Summary:
referencing a user-defined operator new was triggering an assert in clang because we were
registering the function name as string "operator new", instead of using the special operator
enum, which clang has for this purpose. Method operators already had code to handle this, and now
I extend this to cover free standing operator functions as well. Test included.

Reviewers: spyffe

Subscribers: sivachandra, paulherman, lldb-commits

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

llvm-svn: 278670
2016-08-15 14:32:32 +00:00
Greg Clayton 1ae68cdee7 Make pascal debugging work again.
<rdar://problem/27652051>

llvm-svn: 278302
2016-08-10 22:55:26 +00:00
Zachary Turner f343968f5d Delete Host/windows/win32.h
It's always hard to remember when to include this file, and
when you do include it it's hard to remember what preprocessor
check it needs to be behind, and then you further have to remember
whether it's windows.h or win32.h which you need to include.

This patch changes the name to PosixApi.h, which is more appropriately
named, and makes it independent of any preprocessor setting.

There's still the issue of people not knowing when to include this,
because there's not a well-defined set of things it exposes other
than "whatever is missing on Windows", but at least this should
make it less painful to fix when problems arise.

This patch depends on LLVM revision r278170.

llvm-svn: 278177
2016-08-09 23:06:08 +00:00
Hubert Tong 3c02e188cf [Concepts] Add TODO and requires-clause placeholder; NFC
llvm-svn: 277495
2016-08-02 18:36:15 +00:00
Tamas Berghammer 00adc41370 Support for OCaml native debugging
This introduces basic support for debugging OCaml binaries.
Use of the native compiler with DWARF emission support (see
https://github.com/ocaml/ocaml/pull/574) is required.

Available variables are considered as 64 bits unsigned integers,
their interpretation will be left to a OCaml-made debugging layer.

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

llvm-svn: 277443
2016-08-02 11:15:55 +00:00
Ed Maste 75500e72bb Typo corrections identified by codespell
Submitted by giffunip@yahoo.com; I fixed a couple of nearby errors and
incorrect changes in the patch.

llvm.org/pr27634

llvm-svn: 275983
2016-07-19 15:28:02 +00:00
Jason Molenda a41deb1c69 Add missing break stmt to DW_CFA_GNU_args_size case.
llvm-svn: 275729
2016-07-17 19:57:49 +00:00
Greg Clayton 7853dd5dec Add support for Objective-C class properties.
Added test cases to exiting tests to cover the new functionality.

<rdar://problem/24311282> 

llvm-svn: 275459
2016-07-14 19:31:18 +00:00
Pavel Labath 1ee89eb8d9 Add "support" for DW_CFA_GNU_args_size to the unwinder
Summary:
This adds the knowledge of the DW_CFA_GNU_args_size instruction to the eh_frame parsing code.
Right now it is ignored as I am unsure how is it supposed to be handled, but now we are at least
able to parse the rest of the FDE containing this instruction.

I also add a fix for a bug which was exposed by this instruction. Namely, a mismatched sequence
of remember/restore instructions in the input could cause us to pop an empty stack and crash. Now
we just log the error and ignore the offending instruction.

Reviewers: jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 275260
2016-07-13 10:55:24 +00:00
Greg Clayton d28fae834a Remove assert since it was crashing the mutli process driver tests. Made the code behave correctly when indexes are out of range or the collection is empty and is "log enable lldb unwind" is enabled, log an error message.
llvm-svn: 275226
2016-07-12 23:07:50 +00:00
Greg Clayton 12261ecae4 LLDB reads incorrect memory ranges when displaying bitfields when reading bits from file memory.
Bitfields were not correctly describing their offsets within the integer that they are contained within. If we had a bitfield like:

struct MyStruct {
  uint32_t a:8;
  uint32_t b:8;
};
        
ClangASTContext::GetChildCompilerTypeAtIndex would say that child a and b had the following values in their respective ValueObjectChild objects:

name byte-size bit-size bit-offset byte-offset-from-parent
==== ========= ======== ========== =======================
"a"  4         8        0          0
"b"  4         8        0          1

So if we had a "MyStruct" at address 0x1000, we would end up reading 4 bytes from 0x1000 for "a", and 4 bytes from 0x1001 for "b". The fix for this is to fix the "child_byte_offset" and "child_bitfield_bit_offset" values returned by ClangASTContext::GetChildCompilerTypeAtIndex() so that now the table looks like:

name byte-size bit-size bit-offset byte-offset-from-parent
==== ========= ======== ========== =======================
"a"  4         8        0          0
"b"  4         8        8          0

Then we don't run into a problem when reading data from a file's section info using "target variable" before running. It will also stop us from not being able to display a bitfield values if the bitfield is in the last bit of memory before an unmapped region. (Like if address 0x1004 was unmapped and unreadable in the example above, if we tried to read 4 bytes from 0x1001, the memory read would fail and we wouldn't be able to display "b").

<rdar://problem/27208225> 

llvm-svn: 274701
2016-07-06 23:11:13 +00:00
Jason Molenda 0ecfe44092 Enhance FuncUnwinders::GetUnwindPlanAtNonCallSite to detect when we
may be in a function that is non-ABI conformant, and the eh_frame
instructions correctly describe how to unwind out of this function,
but the assembly parsing / arch default unwind plans would be 
incorrect.

This is to address a problem that Ravitheja Addepally reported in
http://reviews.llvm.org/D21221 - I wanted to try handling the problem
with this approach which I think may be more generally helpful, 
Ravitheja tested it and said it solves the problem on Linux/FreeBSD.
Ravi has a test case in http://reviews.llvm.org/D21221 that will
be committed separately.

Thanks for all the help on this one, Ravi.

llvm-svn: 274700
2016-07-06 23:06:19 +00:00
Greg Clayton ad2b63cbaa Warning about debugging optimized code was not happening without dSYMs. Now it works for DWARF in .o files on Darwin.
I changed "m_is_optimized" in lldb_private::CompileUnit over to be a lldb::LazyBool so that it can be set to eLazyBoolCalculate if it needs to be parsed later. With SymbolFileDWARFDebugMap, we don't actually open the DWARF in the .o files for each compile unit until later, and we can't tell if a compile unit is optimized ahead of time. So to avoid pulling in all .o right away just so we can answer the questions of "is this compile unit optimized" we defer it until a point where we will have the compile unit parsed.

<rdar://problem/26068360> 

llvm-svn: 274585
2016-07-05 23:01:20 +00:00
Tamas Berghammer 40aac2b8ae Fix ClangASTContext after some clang API changes
llvm-svn: 274488
2016-07-04 09:11:08 +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
Greg Clayton d781d2c9b7 64-bit LEB values are not always correctly decoded due to a casting issue, now they are.
<rdar://problem/27002247> 

llvm-svn: 274037
2016-06-28 17:14:18 +00:00