Commit Graph

813 Commits

Author SHA1 Message Date
Jim Ingham bc7d7c8119 Few clarifications.
llvm-svn: 113661
2010-09-10 23:12:45 +00:00
Jim Ingham 53c47f1e2f Move the "Object Description" into the ValueObject, and the add an API to
SBValue to access it.  For now this is just the result of ObjC NSPrintForDebugger,
but could be extended.  Also store the results of the ObjC Object Printer in a
Stream, not a ConstString.

llvm-svn: 113660
2010-09-10 23:12:17 +00:00
Jim Ingham baae168e63 Little bit of line wrapping cleanup.
Mainly ExecuteFunction should save & restore the currently selected Thread & Frame.

llvm-svn: 113658
2010-09-10 23:07:48 +00:00
Jim Ingham 59ce7fe05f When the debugger updates its symbol context, if no thread or frame are selected select the first thread's 0th frame.
llvm-svn: 113657
2010-09-10 23:06:30 +00:00
Jim Ingham 39bbba498c Always look up the symbols with FindSymbolByID since we are minimizing the symbol list.
llvm-svn: 113655
2010-09-10 23:02:28 +00:00
Greg Clayton 40b8d8a402 Make sure the address passed into SymbolContext::DumpStopContext() is valid before trying to calculate any offsets.
llvm-svn: 113645
2010-09-10 22:05:05 +00:00
Greg Clayton b57a127a53 There was a check to make sure that the frame had a valid function before the expression parser would allow decl lookups which was not needed. After removing this you can evaluate expressions correctly when stopped in a frame that only has a symbol or has no symbol context at all.
llvm-svn: 113611
2010-09-10 20:20:35 +00:00
Johnny Chen 0e1cb4e0d4 Fixed the breakage of "breakpoint command add -p 1 2" caused by r113596 as
pointed out by Jim Ingham.  The convenient one-liner specification should only
apply when there is only one breakpoint id being specified for the time being.

llvm-svn: 113609
2010-09-10 20:15:13 +00:00
Johnny Chen 3495f25aa7 Updated help text for "breakpoint command add" to reflect r113596 changeset.
llvm-svn: 113607
2010-09-10 19:34:12 +00:00
Greg Clayton 0996003126 Added some missing API for address resolving within a module, and looking
up a seciton offset address (SBAddress) within a module that returns a
symbol context (SBSymbolContext). Also added a SBSymbolContextList in 
preparation for adding find/lookup APIs that can return multiple results.

Added a lookup example code that shows how to do address lookups.

llvm-svn: 113599
2010-09-10 18:31:35 +00:00
Johnny Chen bc1857ba36 These two files should have been in r113596. Oops!
llvm-svn: 113598
2010-09-10 18:28:27 +00:00
Johnny Chen 94de55d5c2 Added the capability to specify a one-liner Python script as the callback
command for a breakpoint, for example:

(lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()"

The ScriptInterpreter interface has an extra method:

    /// Set a one-liner as the callback for the breakpoint command.
    virtual void 
    SetBreakpointCommandCallback (CommandInterpreter &interpreter,
                                  BreakpointOptions *bp_options,
                                  const char *oneliner);

to accomplish the above.

Also added a test case to demonstrate lldb's use of breakpoint callback command
to stop at function c() only when its immediate caller is function a().  The
following session shows the user entering the following commands:

1) command source .lldb (set up executable, breakpoint, and breakpoint command)
2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a())
3) bt (to see that indeed c()'s immediate caller is a())
4) c (to continue and finish the program)

test/conditional_break $ ../../build/Debug/lldb
(lldb) command source .lldb
Executing commands in '.lldb'.
(lldb) file a.out
Current executable set to 'a.out' (x86_64).
(lldb) breakpoint set -n c
Breakpoint created: 1: name = 'c', locations = 1
(lldb) script import sys, os
(lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir))
(lldb) script import conditional_break
(lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()"
(lldb) run
run
Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out'  (x86_64)
(lldb) Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`a at main.c:25
  frame #3: a.out`main at main.c:44
  frame #4: a.out`start
c called from b
Continuing...
Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`main at main.c:47
  frame #3: a.out`start
c called from b
Continuing...
Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`a at main.c:27
  frame #2: a.out`main at main.c:50
  frame #3: a.out`start
c called from a
Stopped at c() with immediate caller as a().
a(1) returns 4
b(2) returns 5
Process 20420 Stopped
* thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread
  36   	
  37   	int c(int val)
  38   	{
  39 ->	    return val + 3;
  40   	}
  41   	
  42   	int main (int argc, char const *argv[])
(lldb) bt
bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
  frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39
  frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27
  frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50
  frame #3: 0x0000000100000d88 a.out`start + 52
(lldb) c
c
Resuming process 20420
Process 20420 Exited
a(3) returns 6
(lldb) 

llvm-svn: 113596
2010-09-10 18:21:10 +00:00
Johnny Chen d0211cc657 Don't flatten lldb and import everything into the global namespace. Instead,
set the debugger_unique_id with the lldb prefix.

llvm-svn: 113589
2010-09-10 16:19:10 +00:00
Jason Molenda fbcb7f2c4e The first part of an lldb native stack unwinder.
The Unwind and RegisterContext subclasses still need
to be finished; none of this code is used by lldb at
this point (unless you call into it by hand).

The ObjectFile class now has an UnwindTable object.

The UnwindTable object has a series of FuncUnwinders
objects (Function Unwinders) -- one for each function
in that ObjectFile we've backtraced through during this
debug session.

The FuncUnwinders object has a few different UnwindPlans.
UnwindPlans are a generic way of describing how to find
the canonical address of a given function's stack frame
(the CFA idea from DWARF/eh_frame) and how to restore the
caller frame's register values, if they have been saved
by this function.

UnwindPlans are created from different sources.  One source is the
eh_frame exception handling information generated by the compiler
for unwinding an exception throw.  Another source is an assembly
language inspection class (UnwindAssemblyProfiler, uses the Plugin
architecture) which looks at the instructions in the funciton
prologue and describes the stack movements/register saves that are
done.

Two additional types of UnwindPlans that are worth noting are
the "fast" stack UnwindPlan which is useful for making a first
pass over a thread's stack, determining how many stack frames there
are and retrieving the pc and CFA values for each frame (enough
to create StackFrameIDs).  Only a minimal set of registers is
recovered during a fast stack walk.  

The final UnwindPlan is an architectural default unwind plan.
These are provided by the ArchDefaultUnwindPlan class (which uses
the plugin architecture).  When no symbol/function address range can
be found for a given pc value -- when we have no eh_frame information
and when we don't have a start address so we can't examine the assembly
language instrucitons -- we have to make a best guess about how to 
unwind.  That's when we use the architectural default UnwindPlan.
On x86_64, this would be to assume that rbp is used as a stack pointer
and we can use that to find the caller's frame pointer and pc value.
It's a last-ditch best guess about how to unwind out of a frame.

There are heuristics about when to use one UnwindPlan versues the other --
this will all happen in the still-begin-written UnwindLLDB subclass of
Unwind which runs the UnwindPlans.

llvm-svn: 113581
2010-09-10 07:49:16 +00:00
Caroline Tice 428a9a58fa If the file the user specifies can't be found in the current directory,
and the user didn't specify a particular directory, search for the file 
using the $PATH environment variable.

llvm-svn: 113575
2010-09-10 04:48:55 +00:00
Greg Clayton c9800667e4 Cleaned up the output of "image lookup --address <ADDR>" which involved
cleaning up the output of many GetDescription objects that are part of a 
symbol context. This fixes an issue where no ranges were being printed out
for functions, blocks and symbols.

llvm-svn: 113571
2010-09-10 01:30:46 +00:00
Caroline Tice f20e8239cd Add comments to InstanceSettings constructors explaining why they have
to be set up the way they are.  Comment out code that removes pending
settings for live instances (after the settings are copied over).

llvm-svn: 113519
2010-09-09 18:26:37 +00:00
Caroline Tice 5c9fdfa46d Move the ProcessPlugins enum definition from lldb-enumerations.h to
Process.h; modify the process.plugins settings variable to use the
correct plugin names.

llvm-svn: 113510
2010-09-09 18:01:59 +00:00
Caroline Tice dd7598578f Make API calls for setting/getting user settable variables static.
Modify Driver to handle SIGWINCH signals and automatically re-set the
term-width variable.

llvm-svn: 113506
2010-09-09 17:45:09 +00:00
Caroline Tice f362c45e8d Modify the command options help generation so that required options
are always printed immediately after the command, before optional
options; also so that in the detailed descriptions of each command
option, the options and their help are output in alphabetical order
(sorted by the short option) rather in whatever order they happened to
be in the table.

llvm-svn: 113496
2010-09-09 16:44:14 +00:00
Greg Clayton 6f35f5cf5d Got the ARM version of debugserver up to date.
Renamed the "dispatchqaddr" setting that was coming back for stop reply packets
to be named "qaddr" so that gdb doesn't thing it is a register number. gdb
was checking the first character and assuming "di" was a hex register number
because 'd' is a hex digit. It has been shortened so gdb can safely ignore it.

llvm-svn: 113475
2010-09-09 06:32:46 +00:00
Caroline Tice 101c7c2060 Make all debugger-level user settable variables into instance variables.
Make get/set variable at the debugger level always set the particular debugger's instance variables rather than
the default variables.

llvm-svn: 113474
2010-09-09 06:25:08 +00:00
Johnny Chen 43a651c609 Added GetStackFrames(thread) utility function.
llvm-svn: 113460
2010-09-09 00:55:07 +00:00
Chris Lattner 311adf3d5b eliminate some clang warnings.
llvm-svn: 113438
2010-09-08 23:01:14 +00:00
Chris Lattner c7fae585ca remove unneeded #include, reducing # static ctors.
llvm-svn: 113437
2010-09-08 23:01:02 +00:00
Chris Lattner 37c1b43144 fix a bunch of signed/unsigned comparison warnings, stop evaluating "getsize" every time through the loop.
llvm-svn: 113433
2010-09-08 22:55:31 +00:00
Johnny Chen 30ee4ef308 Added a lldbutil.py module, which contains utility functions which can be used
from scripting applications.  An example usage from TestConditionalBreak.py is:

            import lldbutil
            lldbutil.PrintStackTrace(thread)

./dotest.py -v conditional_break
----------------------------------------------------------------------
Collected 2 tests

test_with_dsym (TestConditionalBreak.ConditionalBreakTestCase)
Exercise some thread and frame APIs to break if c() is called by a(). ... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`a at main.c:25
  frame #3: a.out`main at main.c:44
  frame #4: a.out`start
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`main at main.c:47
  frame #3: a.out`start
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`a at main.c:27
  frame #2: a.out`main at main.c:50
  frame #3: a.out`start
ok
test_with_dwarf (TestConditionalBreak.ConditionalBreakTestCase)
Exercise some thread and frame APIs to break if c() is called by a(). ... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`a at main.c:25
  frame #3: a.out`main at main.c:44
  frame #4: a.out`start
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`main at main.c:47
  frame #3: a.out`start
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`a at main.c:27
  frame #2: a.out`main at main.c:50
  frame #3: a.out`start
ok

----------------------------------------------------------------------
Ran 2 tests in 7.803s

OK

llvm-svn: 113432
2010-09-08 22:54:46 +00:00
Sean Callanan 80c3e8e66b There is currently a problem with our interaction
with the Clang parser that prevents us from passing
Objective-C types to functions that expect C types.
This quick hack keeps us in business until that
interaction is fixed.

llvm-svn: 113429
2010-09-08 22:38:54 +00:00
Caroline Tice 09799af62e More help text fixes.
llvm-svn: 113421
2010-09-08 22:08:58 +00:00
Caroline Tice e3d2631567 Clean up, clarify and standardize help text, and fix a few help text formatting problems.
llvm-svn: 113408
2010-09-08 21:06:11 +00:00
Johnny Chen 2634032c66 Added '-d' option to the test driver to spit out the process id and do a delay
of 10 seconds in order for the debugger to attach.

llvm-svn: 113407
2010-09-08 20:56:16 +00:00
Sean Callanan afa4237d9b Fixed an expression parser bug that prevented
certain functions from being resolved correctly.

Some functions (particularly varargs functions)
are BitCast before being called, and the problem
was that a CallInst where getCalledValue()
returned a BitCast ConstantExpr was not being
relocated at all.

This problem should now be resolved for the case
of BitCast.

llvm-svn: 113396
2010-09-08 20:04:08 +00:00
Greg Clayton c78e9a2c81 Disable minimized symbol tables for now as this was causing test suite failures.
llvm-svn: 113372
2010-09-08 17:53:19 +00:00
Jim Ingham 9f157f574d "break set -F" should also use the full symbol name completer.
llvm-svn: 113371
2010-09-08 17:52:03 +00:00
Caroline Tice 91123da2d1 Make sure creating a pending instance doesn't also trigger creating a live instance; also make sure creating a
pending instance uses the specified instance name rather than creating a new one; add brackets to instance names
when searching for and removing pending instances.

llvm-svn: 113370
2010-09-08 17:48:55 +00:00
Greg Clayton 928d8294c2 Enable minimized symbol tables when parsing mach-o files. This
new change will omit unneeded symbol table entries and coalesce
function entries (N_FUN stab entries) with their linker code
symbol (N_SECT symbols) into only the function symbol to avoid
duplicate symbol table entries. It will also coalesce N_STSYM and
the data linker symbol into just one static data symbol.

llvm-svn: 113363
2010-09-08 16:38:06 +00:00
Jim Ingham ee8aea1011 Add a user settings controller to Thread. Then added a step-avoid-regexp setting
which controls whether to stop in a function matching the regexp.

llvm-svn: 113335
2010-09-08 03:14:33 +00:00
Jim Ingham 5d06922c36 The functions that return the static ConstString names of the settings should be static
as well.

llvm-svn: 113328
2010-09-08 01:17:36 +00:00
Johnny Chen e027b57b56 Minor tweak to add expected matching strings.
llvm-svn: 113327
2010-09-08 00:55:12 +00:00
Johnny Chen 06d73a0c5f Added a test case which exercises some thread and frame APIs to break only when
the call site of c() is a().

llvm-svn: 113325
2010-09-08 00:46:08 +00:00
Greg Clayton d003a778d9 Added an objective C test that creates some NSString, NSArray and NSDictionary
objects and populates them so we can test making expression calls with these
objects. We will need to make this test case more complete as time goes on to
make sure we can evaluate all functions.

llvm-svn: 113314
2010-09-07 23:55:31 +00:00
Greg Clayton e83e731ec1 Remove the Flags member in lldb_private::Module in favor of bitfield boolean
member variables.

Modified lldb_private::Module to have an accessor that can be used to tell if
a module is a dynamic link editor (dyld) as there are functions in dyld on
darwin that mirror functions in libc (malloc, free, etc) that should not
be used when doing function lookups by name in expressions if there are more
than one match when looking up functions by name.

llvm-svn: 113313
2010-09-07 23:40:05 +00:00
Jim Ingham a767c9a3ae The settings mutexes get used recursively, and deadlock if they are normal mutexes.
llvm-svn: 113309
2010-09-07 23:31:30 +00:00
Sean Callanan 1e87fffb41 Fixed a bug where we did not handle constant
expressions correctly.  These produced a result
variable with an initializer but no store
instruction, and the store instruction was as
a result never rewritten to become a store to a
persistent variable.

Now if the result variable has an initializer
but is never used, we generate a (redundant)
store instruction for it, which is then later
rewritten into a (useful) store to the persistent
result variable.

llvm-svn: 113300
2010-09-07 22:43:19 +00:00
Caroline Tice 3f4c09c1c3 Small help text fixes, to make it more consistent and accurate.
Temporarily remove -l option from 'expr' command (at Sean's request).

llvm-svn: 113298
2010-09-07 22:38:08 +00:00
Greg Clayton 8dc0a9879c Stop line entries from dumping full paths when addresses dump themselves as symbol contexts.
llvm-svn: 113292
2010-09-07 21:56:53 +00:00
Sean Callanan 3883b5ae4e Improved function lookup to avoid conflicts between
symbols with the same name and no debug information.
Also improved the way functions are called so we
don't automatically define them as variadic functions
in the IR.

llvm-svn: 113290
2010-09-07 21:49:41 +00:00
Sean Callanan d0d37d1800 Updated the x86_64 and i386 ABIs to chain RBP
(i.e., leave the value the same, so that a new
stack frame will be linked to the previous
stack) rather than zeroing out RBP.

This fixes calls to dlopen(), for example, which
does a backtrace to see which image is calling
it.

llvm-svn: 113288
2010-09-07 21:23:34 +00:00
Jim Ingham 95852755a8 Move common code from GetSettingsController in Process & Debugger into static functions
in UserSettingsController.cpp.

llvm-svn: 113268
2010-09-07 20:27:09 +00:00
Greg Clayton 2bddd3442f Patch from Jay Cornwall that modifies the LLDB "Host" layer to reuse more
code between linux, darwin and BSD.

llvm-svn: 113263
2010-09-07 20:11:56 +00:00
Johnny Chen ea772bbba0 The output for term-width setting has single quotes around the (int) value.
And added a trace output for the stop function name to breakAfterLaunch() method.

llvm-svn: 113251
2010-09-07 18:55:50 +00:00
Caroline Tice 49e2737eb4 Fix various minor bugs in the Settings stuff.
llvm-svn: 113245
2010-09-07 18:35:40 +00:00
Johnny Chen 41cb55a916 Converted TestUnsignedTypespy and TestStructTypes.py to Dsym/Dwarf combination.
llvm-svn: 113244
2010-09-07 18:32:57 +00:00
Johnny Chen 165a0798a1 Converted TestSTL.py to Dsym/Dwarf combination.
llvm-svn: 113241
2010-09-07 18:27:35 +00:00
Johnny Chen 42aa5e3e22 Converted TestSetValues.py to Dsym/Dwarf combination.
llvm-svn: 113238
2010-09-07 18:19:13 +00:00
Greg Clayton 49bd1c847b Added Symtab::FindSymbolByID() in preparation for enabling the minimal
symbol tables. Minimal symbol tables enable us to merge two symbols, one
debug symbol and one linker symbol, into a single symbol that can carry
just as much information and will avoid duplicate symbols in the symbol
table.

llvm-svn: 113223
2010-09-07 17:36:17 +00:00
Johnny Chen a37764b5ae Added a test case for setting term-width, too.
llvm-svn: 113219
2010-09-07 17:31:05 +00:00
Johnny Chen 881c371af3 Added comments.
llvm-svn: 113214
2010-09-07 17:12:10 +00:00
Johnny Chen 773777727a Added a simple test case for the "settings set" command for instance variable 'prompt'.
llvm-svn: 113211
2010-09-07 17:06:13 +00:00
Johnny Chen ecf9ded375 LLDB command "set term-width 0" needs to be changed to "settings set term-width 0"
after the recent checkin.

llvm-svn: 113206
2010-09-07 16:19:35 +00:00
Greg Clayton 95897c6a3a Added more API to lldb::SBBlock to allow getting the block
parent, sibling and first child block, and access to the
inline function information.

Added an accessor the StackFrame:

	Block * lldb_private::StackFrame::GetFrameBlock();
	
LLDB represents inline functions as lexical blocks that have
inlined function information in them. The function above allows
us to easily get the top most lexical block that defines a stack
frame. When there are no inline functions in function, the block
returned ends up being the top most block for the function. When
the PC is in an inlined funciton for a frame, this will return the
first parent block that has inlined function information. The
other accessor: StackFrame::GetBlock() will return the deepest block
that matches the frame's PC value. Since most debuggers want to display
all variables in the current frame, the Block returned by
StackFrame::GetFrameBlock can be used to retrieve all variables for
the current frame.

Fixed the lldb_private::Block::DumpStopContext(...) to properly
display inline frames a block should display all of its inlined
functions. Prior to this fix, one of the call sites was being skipped.
This is a separate code path from the current default where inlined
functions get their own frames.

Fixed an issue where a block would always grab variables for any
child inline function blocks.

llvm-svn: 113195
2010-09-07 04:20:48 +00:00
Greg Clayton 3c68757c45 Fixed an error that could occur during disassembly that could cause a function name to be printed before the first _and_ the second instruction of disassembly when there are two symbols -- one debug symbol and one linker symbol.
llvm-svn: 113181
2010-09-06 23:11:45 +00:00
Greg Clayton b0458249cf Fixed a buffer overrun error that could occur every time the program was run due to a "sprintf" with a destination string that was too short.
llvm-svn: 113180
2010-09-06 23:04:11 +00:00
Greg Clayton f7c0fd8dc8 Fixed an error where a random string would get executed after a recent fix that checked if the window column size was zero was added on the lldb driver startup.
llvm-svn: 113179
2010-09-06 23:01:25 +00:00
Jim Ingham 56f4ee05e9 Adding some docs on how to use lldb. First cut...
llvm-svn: 113046
2010-09-04 00:49:36 +00:00
Caroline Tice 3df9a8dfd7 This is a very large commit that completely re-does the way lldb
handles user settable internal variables (the equivalent of set/show
variables in gdb).  In addition to the basic infrastructure (most of
which is defined in UserSettingsController.{h,cpp}, there are examples
of two classes that have been set up to contain user settable
variables (the Debugger and Process classes).  The 'settings' command
has been modified to be a command-subcommand structure, and the 'set',
'show' and 'append' commands have been moved into this sub-commabnd
structure.  The old StateVariable class has been completely replaced
by this, and the state variable dictionary has been removed from the
Command Interpreter.  Places that formerly accessed the state variable
mechanism have been modified to access the variables in this new
structure instead (checking the term-width; getting/checking the
prompt; etc.)

Variables are attached to classes; there are two basic "flavors" of
variables that can be set: "global" variables (static/class-wide), and
"instance" variables (one per instance of the class).  The whole thing
has been set up so that any global or instance variable can be set at
any time (e.g. on start up, in your .lldbinit file), whether or not
any instances actually exist (there's a whole pending and default
values mechanism to help deal with that).

llvm-svn: 113041
2010-09-04 00:03:46 +00:00
Johnny Chen 070ebd93d2 Added a default build phase at the beginning of test_load_unload() test case.
llvm-svn: 113039
2010-09-03 23:52:15 +00:00
Johnny Chen 1b1b9accd1 Marked test_process_launch_for_universal() test case as requiring 'darwin' and 'i386'
in order to be run.  And added a default build phase at the beginning of the method.

llvm-svn: 113037
2010-09-03 23:49:16 +00:00
Greg Clayton e41e58997c Improved name demangling performance by 20% on darwin.
llvm-svn: 113032
2010-09-03 23:26:12 +00:00
Johnny Chen bd588549d5 Converted TestGlobalVariables.py to Dsym/Dwarf combination.
llvm-svn: 113030
2010-09-03 23:16:49 +00:00
Johnny Chen 1cdadddf36 Converted TestFunctionTypes.py to Dsym/Dwarf combination.
llvm-svn: 113029
2010-09-03 23:14:26 +00:00
Johnny Chen 84c96b84bd Converted TestEnumTypes.py to Dsym/Dwarf combination.
Marked test_with_dwarf() as expectedFailure where 'image lookup -t days' returns nothing.

llvm-svn: 113028
2010-09-03 23:10:24 +00:00
Greg Clayton 1346f7e098 Cleaned up step logging a bit.
llvm-svn: 113023
2010-09-03 22:45:01 +00:00
Johnny Chen 725945d568 Fixed an lldb infrastructure bug, where the debugger should reaaly update its
execution context only when the process is still alive.  When running the test
suite, the debugger is launching and killing processes constantly.

This might be the cause of the test hang as reported in rdar://problem/8377854,
where the debugger was looping infinitely trying to update a supposedly stale
thread list.

llvm-svn: 113022
2010-09-03 22:35:47 +00:00
Greg Clayton ef3cf2b954 Added some extra logging to track asynchronous packet activity.
llvm-svn: 113012
2010-09-03 21:14:27 +00:00
Greg Clayton 54512bd6c9 Fixed a case where we might be able to acquire a mutex with a try lock and
not release it by making sure a mutex locker object is appropriately used.

llvm-svn: 112996
2010-09-03 19:15:43 +00:00
Jim Ingham 3fec2dd374 Delete the vestigal "select", "info" and "delete" commands.
Also move "Carbon.framework" to the right place.

llvm-svn: 112993
2010-09-03 19:08:19 +00:00
Benjamin Kramer 6b7393017e Pacify operator precedence warnings. No functionality change because eLaunchFlagDisableASLR happens to be 1.
llvm-svn: 112985
2010-09-03 18:20:07 +00:00
Greg Clayton 2cad65a595 Fixed the StackFrame to correctly resolve the StackID's SymbolContextScope.
Added extra logging for stepping.

Fixed an issue where cached stack frame data could be lost between runs when
the thread plans read a stack frame.

llvm-svn: 112973
2010-09-03 17:10:42 +00:00
Johnny Chen 57b47384cc Added comments regarding the two mechanisms of process cleanup to lldbtest.py.
Also changed the expected strings to be matched since "thread list" changed its
output format. 

llvm-svn: 112880
2010-09-02 22:25:47 +00:00
Greg Clayton 6dadd508e7 Added a new bool parameter to many of the DumpStopContext() methods that
might dump file paths that allows the dumping of full paths or just the
basenames. Switched the stack frame dumping code to use just the basenames for
the files instead of the full path.

Modified the StackID class to no rely on needing the start PC for the current
function/symbol since we can use the SymbolContextScope to uniquely identify
that, unless there is no symbol context scope. In that case we can rely upon
the current PC value. This saves the StackID from having to calculate the 
start PC when the StackFrame::GetStackID() accessor is called.

Also improved the StackID less than operator to correctly handle inlined stack
frames in the same stack.

llvm-svn: 112867
2010-09-02 21:44:10 +00:00
Johnny Chen 7d1d7537cf Moved the process cleanup of Script-Bridge-based APIs into TestBase.tearDown()
method where they belong.  Also fixed a logic error in maintaining the command
interface flag (runStarted) indicating whether the lldb "run"/"process launch"
command has been issued.  It was erroneously cleared.

Modified the test cases to take advantage of the refactoring.

llvm-svn: 112863
2010-09-02 21:23:12 +00:00
Johnny Chen 979e796692 (query-replace "variable list" "frame variable")
llvm-svn: 112824
2010-09-02 15:59:20 +00:00
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
Johnny Chen b92555c334 Fixed comment.
llvm-svn: 112750
2010-09-01 22:10:09 +00:00
Johnny Chen 13639089c6 Put the little dances done after SBTarget.LaunchProcess() into the base class.
llvm-svn: 112749
2010-09-01 22:08:51 +00:00
Johnny Chen cbb4be0c93 Changed the test case class names to be noun-like instead of verb-like.
llvm-svn: 112732
2010-09-01 19:59:58 +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 63c2f65ffc Fixed a comment.
llvm-svn: 112725
2010-09-01 19:04:01 +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
Johnny Chen db3d874351 Updated to add plugins directory to PYTHONPATH.
llvm-svn: 112688
2010-09-01 00:55:36 +00:00
Johnny Chen 63dfb27647 Avoid killing the inferior process twice by passing a setCookie=False keyword
argument when issuing a "run" lldb command within the test case meant to
exercise the Python APIs, but is using the command interface due to certain
reason (such as target.LaunchProcess() does not reliably bring up the inferior).

llvm-svn: 112682
2010-09-01 00:15:19 +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
Johnny Chen 11c34a0488 Converted TestDeadStrip.py to Dsym/Dwarf combination.
llvm-svn: 112670
2010-08-31 23:12:15 +00:00
Johnny Chen 9129998061 Converted TestClassTypes.py to Dsym/Dwarf combination. Marked one test case as
expectedFailure because in dwarf format, "variable list this" returns an error.

llvm-svn: 112660
2010-08-31 22:26:16 +00:00
Johnny Chen 65a6524d00 Converted TestBitfields.py to Dsym/Dwarf combination.
llvm-svn: 112646
2010-08-31 21:49:24 +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
Johnny Chen 517210b0f3 Updated to reflect the "plugins" directory.
llvm-svn: 112607
2010-08-31 17:51:08 +00:00
Johnny Chen 8d55a34a34 Changed the buildDsym()/buildDwarf() TestBase methods to use a plugin framework
to delegate the building of binaries to a sys.platform-sepcific plugin.

Modified the dotest.py test driver to add the "plugins" directory to the
PYTHONPATH as well.

darwin.py is the Mac OS X plugin module.

llvm-svn: 112606
2010-08-31 17:42:54 +00:00
Jim Ingham 5024baba16 Add LLDB_EXTERNAL_EDITOR
llvm-svn: 112558
2010-08-30 23:48:25 +00:00
Johnny Chen 324355b9a1 Added doc strings to the array_types test cases. And terminate the current
process being debugged in the TestBase.tearDown() instead of letting it continue
and finish.

llvm-svn: 112556
2010-08-30 23:44:39 +00:00
Sean Callanan f912a8e568 Removed documentation for a non-existent function
parameter.

llvm-svn: 112548
2010-08-30 23:10:43 +00:00
Johnny Chen a33a93cbde Converted TestArrayTypes.py to Dsym/Dwarf combination, and added verbose output
of os command to lldbtest.TestBase.system() method.

llvm-svn: 112547
2010-08-30 23:08:52 +00:00
Johnny Chen 2f1ad5e2bd Added buildDsym() and buildDwarf() methods to lldbtest.TestBase class, and call
them from test cases instead of issuing "make clean; make ..." os command.

llvm-svn: 112542
2010-08-30 22:26:48 +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
Johnny Chen 8952a2d5b6 Added a system() method to the TestBase class of lldbtest.py, which is actually
taken from Python 2.7's subprocess.check_output() convenience function.  The
purpose of this method is to run the os command with arguments and return its
output as a byte string.

Modified hello_world/TestHelloWorld.py to have two test cases:

o test_with_dsym_and_run_command
o test_with_dwarf_and_process_launch_api

with the dsym case conditioned on sys.platform.startswith("darwin") being true.
The two cases utilize the system() method to invoke "make clean; make MAKE_DYSM=YES/NO"
to prepare for the appropriate debugging format before running the test logic.

llvm-svn: 112530
2010-08-30 21:35:00 +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
Johnny Chen 269457515a Fail early, fail fast.
llvm-svn: 112328
2010-08-27 23:53:00 +00:00
Johnny Chen 5ee881948a Added a test case test_breakpoint_creation_by_filespec_python() which creates a
breakpoint by FileSpec and line number and exercises some FileSpec APIs.

Also, RUN_STOPPED is a bad assert name, RUN_SUCCEEDED is better.

llvm-svn: 112327
2010-08-27 23:47:36 +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 fd8967a82f Fixed a typo in the method name.
llvm-svn: 112311
2010-08-27 22:39:49 +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
Johnny Chen ccd570da6b Trivial doc string mod.
llvm-svn: 112293
2010-08-27 21:15:57 +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
Johnny Chen 82d404c886 Added TestHelloWorld.py which exercises the Python APIs for target, breakpoint,
and process.  Added comment within the file about issues of using LaunchProcess
of SBTarget to launch a process (rdar://problem/8364687).

llvm-svn: 112276
2010-08-27 18:08:58 +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
Johnny Chen 827edffafd Added a test case to bitfields which uses the Python APIs from lldb.py.
Added a utility method to TestBase class to debug print an SBValue object.

llvm-svn: 112247
2010-08-27 00:15:48 +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
Johnny Chen c19e3a0946 Modified method doc string for verbose test description output.
llvm-svn: 112236
2010-08-26 22:38:51 +00:00
Johnny Chen bf325e4a37 Changed from dbg.GetCurrentTarget() to dbg.GetSelectedTarget().
llvm-svn: 112231
2010-08-26 22:06: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
Johnny Chen 2771d7bf49 Added comment about target.LaunchProcess() not working.
llvm-svn: 112226
2010-08-26 21:53:26 +00:00
Johnny Chen 27c412320e Added a utility function EnvArray() to lldbtest.py.
llvm-svn: 112223
2010-08-26 21:49:29 +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
Johnny Chen 5fca8ca8cd o Added a test case for array_types which uses the Python APIs from lldb.py,
with the only exception of launching the process from SBTarget which is under
  investigation.

o build-swig-Python.sh should also checks the timestamp of ${swig_input_file}
  for update eligibility.  Also, once an update is in order, there's no need
  to check the remaining header files for timestamps.

o Coaches swig to treat StopReason as an int type, instead of a C++ class.

llvm-svn: 112210
2010-08-26 20:04:17 +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
Johnny Chen 61703c96f2 Minor doc string modification.
llvm-svn: 112103
2010-08-25 22:56:10 +00:00
Johnny Chen f3c59231b3 Added logic to TestUniversal.py to exercise the python APIs:
o SBDebugger.GetCurrentTarget()
o SBTarget.GetProcess()
o SBProcess.GetAddressByteSize()

in order to make sure that, indeed, 64-bit, followed by 32-bit processes have
been launched.

Added invoke() method to TestBase to factor in the tracing logic in one place.
This method allows an object to call a method with no arg reflectively.

llvm-svn: 112102
2010-08-25 22:52:45 +00:00
Johnny Chen 981463d670 Fixed a logic error in the expect() method. If the start string does not match,
there's no point matching further sub strings; the expect() already fails.

Also cleaned up the assert message for VARIABLES_DISPLAYED_CORRECTLY.

llvm-svn: 112074
2010-08-25 19:00:04 +00:00
Johnny Chen f2b70237e6 Allow command retries in case of process launch failures. This recovery
mechanism seems to work fine on my MacBook Pro in some limited test cases.

The default maxLaunchCount and timeWait variables used in the scheme can be
overridden by the env variables LLDB_MAX_LAUNCH_COUNT and LLDB_TIME_WAIT.

llvm-svn: 112071
2010-08-25 18:49:48 +00:00
Greg Clayton a45533defa The destructor for StackFrameList doesn't need to be virtual as we aren't
subclassing it anywhere.

llvm-svn: 112010
2010-08-25 01:01:30 +00:00
Greg Clayton 158483cf62 Thread no longer needs to be a friend in StackFrameList now that StackFrameList
contains the entire stack backtrace.

llvm-svn: 112009
2010-08-25 00:58:59 +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
Johnny Chen c7c9fcfbd6 More descriptive trace messages for the matchings of start and sub strings.
llvm-svn: 112000
2010-08-24 23:48:10 +00:00
Johnny Chen 536b7d2d26 Removed the @unitest2.expectedFailure decorator. The i386 process launch works
correctly after all.  It was my own configuration error (I was building x86_64
only).

llvm-svn: 111992
2010-08-24 23:14:47 +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
Johnny Chen 3c884a014c Added a test for launching a universal binary. Launch of i386 architecture
currently fails: rdar://problem/8349784.

Forgot to check in lldbtest.py in the previous commit r111958.

llvm-svn: 111975
2010-08-24 22:07:56 +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
Johnny Chen 9c194e3e75 Converted to Makefile.rules.
llvm-svn: 111961
2010-08-24 20:54:26 +00:00
Johnny Chen 9d2bd8301d More descriptive method doc string.
llvm-svn: 111960
2010-08-24 20:48:28 +00:00
Johnny Chen 6b900c5dcd Added a test case which uses "image lookup" command on an enum data type.
llvm-svn: 111958
2010-08-24 20:44:33 +00:00
Johnny Chen f2b1419acc Need a better method name.
llvm-svn: 111939
2010-08-24 18:46:00 +00:00
Johnny Chen f0dec3cf31 Converted to Makefile.rules.
llvm-svn: 111938
2010-08-24 18:41:52 +00:00
Johnny Chen ea920fe8b4 Added test case TestBitfields.py for rdar://problem/8348251, where
"variable list bits" display bits variable correctly, but not "variable list".

llvm-svn: 111937
2010-08-24 18:21:23 +00:00
Johnny Chen 734cdb58f1 Converted to Makefile.rules.
llvm-svn: 111928
2010-08-24 17:43:34 +00:00
Johnny Chen e3dc0f048a Generates the .d prerequisite file for dylib as well.
llvm-svn: 111920
2010-08-24 16:35:00 +00:00
Greg Clayton bba1ba8575 Clear the inline stack frame info when we clean all stack frames.
llvm-svn: 111891
2010-08-24 01:28:00 +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
Johnny Chen 9bc867aaf5 Makefile refactoring for the test suite. Added a make directory under test,
which hosts the Makefile.rules and modified most of the Makefiles under each
test case directories to utilize Mekefile.rules.

Added a description of 'make' directory into README-TestSuite file.

llvm-svn: 111868
2010-08-23 23:56:08 +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
Johnny Chen d0190a6182 Changed the keyword argument for runCmd()/expect() from 'verbose' to 'trace',
which, defaults to False, and if set to True, will trace lldb command execution
and result.

Added "-t" command option to the test driver dotest.py which sets the
LLDB_COMMAND_TRACE environment variable to "YES" and as a result always turns on
command tracing regardless of the 'trace' keyword argument to runCmd()/expect().

llvm-svn: 111811
2010-08-23 17:10:44 +00:00
Greg Clayton 2cf205ff23 Fixed the Xcode project file to not build all architectures
for Debug builds. I accidentally checked this in with my last
round of changes.

llvm-svn: 111743
2010-08-21 20:12:22 +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
Johnny Chen ff3d01d0b7 Print the verbose output of runCmd()/expect() to stderr instead of stdout.
And converted the rest of the test cases to runCmd()/expect().

llvm-svn: 111677
2010-08-20 21:03:09 +00:00
Johnny Chen 74f26b8188 Changed TestBase.expect() to allow default 'msg' arg. Converted TestHelp.py.
llvm-svn: 111671
2010-08-20 19:17:39 +00:00
Johnny Chen b145bbaf4b Added more verbose output when string match fails. Converted TestGlobalVariables.py.
llvm-svn: 111666
2010-08-20 18:25:15 +00:00
Johnny Chen 5bbb88ff97 Added verbose option to runCmd()/expect() in lldbtest.py. Converted TestFunctionTypes.py.
llvm-svn: 111658
2010-08-20 17:57:32 +00:00
Johnny Chen 617cca957e Converted some more test cases to use runCmd()/expect().
llvm-svn: 111652
2010-08-20 17:04:20 +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
Johnny Chen f85b0b866c Converted to use runCmd() and expect() for more abstraction.
llvm-svn: 111593
2010-08-20 00:27:37 +00:00
Johnny Chen a6480c124e Use cmd.startswith("run") instead of string equivalence test.
llvm-svn: 111587
2010-08-19 23:53:55 +00:00
Johnny Chen 27f212d1e6 Abstracted the running of command through the command interpreter and checking
its return status into lldbtest.TestBase.runCmd(); and runCmd() in combination
with checking the output against matching substrings (including startswith) into
lldbtest.TestBase.expect().

TestUnsignedTypes.py is refactored to use the abstracted APIs.  Other test cases
to be modified later.

llvm-svn: 111572
2010-08-19 23:26:59 +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
Johnny Chen 0c19186352 Added more informational assert message strings.
llvm-svn: 111536
2010-08-19 18:17:48 +00:00
Johnny Chen 5a2133909d Simplify the assert matched-string criterion.
llvm-svn: 111429
2010-08-18 21:28:35 +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
Jim Ingham ea480e507c Added call stacks with inlined functions higher on the stack, and non-inlined functions at the bottom.
llvm-svn: 111379
2010-08-18 18:28:17 +00:00
Greg Clayton 52d64d9ea9 Added a Thread accessor to the register context.
llvm-svn: 111378
2010-08-18 18:25:47 +00:00
Greg Clayton ddfda9d7a2 Allow the SBDebugger to construct itself with the default constructor so
objects can own one of these objects and assign a valid value at a later point.

llvm-svn: 111377
2010-08-18 18:25:20 +00:00
Sean Callanan 5fb17ea113 Documented RecordingMemoryManager and removed an
undefined, unused function from its API.

llvm-svn: 111335
2010-08-18 00:25:09 +00:00
Sean Callanan 98ab8f0cfc Documented IRToDWARF, and added return value
documentation to IRForTarget.

llvm-svn: 111323
2010-08-17 23:18:59 +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
Johnny Chen 83072afbcd Write out the informational message about the total number of test cases to be
run to stderr, instead of stdout.  The same as what the unittest framework uses.

llvm-svn: 111319
2010-08-17 23:00:13 +00:00
Sean Callanan f346a3dd68 Documented IRForTarget
llvm-svn: 111313
2010-08-17 22:36:13 +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
Johnny Chen 8a05de4d29 Add the ability to specify logging options for lldb and gdb-remote through two
additional env variables.

llvm-svn: 111295
2010-08-17 21:36:09 +00:00
Johnny Chen e76896c987 Specify a more meaningful assert message for TestDeadStrip.py.
llvm-svn: 111294
2010-08-17 21:33:31 +00:00
Sean Callanan 2cdbc722fc Documented DWARFExpression.
llvm-svn: 111276
2010-08-17 20:24:29 +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
Johnny Chen 46c2614b99 Added logging for process.gdb-remote by defining an environment variable named
GDB_REMOTE_LOG which specifies the log file pathname.

llvm-svn: 111198
2010-08-16 22:37:45 +00:00
Sean Callanan b3cecb4c96 Documented ClangPersistentVariable(s). No API
cleanup here, since this is a new and fairly
clean class already.

llvm-svn: 111194
2010-08-16 22:14:59 +00:00
Johnny Chen 6ca006c7c1 Factored the "continue" command execution of the inferior process as part of the
cleanup before finish into the test fixture in lldbtest.TestBase.tearDown().

Derivatives of TestBase is responsible for setting self.runStarted to True if an
inferior process has been started.

llvm-svn: 111188
2010-08-16 21:28:10 +00:00
Johnny Chen dd63f5dbe1 Added a workaround for test suite hang while terminating by checking env variable
LLDB_TESTSUITE_FORCE_FINISH and, if defined, kill the test suite.

llvm-svn: 111056
2010-08-13 22:58:44 +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 f288803a95 Added a test case to exercise persistent variables in combination with the "expr" command.
llvm-svn: 111035
2010-08-13 20:12:05 +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 384cae6e06 Fixed copyright notice on ClangASTSource.h.
llvm-svn: 110977
2010-08-12 23:08:37 +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
Johnny Chen 03b5a8a9ab Applied Pawel Wodnicki's fix for "missing" lldb-forward-rtti.h header file.
llvm-svn: 110943
2010-08-12 19:42:59 +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 4512065130 Test files (but no test cases yet) for handling Universal files.
llvm-svn: 110893
2010-08-12 01:21:40 +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
Johnny Chen edcbecfb1f Call lldb.SBDebugger.Terminate() at the end of test suite run through the atexit
handler similar to what's happening for the individual test case run.

llvm-svn: 110719
2010-08-10 20:23: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
Johnny Chen 1794184ada Modified the remaining test cases to display more meaningful assert messages.
Added a generic message generator to the lldbtest.py base module.

llvm-svn: 110625
2010-08-09 23:44:24 +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
Johnny Chen 0077809bc2 Added some commonly used assert messages to the lldbtest.py module which houses
the TestBase.  Modified TestArrayTypes.py to use the assert messages.  Other
files to follow.

llvm-svn: 110611
2010-08-09 22:01:17 +00:00
Johnny Chen f4804c696d Install the SIGINT (control-c) handler before invoking the text test runner.
llvm-svn: 110595
2010-08-09 20:40:52 +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
Johnny Chen 9289a65f75 Commented out "import traceback".
llvm-svn: 110497
2010-08-07 01:13:18 +00:00
Johnny Chen f5957e0603 Putting out messages about the number of test cases to be run before running the
whole test suite.

llvm-svn: 110487
2010-08-07 00:16:07 +00:00
Johnny Chen ead526a056 Added more comments about unittest2.
llvm-svn: 110470
2010-08-06 21:07:38 +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 c503e784c7 Fixed namespace issues that were breaking the
SWIG wrappers on a non-internal SnowLeopard
system.

llvm-svn: 110413
2010-08-06 00:33:35 +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
Johnny Chen ae9fea401d Added description about unittest2.
llvm-svn: 110400
2010-08-05 23:47:51 +00:00
Johnny Chen 73258830f3 o Added unittest2 which has added the new features in unittest for Python 2.7
backported to Python 2.3+.  Some of the features desired include better
  verbose reporting in unittest2.TextTestRunner and decorator support for
  skipping tests and expected failures.

  http://pypi.python.org/pypi/unittest2

o Modified the existing .py tests to use unittest2 and decorated
  TestSTL.test_step_into_stl(), which is known to always fail currently, with
  @unittest2.expectedFailure.

llvm-svn: 110397
2010-08-05 23:42:46 +00:00
Johnny Chen a21249597e When running a single test case, lldb.SBDebugger.Terminate() is not being called
because unittest.main() calls sys.exit() before returning.  Fixed by registering
an exit handler for this situation.

llvm-svn: 110379
2010-08-05 21:23:45 +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 7620000aa6 Added functionality to our API for SBType. This will allow users to eventually find and peruse static type information from modules.
llvm-svn: 110298
2010-08-05 01:56:48 +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
Johnny Chen fee57bb464 Added README file for the test suite.
llvm-svn: 110160
2010-08-03 22:12:11 +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
Johnny Chen 7f5f2809e8 Added comment.
llvm-svn: 110066
2010-08-02 21:26:00 +00:00
Johnny Chen 8402832e50 Cleanup of test case. Added more comments.
llvm-svn: 110064
2010-08-02 21:19:08 +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 3382c2c80d Fixed debugserver to not exit when we are able to spawn the process, yet not
launch it due to not being able to get the task port. A SIGHUP was killing us
and also an error string wasn't properly being passed along. Got rid of a
class error variable that can only lead to multi-threaded crashes.

llvm-svn: 109930
2010-07-30 23:14:42 +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
Johnny Chen b9e7c0aef6 Add a test case to test that lldb command "command source" works correctly.
llvm-svn: 109806
2010-07-29 21:42:28 +00:00
Johnny Chen c0599ea1e7 Removed redundant import statement.
llvm-svn: 109803
2010-07-29 20:49:07 +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 2d5cdf0615 Added an objective C test case.
llvm-svn: 109798
2010-07-29 20:08:39 +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 ed4377eded Removed debug stmts checked into the previous commit.
llvm-svn: 109712
2010-07-29 00:40:06 +00:00
Johnny Chen 588ddc1c58 Add some comment about possible related bug info.
llvm-svn: 109678
2010-07-28 22:00:42 +00:00
Johnny Chen 377a8ed913 Added a test case to test that we can successfully step into an STL function.
This test case currently always fails.

llvm-svn: 109674
2010-07-28 21:24:31 +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
Johnny Chen 571bfd6a2d Added a test case to test that break on a struct declaration has no effect.
Instead, the first executable statement is set as the breakpoint.

llvm-svn: 109552
2010-07-27 22:48:46 +00:00
Johnny Chen ef2f552de4 Added a test case for showing variables of unsigned types.
llvm-svn: 109545
2010-07-27 21:49:20 +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
Johnny Chen 3c39a980d7 Renaming from TestOrder.py to TestOrderFile.py.
llvm-svn: 109540
2010-07-27 21:03:55 +00:00
Johnny Chen 49583c207f Fixed typos from cut-and-paste errors.
llvm-svn: 109539
2010-07-27 20:59:06 +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 f921790e6e Missed an aspect of the previous makefile patch.
Thanks again to William Lynch!

llvm-svn: 109328
2010-07-24 05:18:16 +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
Benjamin Kramer 5ea4192b72 Remove useless typedef keyword, fix a clang warning.
llvm-svn: 109254
2010-07-23 18:59:12 +00:00
Greg Clayton aaa58c6679 Added a new utility class that I have wanted for a while. The CleanUp
class is a templatized class that allows you to have a cleanup function called
on a data value of type T when the value is set or when the object goes
out of scope. It has support for very rudimentary invalid value detection that
can be enabled by using the appropriate constructor. 

Anyone with template experience that can see ways of improving this class
please let me know. The example code shows a few typical scenarios in which
I would like to use it. It is currently coded with simple type T values
in mind (integer file descriptors, pointers, etc), but I am sure some 
specialization might help out the class for more complex types.

There is a lot of documentation including examples in the CleanUp.h header 
file. 

llvm-svn: 109239
2010-07-23 17:42:15 +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 88f0e04e6f Whoops, fixed the LLVM_CONFIGURATION.
llvm-svn: 109200
2010-07-23 00:16:53 +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