Commit Graph

532 Commits

Author SHA1 Message Date
Greg Clayton e01e07b6e7 Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.
Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.

llvm-svn: 179779
2013-04-18 18:10:51 +00:00
Ashok Thirumurthi b32f6bff30 Fix for regression in TestCPPStaticMethods.py due to refactoring in clang.
- Specify SC_Static given DIE attributes for static methods and operators.

Thanks to Wei Pan for his review and the help with root-causing.

llvm-svn: 179727
2013-04-17 21:36:33 +00:00
Greg Clayton 9594f4c818 Fixed issues with the way ELF symbols are parsed:
- Do not add symbols with no names
- Make sure that symbols from ELF symbol tables know that the byte size is correct. Previously the symbols would calculate their sizes by looking for the next symbol and take symbols that had zero size and make them have invalid sizes.
- Added the ability to dump raw ELF symbols by adding a Dump method to ELFSymbol

Also removed some unused code from lldb_private::Symtab.

llvm-svn: 179466
2013-04-13 23:17:23 +00:00
Greg Clayton 973b6c9b00 Static variables inside classes were not being added to the RecordDecl, now they are. This gets us closer to being able to display static variables in classes.
llvm-svn: 179296
2013-04-11 16:57:51 +00:00
Greg Clayton 1c8ef47681 Added support "__attribute__((__vector_size__(B)))" and "__attribute__((ext_vector_type(N)))".
Now we can:
1 - see the return value for functions that return types that use the "ext_vector_size"
2 - dump values that use the vector attributes ("expr $ymm0")
3 - modified the DWARF parser to correctly parse GNU vector types from the DWARF by turning them into clang::Type::ExtVector types instead of just standard arrays

llvm-svn: 178924
2013-04-05 23:27:21 +00:00
Greg Clayton bc43cab51d <rdar://problem/13384801>
Make lldb_private::RegularExpression thread safe everywhere. This was done by removing the m_matches array from the lldb_private::RegularExpression class and putting it into the new lldb_private::RegularExpression::Match class. When executing a regular expression you now have the option to create a lldb_private::RegularExpression::Match object and pass a pointer in if you want to get parenthesized matching. If you don't want any matching, you pass in NULL. The lldb_private::RegularExpression::Match object is initialized with the number of matches you desire. Any matching strings are now extracted from the lldb_private::RegularExpression::Match objects. This makes the regular expression objects thread safe and as a result many more regex objects were turned into static objects that end up using a local lldb_private::RegularExpression::Match object when executing.

llvm-svn: 178702
2013-04-03 21:37:16 +00:00
Rafael Espindola f24933f65e Fix build.
This should fix the build breakage caused by the api change in 178663.

llvm-svn: 178700
2013-04-03 21:29:21 +00:00
Greg Clayton 43fe217b11 <rdar://problem/13506727>
Symbol table function names should support lookups like symbols with debug info. 

To fix this I:
- Gutted the way FindFunctions is used, there used to be way too much smarts only in the DWARF plug-in
- Made it more efficient by chopping the name up once and using simpler queries so that SymbolFile and Symtab plug-ins don't need to do as much
- Filter the results at a higher level
- Make the lldb_private::Symtab able to chop up C++ mangled names and make as much sense out of them as possible and also be able to search by basename, fullname, method name, and selector name.

llvm-svn: 178608
2013-04-03 02:00:15 +00:00
Sean Callanan 6447c47541 Elide all artificial copy constructors, because
they are probably trivial.  This means that we
don't confuse Clang about whether a class is
trivially copy constructible.  It can figure
that out itself as long as we don't explicitly
feed it the constructors.

If the class is trivially copy-constructible,
this can change the ABI that Clang uses to call
functions that return that class (e.g., by making
the object be returned in a register), so this
is quite important for correctness.

<rdar://problem/13457741>

llvm-svn: 178411
2013-03-30 03:06:45 +00:00
Sean Callanan e55bc8a9c1 Fixed the way ClangASTImporter deports types from
ASTContexts that will not stay around.  Before, we
did this in a very half-hearted way.  Now we maintain
work queues of all Decls that need to be completed
before the source ASTContext can go away; we then
expunge their origins completely.

<rdar://problem/13511875>

llvm-svn: 178410
2013-03-30 02:31:21 +00:00
Greg Clayton 5160ce5c72 <rdar://problem/13521159>
LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down.

All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down.

llvm-svn: 178191
2013-03-27 23:08:40 +00:00
Greg Clayton d00294483e Don't use a "uintptr_t" for the metadata key, use a "void *". This removes all of the casts that were being used and cleans the code up a bit. Also added the ability to dump the metadata.
llvm-svn: 178113
2013-03-27 01:48:02 +00:00
Greg Clayton 365fe21947 Add a way to dump a ClangASTType to stdout for debugging purposes.
llvm-svn: 178071
2013-03-26 21:01:37 +00:00
Jason Molenda c1946cd8e1 Don't bother calling Reserve on the vector unless we have entries to be added.
llvm-svn: 177776
2013-03-22 23:42:09 +00:00
Jason Molenda ee7593fbff Add a Reserve method to RangeVector and RangeDataVector. Have the
DWARFCallFrameInfo method which returns a RangeVector pre-size the
vector based on the number of entries it will be adding insted of
growing the vector as items are added.

llvm-svn: 177773
2013-03-22 22:43:14 +00:00
Sean Callanan 6b200d0b3e Modified the way we report fields of records.
Clang requires them to have complete types, but
we were previously only completing them if they
were of tag or Objective-C object types.

I have implemented a method on the ASTImporter
whose job is to complete a type.  It handles not
only the cases mentioned above, but also array
and atomic types.

<rdar://problem/13446777>

llvm-svn: 177672
2013-03-21 22:15:41 +00:00
Jason Molenda 5635f77a99 Add a new method GetFunctionAddressAndSizeVector to DWARFCallFrameInfo.
This returns a vector of <file address, size> entries for all of
the functions in the module that have an eh_frame FDE.

Update ObjectFileMachO to use the eh_frame FDE function addresses if
the LC_FUNCTION_STARTS section is missing, to fill in the start 
addresses of any symbols that have been stripped from the binary.

Generally speaking, lldb works best if it knows the actual start
address of every function in a module - it's especially important
for unwinding, where lldb inspects the instructions in the prologue
of the function.  In a stripped binary, it is deprived of this
information and it reduces the quality of our unwinds and saved
register retrieval.  

Other ObjectFile users may want to use the function addresses from 
DWARFCallFrameInfo to fill in any stripped symbols like ObjectFileMachO
does already.
<rdar://problem/13365659> 

llvm-svn: 177624
2013-03-21 03:36:01 +00:00
Jason Molenda 7430382970 Change DWARFCallFrameInfo from using a vector of AddressRanges to
track the EH FDEs for the functions in a module to using a
RangeDataVector, a more light-weight data structure that only refers
to File addresses.  Makes the initial FDE scan about 3x faster, uses
less memory.
<rdar://problem/13465650> 

llvm-svn: 177585
2013-03-20 21:57:42 +00:00
Enrico Granata bdbda93f35 Cleanup to the ObjC runtime to remove the now useless ClassDescriptor_Invalid
llvm-svn: 177558
2013-03-20 19:04:28 +00:00
Enrico Granata 92373533a5 The formatters for std::shared_ptr, std::weak_ptr, std::list, std::vector and std::map as provided by libc++ are now written in C++ instead of Python
std::deque is still in Python but is much less commonly used

llvm-svn: 177454
2013-03-19 22:58:48 +00:00
Enrico Granata 7277d201a9 Performance improvements to the IsObjCNil () - we only try to resolve the value if the variable under consideration truly is an “Objective-C thing”
This also changes the ClangASTContext to make sure that id is correctly marked as being such an ObjC thing

llvm-svn: 177203
2013-03-15 23:33:15 +00:00
Greg Clayton faac111870 <rdar://problem/13421412>
Many "byte size" members and variables were using a mixture of uint32_t and size_t. Switching over to using uint64_t everywhere.

llvm-svn: 177091
2013-03-14 18:31:44 +00:00
Greg Clayton 617995c095 <rdar://problem/13413693>
Fixed a crasher in the new DWARF in .o files line table linking function where "back()" could end up being called on an empty std::vector.

llvm-svn: 177082
2013-03-14 16:47:56 +00:00
Sean Callanan 34cf820b8a Switch from CreateTypeSourceInfo, which allocates
uninitialized memory, to getTrivialTypeSourceInfo,
which initializes its memory, when creating trivial
TypeSourceInfos.

<rdar://problem/13332253>

llvm-svn: 176899
2013-03-12 21:22:00 +00:00
Matt Kopec 787d1623b0 Misc. clang build warning fixes.
llvm-svn: 176879
2013-03-12 17:45:38 +00:00
Sean Callanan 6c9265b07e Made LLDB work with the latest Clang. Also fixed
an assertion due to non-implicit Objective-C methods
without source locations.

llvm-svn: 176750
2013-03-09 01:59:31 +00:00
Sean Callanan 8106d8082c Added very lightweight, statically-allocated
counters for a variety of metrics associated
with expression parsing.  This should give some
idea of how much work the expression parser is
doing on Clang's behalf, and help with hopefully
reducing that load over time.

<rdar://problem/13210748> Audit type search/import for expressions

llvm-svn: 176714
2013-03-08 20:04:57 +00:00
Greg Clayton 1bbcc03455 <rdar://problem/13374267>
Fixed error where objective C methods with selectors names starting with ".cxx_" where causing errors for ARC built binaries.

llvm-svn: 176683
2013-03-08 02:42:06 +00:00
Greg Clayton c4ffd66f06 <rdar://problem/13119621>
Make dynamic type detection faster by using the AST metadata to help out and allow us not to complete types when we don't need to.

After running "purge" on a MacOSX system, the Xcode variables view now populates more than 3x faster with this fix.

llvm-svn: 176676
2013-03-08 01:37:30 +00:00
Greg Clayton 084fad6a51 <rdar://problem/13362109>
LLDB was not parsing line tables correctly for DWARF in .o files after recent debug map changes. This has now been fixed. 

llvm-svn: 176592
2013-03-06 23:23:27 +00:00
Greg Clayton 5d14fc061f Fixed enum printing for negative enums. There previously was no testing to validate that enum values were being displayed correctly.
Also added C++11 enum test cases to cover enums as int8_t, int16_t int32_t, int64_t, uint8_t, uint16_t, uint32_t, and uint64_t both for DWARF and dSYM cases. The DWARF being emitted by clang is missing the enum integer type, but the code is now ready to accept and deal with the integral type if it is supplied.

llvm-svn: 176548
2013-03-06 06:23:54 +00:00
Greg Clayton 3e06753408 <rdar://problem/13341472>
LLDB wasn't printing the names for negative enums. Fixed the signed extraction of enumerators and how they were registered with clang's type system.

llvm-svn: 176533
2013-03-05 23:54:39 +00:00
Greg Clayton 9422dd64f8 <rdar://problem/13338643>
DWARF with .o files now uses 40-60% less memory!

Big fixes include:
- Change line table internal representation to contain "file addresses". Since each line table is owned by a compile unit that is owned by a module, it makes address translation into lldb_private::Address easy to do when needed.
- Removed linked address members/methods from lldb_private::Section and lldb_private::Address
- lldb_private::LineTable can now relink itself using a FileRangeMap to make it easier to re-link line tables in the future
- Added ObjectFile::ClearSymtab() so that we can get rid of the object file symbol tables after we parse them once since they are not needed and kept memory allocated for no reason
- Moved the m_sections_ap (std::auto_ptr to section list) and m_symtab_ap (std::auto_ptr to the lldb_private::Symtab) out of each of the ObjectFile subclasses and put it into lldb_private::ObjectFile.
- Changed how the debug map is parsed and stored to be able to:
    - Lazily parse the debug map for each object file
    - not require the address map for a .o file until debug information is linked for a .o file

llvm-svn: 176454
2013-03-04 21:46:16 +00:00
Enrico Granata c1a5b2eba8 <rdar://problem/12897838>
Making sure we do not try to copy memory at address 0 - that would make us crash

llvm-svn: 176438
2013-03-04 17:20:57 +00:00
Sean Callanan 933ca2e2ea Fixed some problems with type deportation:
- made sure we tell Clang not to try to
    complete the type since it can't be
    completed from its origin any more; and

  - fixed a silly bug where we tried to
    forget about the original decl's origins
    rather than the deported decl's origin.

These produced some crashes in ptr_refs,
especially under libgmalloc.

<rdar://problem/13256150>

llvm-svn: 176233
2013-02-28 03:12:58 +00:00
Greg Clayton 059f724170 Added eSymbolTypeResolver to a few switch statements that needed it.
llvm-svn: 176210
2013-02-27 21:16:04 +00:00
Matt Kopec 00049b8b96 Add GNU indirect function support in expressions for Linux.
llvm-svn: 176206
2013-02-27 20:13:38 +00:00
Greg Clayton 72310355ff <rdar://problem/13265297>
StackFrame assumes m_sc is additive, but m_sc can lose its target. So now the SymbolContext::Clear() method takes a bool that indicates if the target should be cleared. Modified all existing code to properly set the bool argument.

llvm-svn: 175953
2013-02-23 04:12:47 +00:00
Daniel Malea 23720cc66c Adding CMake build system to LLDB. Some known issues remain:
- generate-vers.pl has to be called by cmake to generate the version number
- parallel builds not yet supported; dependency on clang must be explicitly specified

Tested on Linux.
- Building on Mac will require code-signing logic to be implemented.
- Building on Windows will require OS-detection logic and some selective directory inclusion

Thanks to Carlo Kok (who originally prepared these CMakefiles for Windows) and Ben Langmuir
who ported them to Linux!

llvm-svn: 175795
2013-02-21 20:58:22 +00:00
Sean Callanan 37f76e53d7 Updated to support latest Clang option naming.
llvm-svn: 175546
2013-02-19 19:16:37 +00:00
Greg Clayton 142c5a4f66 Quiet "the missing case in switch statement" warnings from newer clang builds.
llvm-svn: 175061
2013-02-13 18:15:56 +00:00
Sean Callanan eeffea416b Made LLDB build with the latest Clang. This meant
changing the ClangASTSource to return a bool instead
of returning a list of results.  Our testsuite mostly
works with this change, but some minor issues may
remain both on LLDB's side and on Clang's side.

llvm-svn: 174949
2013-02-12 08:01:13 +00:00
Greg Clayton 2452ab7fa8 Fixed 2 more issues found by the address sanitizer:
1 - A store off the end of a buffer in ValueObject.cpp
2 - DataExtractor had cases where bad offsets could cause invalid memory to be accessed.

llvm-svn: 174757
2013-02-08 22:02:02 +00:00
Sean Callanan c3a1d5629a Fixed a problem that would cause LLDB to crash
if it encountered bad debug information.  This
debug information had an Objective-C method whose
selector disagreed with the true number of arguments
to that method.

<rdar://problem/12992864>

llvm-svn: 174557
2013-02-06 23:21:59 +00:00
Greg Clayton 5ce9c5657c <rdar://problem/13159777>
lldb was mmap'ing archive files once per .o file it loads, now it correctly shares the archive between modules.

LLDB was also always mapping entire contents of universal mach-o files, now it maps just the slice that is required.

Added a new logging channel for "lldb" called "mmap" to help track future regressions.

Modified the ObjectFile and ObjectContainer plugin interfaces to take a data offset along with the file offset and size so we can implement the correct caching and efficient reading of parts of files without mmap'ing the entire file like we used to.

The current implementation still keeps entire .a files mmaped (once) and entire slices from universal files mmaped to ensure that if a client builds their binaries during a debug session we don't lose our data and get corrupt object file info and debug info.

llvm-svn: 174524
2013-02-06 17:22:03 +00:00
Greg Clayton 906ba47143 <rdar://problem/11109570>
The first part of the fix for having LLDB handle LTO debugging when the DWARF is in the .o files. This part separates the object file's modules into a separate cache map that maps unique C strings for the N_OSO path to the ModuleSP since one object file might be mentioned more than once in LTO binaries.

llvm-svn: 174476
2013-02-06 00:38:25 +00:00
Greg Clayton 39f7ee86c8 <rdar://problem/13092722>
Fix in loading mach files from memory when using DynamicLoaderMacOSXDYLD.

Removed the uuid mismatch warning that could be spit out and any time during debugging and removed the test case that was looking for that. Currently the "add-dsym" or "target symbols add" command will report an error when the UUID's don't match.

Be more careful when checking and resolving section + offset addresses to make sure none of the base addresses are invalid.

llvm-svn: 174222
2013-02-01 21:38:35 +00:00
Sean Callanan fa4fab77d4 Modified the expression parser's class wrapper to
support reporting "this" as a templated class.  The
expression parser wraps expressions in C++ methods
as methods with the signature

$__lldb_class::$__lldb_expr(...)

and previously responded to clang's queries about
$__lldb_class with the type of *this.  This didn't
work if *this was a ClassTemplateSpecializationDecl
because ClassTemplateSpecializationDecls can't be
the result of simple name queries.

Instead what we do now is respond that $__lldb_class
is a typedef and that the target of the typedef is
the (potentially templated) type of *this.  That is
much more robust.

Thanks to John McCall for key insights.

<rdar://problem/10987183>

llvm-svn: 174153
2013-02-01 06:55:48 +00:00
Greg Clayton 3dcaa2c8c8 Get rid for switch statement warning for unhandled cases.
llvm-svn: 174128
2013-02-01 00:46:49 +00:00
Greg Clayton 1b3815cbf4 <rdar://problem/9141269>
Cleaned up the objective C name parsing code to use a class.

Now breakpoints that are set by name that are objective C methods without the leading '+' or '-' will resolve. We do this by expanding all the objective C names for a given string. For example:

(lldb) b [MyString cStringUsingEncoding:]

Will set a breakpoint with multiple possible names: 
-[MyString cStringUsingEncoding:]
+[MyString cStringUsingEncoding:]

Also if you have a category, it will strip the category and set a breakpoint in all variants:

(lldb) [MyString(my_category) cStringUsingEncoding:]

Will resolve to the following names:

-[MyString(my_category) cStringUsingEncoding:]
+[MyString(my_category) cStringUsingEncoding:]
-[MyString cStringUsingEncoding:]
+[MyString cStringUsingEncoding:]

Likewise when we have:

(lldb) b -[MyString(my_category) cStringUsingEncoding:]

It will resolve to two names:
-[MyString(my_category) cStringUsingEncoding:]
-[MyString cStringUsingEncoding:]

llvm-svn: 173858
2013-01-30 00:18:29 +00:00