Commit Graph

596 Commits

Author SHA1 Message Date
Sean Callanan b5717e00c8 Added support for registers to the Materializer.
Also improved logging and error handling in a few
spots in the Materializer.

llvm-svn: 179557
2013-04-15 20:51:24 +00:00
Sean Callanan b024d87822 Audited the existing Materializer code to ensure
that it works in the absence of a process.  Codepaths
in the Materializer now use the best execution context
scope available to them.

llvm-svn: 179539
2013-04-15 17:12:47 +00:00
Sean Callanan 2f1edcd758 Added symbol materialization support to the new
Materializer.

llvm-svn: 179445
2013-04-13 02:25:02 +00:00
Sean Callanan 458ae1c6eb Now that ValueObjects permit writing, made the
Materializer use that API when dematerializing
variables.

llvm-svn: 179443
2013-04-13 02:06:42 +00:00
Sean Callanan f8043fa527 Implemented materialization and dematerialization
for variables in the new Materializer.  This is
much easier now that the ValueObject API is solid.

I still have to implement reading bytes into a
ValueObject, but committing what I have so far.

This code is not yet used, so there will be fixes
when I switch the expression parser over to use the
new Materializer.

llvm-svn: 179416
2013-04-12 21:40:34 +00:00
Sean Callanan 35005f768e Replicated the materialization logic for persistent
variables in the Materializer.  We don't use this
code yet, but will soon once the other materializers
are online.

llvm-svn: 179390
2013-04-12 18:10:34 +00:00
Sean Callanan 3dd6a42306 Hand over the job of laying out the argument structure
to the Materializer.  Materialization is still done by
the ClangExpressionDeclMap; this will be the next thing
to move.

Also fixed a layout bug that this uncovered.

llvm-svn: 179318
2013-04-11 21:16:36 +00:00
Sean Callanan 0ff3bf96f2 Handle C++ static variables in the expression
parser.

<rdar://problem/13631469>

llvm-svn: 179304
2013-04-11 17:57:16 +00:00
Sylvestre Ledru 9eb4b33f85 cmake build of lldb was complaining about missing files.
Example:
CMake Error at cmake/modules/LLVMProcessSources.cmake:89 (message):
  Found unknown source file
  /llvm-toolchain-3.3~svn179293.cmake/tools/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

llvm-svn: 179295
2013-04-11 16:32:47 +00:00
Sean Callanan df66765d35 Changed the way ClangExpressionDeclMap registers
entities with the new Materializer so that it only
registers those entities that actually need to be
placed in the struct.

llvm-svn: 179253
2013-04-11 02:05:11 +00:00
Sean Callanan 96d2730a7b Added a Materializer class that contains
information about each variable that needs to
be materialized for an expression to work.  The
next step is to migrate all materialization code
from ClangExpressionDeclMap to Materializer, and
to use it for variable materialization.

llvm-svn: 179245
2013-04-11 00:09:05 +00:00
Sean Callanan dfb87d616b Hardening so we won't crash if an Objective-C interface
doesn't have a corresponding type.

<rdar://problem/13596142>

llvm-svn: 179130
2013-04-09 21:30:48 +00:00
Sean Callanan ec1c0b3faa Fixed the way we allocate executable memory on
behalf of the JIT.  We don't need it to be writable
since we are using special APIs to write into it.

<rdar://problem/13599185>

llvm-svn: 179077
2013-04-09 01:13:08 +00:00
Sean Callanan 5a1af4e63a Factored out memory access into the target process
from IRExecutionUnit into a superclass called
IRMemoryMap.  IRMemoryMap handles all reading and
writing, ensuring that areas are kept track of and
memory is properly cached (and deleted).

Also fixed several cases where we would simply leak
binary data in the target process over time.  Now
the expression objects explicitly own their
IRExecutionUnit and delete it when they go away.  This
is why I had to modify ClangUserExpression,
ClangUtilityFunction, and ClangFunction.

As a side effect of this, I am removing the JIT
mutex for an IRMemoryMap.  If it turns out that we
need this mutex, I'll add it in then, but right now
it's just adding complexity.

This is part of a more general project to make
expressions fully reusable.  The next step is to
make materialization and dematerialization use
the IRMemoryMap API rather than writing and
reading directly from the process's memory. 
This will allow the IR interpreter to use the
same data, but in the host's memory, without having
to use a different set of pointers.

llvm-svn: 178832
2013-04-05 02:22:57 +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 eeb4384924 Enabled blocks support in the expression parser.
Note: although it is now possible to declare blocks
and call them inside the same expression, we do not
generate correct block descriptors so these blocks
cannot be passed to functions like dispatch_async.

<rdar://problem/12578656>

llvm-svn: 178509
2013-04-01 22:12:37 +00:00
Sean Callanan 42f26b488b Disable warnings from Clang correctly, by directly
manipulating the diagnostics engine.

<rdar://problem/13508470>

llvm-svn: 178399
2013-03-30 01:26:06 +00:00
Greg Clayton 3faf47c462 <rdar://problem/11730263>
PC relative loads are missing disassembly comments when disassembled in a live process.

This issue was because some sections, like __TEXT and __DATA in libobjc.A.dylib, were being moved when they were put into the dyld shared cache. This could also affect any other system that slides sections individually.

The solution is to keep track of wether the bytes we will disassemble are from an executable file (file address), or from a live process (load address). We now do the right thing based off of this input in all cases.

llvm-svn: 178315
2013-03-28 23:42:53 +00:00
Jim Ingham 23460c369c Use the error from ValidatePlan.
llvm-svn: 178204
2013-03-28 00:08:00 +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
Sean Callanan 44bc657efe Fixed a problem where inline assembly errors caused
LLDB to crash.

<rdar://problem/13497915>

llvm-svn: 178115
2013-03-27 03:09:55 +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
Sean Callanan eb7b27dab5 Fixed a potential crash if layout for a structure
went wrong and we tried to get layout information
that wasn't there.

<rdar://problem/13490170>

llvm-svn: 177880
2013-03-25 18:27:07 +00:00
Sean Callanan 719a4d5d83 If there are multiple uses of an Objective-C
class symbol in the same expression, handle all
of them instead of just the first one.

<rdar://problem/13440133>

llvm-svn: 177794
2013-03-23 01:01:16 +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
Andy Gibbs 27f065af2c Update source/Expression/CMakeLists.txt to reflect actual source files.
llvm-svn: 177503
2013-03-20 09:34:46 +00:00
Sean Callanan 2c04735630 Updated the IRExecutionUnit to keep local copies
of the data it writes down into the process even
if the process doesn't exist.  This will allow
the IR interpreter to access static data allocated
on the expression's behalf.

Also cleaned up object ownership in the
IRExecutionUnit so that allocations are created
into the allocations vector.  This avoids needless
data copies.

<rdar://problem/13424594>

llvm-svn: 177456
2013-03-19 23:03:21 +00:00
Sean Callanan 9be9d172bf Fixed handling of function pointers in the IR
interpreter.  They now have correct values, even
when the process is not running.

llvm-svn: 177372
2013-03-19 01:45:02 +00:00
Sean Callanan 8dfb68e039 Refactored the expression parser so that the IR
and the JITted code are managed by a standalone
class that handles memory management itself.

I have removed RecordingMemoryManager and
ProcessDataAllocator, which filled similar roles
and had confusing ownership, with a common class
called IRExecutionUnit.  The IRExecutionUnit
manages all allocations ever made for an expression
and frees them when it goes away.  It also contains
the code generator and can vend the Module for an
expression to other clases.

The end goal here is to make the output of the
expression parser re-usable; that is, to avoid
re-parsing when re-parsing isn't necessary.

I've also cleaned up some code and used weak pointers
in more places.  Please let me know if you see any
leaks; I checked myself as well but I might have
missed a case.

llvm-svn: 177364
2013-03-19 00:10:07 +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
Sean Callanan c4b1ab442d Fixed a problem where we didn't return TypedefNameDecls
when clang asked for them by name.

llvm-svn: 177085
2013-03-14 17:21:53 +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
Sylvestre Ledru 1573b1b32c Match the new declaration of clang::ASTContext::getFunctionType introduced in clang r176726. Fix the build of lldb
llvm-svn: 176790
2013-03-10 20:13:16 +00:00
Sean Callanan 83b3da95f6 Removed One Definition Rule warnings because they're
noisy when dealing with anonymous structs.

<rdar://problem/13246914>

llvm-svn: 176738
2013-03-08 23:38:53 +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
Andrew Kaylor 9e9f1db866 Adding support for DW_OP_stack_value in DWARFExpression::Evaluate
llvm-svn: 176578
2013-03-06 21:13:09 +00:00
Sean Callanan f58b12d8eb Added a little bit of logging to ClangFunction to
make it more obvious what's going on.

llvm-svn: 176575
2013-03-06 19:57:25 +00:00
Andrew Kaylor 60cdeb6aa8 Add support for non-register scalar values in DoMaterializeOneVariable.
llvm-svn: 176574
2013-03-06 19:35:33 +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
Jim Ingham 0f063ba6b4 Convert from the C-based LLVM Disassembler shim to the full MC Disassembler API's.
Calculate "can branch" using the MC API's rather than our hand-rolled regex'es.
As extra credit, allow setting the disassembly flavor for x86 based architectures to intel or att.

<rdar://problem/11319574>
<rdar://problem/9329275>

llvm-svn: 176392
2013-03-02 00:26:47 +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
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
Matt Kopec 676a48751d Fix clang warnings related to python macro redefinition and printf format specifiers.
llvm-svn: 175829
2013-02-21 23:55:31 +00:00
Andrew Kaylor cd5c7247ab Change to JITDefault code model for ELF targets
On x86-64 platforms, the small code model assumes that code will be loaded below the 2GB boundary.  With the static relocation model, the fact that the expression code is initially loaded (in the LLDB debugger address space) above that boundary causes problems.  Switching to the JITDefault code model causes the large code model to be used for 64-bit targets and small code model of 32-bit targets.

llvm-svn: 175828
2013-02-21 23:45:19 +00:00
Sean Callanan d4fac256b0 Hardening in case a thread's frames are missing.
<rdar://problem/13254824>

llvm-svn: 175806
2013-02-21 22:01:43 +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 b45a6f065e Fixed a bug where certain vector code didn't
work on i386.  Now we let the JIT emit SSE/SSE2
instructions on i386.

<rdar://problem/13240476>

llvm-svn: 175700
2013-02-21 01:04:23 +00:00