Commit Graph

596 Commits

Author SHA1 Message Date
Sean Callanan fc16cc0a0c Removed the -i option from the expr command, and
made IR-based expression evaluation the default.

Also added a new class to hold persistent variables.
The class is empty as yet while I write up a design
document for what it will do.  Also the place where
it is currently created (by the Expression command)
is certainly wrong.

llvm-svn: 110415
2010-08-06 00:35:32 +00:00
Greg Clayton f4b47e1579 Abtracted the old "lldb_private::Thread::StopInfo" into an abtract class.
This will allow debugger plug-ins to make any instance of "lldb_private::StopInfo"
that can completely describe any stop reason. It also provides a framework for
doing intelligent things with the stop info at important times in the lifetime
of the inferior. 

Examples include the signal stop info in StopInfoUnixSignal. It will check with
the process to see that the current action is for the signal. These actions
include wether to stop for the signal, wether the notify that the signal was
hit, and wether to pass the signal along to the inferior process. The 
StopInfoUnixSignal class overrides the "ShouldStop()" method of StopInfo and
this allows the stop info to determine if it should stop at the signal or 
continue the process. 


StopInfo subclasses must override the following functions:

    virtual lldb::StopReason
    GetStopReason () const = 0;

    virtual const char *
    GetDescription () = 0;


StopInfo subclasses can override the following functions:


    // If the subclass returns "false", the inferior will resume. The default
    // version of this function returns "true" which means the default stop
    // info will stop the process. The breakpoint subclass will check if
    // the breakpoint wants us to stop by calling any installed callback on
    // the breakpoint, and also checking if the breakpoint is for the current
    // thread. Signals will check if they should stop based off of the 
    // UnixSignal settings in the process.
    virtual bool
    ShouldStop (Event *event_ptr);

    // Sublasses can state if they want to notify the debugger when "ShouldStop"
    // returns false. This would be handy for breakpoints where you want to
    // log information and continue and is also used by the signal stop info
    // to notify that a signal was received (after it checks with the process
    // signal settings).
    virtual bool
    ShouldNotify (Event *event_ptr)
    {
        return false;
    }

    // Allow subclasses to do something intelligent right before we resume.
    // The signal class will figure out if the signal should be propagated
    // to the inferior process and pass that along to the debugger plug-ins.
    virtual void
    WillResume (lldb::StateType resume_state)
    {
        // By default, don't do anything
    }


The support the Mach exceptions was moved into the lldb/source/Plugins/Process/Utility
folder and now doesn't polute the lldb_private::Thread class with platform
specific code.

llvm-svn: 110184
2010-08-04 01:40:35 +00:00
Sean Callanan 5666b674f3 Added support for accessing members of C++ objects,
including superclass members.  This involved ensuring
that access control was ignored, and ensuring that
the operands of BitCasts were properly scanned for
variables that needed importing.

Also laid the groundwork for declaring objects of
custom types; however, this functionality is disabled
for now because of a potential loop in ASTImporter.

llvm-svn: 110174
2010-08-04 01:02:13 +00:00
Greg Clayton b0b9fe610a Added support for objective C built-in types: id, Class, and SEL. This
involved watching for the objective C built-in types in DWARF and making sure
when we convert the DWARF types into clang types that we use the appropriate
ASTContext types.

Added a way to find and dump types in lldb (something equivalent to gdb's 
"ptype" command):

    image lookup --type <TYPENAME>

This only works for looking up types by name and won't work with variables.
It also currently dumps out verbose internal information. I will modify it
to dump more appropriate user level info in my next submission.

Hookup up the "FindTypes()" functions in the SymbolFile and SymbolVendor so
we can lookup types by name in one or more images.

Fixed "image lookup --address <ADDRESS>" to be able to correctly show all
symbol context information, but it will only show this extra information when
the new "--verbose" flag is used.

Updated to latest LLVM to get a few needed fixes.

llvm-svn: 110089
2010-08-03 00:35:52 +00:00
Sean Callanan 4cf04d209b Set a CodeGenOption in Clang to inhibit insertion
of profiling code into expressions.

Modified IRForTarget to emit array and record
member accesses correctly.  (Reading and writing
both work.)

llvm-svn: 110088
2010-08-03 00:23:29 +00:00
Sean Callanan 5300d37aa7 Added support for rewriting objc_msgSend so we can
call Objective-C methods from expressions.  Also added
some more logging to the function-calling thread plan
so that we can see the registers when a function
finishes.

Also documented things maybe a bit better.

llvm-svn: 109938
2010-07-31 01:32:05 +00:00
Greg Clayton e637112102 Updated to llvm/clang from July 30, 2010 at 08:00.
llvm-svn: 109887
2010-07-30 20:30:44 +00:00
Johnny Chen 1bb9bc72b9 Fixed "warning: unused variable 'log'".
llvm-svn: 109794
2010-07-29 19:51:52 +00:00
Sean Callanan 4ed7c5b2f8 Fixed the expression code to use the right
code model with the JIT.

llvm-svn: 109792
2010-07-29 19:03:08 +00:00
Sean Callanan cc54bd3cef Added and improved logging. This is helping us as we
diagnose a problem where we're not correctly emitting
PIC code.

llvm-svn: 109568
2010-07-28 01:00:59 +00:00
Sean Callanan 7ea3501bd8 Added support for calling functions from expressions.
Right now we mock up the function as a variadic
function when generating the IR for the call; we need
to eventually make the function be the right type if
the type is available.

llvm-svn: 109543
2010-07-27 21:39:39 +00:00
Sean Callanan 4edba2d130 Added support for locating a function that is
referenced in the IR.  We don't yet support updating
the call to that function.

llvm-svn: 109483
2010-07-27 02:07:53 +00:00
Sean Callanan b27a62fd13 Fixed a bug in the IR transformer where we were
trying to do replaceUsesOfWith on a constant,
which doesn't work.  Turns out we don't need to
do anything for constants.

llvm-svn: 109477
2010-07-27 01:17:28 +00:00
Sean Callanan 8ade104a0a Changed SymbolContext so when you search for functions
it returns a list of functions as a SymbolContextList.

Rewrote the clients of SymbolContext to use this
SymbolContextList.

Rewrote some of the providers of the data to SymbolContext
to make them respect preferences as to whether the list
should be cleared first; propagated that change out.

ClangExpressionDeclMap and ClangASTSource use this new
function list to properly generate function definitions -
even for functions that don't have a prototype in the
debug information.

llvm-svn: 109476
2010-07-27 00:55:47 +00:00
Sean Callanan 138e74e347 Fixed a bug where we didn't restore thread and
frame state after running a function.  This
caused nondeterministic crashes in the expression
evaluation code.

llvm-svn: 109454
2010-07-26 22:14:36 +00:00
Sean Callanan ddb46efcca Updated the IR converter for the target to eliminate
spurious guard variables on expression statics.

Updated the AST result synthesizer to eliminate the
unneeded result pointer.

Very rudimentary expressions now evaluate correctly
in the target using the new JIT-based mechanism.

llvm-svn: 109317
2010-07-24 01:37:44 +00:00
Sean Callanan 289e07b9d0 Added logging:
- When we JIT an expression, we print the disassembly
  of the generated code
- When we put the structure into the target, we print
  the individual entries in the structure byte for
  byte.

llvm-svn: 109278
2010-07-23 22:19:18 +00:00
Sean Callanan 6dde30e964 Added extensive logging of the code that is actually going
to be executed by the inferior.  This required explicit support
from RecordingMemoryManager for finding the address range
belonging to a particular function.

Also fixed a bug in DisassemblerLLVM where the disassembler
assumed there was an AddressRange available even when it was
NULL.

llvm-svn: 109209
2010-07-23 02:19:15 +00:00
Sean Callanan ebf7707e53 Modified TaggedASTType to inherit from ClangASTType
and moved it to its own header file for cleanliness.

Added more logging to ClangFunction so that we can
diagnose crashes in the executing expression.

Added code to extract the result of the expression
from the struct that is passed to the JIT-compiled
code.

llvm-svn: 109199
2010-07-23 00:16:21 +00:00
Greg Clayton e1a916a74d Change over to using the definitions for mach-o types and defines to the
defines that are in "llvm/Support/MachO.h". This should allow ObjectFileMachO
and ObjectContainerUniversalMachO to be able to be cross compiled in Linux.

Also did some cleanup on the ASTType by renaming it to ClangASTType and
renaming the header file. Moved a lot of "AST * + opaque clang type *"
functionality from lldb_private::Type over into ClangASTType.

llvm-svn: 109046
2010-07-21 22:12:05 +00:00
Sean Callanan 1d18066411 Added functionality to dematerialize values that were
used by the JIT compiled expression, including the
result of the expression.

Also added a new class, ASTType, which encapsulates an
opaque Clang type and its associated AST context.

Refactored ClangExpressionDeclMap to use ASTTypes,
significantly reducing the possibility of mixups of
types from different AST contexts.

llvm-svn: 108965
2010-07-20 23:31:16 +00:00
Greg Clayton 471b31ce62 Remove use of STL collection class use of the "data()" method since it isn't
part of C++'98. Most of these were "std::vector<T>::data()" and 
"std::string::data()".

llvm-svn: 108957
2010-07-20 22:52:08 +00:00
Sean Callanan 6b4067c14e Added the necessary code to copy variables used by
an expression into the struct prepared for the JIT
compiled code to use.

llvm-svn: 108596
2010-07-17 00:43:37 +00:00
Greg Clayton ea3b0ae8ed Fixed a copyright header.
llvm-svn: 108544
2010-07-16 18:28:27 +00:00
Sean Callanan ea22d4288a Wrote the code that looks at a context to see
if the variables in that context allow a particular
JIT compiled expression to run in that context.

llvm-svn: 108485
2010-07-16 00:09:46 +00:00
Sean Callanan 7618f4ebaf Fixes to the IR generator in the expression parser
to correctly unfold constant-folded global variables.
Also added code to JIT the expression.  Simple 
expressions are now JIT compiled successfully.

llvm-svn: 108380
2010-07-14 23:40:29 +00:00
Greg Clayton b132097b45 I enabled some extra warnings for hidden local variables and for hidden
virtual functions and caught some things and did some general code cleanup.

llvm-svn: 108299
2010-07-14 00:18:15 +00:00
Greg Clayton b6f75dfd96 Removed unused variable "log".
Fixed the llvm build for Mac OS X builds to look in llvm/lib/Release+Asserts 
output directory for all configurations (Debug, Release, BuildAndIntegration).

llvm-svn: 108289
2010-07-13 22:26:45 +00:00
Sean Callanan 549c9f7f9a "expr -i" now performs the required transforms to
prepare the IR for JIT compilation.  We still need
to do the JIT compilation and move the arguments
in/out of target memory.

llvm-svn: 108279
2010-07-13 21:41:46 +00:00
Greg Clayton c8e11e17aa Patch from Jean-Daniel Dupas:
Makefile patch to explicitly use PROJ_SRC_DIR when required. It fixes 
        build when obj dir is not source dir. 

I also fixed a build warning in ClangResultSynthesizer.cpp.

llvm-svn: 108210
2010-07-12 23:14:00 +00:00
Greg Clayton c982c768d2 Merged Eli Friedman's linux build changes where he added Makefile files that
enabled LLVM make style building and made this compile LLDB on Mac OS X. We
can now iterate on this to make the build work on both linux and macosx.

llvm-svn: 108009
2010-07-09 20:39:50 +00:00
Jason Molenda ea84e76479 Switch over to using llvm's dwarf constants file.
llvm-svn: 107716
2010-07-06 22:38:03 +00:00
Sean Callanan 2ab712f212 Added the skeleton of an IR transformer that will
prepare IR for execution in the target.  Wired the
expression command to use this IR transformer when
conversion to DWARF fails, and wired conversion to
DWARF to always fail (well, we don't generate any
DWARF...)

llvm-svn: 107559
2010-07-03 01:35:46 +00:00
Sean Callanan 248e64b5b8 Fixes to improve logging (by printing basic
block labels) and produce cleaner IR (by removing
the thread-safe statics guards)

llvm-svn: 107528
2010-07-02 22:22:28 +00:00
Sean Callanan 177909a350 Small fixes to the DWARF relocator.
llvm-svn: 107518
2010-07-02 21:28:35 +00:00
Sean Callanan 2df8a1f39c Added the skeleton of a transformation pass to
convert IR to DWARF.  So far, this pass only
performs a depth-first traversal of the IR,
logging each basic block as it finds it.

llvm-svn: 107515
2010-07-02 21:09:36 +00:00
Greg Clayton d2d60ce388 Updated to llvm/clang from July 2, 2010 at 8:00AM.
llvm-svn: 107494
2010-07-02 18:39:06 +00:00
Sean Callanan 116be5347e Added a SemaConsumer that transforms the ASTs for
an expression, adding code to put the value of the
last expression (if there is one) into a variable
and write the address of that variable to a global
pointer.

llvm-svn: 107419
2010-07-01 20:08:22 +00:00
Sean Callanan 562a5a3904 Improved printing of LLVM IR. We now print
complete instructions rather than simply their
opcodes.

llvm-svn: 106708
2010-06-24 00:47:05 +00:00
Sean Callanan 1d389c4b02 Added the temporary -i option to expr, which
switches the expression parsing over to use the
LLVM IR as opposed to Clang ASTs.  Right now,
that functionality only logs.

llvm-svn: 106695
2010-06-23 23:18:04 +00:00
Sean Callanan d448c1ba04 Fixes for array handling and dynamic type casting
errors pointed out by John McCall.

llvm-svn: 106665
2010-06-23 18:58:10 +00:00
Sean Callanan f06ba8d89c Updated the expression parser to use proper logging when
looking for external variables.  Also cleaned up the log
messages coming from the DWARF interpreter.

llvm-svn: 106613
2010-06-23 00:47:48 +00:00
Sean Callanan 468574bd34 Added support to the expression parser for locating
externally-defined functions.

llvm-svn: 106606
2010-06-22 23:46:24 +00:00
Greg Clayton 94e5d78888 Updated LLVM/Clang to revision from 2010-06-13T06:00.
llvm-svn: 105918
2010-06-13 17:34:29 +00:00
Greg Clayton ef59f829e4 Switched over to using the new lldb::SharingPtr from Howard Hinnant.
We need to put this in LLDB since we need to vend this in our API
because our public API uses shared pointers to our private objects.

Removed a deprecated file: include/lldb/Host/Types.h

Added the new SharingPtr.cpp/.h files into source/Utility.

Added a shell script build phase that fixes up all headers in the
LLDB.framework.

llvm-svn: 105895
2010-06-12 17:45:57 +00:00
Chris Lattner 30fdc8d841 Initial checkin of lldb code from internal Apple repo.
llvm-svn: 105619
2010-06-08 16:52:24 +00:00