Commit Graph

474 Commits

Author SHA1 Message Date
Greg Clayton 288bdf9c1d StackFrame objects now own ValueObjects for any frame variables (locals, args,
function statics, file globals and static variables) that a frame contains. 
The StackFrame objects can give out ValueObjects instances for
each variable which allows us to track when a variable changes and doesn't
depend on variable names when getting value objects.

StackFrame::GetVariableList now takes a boolean to indicate if we want to
get the frame compile unit globals and static variables.

The value objects in the stack frames can now correctly track when they have
been modified. There are a few more tweaks needed to complete this work. The
biggest issue is when stepping creates partial stacks (just frame zero usually)
and causes previous stack frames not to match up with the current stack frames
because the previous frames only has frame zero. We don't really want to 
require that all previous frames be complete since stepping often must check
stack frames to complete their jobs. I will fix this issue tomorrow.

llvm-svn: 112800
2010-09-02 02:59:18 +00:00
Sean Callanan 8e999e4015 Added code to run pointer validation checks in
expressions.  If an expression dereferences an
invalid pointer, there will still be a crash -
just now the crash will be in the function
___clang_valid_pointer_check().

llvm-svn: 112785
2010-09-02 00:37:32 +00:00
Jim Ingham 6d56d2ce84 Move "variable list" to "frame variable"
llvm-svn: 112782
2010-09-02 00:18:39 +00:00
Jim Ingham 91b9383b76 Stream::Printf doesn't add a newline, so it needs to be added to all the error messages in CommandObjectExpression::EvaluateExpression.
llvm-svn: 112731
2010-09-01 19:53:33 +00:00
Sean Callanan 6961e87847 Added support for dynamic sanity checking in
expressions.  Values used by the expression are
checked by validation functions which cause the
program to crash if the values are unsafe.

Major changes:

- Added IRDynamicChecks.[ch], which contains the
  core code related to this feature

- Modified CommandObjectExpression to install the
  validator functions into the target process.

- Added an accessor to Process that gets/sets the
  helper functions

llvm-svn: 112690
2010-09-01 00:58:00 +00:00
Jim Ingham 680e177833 Don't re-look up the symbol in ResolveSymbolContextForAddress.
llvm-svn: 112679
2010-08-31 23:51:36 +00:00
Greg Clayton bda8065107 Cleaned up my previous submission which had some header search paths that
were not needed and fixed a merge issue.

llvm-svn: 112626
2010-08-31 18:56:24 +00:00
Greg Clayton f681b94f90 Added the ability to disable ASLR (Address Space Layout Randomization). ASLR
is disabled by default, and can be enabled using:

(lldb) set disable-aslr 0

llvm-svn: 112616
2010-08-31 18:35:14 +00:00
Jim Ingham b4dcbaeec2 Add a "lldb host" logging channel, and put logging in the Host::OpenInExternalEditor code.
llvm-svn: 112614
2010-08-31 18:05:13 +00:00
Jim Ingham 5024baba16 Add LLDB_EXTERNAL_EDITOR
llvm-svn: 112558
2010-08-30 23:48:25 +00:00
Sean Callanan 823bb4cc24 Fixed a bug where the parser-specific members of
persistent variables were staying around too long.
This caused the following problem:

- A persistent result variable is created for the
  result of an expression.  The pointer to the
  corresponding Decl is stored in the variable.

- The persistent variable is looked up during
  struct generation (correctly) using its Decl.

- Another expression defines a new result variable
  which happens to have a Decl in the same place
  as the original result variable.

- The persistent variable is looked up during
  struct generation using its Decl, but the old
  result variable appears first in the list and
  has the same Decl pointer.

The fix is to destroy parser-specific data when
it is no longer valid.

Also improved some logging as I diagnosed the
bug.

llvm-svn: 112540
2010-08-30 22:17:16 +00:00
Greg Clayton ff3c05419e Stopped the external editor from adding stuff to the recent list when lldb
is launched with the -e option on Mac OS X.

llvm-svn: 112536
2010-08-30 22:00:34 +00:00
Sean Callanan eb43397181 Fixed a bug where ClangExpressionVariableList was
storing pointers to objects inside a std::vector.
These objects can move around as the std::vector
changes, invalidating the pointers.

llvm-svn: 112527
2010-08-30 21:15:33 +00:00
Jim Ingham e40e42181f Added a way to open the current source file & line in an external editor, and you can turn this on with:
lldb -e

llvm-svn: 112502
2010-08-30 19:44:40 +00:00
Greg Clayton 59e8fc1c74 Clarified the intent of the SymbolContextScope class in the header
documentation. Symbol now inherits from the symbol
context scope so that the StackID can use a "SymbolContextScope *"
instead of a blockID (which could have been the same as some other
blockID from another symbol file). 

Modified the stacks that are created on subsequent stops to reuse
the previous stack frame objects which will allow for some internal
optimization using pointer comparisons during stepping. 

llvm-svn: 112495
2010-08-30 18:11:35 +00:00
Greg Clayton 73b953bc1f Detect when ValueObject values change each time they are evaluated.
llvm-svn: 112331
2010-08-28 00:08:07 +00:00
Sean Callanan e71d553cd4 Added a ClangUtilityFunction class that allows the
debugger to insert self-contained functions for use by
expressions (mainly for error-checking).

In order to support detecting whether a crash occurred
in one of these helpers -- currently our preferred way
of reporting that an error-check failed -- added a bit
of support for getting the extent of a JITted function
in addition to just its base.

llvm-svn: 112324
2010-08-27 23:31:21 +00:00
Johnny Chen 23fd10cb4e o Exposed SBFileSpec to the Python APIs in lldb.py.
o Fixed a crasher when getting it via SBTarget.GetExecutable().

>>> filespec = target.GetExecutable()
Segmentation fault

o And renamed SBFileSpec::GetFileName() to GetFilename() to be consistent with FileSpec::GetFilename().

llvm-svn: 112308
2010-08-27 22:35:26 +00:00
Greg Clayton 68275d5e56 Made it so we update the current frames from the previous frames by doing STL
swaps on the variable list, value object list, and disassembly. This avoids
us having to try and update frame indexes and other things that were getting
out of sync.

llvm-svn: 112301
2010-08-27 21:47:54 +00:00
Greg Clayton 5082c5fdf6 Simplified the StackFrameList class down to a single frames list again
instead of trying to maintain the real frame list (unwind frames) and an
inline frame list. The information is cheap to produce when we already have
looked up a block and was making stack frame uniquing difficult when trying
to use the previous stack when making the current stack.

We now maintain the previous value object lists for common frames between
a previous and current frames so we will be able to tell when variable values
change.

llvm-svn: 112277
2010-08-27 18:24:16 +00:00
Sean Callanan 1a8d40935d This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients.  This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.

Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression.  The main effects of this refactoring 
are:

- reducing ClangExpression to an abstract class that
  declares methods that any client must expose to the
  expression parser,

- moving the code specific to implementing the "expr"
  command from ClangExpression and
  CommandObjectExpression into ClangUserExpression,
  a new class,

- moving the common parser interaction code from
  ClangExpression into ClangExpressionParser, a new
  class, and

- making ClangFunction rely only on
  ClangExpressionParser and not depend on the
  internal implementation of ClangExpression.

Side effects include:

- the compiler interaction code has been factored
  out of ClangFunction and is now in an AST pass
  (ASTStructExtractor),

- the header file for ClangFunction is now fully
  documented,

- several bugs that only popped up when Clang was
  deallocated (which never happened, since the
  lifetime of the compiler was essentially infinite)
  are now fixed, and

- the developer-only "call" command has been
  disabled.

I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work.  Please let me know if you encounter bugs or
poor documentation.

llvm-svn: 112249
2010-08-27 01:01:44 +00:00
Jim Ingham 09b263e05c Make:
bt all

show the backtrace for all threads, and:

bt 1 3 4

show the backtrace for threads 1, 3 and 4.  If we want to come up with some fancier syntax for thread lists later, that will be great, but this will do for now.

llvm-svn: 112248
2010-08-27 00:58:05 +00:00
Jim Ingham 2561aa6124 Change the "-S", "-F" and "-M" options to take their arguments directly, rather than requiring the -n option. This means you can't "or" together the types (i.e. set a breakpoint on a method or selector called "whatever". But that is a pretty uncommon operation, and having to provide two flags for the more common "set a breakpoint on this selector" is annoying.
llvm-svn: 112245
2010-08-26 23:56:11 +00:00
Jim Ingham e2e0b451d5 Add -c (count - i.e. number of frames to show) and -s (start frame.)
llvm-svn: 112243
2010-08-26 23:36:03 +00:00
Greg Clayton 12fc3e0f3e Changed the StackID to store its start PC address as a load address instead of
a section offset address.

Fixed up some very inefficient STL code.

llvm-svn: 112230
2010-08-26 22:05:43 +00:00
Jim Ingham 2976d00adb Change "Current" as in GetCurrentThread, GetCurrentStackFrame, etc, to "Selected" i.e. GetSelectedThread. Selected makes more sense, since these are set by some user action (a selection). I didn't change "CurrentProcess" since this is always controlled by the target, and a given target can only have one process, so it really can't be selected.
llvm-svn: 112221
2010-08-26 21:32:51 +00:00
Jim Ingham 6b8379c4e0 Add StackFrame::IsInlined.
llvm-svn: 112217
2010-08-26 20:44:45 +00:00
Greg Clayton 0445d8f498 Cleaned up the inline stack frame code one more time to prepare for inlined
code stepping. Also we now store the stack frames for the current and previous
stops in the thread in std::auto_ptr objects. When we create a thread stack
frame list we pass the previous frame into it so it can re-use the frames
and maintain will allow for variable changes to be detected. I will implement
the stack frame reuse next.

llvm-svn: 112152
2010-08-26 02:28:22 +00:00
Greg Clayton 12daf946c8 Cleaned up the inline backtrace code even more by moving all stack backtracing
functionality into StackFrameList. This will allow us to copy the previous
stack backtrace from the previous stop into another variable so we can re-use
as much as possible from the previous stack backtrace.

llvm-svn: 112007
2010-08-25 00:35:26 +00:00
Greg Clayton 288e5afe6b Fixed another issue with the inline stack frames where if the first frame
has inlined functions that all started at the same address, then the inlined
backtrace would not produce correct stack frames.

Also cleaned up and inlined a lot of stuff in lldb_private::Address.

Added a function to StackFrame to detect if the frame is a concrete frame so
we can detect the difference between actual frames and inlined frames.

llvm-svn: 111989
2010-08-24 22:59:52 +00:00
Greg Clayton 9da7bd0739 Got a lot of the kinks worked out in the inline support after debugging more
complex inlined examples.

StackFrame classes don't have a "GetPC" anymore, they have "GetFrameCodeAddress()".
This is because inlined frames will have a PC value that is the same as the 
concrete frame that owns the inlined frame, yet the code locations for the
frame can be different. We also need to be able to get the real PC value for
a given frame so that variables evaluate correctly. To get the actual PC
value for a frame you can use:

    addr_t pc = frame->GetRegisterContext()->GetPC();

Some issues with the StackFrame stomping on its own symbol context were 
resolved which were causing the information to change for a frame when the
stack ID was calculated. Also the StackFrame will now correctly store the
symbol context resolve flags for any extra bits of information that were 
looked up (if you ask for a block only and you find one, you will alwasy have
the compile unit and function).

llvm-svn: 111964
2010-08-24 21:05:24 +00:00
Greg Clayton 1b72fcb7d1 Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.

I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.

Fixed setting breakpoint by address to not require addresses to resolve.

A quick example:

% cat main.cpp

% ./build/Debug/lldb test/stl/a.out 
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out'  (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
 277   	
 278   	      _CharT*
 279   	      _M_data() const
 280 ->	      { return  _M_dataplus._M_p; }
 281   	
 282   	      _CharT*
 283   	      _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
  frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
  frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
  frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
  frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
  frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
  frame #5: pc = 0x0000000100000d08, where = a.out`start + 52

Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.

llvm-svn: 111877
2010-08-24 00:45:41 +00:00
Sean Callanan 64dfc9a3f9 Refactored ClangExpressionDeclMap to use
ClangExpressionVariables for found external variables
as well as for struct members, replacing the Tuple
and StructMember data structures.

llvm-svn: 111859
2010-08-23 23:09:38 +00:00
Johnny Chen a73af6f698 Fixed a crasher where during shutdown, loggings attempted to access the
thread name but the static map instance had already been destructed.

rdar://problem/8153284

llvm-svn: 111812
2010-08-23 17:13:12 +00:00
Greg Clayton 0b76a2c21f Modified the host process monitor callback function Host::StartMonitoringChildProcess
to spawn a thread for each process that is being monitored. Previously
LLDB would spawn a single thread that would wait for any child process which
isn't ok to do as a shared library (LLDB.framework on Mac OSX, or lldb.so on
linux). The old single thread used to call wait4() with a pid of -1 which 
could cause it to reap child processes that it shouldn't have.

Re-wrote the way Function blocks are handles. Previously I attempted to keep
all blocks in a single memory allocation (in a std::vector). This made the
code somewhat efficient, but hard to work with. I got rid of the old BlockList
class, and went to a straight parent with children relationship. This new 
approach will allow for partial parsing of the blocks within a function.

llvm-svn: 111706
2010-08-21 02:22:51 +00:00
Jim Ingham 5466e751f0 Added "source list -n" so you can list by symbol name. Moved "--count" from "-n" to "-c". Added a -s option so you can restrict the source listing to a particular shared library.
llvm-svn: 111608
2010-08-20 01:17:07 +00:00
Jim Ingham 64b931c1e1 Add an accessor to get the Declaration for a type.
llvm-svn: 111607
2010-08-20 01:15:38 +00:00
Jim Ingham 9976033698 Add methods to Function to get the first and last source lines of the function, and to get whether this Function is an inlined instance or not.
llvm-svn: 111606
2010-08-20 01:15:01 +00:00
Jim Ingham 182702076b Remove redundant call to ParseCompileUnitLineTable. The call to sc.comp_unit->GetLineTable() will parse the line table if it hasn't been read in.
llvm-svn: 111605
2010-08-20 01:13:58 +00:00
Sean Callanan d0ef0eff61 First step of refactoring variable handling in the
expression parser.  There shouldn't be four separate
classes encapsulating a variable.

ClangExpressionVariable is now meant to be the
container for all variable information.  It has
several optional components that hold data for
different subsystems.

ClangPersistentVariable has been removed; we now
use ClangExpressionVariable instead.

llvm-svn: 111600
2010-08-20 01:02:30 +00:00
Greg Clayton be77e3bd6e Fixed a long delay in shutdown times by invalidating m_private_state_thread right before the private state thread (which calls "void *Process::RunPrivateStateThread ()") exits.
llvm-svn: 111567
2010-08-19 21:50:06 +00:00
Jim Ingham e1be14df1e Some Block:: methods wandered to the end of the file after the BlockList:: methods. I moved them back.
llvm-svn: 111396
2010-08-18 19:29:16 +00:00
Sean Callanan eaacbc9da6 Patch by Bill Lynch fixing handling of the pid
in the IR transformation passes.

llvm-svn: 111388
2010-08-18 18:50:51 +00:00
Greg Clayton d1f57fc6a3 Avoid an assertion crash by avoiding a circular dependency in the objective
C builtin type conversion.

llvm-svn: 111381
2010-08-18 18:29:55 +00:00
Greg Clayton ad3843c93b Changed "Error Value::GetValueAsData (...)" to set the data extractor byte
order and address size correctly when the value comes from a file address.
Values have "file" addresses when they are globals and the debug information
specifies that they live in the object file at a given address (DWARF will
represent this as a location "DW_OP_addr <addr>"). This causes global pointers
to correctly extract their children on 64 bit programs.

llvm-svn: 111380
2010-08-18 18:28:52 +00:00
Greg Clayton 3ef3fc6462 Fixed an issue where we would return matches for DWARF in the .o files when
the resulting function from the .o file DWARF didn't make it into the final
executable. I recently changed the way FindFunctions() worked in the DWARF
with debug map case that caused regressions in our test suite for dead 
stripped functions. The previous changes allowed us to leverage the powerful 
searching added to the DWARF parser (search by full name, basename, selector, 
or method name), without having to chop up the symbol names from the symbol
table and do any special parsing of the names to extract the basename, 
selector or method. Previously we would look through the symbol table for 
matches first, then try and find the .o file with DWARF for that symbol and
only search those .o files. Now we let the DWARF for the .o file search using
the new search styles, and filter out any functions that didn't make it.

llvm-svn: 111322
2010-08-17 23:16:15 +00:00
Jim Ingham 2ecb7421c1 Don't try to get the architecture up front when doing attach -w.
llvm-svn: 111302
2010-08-17 21:54:19 +00:00
Jim Ingham c55e951523 Check for errors in Resume before waiting for the resume to complete.
llvm-svn: 111216
2010-08-17 00:35:35 +00:00
Greg Clayton 57a6b999af Fixed FindFunctions so it works with all the new name types for the DWARF in object files case.
llvm-svn: 111215
2010-08-17 00:35:34 +00:00
Sean Callanan 6dce6de80c Documented ClangResultSynthesizer and added very minor
API fixes.

llvm-svn: 111202
2010-08-16 23:01:35 +00:00
Sean Callanan df4581f1c5 Documented ClangExpressionVariable(List), and
cleaned up its API slightly.

llvm-svn: 111053
2010-08-13 22:52:29 +00:00
Sean Callanan 03e9771458 Added documentation to ClangExpressionDeclMap.
Also cleaned up its API a tiny bit (but not the
extensive amount that is actually needed.  That's
still coming.)

llvm-svn: 111049
2010-08-13 22:29:54 +00:00
Johnny Chen fcd43b719b Modified CommandObjectExpression::EvaluateExpression() so that it takes an
additional (ComandReturnObject *) result parameter (default to NULL) and does
the right thing in setting the result status.

Also removed used variable ast_context.

llvm-svn: 110992
2010-08-13 00:42:30 +00:00
Sean Callanan b269b6eabb Documented ClangExpression and made parts of it
more sane (i.e., removed dead arguments, made
sensible defaults, etc.)

llvm-svn: 110990
2010-08-13 00:28:39 +00:00
Sean Callanan 04949cc65e Added documentation to ClangASTSource and
NameSearchContext.

llvm-svn: 110980
2010-08-12 23:45:38 +00:00
Sean Callanan 35053747cc Removed the ClangStmtVisitor, which is old code
that translates Clang ASTs straight to DWARF.  We
are now using IR instead.

llvm-svn: 110957
2010-08-12 21:29:03 +00:00
Jim Ingham 87c1191e0e Now that we are using the Unwinder (or Jason's new unwinder when that comes about) all the plugin-specific details of getting stack frames
should be hidden behind that, and the "GetStackFrameAtIndex" and "GetStackFrameCount" algorithms become generic.  So I moved them to Thread.cpp.

llvm-svn: 110899
2010-08-12 02:14:28 +00:00
Sean Callanan d1e5b439c9 Added automatically generated result variables for each
expression.  It is now possible to do things like this:

(lldb) expr int $i = 5; $i + 1
$0 = (int) 6
(lldb) expr $i + 3
$1 = (int) 8
(lldb) expr $1 + $0
$2 = (int) 14

As a bonus, this allowed us to move printing of
expression results into the ClangPersistentVariable
class.  This code needs a bit of refactoring -- in
particular, ClangExpressionDeclMap has eaten one too
many bacteria and needs to undergo mitosis -- but the
infrastructure appears to be holding up nicely.

llvm-svn: 110896
2010-08-12 01:56:52 +00:00
Jim Ingham b0be442408 Few little fixes to reading in inlined functions. Also added a test case with some inlining.
llvm-svn: 110892
2010-08-12 01:20:14 +00:00
Sean Callanan 2235f32bbd Added support for persistent variables to the
expression parser.  It is now possible to type:

(lldb) expr int $i = 5; $i + 1
(int) 6
(lldb) expr $i + 2
(int) 7

The skeleton for automatic result variables is
also implemented.  The changes affect:

- the process, which now contains a 
  ClangPersistentVariables object that holds
  persistent variables associated with it
- the expression parser, which now uses
  the persistent variables during variable
  lookup
- TaggedASTType, where I loaded some commonly
  used tags into a header so that they are
  interchangeable between different clients of
  the class

llvm-svn: 110777
2010-08-11 03:57:18 +00:00
Johnny Chen 705c3b6aaa There is no need to restore (sys.stdin, sys.stdout) of the python script
interpreter right before calling Py_Finalize().  This also fixed the crash as
reported in rdar://problem/8252903.

llvm-svn: 110731
2010-08-10 21:26:55 +00:00
Benjamin Kramer cb61b8c42b Fix clang warnings.
llvm-svn: 110676
2010-08-10 13:22:03 +00:00
Jim Ingham a73f8ea4e5 Looks like this is how you identify executables in ELF.
llvm-svn: 110641
2010-08-10 01:36:46 +00:00
Jim Ingham 3ebcf7f09b Make breakpoint commands work again. Added a PerformAction to the stop info - actions are run when the
stop event is pulled from the event queue.  Then made the StopInfoBreakpoint's PerformAction do the 
breakpoint command.
Also fixed the StopInfoBreakpoint's GetDescription so it gets the breakpoint location info, not the breakpoint
site info.

llvm-svn: 110637
2010-08-10 00:59:59 +00:00
Jason Molenda 2f1a7d9e76 Remove unused powerpc unwind support.
llvm-svn: 110626
2010-08-09 23:56:27 +00:00
Jim Ingham 5aee162f97 Change Target & Process so they can really be initialized with an invalid architecture.
Arrange that this then gets properly set on attach, or when a "file" is set.
Add a completer for "process attach -n".

Caveats: there isn't currently a way to handle multiple processes with the same name.  That
will have to wait on a way to pass annotations along with the completion strings.

llvm-svn: 110624
2010-08-09 23:31:02 +00:00
Sean Callanan 0708e2c253 Updated help text to refer to "commands alias"
instead of "alias."  Also fixed a bunch of
indentation in the help for "commands alias."

llvm-svn: 110585
2010-08-09 18:50:15 +00:00
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
Sean Callanan c7fbf73651 Fixed namespace visibility problems that were
breaking the build for me on a non-internal
SnowLeopard system.

llvm-svn: 110412
2010-08-06 00:32:49 +00:00
Greg Clayton c86103d4d6 More missing files from my previous checkin.
llvm-svn: 110299
2010-08-05 01:57:25 +00:00
Greg Clayton ba9fbbb880 Added functionality to our API for SBType. This will allow users to eventually find and peruse static type information from modules.
llvm-svn: 110297
2010-08-05 01:56:31 +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 3504eee8a8 Added FindTypes to Module and ModuleList.
llvm-svn: 110093
2010-08-03 01:26:16 +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
Johnny Chen 7dc2e4784e We can do better when reporting the status of one-liner script execution.
Change the prototype of ScriptInterpreter::ExecuteOneLine() to return bool
instead of void and take one additional parameter as CommandReturnObject *.

Propagate the status of one-liner execution back appropriately.

llvm-svn: 109899
2010-07-30 22:33:14 +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
Greg Clayton 48e4254989 Added "void Clear();" methods to SBDebugger, SBTarget and SBThread so they can release their shared pointers.
llvm-svn: 109882
2010-07-30 20:12:55 +00:00
Greg Clayton 76a5cce6c0 Removed pending TODOs after resolving them with help of the clang folks and the discussion list.
llvm-svn: 109802
2010-07-29 20:38:50 +00:00
Greg Clayton 5fb47cd535 Fixed "void *ClangASTContext::CreatePointerType (void *clang_type);" to return objective C pointers for clang::Type::TypeClass types that are "clang::Type::ObjCObject" and "clang::Type::ObjCInterface" .
llvm-svn: 109795
2010-07-29 20:06:32 +00:00
Johnny Chen 1bb9bc72b9 Fixed "warning: unused variable 'log'".
llvm-svn: 109794
2010-07-29 19:51:52 +00:00
Greg Clayton 4b4b5fcebc Fixed expression result printing to have the expression result type be in
parens and to have a space before the value.

Before:
(lldb) expr 3 + 1
int4

(lldb) expr 3 + 1
(int) 4

llvm-svn: 109793
2010-07-29 19:36:30 +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
Johnny Chen 85ffddc1bf The unix "source" command maps to "command source" in lldb. :-)
llvm-svn: 109673
2010-07-28 21:16:11 +00:00
Greg Clayton 9e40956aea Created lldb::LanguageType by moving an enumeration from the
lldb_private::Language class into the enumerations header so it can be freely
used by other interfaces.

Added correct objective C class support to the DWARF symbol parser. Prior to
this fix we were parsing objective C classes as C++ classes and now that the
expression parser is ready to call functions we need to make sure the objective
C classes have correct AST types.

llvm-svn: 109574
2010-07-28 02:04:09 +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
Stephen Wilson 4ec3fb9353 Fix makefiles to build properly on Darwin.
Patch by William Lynch!

llvm-svn: 109327
2010-07-24 04:10:59 +00:00
Stephen Wilson e6f9f66b39 Add a new Process plugin for Linux.
This component is still at an early stage, but allows for simple
breakpoint/step-over operations and basic process control.

The makefiles are set up to build the plugin under Linux only.

llvm-svn: 109318
2010-07-24 02:19:04 +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
Greg Clayton 9fed0d85b2 Added needed breakpoint functionality to the public API that includes:
SBTarget:
    - get breakpoint count
    - get breakpoint at index
  SBBreakpoint:
    - Extract data from breakpoint events

llvm-svn: 109289
2010-07-23 23:33:17 +00:00
Greg Clayton 4eb82d9216 Get rid of using EXC_SOFT_SIGNAL define in host agnostic code.
llvm-svn: 109281
2010-07-23 22:50:09 +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
Stephen Wilson ebb84b243b Fix a typo.
llvm-svn: 109271
2010-07-23 21:47:22 +00:00
Greg Clayton 896dff661a Centralized the Mach exception stop info code by adding it as a first
class citizen on the StopInfo class. 

llvm-svn: 109235
2010-07-23 16:45:51 +00:00
Greg Clayton 572404311a Remove a deadlock condition. A bit of explanation is needed: When calling
ThreadCancel in Host::WillTerminate g_monitor_thread may be blocked on a call
to pthread_cond_wait (for example, line 640).  Now, by default, when a 
cancellation request is serviced g_monitor_thread will again own the mutex
guarding the condition variable it was waiting on.  This causes the call to 
SetValue in Host::WillTerminate to hit a deadlock.

The call to SetValue does not appear to be needed, so removing it solves
the issue.

Patch from Stephen Wilson.

llvm-svn: 109228
2010-07-23 15:47:19 +00:00
Greg Clayton 26661bca20 Remove a premature invalidation of a threads pthread_t handle, thus avoiding
a segfault when calling pthread_cancel.  Also, sets m_read_thread_enabled if
the thread is actually spawned.

Patch from Stephen Wilson.

llvm-svn: 109227
2010-07-23 15:43:25 +00:00
Greg Clayton 19503a2a78 Warnings cleanup patch from Jean-Daniel Dupas.
llvm-svn: 109226
2010-07-23 15:37:46 +00:00
Greg Clayton 5b9a1ea9c6 Added Mach exception stop descriptions. The chunk of code I just added needs to be placed into a utility location so it can be used by ProcessMacOSX and debugserver.
llvm-svn: 109214
2010-07-23 03:40:38 +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 49182ed65a This patch changes the point at which Process::m_private_state_thread is
invalidated.  There was a race condition where the private thread would
invalidate its own pthread_t object before the parent could perform a
pthread_cancel/pthread_join sequence.

Patch from Stephen Wilson.

llvm-svn: 109131
2010-07-22 18:34:21 +00:00
Greg Clayton 8cf0593c87 Added a new enumeration named "ClangASTContext::AccessType" that abstracts the type creation from the various access enumerations in Clang. Currently there are clang::AccessSpecifier and the objective C ivars have their own enumeration. So I added a new enumeration that will allow a consistent interface when creating types through ClangASTContext.
I also added new functions to create an Objective C class, ivar and set an objective C superclass. They aren't hooked up in the DWARF parser yet. That is the next step, though I am unsure if I will do this in the DWARF parser or try and do it generically in the existing Record manipulation functions.

llvm-svn: 109130
2010-07-22 18:30:50 +00:00
Greg Clayton 4ceb9980c8 Modified both the ObjectFileMachO and ObjectFileELF to correctly set the
SectionType for Section objects for DWARF.

Modified the DWARF plug-in to get the DWARF sections by SectionType so we
can safely abstract the LLDB core from section names for the various object
file formats.

Modified the SectionType definitions for .debug_pubnames and .debug_pubtypes
to use the correct case.

llvm-svn: 109054
2010-07-21 22:54:26 +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
Greg Clayton 70e33eb06e Allow searching for a section by SectionType.
llvm-svn: 109040
2010-07-21 21:49:46 +00:00
Greg Clayton d1daf00b28 Updated LLVM and Clang to July 20 at 16:00.
llvm-svn: 109016
2010-07-21 16:57:26 +00:00
Greg Clayton a0e7f0c1b1 Avoid std::bitset<64>::to_string() since it is missing in earlier C++
libraries (from William Lynch).

llvm-svn: 108976
2010-07-21 01:08:41 +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 ede0585ec2 Fixing a crashing bug in multiword commands from William Lynch.
llvm-svn: 108958
2010-07-20 22:54:09 +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
Stephen Wilson 4ab47682bb Fix assertion conditions.
llvm-svn: 108879
2010-07-20 18:41:11 +00:00
Greg Clayton 044672b076 Logic fix to properly determine when a symbol is not from the current
symbol table (from William Lynch).

llvm-svn: 108871
2010-07-20 18:30:17 +00:00
Benjamin Kramer 40e155dfc2 More constructor warning fixes from William Lynch.
llvm-svn: 108840
2010-07-20 14:37:45 +00:00
Stephen Wilson 50bd94f961 Have Process::CreateBreakpointSite return a break_id_t instead of a user_id_t.
Also, update BreakpointLocation::ResolveBreakpointSite to check for invalid
breakpoint ID's using the proper magic constant.

llvm-svn: 108598
2010-07-17 00:56:13 +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
Benjamin Kramer 1ee0d4f7f3 Fix constructor initialization order. Patch by Bill Lynch.
llvm-svn: 108524
2010-07-16 12:32:33 +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 23a3027a67 Oops, didn't define AreTypesSame correctly.
llvm-svn: 108483
2010-07-16 00:00:27 +00:00
Sean Callanan 4dcca262f4 Added a function to test whether two types are
the same.

llvm-svn: 108467
2010-07-15 22:30:52 +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
Jim Ingham a3241c1bf5 Don't call PrepareForResume on threads that aren't going to get a chance to run this time around.
llvm-svn: 108312
2010-07-14 02:27:20 +00:00
Jim Ingham 9d790c5d12 Stepping through a trampoline should do "stop others" unless All Threads is requested.
llvm-svn: 108311
2010-07-14 02:25:06 +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
Stephen Wilson 11e8f3ba37 Remove our local ELF definitions and rely on llvm/Support/ELF.h instead.
llvm-svn: 108293
2010-07-13 23:09:42 +00:00
Stephen Wilson f325ba9d45 Combine 32 and 64 bit ELF readers.
This patch provides a generic ELF reader plugin to handle both 32 and 64 bit
formats.

llvm-svn: 108292
2010-07-13 23:07:23 +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 0428b7dcc8 Don't build the SymbolVendor/MacOSX when not building on Darwin.
llvm-svn: 108208
2010-07-12 23:11:00 +00:00
Jim Ingham a56c800607 Add an "Avoid Frames matching this regular expression" to ThreadPlanStepInRange.
This relies on ThreadPlanStepOut working correctly, which it doesn't currently for Inlined functions, so this feature is only partially useful until we take care of Stepping Out of inlined functions.
Added an option to "thread step-in" to set the avoid regular expression.  This is mostly for testing, once the Setting code is redone, we'll move this to a general setting.

llvm-svn: 108036
2010-07-10 02:27:39 +00:00
Jim Ingham 35b21fef65 Properly set the PlanKind for the ThreadPlanStepRange derived classes.
llvm-svn: 108035
2010-07-10 02:23:31 +00:00
Eli Friedman 07a2437a91 A few more misc warning fixes.
llvm-svn: 108030
2010-07-09 23:04:08 +00:00
Eli Friedman 8878f87fb6 Misc warning fixes.
llvm-svn: 108029
2010-07-09 22:53:18 +00:00
Eli Friedman 78ed6b7469 Remove unnecessary directory (accidentally committed with r108009).
llvm-svn: 108024
2010-07-09 22:03:05 +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
Sean Callanan 246549c50b Moved NDEBUG from a global setting to a specific
hack.

llvm-svn: 107894
2010-07-08 18:16:16 +00:00
Greg Clayton 51dc188216 64 bit ELF support from Stephen Wilson.
llvm-svn: 107817
2010-07-07 21:52:01 +00:00
Greg Clayton a624358728 Added some comments to clarify where "init_lldb" comes from.
llvm-svn: 107801
2010-07-07 18:40:03 +00:00
Greg Clayton 69b518f6ef typedef fixups, patch from Jean-Daniel Dupas.
llvm-svn: 107794
2010-07-07 17:07:17 +00:00
Greg Clayton 72db59664f Fixed "#endif"s followed by non comments, patch from Jean-Daniel Dupas.
llvm-svn: 107793
2010-07-07 17:06:20 +00:00
Benjamin Kramer 59d9a5c209 Declare LLDBVersionNumber extern "C" to make sure clang++ mangles it properly. Patch from Jean-Daniel Dupas!
llvm-svn: 107765
2010-07-07 09:33:41 +00:00
Benjamin Kramer 3f3ff5cc87 Fix build for newer versions of GCC that don't include cstring implicitly. Based on a patch by Pawel Wodnicki!
llvm-svn: 107763
2010-07-07 09:19:50 +00:00
Jim Ingham 6f80bc5602 Remove includes for removed files...
llvm-svn: 107753
2010-07-07 03:39:43 +00:00
Jim Ingham ebc09c36e9 Fix GetRepeatCommand so it works with multi-word commands.
Move the "source", "alias", and "unalias" commands to "commands *".
Move "source-file" to "source list".
Added a "source info" command but it isn't implemented yet.

llvm-svn: 107751
2010-07-07 03:36:20 +00:00
Jim Ingham 1308bb2791 Added a "GetRepeatCommand" to the command object. The Interpreter uses this
instead of the last history item to provide a command for the "empty" command.
Use this in the source-file command to make <RETURN> continue the listing rather
than relist the first listing...

llvm-svn: 107736
2010-07-06 23:48:33 +00:00
Greg Clayton 364f1167cb Fixed an issue with looking up line table entries by address where internal
line table entries that were termination entries (ones that define the bounds
of the previous entry) could be found when looking up line table entries.
We now properly skip these termination entries and check the next entry to
try for a match.

llvm-svn: 107729
2010-07-06 23:34:08 +00:00
Jim Ingham 279a6c2669 Hide the logic for command resolution for commands, aliases & user commands behind a single
interface so everybody does it the same way.  Add an "exact" lookup for internal uses.

Fix up a few little cases where we weren't reporting command lookup errors correctly.

Added "b" as an alias for "breakpoint" so it doesn't collide with "bt".

llvm-svn: 107718
2010-07-06 22:46:59 +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
Greg Clayton 6b6742b08e Remove extraneous semicolon after if condition (from Jean-Daniel Dupas).
llvm-svn: 107694
2010-07-06 20:30:35 +00:00
Greg Clayton 5f067820ba Avoid duplicate names (something else that clang++ really doesn't like) in
function prototype (from Jean-Daniel Dupas).

llvm-svn: 107693
2010-07-06 20:29:25 +00:00
Greg Clayton 3afe8a9f1d Applied pid.patch from Jean-Daniel Dupas.
llvm-svn: 107692
2010-07-06 20:27:00 +00:00
Greg Clayton a08073565a Jean-Daniel Dupas patch that fixes a bad if statement with assignment.
llvm-svn: 107671
2010-07-06 16:11:44 +00:00
Eric Christopher 2159b4ae6d Change order of initialization.
Patch by Stephen Wilson!

llvm-svn: 107623
2010-07-05 19:13:23 +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
Greg Clayton 13a177aeb8 Plugged 4 more leaks in the libunwind code. One leaks is still left in as it
is quite gnarly code and there is no good way to clean it up. I will have
Jason look at a fix for this.

llvm-svn: 107539
2010-07-02 23:23:14 +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
Eli Friedman b6c9e103a1 Implement GetProgramFileSpec().
llvm-svn: 107502
2010-07-02 19:38:10 +00:00
Eli Friedman 5423ebff13 Add hacky, incomplete Linux host implementation; barely enough to allow
compiling lldb.  Someone else might try to improve it, though. :)

llvm-svn: 107501
2010-07-02 19:28:44 +00:00
Eli Friedman feaeebfb5d Add const qualification; fixes error on gcc 4.4.
llvm-svn: 107499
2010-07-02 19:15:50 +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 609f8c584a Added a method to get a stream's byte order.
llvm-svn: 107460
2010-07-02 02:43:42 +00:00
Greg Clayton 0b42ac32c8 More leaks detection:
- fixed 3 posix spawn attributes leaks 
- fixed us always leaking CXXBaseSpecifier objects when we create class 
  base classes. Clang apparently copies the base classes we pass in.

Fixed some code formatting in ClangASTContext.cpp.

llvm-svn: 107459
2010-07-02 01:29:13 +00:00
Jim Ingham 7cc478b9a2 Remove duplicate def'n from FileSpec.h.
Add user name completion to the file completer.

llvm-svn: 107455
2010-07-02 00:45:55 +00:00
Greg Clayton c228ebba77 Removed the thread specific data that was being used for demangling since
removing it didn't cause any performance loss, and leaks were showing up
when run under instruments when we tried to re-use the buffer. We are now leak
free and still just as performant.

llvm-svn: 107453
2010-07-02 00:29:31 +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
Greg Clayton a5d24f6683 Added a missing static function prototype to FileSpec.h for ResolveUsername.
Did a bit of code formatting and cleanup.

llvm-svn: 107403
2010-07-01 17:07:48 +00:00
Jim Ingham f818ca3736 Moved the User Name expansion over to FileSpec, and converted it to use getpwname directly.
Changed the file completion to deal with this, and FileSpec::Resolve now resolves all user names (not just ~/).

llvm-svn: 107370
2010-07-01 01:48:53 +00:00
Greg Clayton 54b8b8c1a7 Fixed up disassembly to not emit the module name before all function names
that are in the disassembly comments since most of them are in the same
module (shared library). 

Fixed a crasher that could happen when disassembling special section data.

Added an address dump style that shows the symbol context without the module
(used in the disassembly code).

llvm-svn: 107366
2010-07-01 01:26:43 +00:00
Greg Clayton 35f3dd20a6 Removed a commented out function and did a little reformatting.
llvm-svn: 107352
2010-06-30 23:04:24 +00:00
Greg Clayton dda4f7b520 Centralized all disassembly into static functions in source/Core/Disassembler.cpp.
Added the ability to read memory from the target's object files when we aren't
running, so disassembling works before you run!

Cleaned up the API to lldb_private::Target::ReadMemory().

Cleaned up the API to the Disassembler to use actual "lldb_private::Address"
objects instead of just an "addr_t". This is nice because the Address objects
when resolved carry along their section and module which can get us the 
object file. This allows Target::ReadMemory to be used when we are not 
running.

Added a new lldb_private::Address dump style: DumpStyleDetailedSymbolContext
This will show a full breakdown of what an address points to. To see some
sample output, execute a "image lookup --address <addr>".

Fixed SymbolContext::DumpStopContext(...) to not require a live process in
order to be able to print function and symbol offsets.

llvm-svn: 107350
2010-06-30 23:03:03 +00:00
Caroline Tice ebc1bb277c Add a unique ID to each debugger instance.
Add functions to look up debugger by id
Add global variable to lldb python module, to hold debugger id
Modify embedded Python interpreter to update the global variable with the
 id of its current debugger.
Modify the char ** typemap definition in lldb.swig to accept 'None' (for NULL)
 as a valid value.

The point of all this is so that, when you drop into the embedded interpreter
from the command interpreter (or when doing Python-based breakpoint commands),
there is a way for the Python side to find/get the correct debugger
instance ( by checking debugger_unique_id, then calling 
SBDebugger::FindDebuggerWithID  on it).

llvm-svn: 107287
2010-06-30 16:22:25 +00:00
Benjamin Kramer 021b605d17 Fix an obvious typo and replace deprecated bcopy(3) with memcpy(3).
llvm-svn: 107281
2010-06-30 13:43:47 +00:00
Jim Ingham 558ce124eb Add a source file completer to the CommandCompleters.
Add a way for the completers to say whether the completed argument should have a space inserted after is
or not.
Added the file name completer to the "file" command.

llvm-svn: 107247
2010-06-30 05:02:46 +00:00
Greg Clayton d0c8a0f031 A little code cleanup to not create an script bridging object just to feed
the private object back to another internal function.

llvm-svn: 107118
2010-06-29 01:42:03 +00:00
Greg Clayton 8d38ac4536 Fixed debug map in executable + DWARF in .o debugging on Mac OS X.
Added the ability to dump any file in the global module cache using any of
the "image dump" commands. This allows us to dump the .o files that are used
with DWARF + .o since they don't belong the the target list for the current
target.

llvm-svn: 107100
2010-06-28 23:51:11 +00:00
Greg Clayton 0c5cd90d63 Added function name types to allow us to set breakpoints by name more
intelligently. The four name types we currently have are:

eFunctionNameTypeFull       = (1 << 1), // The function name.
                                        // For C this is the same as just the name of the function
                                        // For C++ this is the demangled version of the mangled name.
                                        // For ObjC this is the full function signature with the + or
                                        // - and the square brackets and the class and selector
eFunctionNameTypeBase       = (1 << 2), // The function name only, no namespaces or arguments and no class 
                                        // methods or selectors will be searched.
eFunctionNameTypeMethod     = (1 << 3), // Find function by method name (C++) with no namespace or arguments
eFunctionNameTypeSelector   = (1 << 4)  // Find function by selector name (ObjC) names


this allows much more flexibility when setting breakoints:

(lldb) breakpoint set --name main --basename
(lldb) breakpoint set --name main --fullname
(lldb) breakpoint set --name main --method
(lldb) breakpoint set --name main --selector

The default:

(lldb) breakpoint set --name main

will inspect the name "main" and look for any parens, or if the name starts
with "-[" or "+[" and if any are found then a full name search will happen.
Else a basename search will be the default.

Fixed some command option structures so not all options are required when they
shouldn't be.

Cleaned up the breakpoint output summary.

Made the "image lookup --address <addr>" output much more verbose so it shows
all the important symbol context results. Added a GetDescription method to 
many of the SymbolContext objects for the more verbose output.

llvm-svn: 107075
2010-06-28 21:30:43 +00:00
Jim Ingham d43e0094b7 Handle completing "-" and "--".
llvm-svn: 106784
2010-06-24 20:31:04 +00:00
Jim Ingham d6ccc60035 Convert direct access to the required & optional option sets to an accessor so we can lazily run BuildValidOptionSet, but make sure it is done before access.
llvm-svn: 106783
2010-06-24 20:30:15 +00:00
Jim Ingham 490ac55536 Fix a bug in handling command resolution for non-exact matches. Now we will correctly give help options when there are both aliases & real commands matching the current input string.
llvm-svn: 106782
2010-06-24 20:28:42 +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 16ad5faeeb Extensive code cleanup of the expression command.
- Rationalized EvaluateExpression to remove a lot
  of nesting; also added comments to make it easy
  to find what's happening where
- Made ExecuteRawCommandString subcontract out to
  EvaluateExpression
- Minor logging improvements

llvm-svn: 106703
2010-06-24 00:16:27 +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 4be3990f3b Fixed the log streams for logs that output to
standard output, resolving a crasher.

llvm-svn: 106682
2010-06-23 21:28:25 +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
Greg Clayton 6611103cfe Very large changes that were needed in order to allow multiple connections
to the debugger from GUI windows. Previously there was one global debugger
instance that could be accessed that had its own command interpreter and
current state (current target/process/thread/frame). When a GUI debugger
was attached, if it opened more than one window that each had a console
window, there were issues where the last one to setup the global debugger
object won and got control of the debugger.

To avoid this we now create instances of the lldb_private::Debugger that each 
has its own state:
- target list for targets the debugger instance owns
- current process/thread/frame
- its own command interpreter
- its own input, output and error file handles to avoid conflicts
- its own input reader stack

So now clients should call:

    SBDebugger::Initialize(); // (static function)

    SBDebugger debugger (SBDebugger::Create());
    // Use which ever file handles you wish
    debugger.SetErrorFileHandle (stderr, false);
    debugger.SetOutputFileHandle (stdout, false);
    debugger.SetInputFileHandle (stdin, true);

    // main loop
    
    SBDebugger::Terminate(); // (static function)
    
SBDebugger::Initialize() and SBDebugger::Terminate() are ref counted to
ensure nothing gets destroyed too early when multiple clients might be
attached.

Cleaned up the command interpreter and the CommandObject and all subclasses
to take more appropriate arguments.

llvm-svn: 106615
2010-06-23 01:19:29 +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
Benjamin Kramer 1e89cd804c Avoid tolower, it's slow and unnecessary.
llvm-svn: 106580
2010-06-22 21:28:05 +00:00
Benjamin Kramer b328d72d77 Turns out __cxa_demangle returns the size of the buffer instead of the size of
the demangled name. Fall back to strlen.

llvm-svn: 106579
2010-06-22 21:27:55 +00:00
Jim Ingham 05407f6b25 Make an explicit GetThreadSpecNoCreate accessor so you don't have to get the const-ness right to ensure you are not making a copy of the owning breakpoint's ThreadSpec in a breakpoint location. Also change the name from NoCopy to NoCreate since that's clearer.
llvm-svn: 106578
2010-06-22 21:12:54 +00:00
Benjamin Kramer eb9165c08f Reduce code duplication.
This also moves strlen out of the mutex scope.

llvm-svn: 106545
2010-06-22 15:28:34 +00:00
Benjamin Kramer 53a61dc531 Ensure GetDemangledName's thread safety by making the demangle buffer thread specific.
I'm not sure when multiple threads enter this method but a race-condition
causing a crash in malloc can be reproduced with this little script:

echo file $(which lldb) > cmd
echo "run\nbreak set -n main\nrun\nexit" >> cmd
lldb -s cmd

It may need a few runs before it crashes though.

llvm-svn: 106544
2010-06-22 15:28:29 +00:00
Benjamin Kramer 104819c6eb Move trivial parts of UserID into the header.
llvm-svn: 106535
2010-06-22 10:44:12 +00:00
Benjamin Kramer 466b31e900 Move a bunch of trivial methods into the header. These compile down to 1-2
instructions so it's really profitable to inline them.

llvm-svn: 106450
2010-06-21 19:26:54 +00:00
Benjamin Kramer 1e909fc0b6 Initialize member so GDBRemoteRegisterContext::ReadRegisterBytes doesn't rely on
an unitialized variable.

valgrind_errors -= 1;

llvm-svn: 106418
2010-06-21 14:39:40 +00:00
Benjamin Kramer ae39fc196b Return false from FileSpec::GetPath early instead of making the return value
dependent on the last byte of the buffer, which could be unitialized.

llvm-svn: 106417
2010-06-21 14:36:20 +00:00
Benjamin Kramer e1ce369628 Don't snprintf directly into a std::string, it's undefined behavior per C++03.
This also fixes a bug where we were trying to copy m_string into itself
via a format string. The pointer was invalidated by m_string.resize and
lldb (sometimes) crashed inside vsnprintf.

llvm-svn: 106416
2010-06-21 14:34:03 +00:00
Jim Ingham b01e742af7 Two changes in this checkin. Added a ThreadPlanKind so that I can do some reasoning based on the kind of thread plan
without having to use RTTI.
Removed the ThreadPlanContinue and replaced with a ShouldAutoContinue query that serves the same purpose.  Having to push
another plan to assert that if there's no other indication the target should continue when this plan is popped was flakey
and error prone.  This method is more stable, and fixed problems we were having with thread specific breakpoints.

llvm-svn: 106378
2010-06-19 04:45:32 +00:00
Jim Ingham b2a38a7286 Remember whether a queue or thread name were passed into "breakpoint modify" so we can recognize an empty argument as unsetting the option.
llvm-svn: 106377
2010-06-19 04:35:20 +00:00
Jim Ingham 8dae7f2e8f Remove an include of the deleted CommandObjectStatus.h.
llvm-svn: 106297
2010-06-18 18:17:30 +00:00
Jim Ingham 62b02c61c9 Adding setting thread specific breakpoints by name, ID, index & queue name to the SB interfaces.
llvm-svn: 106268
2010-06-18 01:47:08 +00:00
Jim Ingham 4b9bea87e6 Move the "status" command to "process status" since that's where it belongs. Also make it print "running" if invoked
when the current process is running.

llvm-svn: 106265
2010-06-18 01:23:09 +00:00
Jim Ingham 0136309f5a Change the Breakpoint & BreakpointLocation GetDescription methods so they call the BreakpointOptions::GetDescription rather
than picking bits out of the breakpoint options.  Added BreakpointOptions::GetDescription to do this job.  Some more mucking
around to keep the breakpoint listing from getting too verbose.

llvm-svn: 106262
2010-06-18 01:00:58 +00:00
Jim Ingham ae1c4cf568 Change "breakpoint configure" to "breakpoint modify" so it doesn't collide with "breakpoint command"
Change "breakpoint enable/disable" so changing a breakpoint's state doesn't also overwrite the location states.

llvm-svn: 106261
2010-06-18 00:58:52 +00:00
Owen Anderson 836af6bb36 Fix comment, per Chris' suggestion.
llvm-svn: 106192
2010-06-17 00:51:12 +00:00
Sean Callanan a68c1a2188 Unstick the -r option for the disassemble command.
llvm-svn: 106186
2010-06-17 00:32:05 +00:00
Sean Callanan d50c96a002 Fixed a problem where invalid triples were being passed
into the constructor for the LLVMDisassembler, resulting
in asserts.

llvm-svn: 106160
2010-06-16 22:19:05 +00:00
Owen Anderson c7da5f413b Switch from qsort_r to std::stable_sort for a performance win and improved portability.
llvm-svn: 106116
2010-06-16 17:34:05 +00:00
Jim Ingham 1b54c88cc4 Add a "thread specification" class that specifies thread specific breakpoints by name, index, queue or TID.
Push this through all the breakpoint management code.  Allow this to be set when the breakpoint is created.
Fix the Process classes so that a breakpoint hit that is not for a particular thread is not reported as a 
breakpoint hit event for that thread.
Added a "breakpoint configure" command to allow you to reset any of the thread 
specific options (or the ignore count.)

llvm-svn: 106078
2010-06-16 02:00:15 +00:00
Jim Ingham 40af72e106 Move Args.{cpp,h} and Options.{cpp,h} to Interpreter where they really belong.
llvm-svn: 106034
2010-06-15 19:49:27 +00:00
Jim Ingham 8651121c11 Change the Options parser over to use a mask rather than an ordinal for option sets.
Fixed the Disassemble arguments so you can't specify start address or name in multiple ways.
Fixed the command line input so you can specify the filename without "-f" even if you use other options.

llvm-svn: 106020
2010-06-15 18:47:14 +00:00
Greg Clayton 7a47bd9f02 Move posix specific files into posix subdirectory so they can
be shared with linux.

Updated Xcode project.

llvm-svn: 105928
2010-06-14 04:30:13 +00:00
Greg Clayton 13238c4455 patch from: Jean-Daniel Dupas
BreakpointLocation::GetLoadAddress() does not match the 'StoppointLocation::GetLoadAddress() const' virtual function prototype, and so, does not override the superclass function.

llvm-svn: 105927
2010-06-14 04:18:27 +00:00
Eli Friedman e13a8dbf14 Make include paths work on Linux. ifdef out stuff that isn't relevant to
Linux or doesn't compile on Linux.

llvm-svn: 105923
2010-06-13 19:36:42 +00:00
Eli Friedman adb3502477 Make getopt() use portable to Linux.
llvm-svn: 105922
2010-06-13 19:18:49 +00:00
Eli Friedman 932197d89c Add missing stdio.h include; fix include path for ClangASTContext.h.
llvm-svn: 105921
2010-06-13 19:06:42 +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
Eli Friedman 3afb70c85a Fix include paths; please check that this works on Mac.
llvm-svn: 105906
2010-06-13 02:17:17 +00:00
Eli Friedman 3afa33ced6 Remove Mac-specific includes.
llvm-svn: 105905
2010-06-13 02:13:20 +00:00
Greg Clayton 474966a41e I have eliminated RTTI from LLDB!
Also added a shell script build phase that fixes the headers in 
LLDB.framework.

llvm-svn: 105899
2010-06-12 18:59:55 +00:00
Eli Friedman 81ad726f04 Move SharingPtr.h into include/.
llvm-svn: 105896
2010-06-12 18:29:53 +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
Greg Clayton c9af18a502 Moved files around for linux build. Fixed up Xcode project to
refer to the new locations.

llvm-svn: 105885
2010-06-12 15:43:35 +00:00
Greg Clayton 1ba811dd81 Fixed an issue with the new DW_TAG_ptr_to_member_type changes where the clang type that was being created was using the pointee_type for both the class and the member pointer.
llvm-svn: 105883
2010-06-12 15:33:14 +00:00
Greg Clayton 9b81a3146f Anders Carlsson patch for member pointers. Thanks Anders.
llvm-svn: 105868
2010-06-12 01:20:30 +00:00
Greg Clayton e20855403b Fixed the build after recent header changes.
Fixed an extra include path in the Xcode project.

llvm-svn: 105867
2010-06-12 01:12:23 +00:00
Greg Clayton b852a111d0 Avoid calls to memcpy.
llvm-svn: 105866
2010-06-12 01:03:17 +00:00
Jason Molenda 3041cbd2b2 Include mach/mach_types.h in two files to adjust for their
removal from lldb-types.h

llvm-svn: 105865
2010-06-12 00:43:41 +00:00
Jason Molenda 743e86ae3d Applied PluginManager.cpp patch from Jean-Daniel Dupas.
Fixed problem Jean-Daniel Dupas found in ProcessGDBRemote.cpp.

llvm-svn: 105857
2010-06-11 23:44:18 +00:00
Owen Anderson 571e864e84 Revert my previous patch. Apparently the code-size impact of std::sort isn't acceptable.
llvm-svn: 105835
2010-06-11 21:07:26 +00:00
Owen Anderson dc433611a2 Replace qsort_r with std::sort. This gets rid of a lot of portability
ickiness, and is cleaner to boot.

I'm fairly confident that I converted the comparator over properly,
and what testing I could figure out how to run seemed to pass, but it
would be great if someone in the know could check behind me.

llvm-svn: 105834
2010-06-11 20:52:57 +00:00
Eli Friedman a82475ab74 Fix includes.
llvm-svn: 105814
2010-06-11 04:54:56 +00:00
Eli Friedman 6abb634bcf Use st_mtime instead of st_mtimespec for portability.
llvm-svn: 105813
2010-06-11 04:52:22 +00:00
Eli Friedman 8d860d557f Fix TimeValue::Offset* to take uint64_t
llvm-svn: 105812
2010-06-11 04:50:35 +00:00
Eli Friedman e01b70bf30 Use Host::GetCurrentThreadID() instead of mach_thread_self().
llvm-svn: 105811
2010-06-11 04:29:29 +00:00
Eli Friedman 50fac2f7b5 Add missing include; fix missed constant to use llvm::MachO.
llvm-svn: 105810
2010-06-11 04:26:08 +00:00
Greg Clayton 41f923275e Made lldb_private::ArchSpec more generic so that it can take a mach-o cpu
type and sub-type, or an ELF e_machine value. Also added a generic CPU type
to the arch spec class so we can have a single arch definition that the LLDB
core code can use. Previously a lot of places in the code were using the
mach-o definitions from a macosx header file. 

Switches over to using "llvm/Support/MachO.h" for the llvm::MachO::XXX for the
CPU types and sub types for mach-o ArchSpecs. Added "llvm/Support/ELF.h" so 
we can use the "llvm::ELF::XXX" defines for the ELF ArchSpecs.

Got rid of all CPU_TYPE_ and CPU_SUBTYPE_ defines that were previously being
used in LLDB.

llvm-svn: 105806
2010-06-11 03:25:34 +00:00
Greg Clayton ae5680be64 Fixed an issue where a return value wasn't being returned from Symtab::CompareSymbolValueByIndexLinux.
llvm-svn: 105802
2010-06-11 00:51:46 +00:00
Eli Friedman 5b405edd5e Remove dependency on Mac-specific libkern/OSByteOrder.h.
llvm-svn: 105799
2010-06-10 23:56:16 +00:00
Eli Friedman 6eb685c264 Make Error.h and Error.cpp compile on Linux.
llvm-svn: 105798
2010-06-10 23:45:58 +00:00