Commit Graph

628 Commits

Author SHA1 Message Date
Greg Clayton 6d5e68eaf2 Added the ability to StackFrame::GetValueForVariableExpressionPath(...) to avoid
fragile ivars if requested. This was done by changing the previous second parameter
to an options bitfield that can be populated by logical OR'ing the new 
StackFrame::ExpressionPathOption enum values together:

    typedef enum ExpressionPathOption
    {
        eExpressionPathOptionCheckPtrVsMember   = (1u << 0),
        eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
    };

So the old function was:
     lldb::ValueObjectSP
     StackFrame::GetValueForVariableExpressionPath (const char *var_expr, bool check_ptr_vs_member, Error &error);

But it is now:

    lldb::ValueObjectSP
    StackFrame::GetValueForVariableExpressionPath (const char *var_expr, uint32_t options, Error &error);

This allows the expression parser in Target::EvaluateExpression(...) to avoid
using simple frame variable expression paths when evaluating something that might
be a fragile ivar.

llvm-svn: 123938
2011-01-20 19:27:18 +00:00
Greg Clayton 16b2d2bf19 Made the DWARF + debug map symbol file parser be much more efficient when it isn't
going to actually be used as the symbol file plug-in by looking only for suitable
N_OSO symbols and avoiding sorting function (N_FUN) and global/static (N_GSYM/N_STSYM)
symbols when there are no suitable N_OSO objects.

llvm-svn: 123889
2011-01-20 06:08:59 +00:00
Jim Ingham 77787033b9 Back up both the register AND the stop state when calling functions.
Set the thread state to "bland" before calling functions so they don't 
  inherit the pending signals and die.

llvm-svn: 123869
2011-01-20 02:03:18 +00:00
Greg Clayton 22a939a782 Make expressions clean up their JIT'ed code allocation.
llvm-svn: 123855
2011-01-19 23:00:49 +00:00
Jim Ingham e8231f41aa ThreadPlanCallUserExpression's WillPop needs to call it's parent's WillPop.
llvm-svn: 123816
2011-01-19 09:45:44 +00:00
Greg Clayton 6f535b98e9 Remove trailing commas from lldb enumerations (patch from Stephen Wilson).
llvm-svn: 123782
2011-01-18 21:49:11 +00:00
Jim Ingham bda4e5eb33 In ThreadPlanCallFunction, do the Takedown right when the thread plan gets popped. When the function call is discarded (e.g. when it crashes and discard_on_error is true) the plan gets discarded. You need to make sure that the stack gets restored right then, and not wait till you start again and the thread plan stack is cleared.
llvm-svn: 123716
2011-01-18 01:58:06 +00:00
Sean Callanan c3a160062d Added support for the fragile ivars provided by
Apple's Objective-C 2.0 runtime.  They are enabled
if the Objective-C runtime has the proper version.

llvm-svn: 123694
2011-01-17 23:42:46 +00:00
Jim Ingham 5caed4e8a8 Add a method on the ObjC Language Runtime that returns the runtime version.
llvm-svn: 123693
2011-01-17 23:06:54 +00:00
Greg Clayton 47a15b7c0b Added missing source files.
llvm-svn: 123614
2011-01-17 04:19:51 +00:00
Greg Clayton 6beaaa680a A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a 
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.

A few months ago I worked with the llvm/clang folks to have the 
ExternalASTSource class be able to complete classes if there weren't completed
yet:

class ExternalASTSource {
....

    virtual void
    CompleteType (clang::TagDecl *Tag);
    
    virtual void 
    CompleteType (clang::ObjCInterfaceDecl *Class);
};

This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.

This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
  objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
  types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
  ClangASTType, and more) can now be iterating through children of any type,
  and if a class/union/struct type (clang::RecordType or ObjC interface) 
  is found that is incomplete, we can ask the AST to get the definition. 
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
  all child SymbolFileDWARF classes will share (much like what happens when
  we have a complete linked DWARF for an executable).
  
We will need to modify some of the ClangUserExpression code to take more 
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.

llvm-svn: 123613
2011-01-17 03:46:26 +00:00
Greg Clayton 49462ea7e4 Added complete complex support for displaying and parsing complex types.
llvm-svn: 123509
2011-01-15 02:52:14 +00:00
Greg Clayton 714ab86491 Added the ability to wait for a predicate value, and set it to a new value all in a thread safe fashion.
llvm-svn: 123492
2011-01-14 23:37:51 +00:00
Stephen Wilson c6c7ca58e4 Extend the ObjectFile interface to support dynamic loading on ELF platforms.
Debuggers on ELF platforms hook into the runtime linker by monitoring a special
"rendezvous" embedded in the address space of the inferior process.  The exact
location of this structure is filled in by the runtime linker and can be
resolved by locating the DT_DEBUG entry in the processes .dynamic section.  The
new GetImageInfoAddress() method (morally equivalent to
Process::GetImageInfoAddress) provides the mechanism to locate this information.

GetEntryPoint() simply returns the address of the start symbol in the executable
if present.  It is useful to the dynamic loader plugin for ELF systems as this
is the earliest point where LLDB can break and probe the inferiors .dynamic
section and rendezvous structure.  Also, this address can be used in the
computation of the virtual base address for position independent executables.

llvm-svn: 123466
2011-01-14 21:08:59 +00:00
Greg Clayton ca512b397c Fixed an error in the type map for "char **" that was a bad memory smasher.
Anytime we had a valid python list that was trying to go from Python down into
our C++ API, it was allocating too little memory and it ended up smashing
whatever was next to the allocated memory.

Added typemap conversions for "void *, size_t" so we can get 
SBProcess::ReadMemory() working. Also added a typemap for "const void *, size_t"
so we can get SBProcess::WriteMemory() to work.

Fixed an issue in the DWARF parser where we weren't correctly calculating the
DeclContext for all types and classes. We now should be a lot more accurate.
Fixes include: enums should now be setting their parent decl context correctly.
We saw a lot of examples where enums in classes were not being properly
namespace scoped. Also, classes within classes now get properly scoped.

Fixed the objective C runtime pointer checkers to let "nil" pointers through
since these are accepted by compiled code. We also now don't call "abort()"
when a pointer doesn't validate correctly since this was wreaking havoc on
the process due to the way abort() works. We now just dereference memory
which should give us an exception from which we can easily and reliably 
recover.

llvm-svn: 123428
2011-01-14 04:54:56 +00:00
Caroline Tice 2f88aadff1 Split up the Python script interpreter code to allow multiple script interpreter objects to
exist within the same process (one script interpreter object per debugger object).  The
python script interpreter objects are all using the same global Python script interpreter;
they use separate dictionaries to keep their data separate, and mutex's to prevent any object
attempting to use the global Python interpreter when another object is already using it.

llvm-svn: 123415
2011-01-14 00:29:16 +00:00
Sean Callanan 92adcac9ec Implemented a major overhaul of the way variables are handled
by LLDB.  Instead of being materialized into the input structure
passed to the expression, variables are left in place and pointers
to them are materialzied into the structure.  Variables not resident
in memory (notably, registers) get temporary memory regions allocated
for them.

Persistent variables are the most complex part of this, because they
are made in various ways and there are different expectations about
their lifetime.  Persistent variables now have flags indicating their
status and what the expectations for longevity are.  They can be
marked as residing in target memory permanently -- this is the
default for result variables from expressions entered on the command
line and for explicitly declared persistent variables (but more on
that below).  Other result variables have their memory freed.

Some major improvements resulting from this include being able to
properly take the address of variables, better and cleaner support
for functions that return references, and cleaner C++ support in
general.  One problem that remains is the problem of explicitly
declared persistent variables; I have not yet implemented the code
that makes references to them into indirect references, so currently
materialization and dematerialization of these variables is broken.

llvm-svn: 123371
2011-01-13 08:53:35 +00:00
Greg Clayton 722a0cdc95 Added the following functions to SBThread to allow threads to be suspended when a process is resumed:
bool SBThread::Suspend();
bool SBThread::Resume();
bool SBThread::IsSuspended();

llvm-svn: 123300
2011-01-12 02:25:42 +00:00
Greg Clayton 3e06bd90b5 Put more smarts into the RegisterContext base class. Now the base class has
a method:

    void RegisterContext::InvalidateIfNeeded (bool force);

Each time this function is called, when "force" is false, it will only call
the pure virtual "virtual void RegisterContext::InvalideAllRegisters()" if
the register context's stop ID doesn't match that of the process. When the
stop ID doesn't match, or "force" is true, the base class will clear its
cached registers and the RegisterContext will update its stop ID to match
that of the process. This helps make it easier to correctly flush the register
context (possibly from multiple locations depending on when and where new
registers are availabe) without inadvertently clearing the register cache 
when it doesn't need to be.

Modified the ProcessGDBRemote plug-in to be much more efficient when it comes
to:
- caching the expedited registers in the stop reply packets (we were ignoring
  these before and it was causing us to read at least three registers every
  time we stopped that were already supplied in the stop reply packet).
- When a thread has no stop reason, don't keep asking for the thread stopped
  info. Prior to this fix we would continually send a qThreadStopInfo packet
  over and over when any thread stop info was requested. We now note the stop
  ID that the stop info was requested for and avoid multiple requests.

Cleaned up some of the expression code to not look for ClangExpressionVariable
objects up by name since they are now shared pointers and we can just look for
the exact pointer match and avoid possible errors.

Fixed an bug in the ValueObject code that would cause children to not be 
displayed.

llvm-svn: 123127
2011-01-09 21:07:35 +00:00
Greg Clayton 877aaa589b Made FuncUnwinders threadsafe.
Other small cleanups as well.

llvm-svn: 123088
2011-01-08 21:19:00 +00:00
Greg Clayton b0848c5d91 Fixed issues with the unwinding code where the collection of FuncUnwinders
was being searched and sorted using a shared pointer as the value which means
the pointer value was what was being searched for. This means that anytime
you did a stack backtrace, the collection of FuncUnwinders doubled and then
the array or shared pointer got sorted (by pointer value), so you had an ever
increasing collection of shared pointer where a match was never found. This
means we had a ton of duplicates in this table and would cause issues after
one had been debugging for a long time.

llvm-svn: 123045
2011-01-08 00:05:12 +00:00
Greg Clayton 58be07b28c Added memory caching to lldb_private::Process. All lldb_private::Process
subclasses will automatically be able to take advantage of caching. The
cache line size is set to 512 by default.

This greatly speeds up stack backtraces on MacOSX when using the 
ProcessGDBRemote process plug-in since only about 6300 packets per second
can be sent.

Initial speedups show:

Prior to caching: 10,000 stack frames took 5.2 seconds
After caching: 10,000 stack frames in 240 ms!

About a 20x speedup!

llvm-svn: 122996
2011-01-07 06:08:19 +00:00
Greg Clayton db59823068 Added the ability for Target::ReadMemory to prefer to read from the file
cache even when a valid process exists. Previously, Target::ReadMemory would
read from the process if there was a valid one and then fallback to the
object file cache.

llvm-svn: 122989
2011-01-07 01:57:07 +00:00
Greg Clayton 5ccbd294b2 Fixed issues with RegisterContext classes and the subclasses. There was
an issue with the way the UnwindLLDB was handing out RegisterContexts: it
was making shared pointers to register contexts and then handing out just
the pointers (which would get put into shared pointers in the thread and
stack frame classes) and cause double free issues. MallocScribble helped to
find these issues after I did some other cleanup. To help avoid any
RegisterContext issue in the future, all code that deals with them now
returns shared pointers to the register contexts so we don't end up with
multiple deletions. Also now that the RegisterContext class doesn't require
a stack frame, we patched a memory leak where a StackFrame object was being
created and leaked.

Made the RegisterContext class not have a pointer to a StackFrame object as
one register context class can be used for N inlined stack frames so there is
not a 1 - 1 mapping. Updates the ExecutionContextScope part of the 
RegisterContext class to never return a stack frame to indicate this when it
is asked to recreate the execution context. Now register contexts point to the
concrete frame using a concrete frame index. Concrete frames are all of the
frames that are actually formed on the stack of a thread. These concrete frames
can be turned into one or more user visible frames due to inlining. Each 
inlined stack frame has the exact same register context (shared via shared
pointers) as any parent inlined stack frames all the way up to the concrete 
frame itself.

So now the stack frames and the register contexts should behave much better.

llvm-svn: 122976
2011-01-06 22:15:06 +00:00
Greg Clayton dc4e9637ac Added the ability to get an set the desired format for SBValue objects.
Fixed the display of complex numbers in lldb_private::DataExtractor::Dump(...)
and also fixed other edge display cases in lldb_private::ClangASTType::DumpTypeValue(...).

llvm-svn: 122895
2011-01-05 18:43:15 +00:00
Johnny Chen 8c46c6fee1 Patch from Stephen Wilson:
Provide full qualification for #include's.

llvm-svn: 122274
2010-12-20 21:45:22 +00:00
Greg Clayton af67cecd47 The LLDB API (lldb::SB*) is now thread safe!
llvm-svn: 122262
2010-12-20 20:49:23 +00:00
Caroline Tice 3d6086f628 Add code to make sure InputReaders finish and are cleaned up when
a Debugger object is destroyed or re-set. (Thus making sure that, for
example, the Python interpreter finishes and exits cleanly rather than
being left in an undefined state.)

llvm-svn: 122255
2010-12-20 18:35:50 +00:00
Greg Clayton fff42e6241 Line tables were trying to be too clever and only use 24 bits for a line
table offset where the offset is within a section. Increased the section
offset for line table entries to be 32 bits (from 24 bits), giving each 
section a 4G offset, and increased the section index to 32 bits (from 8 bits).

llvm-svn: 122200
2010-12-19 22:07:39 +00:00
Greg Clayton 6ad07dd9e9 Improved our argument parsing abilities to be able to handle stuff more like
a shell would interpret it. A few examples that we now handle correctly

INPUT: "Hello "world
OUTPUT: "Hello World"

INPUT: "Hello "' World'
OUTPUT: "Hello World"

INPUT: Hello" World"
OUTPUT: "Hello World"

This broke the setting of dictionary values for the "settings set" command
for things like:

(lldb) settings set target.process.env-vars ["MY_ENV_VAR"]=YES

since we would drop the quotes. I fixed the user settings controller to use
a regular expression so it can accept any of the following inputs for
dictionary setting:

settings set target.process.env-vars ["MY_ENV_VAR"]=YES
settings set target.process.env-vars [MY_ENV_VAR]=YES
settings set target.process.env-vars MY_ENV_VAR=YES

We might want to eventually drop the first two syntaxes, but I won't make
that decision right now.

This allows more natural setting of the envirorment variables:

settings set target.process.env-vars MY_ENV_VAR=YES ABC=DEF CWD=/tmp

llvm-svn: 122166
2010-12-19 03:41:24 +00:00
Greg Clayton 5c844d51c8 Linux patches from Stephen Wilson.
llvm-svn: 122128
2010-12-18 01:52:51 +00:00
Greg Clayton deaeb2c18e Linux patches from Stephen Wilson.
llvm-svn: 122127
2010-12-18 01:52:08 +00:00
Greg Clayton b096dcae4a Linux patches from Stephen Wilson.
llvm-svn: 122126
2010-12-18 01:49:57 +00:00
Greg Clayton 442d7544ac Removed libunwind sources as we aren't using them anymore.
llvm-svn: 122059
2010-12-17 15:50:20 +00:00
Greg Clayton f028a1fb84 Added access to set the current stack frame within a thread so any command
line commands can use the current thread/frame.

Fixed an issue with expressions that get sandboxed in an objective C method
where unichar wasn't being passed down.

Added a "static size_t Scalar::GetMaxByteSize();" function in case we need
to know the max supported by size of something within a Scalar object.

llvm-svn: 122027
2010-12-17 02:26:24 +00:00
Greg Clayton ed6deadb46 Added header doc for the recently added Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error) function.
llvm-svn: 121999
2010-12-16 20:15:34 +00:00
Greg Clayton 58a4c46766 Added the ability to read unsigned integers from the Process:
uint64_t Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error);

llvm-svn: 121996
2010-12-16 20:01:20 +00:00
Sean Callanan e4ec90e990 Implemented a feature where the expression parser
can avoid running the code in the target if the
expression's result is known and the expression
has no side effects.

Right now this feature is quite conservative in
its guess about side effects, and it only computes
integer results, but the machinery to make it more
sophisticated is there.

llvm-svn: 121952
2010-12-16 03:17:46 +00:00
Greg Clayton 54979cddda Fixed the "expression" command object to use the StackFrame::GetValueForExpressionPath()
function and also hooked up better error reporting for when things fail.

Fixed issues with trying to display children of pointers when none are
supposed to be shown (no children for function pointers, and more like this).
This was causing child value objects to be made that were correctly firing
an assertion.

llvm-svn: 121841
2010-12-15 05:08:08 +00:00
Greg Clayton 69b582fa94 Changed:
SBValue SBFrame::LookupVar(const char *name);
To
	SBValue SBFrame::FindVariable (const char *name);

Changed:
	SBValue LookupVarInScope (const char *name, const char *scope);
to
	SBValue FindValue (const char *name, ValueType value_type);

The latter makes it possible to not only find variables (params, locals, globals, and statics), but we can also now get register sets, registers and persistent variables using the frame as the context.

llvm-svn: 121777
2010-12-14 18:39:31 +00:00
Greg Clayton 72eff18ae4 Fixed SBFrame to properly check to make sure it has a valid m_opaque_sp object
before trying to use it.

llvm-svn: 121748
2010-12-14 04:58:53 +00:00
Greg Clayton 8b2fe6dcbd Modified LLDB expressions to not have to JIT and run code just to see variable
values or persistent expression variables. Now if an expression consists of
a value that is a child of a variable, or of a persistent variable only, we
will create a value object for it and make a ValueObjectConstResult from it to
freeze the value (for program variables only, not persistent variables) and
avoid running JITed code. For everything else we still parse up and JIT code
and run it in the inferior. 

There was also a lot of clean up in the expression code. I made the 
ClangExpressionVariables be stored in collections of shared pointers instead
of in collections of objects. This will help stop a lot of copy constructors on
these large objects and also cleans up the code considerably. The persistent
clang expression variables were moved over to the Target to ensure they persist
across process executions.

Added the ability for lldb_private::Target objects to evaluate expressions.
We want to evaluate expressions at the target level in case we aren't running
yet, or we have just completed running. We still want to be able to access the
persistent expression variables between runs, and also evaluate constant 
expressions. 

Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects
can now dump their contents with the UUID, arch and full paths being logged with
appropriate prefix values.

Thread hardened the Communication class a bit by making the connection auto_ptr
member into a shared pointer member and then making a local copy of the shared
pointer in each method that uses it to make sure another thread can't nuke the
connection object while it is being used by another thread.

Added a new file to the lldb/test/load_unload test that causes the test a.out file
to link to the libd.dylib file all the time. This will allow us to test using
the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else.

llvm-svn: 121745
2010-12-14 02:59:59 +00:00
Sean Callanan 9d48e80426 Bugfixes for the new "self" pointer handling. Specifically,
the code to pass the _cmd pointer has been improved, and _cmd
is now set to the value of _cmd for the current context, as
opposed to being simply NULL.

llvm-svn: 121739
2010-12-14 00:42:36 +00:00
Sean Callanan 1782783095 Added support for generating expressions that have
access to the members of the Objective-C self object.

The approach we take is to generate the method as a
@category on top of the self object, and to pass the
"self" pointer to it.  (_cmd is currently NULL.)

Most changes are in ClangExpressionDeclMap, but the
change that adds support to the ABIs to pass _cmd
touches a fair amount of code.

llvm-svn: 121722
2010-12-13 22:46:15 +00:00
Greg Clayton 7d07a45fff Fixed an issue where the macosx dynamic loader, on the first shared library loaded notification, wasn't properly removing shared libraries from the target that didn't get loaded. This usually happens when a different shared library is loaded in place of another due to DYLD_LIBRARY_PATH or DYLD_FRAMEWORK_PATH environment variables. We now properly remove any images that didn't make it into the executable.
llvm-svn: 121641
2010-12-12 21:03:32 +00:00
Greg Clayton ac2eb9b1ec Added the ability for SBTarget to resolve load addresses (convert lldb::addr_t values into resolved SBAddress objects). These SBAddress objects can then be used to resolve a symbol context using "lldb::SBSymbolContext ResolveSymbolContextForAddress (const lldb::SBAddress& addr, uint32_t resolve_scope);".
llvm-svn: 121638
2010-12-12 19:25:26 +00:00
Johnny Chen f6eaba85a8 Add test_display_source_python() test case to TestSourceManager.py which uses
the lldb PyThon API SBSourceManager to display source files.

To accomodate this, the C++ SBSourceManager API has been changed to take an
lldb::SBStream as the destination for display of source lines.  Modify SBStream::ctor()
so that its opaque pointer is initialized with an StreamString instance.

llvm-svn: 121605
2010-12-11 01:20:39 +00:00
Sean Callanan 7fddd4c1f2 Made all LLDB-generated ASTContexts have valid
DiagnosticClients, and removed code that was patching
over the original problem.

llvm-svn: 121601
2010-12-11 00:08:56 +00:00
Caroline Tice 2d5289d621 Various fixes mostly relating to the User Settings stuff:
- Added new utility function to Arg, GetQuotedCommandString, which re-assembles
the args into a string, replacing quotes that were originally there.

- Modified user settings stuff to always show individual elements when printing out
arrays and dictionaries.

- Added more extensive help to 'settings set', explaining more about dictionaries
and arrays (including current dictionary syntax).

- Fixed bug in user settings  where quotes were being stripped and lost, so that
sometimes array or dictionary elements that ought to have been a single element
were being split up.

llvm-svn: 121438
2010-12-10 00:26:54 +00:00
Jim Ingham 957373fc84 Changing the ObjC find method implementation to use a ClangUtilityFunction inserted into the target. Consolidate all the
logic for finding the target of a method dispatch into this function, insert & call it.  Gets calls to super, and all the
fixup & fixedup variants working properly.  Also gets the class from the object so that we step through KVO wrapper methods
into the actual user code.

llvm-svn: 121437
2010-12-10 00:26:25 +00:00
Caroline Tice 844d230332 Modify HandleCommand to not do any argument processing until it has determined whether or
not the command should take raw input, then handle & dispatch the arguments appropriately.

Also change the 'alias' command to be a command that takes raw input.  This is necessary to
allow aliases to be created for other commands that take raw input and might want to include
raw input in the alias itself.

Fix a bug in the aliasing mechanism when creating aliases for commands with 3-or-more words.

Raw input should now be properly handled by all the command and alias mechanisms.

llvm-svn: 121423
2010-12-09 22:52:49 +00:00
Greg Clayton 9625d08cec Fixed an issue in our source manager where we were permanently caching source
file data, so if a source file was modified, we would always show the first
cached copy of the source data. We now check file modification times when
displaying source info so we can show the update source info.

llvm-svn: 121278
2010-12-08 20:16:12 +00:00
Greg Clayton 10177aa05e Added the ability to dump sections to a certain depth (for when sections
have children sections).

Modified SectionLoadList to do it's own multi-threaded protected on its map.
The ThreadSafeSTLMap class was difficult to deal with and wasn't providing
much utility, it was only getting in the way.

Make sure when the communication read thread is about to exit, it clears the
thread in the main class.

Fixed the ModuleList to correctly ignore architectures and UUIDs if they aren't
valid when searching for a matching module. If we specified a file with no arch,
and then modified the file and loaded it again, it would not match on subsequent
searches if the arch was invalid since it would compare an invalid architecture
to the one that was found or selected within the shared library or executable.
This was causing stale modules to stay around in the global module list when they
should have been removed.

Removed deprecated functions from the DynamicLoaderMacOSXDYLD class.

Modified "ProcessGDBRemote::IsAlive" to check if we are connected to a gdb
server and also make sure our process hasn't exited.

llvm-svn: 121236
2010-12-08 05:08:21 +00:00
Caroline Tice d9d63369df - Fix alias-building & resolving to properly handle optional arguments for command options.
- Add logging for command resolution ('log enable lldb commands')
- Fix alias resolution to properly handle commands that take raw input (resolve the alias, but
  don't muck up the raw arguments).

Net result:  Among other things, 'expr' command can now take strings with escaped characters and
not have the command handling & alias resolution code muck up the escaped characters. E.g.
 'expr printf ("\n\n\tHello there!")' should now work properly.


Not working yet:  Creating aliases with raw input for commands that take raw input.  Working on that.
e.g. 'command alias print_hi expr printf ("\n\tHi!")' does not work yet.

llvm-svn: 121171
2010-12-07 19:58:26 +00:00
Greg Clayton 2a43368a03 Cleanup before making the objective C ivar changes.
llvm-svn: 121158
2010-12-07 18:26:09 +00:00
Greg Clayton 75dbe3c799 Forgot to qualify SBSymbol with the lldb namespace for SWIG.
llvm-svn: 121115
2010-12-07 05:59:16 +00:00
Greg Clayton bbdabce2f7 Added symbol table access through the module for now. We might need to expose
a SBSymtab class, but for now, we expose the symbols through the module.

llvm-svn: 121112
2010-12-07 05:40:31 +00:00
Greg Clayton a4d7830017 When shared libraries are unloaded, they are now removed from the target
ModuleList so they don't show up in the images. Breakpoint locations that are
in shared libraries that get unloaded will persist though so that if you
have plug-ins that load/unload and you have a breakpoint set on functions
in the plug-ins, the hit counts will persist between loads/unloads.

llvm-svn: 121069
2010-12-06 23:51:26 +00:00
Greg Clayton f7d6a2a6a8 Added a less than operator that will compare the internal opaque pointer values so SBBroadcaster objects can be contained in ordered containers or sorted.
llvm-svn: 120967
2010-12-05 23:14:19 +00:00
Greg Clayton 1c2f283864 Added "void SBBroadcaster::Clear ();" method to SBBroadcaster.
llvm-svn: 120949
2010-12-05 19:36:39 +00:00
Greg Clayton d46c87a1a8 More reverting of the EOF stuff as the API was changed which we don't want to
do. Closing on EOF is an option that can be set on the 
lldb_private::Communication or the lldb::SBCommunication objects after they
are created. Of course the EOF support isn't hooked up, so they don't do 
anything at the moment, but they are left in so when the code is fixed, it 
will be easy to get working again.

llvm-svn: 120885
2010-12-04 02:39:47 +00:00
Greg Clayton 85851dde89 Added the ability for a process to inherit the current host environment. This
was done as an settings variable in the process for now. We will eventually
move all environment stuff over to the target, but we will leave it with the
process for now. The default setting is for a process to inherit the host
environment. This can be disabled by setting the "inherit-env" setting to
false in the process.

llvm-svn: 120862
2010-12-04 00:10:17 +00:00
Caroline Tice f8da863196 Add '-no-stdio' option to 'process launch' command, which causes the
inferior to be launched without setting up terminal stdin/stdout for it
(leaving the lldb command line accessible while the program is executing).
Also add a user settings variable, 'target.process.disable-stdio' to allow
the user to set this globally rather than having to use the command option
each time the process is launched.

llvm-svn: 120825
2010-12-03 18:46:09 +00:00
Greg Clayton eb5596b4af Make sure timed_out is initialized to false just to be on the safe side.
llvm-svn: 120813
2010-12-03 17:47:00 +00:00
Greg Clayton e521966054 Fixed a race condition that could cause ProcessGDBRemote::DoResume() to return
an error saying the resume timed out. Previously the thread that was trying
to resume the process would eventually call ProcessGDBRemote::DoResume() which
would broadcast an event over to the async GDB remote thread which would sent the
continue packet to the remote gdb server. Right after this was sent, it would
set a predicate boolean value (protected by a mutex and condition) and then the
thread that issued the ProcessGDBRemote::DoResume() would then wait for that
condition variable to be set. If the async gdb thread was too quick though, the
predicate boolean value could have been set to true and back to false by the
time the thread that issued the ProcessGDBRemote::DoResume() checks the boolean
value. So we can't use the predicate value as a handshake. I have changed the code
over to using a Event by having the GDB remote communication object post an
event: 

	GDBRemoteCommunication::eBroadcastBitRunPacketSent

This allows reliable handshaking between the two threads and avoids the erroneous
ProcessGDBRemote::DoResume() errors.

Added a host backtrace service to allow in process backtraces when trying to track
down tricky issues. I need to see if LLVM has any backtracing abilities abstracted
in it already, and if so, use that, but I needed something ASAP for the current issue
I was working on. The static function is:

void
Host::Backtrace (Stream &strm, uint32_t max_frames);

And it will backtrace at most "max_frames" frames for the current thread and can be
used with any of the Stream subclasses for logging.

llvm-svn: 120793
2010-12-03 06:02:24 +00:00
Sean Callanan 979f74d1dd Fixed object lifetimes in ClangExpressionDeclMap
so that it is not referring to potentially stale
state during IR execution.

This was done by introducing modular state (like
ClangExpressionVariable) where groups of state
variables have well-defined lifetimes:

- m_parser_vars are specific to parsing, and only
  exist between calls to WillParse() and DidParse().

- m_struct_vars survive for the entire execution
  of the ClangExpressionDeclMap because they
  provide the template for a materialized set of
  expression variables.

- m_material_vars are specific to a single
  instance of materialization, and only exist
  between calls to Materialize() and
  Dematerialize().

I also removed unnecessary references to long-
lived state that really didn't need to be referred
to at all, and also introduced several assert()s
that helped me diagnose a few bugs (fixed too).

llvm-svn: 120778
2010-12-03 01:38:59 +00:00
Greg Clayton 38a614034a Updated to latest LLVM/Clang for external AST source changes that allow
TagDecl subclasses and Objective C interfaces to complete themselves through
the ExternalASTSource class.

llvm-svn: 120749
2010-12-02 23:20:03 +00:00
Caroline Tice 82305fc59a Add proper EOF handling to Communication & Connection classes:
Add bool member to Communication class indicating whether the
Connection should be closed on receiving an EOF or not.  Update the
Connection read to return an EOF status when appropriate.  Modify the
Communication class to pass the EOF along or not, and to close the
Connection or not, as appropriate.

llvm-svn: 120723
2010-12-02 18:31:56 +00:00
Sean Callanan 3670ba5c87 Fixed ClangUserExpression's wrapping of expressions
in C++ methods.  There were two fixes involved:

 - For an object whose contents are not known, the
   expression should be treated as a non-member, and
   "this" should have no meaning.

 - For a const object, the method should be declared
   const as well.

llvm-svn: 120606
2010-12-01 21:35:54 +00:00
Jim Ingham f48169bb4f Moved the code in ClangUserExpression that set up & ran the thread plan with timeouts, and restarting with all threads into a utility function in Process. This required a bunch of renaming.
Added a ThreadPlanCallUserExpression that differs from ThreadPlanCallFunction in that it holds onto a shared pointer to its ClangUserExpression so that can't go away before the thread plan is done using it.

Fixed the stop message when you hit a breakpoint while running a user expression so it is more obvious what has happened.

llvm-svn: 120386
2010-11-30 02:22:11 +00:00
Sean Callanan 348b5897f9 Added a feature where registers can be referred to
using special $-variables from expressions.

(lldb) expr $rip

These variables are available for reading and
writing.

llvm-svn: 120367
2010-11-30 00:27:43 +00:00
Jason Molenda 2d107dd02b Change the DWARFExpression::Evaluate methods to take an optional
RegisterContext* - normally this is retrieved from the ExecutionContext's
StackFrame but when we need to evaluate an expression while creating
the stack frame list this can be a little tricky.

Add DW_OP_deref_size, needed for the _sigtramp FDE expression.

Add support for processing DWARF expressions in RegisterContextLLDB.

Update callers to DWARFExpression::Evaluate.

llvm-svn: 119885
2010-11-20 01:28:30 +00:00
Caroline Tice efed613172 Add the ability to catch and do the right thing with Interrupts (often control-c)
and end-of-file (often control-d).

llvm-svn: 119837
2010-11-19 20:47:54 +00:00
Sean Callanan 6abfabff61 Modifications to type handling logic. We no longer
perform recursive type lookups, because these are not
required for full type fidelity.  We also make the
SelectorTable last for the full lifetime of the Clang
compiler; this was the source of many bugs.

llvm-svn: 119835
2010-11-19 20:20:02 +00:00
Sean Callanan f7c3e27f62 Added support for indicating to the expression parser
that the result of an expression should be coerced to
a specific type.  Also made breakpoint conditions pass
in the bool type for this type.

The expression parser ignores this indication for now.

llvm-svn: 119779
2010-11-19 02:52:21 +00:00
Greg Clayton 1b95a6ff95 Added some logging back and cleaned up the code to match LLDB's coding
conventions.

llvm-svn: 119771
2010-11-19 01:05:25 +00:00
Greg Clayton 99d0faf27e Cleaned up code that wasn't using the Initialize and Terminate paradigm by
changing it to use it. There was an extra parameter added to the static
accessor global user settings controllers that wasn't needed. A bool was being
used as a parameter to the accessor just so it could be used to clean up 
the global user settings controller which is now fixed by splitting up the
initialization into the "static void Class::Initialize()", access into the
"static UserSettingsControllerSP & Class::GetSettingsController()", and
cleanup into "static void Class::Terminate()".

Also added initialize and terminate calls to the logging code to avoid issues
when LLDB is shutting down. There were cases after the logging was switched
over to use shared pointers where we could crash if the global destructor
chain was being run and it causes the log to be destroyed and any any logging
occurred.

llvm-svn: 119757
2010-11-18 23:32:35 +00:00
Greg Clayton 4e78f60660 Added the ability to get more information on the SBThread's stop reason
by being able to get the data count and data. Each thread stop reason
has one or more data words that can help describe the stop. To do this
I added:

    size_t
	SBThread::GetStopReasonDataCount();

	uint64_t
	SBThread::GetStopReasonDataAtIndex(uint32_t idx);

llvm-svn: 119720
2010-11-18 18:52:36 +00:00
Greg Clayton 3af9ea56d3 Fixed Process::Halt() as it was broken for "process halt" after recent changes
to the DoHalt down in ProcessGDBRemote. I also moved the functionality that
was in ProcessGDBRemote::DoHalt up into Process::Halt so not every class has
to implement a tricky halt/resume on the internal state thread. The 
functionality is the same as it was before with two changes:
- when we eat the event we now just reuse the event we consume when the private
  state thread is paused and set the interrupted bool on the event if needed
- we also properly update the Process::m_public_state with the state of the
  event we consume.
  
Prior to this, if you issued a "process halt" it would eat the event, not 
update the process state, and then produce a new event with the interrupted
bit set and send it. Anyone listening to the event would get the stopped event
with a process that whose state was set to "running".

Fixed debugserver to not have to be spawned with the architecture of the
inferior process. This worked fine for launching processes, but when attaching
to processes by name or pid without a file in lldb, it would fail.

Now debugserver can support multiple architectures for a native debug session
on the current host. This currently means i386 and x86_64 are supported in
the same binary and a x86_64 debugserver can attach to a i386 executable.
This change involved a lot of changes to make sure we dynamically detect the
correct registers for the inferior process.

llvm-svn: 119680
2010-11-18 05:57:03 +00:00
Sean Callanan 79439e86d1 Updated to the LLVM/Clang of 2010-11-17 at 3:30pm.
llvm-svn: 119677
2010-11-18 02:56:27 +00:00
Jim Ingham 773d981ce2 The thread plan destructors may call Thread virtual methods. That means they have to get cleaned up in the derived class's destructor. Make sure that happens.
llvm-svn: 119675
2010-11-18 02:47:07 +00:00
Sean Callanan afe16a71f7 Added support for constant strings of the form @"this-is-a-string".
They are replaced with calls to the CoreFoundation function 
CFStringCreateWithBytes() by a portion of the IRForTarget pass.

llvm-svn: 119582
2010-11-17 23:00:36 +00:00
Jim Ingham a80ef35902 Add a ThreadPlanAssemblyTracer that takes just a thread (since that's how we call it from ThreadPlanBase...)
llvm-svn: 119549
2010-11-17 20:19:50 +00:00
Jim Ingham 0d8bcc79f4 Added an "Interrupted" bit to the ProcessEventData. Halt now generates an event
with the Interrupted bit set.  Process::HandlePrivateEvent ignores Interrupted events.
DoHalt is changed to ensure that the stop even is processed, and an event with
the Interrupted event is posted.  Finally ClangFunction is rationalized to use this
facility so the that Halt is handled more deterministically.

llvm-svn: 119453
2010-11-17 02:32:00 +00:00
Caroline Tice ef5c6d02f5 Make processes use InputReaders for their input. Move the process
ReadThread stuff into the main Process class (out of the Process Plugins).
This has the (intended) side effect of disabling the command line tool
from reading input/commands while the process is running (the input is
directed to the running process rather than to the command interpreter).

llvm-svn: 119329
2010-11-16 05:07:41 +00:00
Greg Clayton 7fedea2c6f First attempt and getting "const" C++ method function signatures correct.
It currently isn't working, but it should be close. I will work on this more
when I figure out what I am not doing correctly.

llvm-svn: 119324
2010-11-16 02:10:54 +00:00
Greg Clayton 83c5cd9dfd Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.

Variables now have support for having a basename ("i"), and a mangled name 
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").

Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable 
and Mangled classes as:

	bool NameMatches (const ConstString &name);
	bool NameMatches (const RegularExpression &regex);

I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.

Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that 
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.

llvm-svn: 119085
2010-11-14 22:13:40 +00:00
Greg Clayton d7e054694e Fixed a crasher (an assert was firing in the DWARF parser) when setting
breakpoints on inlined functions by name. This involved fixing the DWARF parser
to correctly back up and parse the concrete function when we find inlined
functions by name, then grabbing any appropriate inlined blocks and returning
symbol contexts with the block filled in. After this was fixed, the breakpoint
by name resolver needed to correctly deal with symbol contexts that had the
inlined block filled in in the symbol contexts.

llvm-svn: 119017
2010-11-14 00:22:48 +00:00
Greg Clayton 580c5dacd0 Got namespace lookup working and was able to print a complex "this" as an
expression. This currently takes waaaayyyyy too much time to evaluate. We will
need to look at the expression parser and find ways to optimize the info we
provide and get this to evaluate quicker. I believe the performance issue is
currently related to us always providing a complete C++ class type when asked
about a C++ class which can cause a lot of information to be pulled since all
classes will be fully created (methods, base classes, members, all their 
types). We will need to give the classes back the parser and mark them as 
having external sources and get parser (Sema) to query us when it needs more
info. This should bring things up to an acceptable level.

llvm-svn: 118979
2010-11-13 04:18:24 +00:00
Greg Clayton 526e5afb2d Modified the lldb_private::Type clang type resolving code to handle three
cases when getting the clang type:
- need only a forward declaration
- need a clang type that can be used for layout (members and args/return types)
- need a full clang type

This allows us to partially parse the clang types and be as lazy as possible.
The first case is when we just need to declare a type and we will complete it
later. The forward declaration happens only for class/union/structs and enums.
The layout type allows us to resolve the full clang type _except_ if we have
any modifiers on a pointer or reference (both R and L value). In this case
when we are adding members or function args or return types, we only need to
know how the type will be laid out and we can defer completing the pointee
type until we later need it. The last type means we need a full definition for
the clang type.

Did some renaming of some enumerations to get rid of the old "DC" prefix (which
stands for DebugCore which is no longer around).

Modified the clang namespace support to be almost ready to be fed to the
expression parser. I made a new ClangNamespaceDecl class that can carry around
the AST and the namespace decl so we can copy it into the expression AST. I
modified the symbol vendor and symbol file plug-ins to use this new class.

llvm-svn: 118976
2010-11-13 03:52:47 +00:00
Jason Molenda cabd1b71c7 I'm not thrilled with how I structured this but RegisterContextLLDB
needs to use the current pc and current offset in two ways:  To 
determine which function we are currently executing, and the decide
how much of that function has executed so far.  For the former use,
we need to back up the saved pc value by one byte if we're going to
use the correct function's unwind information -- we may be executing
a CALL instruction at the end of a function and the following instruction
belongs to a new function, or we may be looking at unwind information
which only covers the call instruction and not the subsequent instruction.

But when we're talking about deciding which row of an UnwindPlan to
execute, we want to use the actual byte offset in the function, not the
byte offset - 1.

Right now RegisterContextLLDB is tracking both the "real" offset and
an "offset minus one" and different parts of the class have to know 
which one to use and they need to be updated/set in tandem.  I want
to revisit this at some point.

The second change made in looking up eh_frame information; it was
formerly done by looking for the start address of the function we
are currently executing.  But it is possible to have unwind information
for a function which only covers a small section of the function's
address range.  In which case looking up by the start pc value may not
find the eh_frame FDE.

The hand-written _sigtramp() unwind info on Mac OS X, which covers
exactly one instruction in the middle of the function, happens to
trigger both of these issues.

I still need to get the UnwindPlan runner to handle arbitrary dwarf
expressions in the FDE but there's a good chance it will be easy to
reuse the DWARFExpression class to do this.

llvm-svn: 118882
2010-11-12 05:23:10 +00:00
Sean Callanan 8c9e538384 Added a thread plan tracer that prints lines of
assembly as well as registers that changed.

llvm-svn: 118879
2010-11-12 03:22:21 +00:00
Jim Ingham 929937286b Added OnStart and OnEnd methods to the tracer.
llvm-svn: 118876
2010-11-12 02:30:38 +00:00
Sean Callanan 36695cdecd Excised a version of the low-level function calling
logic that supported calling functions with arbitrary
arguments.  We use ClangFunction for this, and the
low-level logic is only required to support one or two
pointer arguments.

llvm-svn: 118871
2010-11-12 01:37:02 +00:00
Jim Ingham 06e827cc43 Add ThreadPlanTracer class to allow instruction step tracing of execution.
Also changed eSetVarTypeBool to eSetVarTypeBoolean to make it consistent with eArgTypeBoolean.

llvm-svn: 118824
2010-11-11 19:26:09 +00:00
Greg Clayton 96d7d7453c Added initial support to the lldb_private::SymbolFile for finding
namespaces by name given an optional symbol context. I might end up
dressing up the "clang::NamespaceDecl" into a lldb_private::Namespace
class if we need to do more than is currenlty required of namespaces.
Currently we only need to be able to lookup a namespace by name when
parsing expressions, so I kept it simple for now. The idea here is
even though we are passing around a "clang::NamespaceDecl *", that
we always have it be an opaque pointer (it is forward declared inside
of "lldb/Core/ClangForward.h") and we only use clang::NamespaceDecl
implementations inside of ClangASTContext, or ClangASTType when we need
to extract information from the namespace decl object.

llvm-svn: 118737
2010-11-10 23:42:09 +00:00
Caroline Tice 5c2816d903 Move the embedded Python interpreter onto a separate thread, to prevent
main thread from having to wait on it (which was causing some I/O 
hangs).

llvm-svn: 118700
2010-11-10 19:18:14 +00:00
Greg Clayton 2d95dc9b22 Modified lldb_private::SymboleFile to be able to override where its TypeList
comes from by using a virtual function to provide it from the Module's
SymbolVendor by default. This allows the DWARF parser, when being used to
parse DWARF in .o files with a parent DWARF + debug map parser, to get its
type list from the DWARF + debug map parser so when we go and find full 
definitions for types (that might come from other .o files), we can use the
type list from the debug map parser. Otherwise we ended up mixing clang types
from one .o file (say a const pointer to a forward declaration "class A") with
the a full type from another .o file. This causes expression parsing, when 
copying the clang types from those parsed by the DWARF parser into the 
expression AST, to fail -- for good reason. Now all types are created in the
same list.

Also added host support for crash description strings that can be set before
doing a piece of work. On MacOSX, this ties in with CrashReporter support
that allows a string to be dispalyed when the app crashes and allows 
LLDB.framework to print a description string in the crash log. Right now this
is hookup up the the CommandInterpreter::HandleCommand() where each command
notes that it is about to be executed, so if we crash while trying to do this
command, we should be able to see the command that caused LLDB to exit. For
all other platforms, this is a nop.

llvm-svn: 118672
2010-11-10 04:57:04 +00:00
Greg Clayton 7a34528d68 Did a lot of code cleanup.
Fixed the DWARF plug-in such that when it gets all attributes for a DIE, that
it omits the DW_AT_sibling and DW_AT_declaration when getting attributes
from a DW_AT_abstract_origin or DW_AT_specification DIE.

llvm-svn: 118654
2010-11-09 23:46:37 +00:00
Jason Molenda 45b4924550 Fix thinko in UnwindTable.cpp where it wouldn't provde a
FuncUnwinders object if the eh_frame section was missing
from an objfile.  Worked fine on x86_64 but on i386 where
eh_frame is unusual, that resulted in the arch default 
UnwindPlan being used all the time instead of picking up
an assembly profile based unwindplan.

llvm-svn: 118467
2010-11-09 01:21:22 +00:00
Sean Callanan a4e55178bc Made variable resolution more robust by handling
every external variable reference in the module,
and returning a clean error (instead of letting
LLVM issue a fatal error) if the variable could
not be resolved.

llvm-svn: 118388
2010-11-08 00:31:32 +00:00
Greg Clayton 7481c20f09 Fixed FileSpec's operator == to deal with equivalent paths such as "/tmp/a.c"
and "/private/tmp/a.c". This was done by adding a "mutable bool m_is_resolved;"
member to FileSpec and then modifying the equal operator to check if the
filenames are equal, and if they are, then check the directories. If they are
not equal, then both paths are checked to see if they have been resolved. If
they have been resolved, we resolve the paths in temporary FileSpec objects
and set each of the m_is_resolved bools to try (for lhs and rhs) if the paths
match what is contained in the path. This allows us to do more intelligent
compares without having to resolve all paths found in the debug info (which
can quickly get costly if the files are on remote NFS mounts).

llvm-svn: 118387
2010-11-08 00:28:40 +00:00
Greg Clayton 2d4edfbc6a Modified all logging calls to hand out shared pointers to make sure we
don't crash if we disable logging when some code already has a copy of the
logger. Prior to this fix, logs were handed out as pointers and if they were
held onto while a log got disabled, then it could cause a crash. Now all logs
are handed out as shared pointers so this problem shouldn't happen anymore.
We are also using our new shared pointers that put the shared pointer count
and the object into the same allocation for a tad better performance.

llvm-svn: 118319
2010-11-06 01:53:30 +00:00
Greg Clayton c52df286ea Howard Hinnant gave us changes for lldb_private::SharingPtr that gives us the ability have a single allocation contain both the class and the ref count without having to do intrusive pointer type stuff. They will intermingle correctly with other shared pointers as well. In order to take advantage of this you need to create your pointer in your class with the make_shared function:
lldb_private::SharingPtr<A> p = llvm::make_shared<A>(i, j);

Currently up to five constructor arguments are supported and each must be an LValue.

llvm-svn: 118317
2010-11-06 00:12:48 +00:00
Greg Clayton efabb123af Added copy constructors and assignment operators to all lldb::SB* classes
so we don't end up with weak exports with some compilers.

llvm-svn: 118312
2010-11-05 23:17:00 +00:00
Jim Ingham 399f1cafa6 Added the equivalent of gdb's "unwind-on-signal" to the expression command, and a parameter to control it in ClangUserExpression, and on down to ClangFunction.
llvm-svn: 118290
2010-11-05 19:25:48 +00:00
Jim Ingham e4caae4f48 Don't need both LIBLLDB_LOG_DYNAMIC_LOADER and LIBLLDB_LOG_SHLIB. Go with the former.
llvm-svn: 118284
2010-11-05 17:59:46 +00:00
Jim Ingham f7f4f50113 Added a setting to "log timer" so you can see the incremental timings as well:
log timer increment true/false

llvm-svn: 118268
2010-11-04 23:19:21 +00:00
Jim Ingham 2a5e0f03fb Add a ObjC V1 runtime, and a generic AppleObjCRuntime plugin.
Also move the Checker creation into the Apple Runtime code.

llvm-svn: 118255
2010-11-04 18:30:59 +00:00
Jason Molenda fa19c3e7d6 Built the native unwinder with all the warnings c++-4.2 could muster;
fixed them.  Added DISALLOW_COPY_AND_ASSIGN to classes that should
not be bitwise copied.  Added default initializers for member
variables that weren't being initialized in the ctor.  Fixed a few
shadowed local variable mistakes.

llvm-svn: 118240
2010-11-04 09:40:56 +00:00
Greg Clayton 8f343b09e9 Added support for loading and unloading shared libraries. This was done by
adding support into lldb_private::Process:

    virtual uint32_t
    lldb_private::Process::LoadImage (const FileSpec &image_spec, 
                                      Error &error);

    virtual Error
    lldb_private::Process::UnloadImage (uint32_t image_token);

There is a default implementation that should work for both linux and MacOSX.
This ability has also been exported through the SBProcess API:

    uint32_t
    lldb::SBProcess::LoadImage (lldb::SBFileSpec &image_spec, 
                                lldb::SBError &error);

    lldb::SBError
    lldb::SBProcess::UnloadImage (uint32_t image_token);

Modified the DynamicLoader plug-in interface to require it to be able to 
tell us if it is currently possible to load/unload a shared library:

    virtual lldb_private::Error
    DynamicLoader::CanLoadImage () = 0;

This way the dynamic loader plug-ins are allows to veto whether we can 
currently load a shared library since the dynamic loader might know if it is
currenlty loading/unloading shared libraries. It might also know about the
current host system and know where to check to make sure runtime or malloc
locks are currently being held.

Modified the expression parser to have ClangUserExpression::Evaluate() be
the one that causes the dynamic checkers to be loaded instead of other code
that shouldn't have to worry about it.

llvm-svn: 118227
2010-11-04 01:54:29 +00:00
Sean Callanan 10af7c430a Re-enabled LLDB's pointer checkers, and moved the
implementation of the Objective-C object checkers
into the Objective-C language runtime.

llvm-svn: 118226
2010-11-04 01:51:38 +00:00
Sean Callanan f211510ff6 Factored the code that implements breakpoints on
exceptions for different languages out of 
ThreadPlanCallFunction and put it into the 
appropriate language runtimes.

llvm-svn: 118200
2010-11-03 22:19:38 +00:00
Johnny Chen a67d2981b9 Fix comment about eValueTypeConstResult.
llvm-svn: 118196
2010-11-03 21:10:38 +00:00
Sean Callanan c98aca605f Modified ThreadPlanCallFunction to perform the
exception checks at the right time, and modified
ClangFunction so that it doesn't misinterpret the
stop as a timeout stop.

llvm-svn: 118189
2010-11-03 19:36:28 +00:00
Greg Clayton 6ba508507e Fixed shared library unloads when the unloaded library doesn't come off
the end of the list. We had an issue in the MacOSX dynamic loader where if
we had shlibs:
1 - a.out
2 - a.dylib
3 - b.dylib

And then a.dylib got unloaded, we would unload b.dylib due to the assumption
that only shared libraries could come off the end of the list. We now properly
search and find which ones get loaded.

Added a new internal logging category for the "lldb" log channel named "dyld".
This should allow all dynamic loaders to use this as a generic log channel so
we can track shared library loads and unloads in the logs without having to 
have each plug-in make up its own logging channel.

llvm-svn: 118147
2010-11-03 04:08:06 +00:00
Sean Callanan 6db73ca5e2 Modified the thread plan that calls functions to
set breakpoints at the different locations where
an exception could be thrown, so that exceptions
thrown by expressions are properly caught.

llvm-svn: 118142
2010-11-03 01:37:52 +00:00
Greg Clayton cfd1aced7e Cleaned up the API logging a lot more to reduce redundant information and
keep the file size a bit smaller.

Exposed SBValue::GetExpressionPath() so SBValue users can get an expression
path for their values.

llvm-svn: 117851
2010-10-31 03:01:06 +00:00
Greg Clayton 4838131baf Improved API logging.
llvm-svn: 117772
2010-10-30 04:51:46 +00:00
Caroline Tice 20ad3c40f4 Add the ability to disable individual log categories, rather
than just the entire log channel.

Add checks, where appropriate, to make sure a log channel/category has 
not been disabled before attempting to write to it.

llvm-svn: 117715
2010-10-29 21:48:37 +00:00
Sean Callanan 31e851c9f3 Updated LLVM to latest version as of 10/28 at
7pm, and made minor integration fixes.

llvm-svn: 117680
2010-10-29 18:38:40 +00:00
Greg Clayton 93aa84e83b Modified the lldb_private::TypeList to use a std::multimap for quicker lookup
by type ID (the most common type of type lookup).

Changed the API logging a bit to always show the objects in the OBJECT(POINTER)
format so it will be easy to locate all instances of an object or references
to it when looking at logs.

llvm-svn: 117641
2010-10-29 04:59:35 +00:00
Sean Callanan 322f529b37 Added a user-settable variable, 'target.expr-prefix',
which holds the name of a file whose contents are
prefixed to each expression.  For example, if the file
~/lldb.prefix.header contains:

typedef unsigned short my_type;

then you can do this:

(lldb) settings set target.expr-prefix '~/lldb.prefix.header'
(lldb) expr sizeof(my_type)
(unsigned long) $0 = 2

When the variable is changed, the corresponding file
is loaded and its contents are fetched into a string
that is stored along with the target.  This string
is then passed to each expression and inserted into
it during parsing, like this:

typedef unsigned short my_type;
                             
void                           
$__lldb_expr(void *$__lldb_arg)          
{                              
    sizeof(my_type);                        
}

llvm-svn: 117627
2010-10-29 00:29:03 +00:00
Johnny Chen b7234e4014 Check in an initial implementation of the "breakpoint clear" command, whose purpose is clear
the breakpoint associated with the (filename, line_number) combo when an arrow is pointing to
a source position using Emacs Grand Unified Debugger library to interact with lldb.

The current implmentation is insufficient in that it only asks the breakpoint whether it is
associated with a breakpoint resolver with FileLine type and whether it matches the (filename, line_number)
combo.  There are other breakpoint resolver types whose breakpoint locations can potentially
match the (filename, line_number) combo.

The BreakpointResolver, BreakpointResolverName, BreakpointResolverAddress, and BreakpointResolverFileLine
classes have extra static classof methods to support LLVM style type inquiry through isa, cast, and dyn_cast.

The Breakpoint class has an API method bool GetMatchingFileLine(...) which is invoked from CommandObjectBreak.cpp
to implement the "breakpoint clear" command.

llvm-svn: 117562
2010-10-28 17:27:46 +00:00
Greg Clayton 73b472d42a Updated the lldb_private::Flags class to have better method names and made
all of the calls inlined in the header file for better performance.

Fixed the summary for C string types (array of chars (with any combo if
modifiers), and pointers to chars) work in all cases.

Fixed an issue where a forward declaration to a clang type could cause itself
to resolve itself more than once if, during the resolving of the type itself
it caused something to try and resolve itself again. We now remove the clang
type from the forward declaration map in the DWARF parser when we start to 
resolve it and avoid this additional call. This should stop any duplicate
members from appearing and throwing all the alignment of structs, unions and
classes.

llvm-svn: 117437
2010-10-27 03:32:59 +00:00
Caroline Tice 750cd1755d Clean up the API logging code:
- Try to reduce logging to one line per function call instead of tw
      - Put all arguments & their values into log for calls
      - Add 'this' parameter information to function call logging, making it show the appropriate
        internal pointer (this.obj, this.sp, this.ap...)
      - Clean up some return values
      - Remove logging of constructors that construct empty objects
      - Change '==>' to '=>'  for showing result values...
      - Fix various minor bugs
      - Add some protected 'get' functions to help getting the internal pointers for the 'this' arguments...      

llvm-svn: 117417
2010-10-26 23:49:36 +00:00
Caroline Tice ceb6b1393d First pass at adding logging capabilities for the API functions. At the moment
it logs the function calls, their arguments and the return values.  This is not
complete or polished, but I am committing it now, at the request of someone who
really wants to use it, even though it's not really done.  It currently does not
attempt to log all the functions, just the most important ones.  I will be 
making further adjustments to the API logging code over the next few days/weeks.
(Suggestions for improvements are welcome).


Update the Python build scripts to re-build the swig C++ file whenever 
the python-extensions.swig file is modified.

Correct the help for 'log enable' command (give it the correct number & type of
arguments).

llvm-svn: 117349
2010-10-26 03:11:13 +00:00
Jim Ingham 40d871fa24 The call function thread plan should allow internal breakpoints to continue on. Also made stopping
in mid-expression evaluation when we hit a breakpoint/signal work.

llvm-svn: 117341
2010-10-26 00:27:45 +00:00
Jason Molenda ab4f1924db Check in the native lldb unwinder.
Not yet enabled as the default unwinder but there are no known
backtrace problems with the code at this point.

Added 'log enable lldb unwind' to help diagnose backtrace problems;
this output needs a little refining but it's a good first step.

eh_frame information is currently read unconditionally - the code
is structured to allow this to be delayed until it's actually needed.
There is a performance hit when you have to parse the eh_frame
information for any largeish executable/library so it's necessary
to avoid if possible.

It's confusing having both the UnwindPlan::RegisterLocation struct
and the RegisterConextLLDB::RegisterLocation struct, I need to rename
one of them.

The writing of registers isn't done in the RegisterConextLLDB subclass
yet; neither is the running of complex DWARF expressions from eh_frame
(e.g. used for _sigtramp on Mac OS X).

llvm-svn: 117256
2010-10-25 11:12:07 +00:00
Jim Ingham 041a12fc31 Add and SB API to set breakpoint conditions.
llvm-svn: 117082
2010-10-22 01:15:49 +00:00
Greg Clayton 58fc50e0e1 Fixed a crasher that could happen if a FileSpec had a filename only, or vice
versa.

llvm-svn: 116963
2010-10-20 22:52:05 +00:00
Johnny Chen a9b56f68be Fixed a typo in the comment.
llvm-svn: 116949
2010-10-20 21:44:39 +00:00
Greg Clayton 274060b6f1 Fixed an issue where we were resolving paths when we should have been.
So the issue here was that we have lldb_private::FileSpec that by default was 
always resolving a path when using the:

FileSpec::FileSpec (const char *path);

and in the:

void FileSpec::SetFile(const char *pathname, bool resolve = true);

This isn't what we want in many many cases. One example is you have "/tmp" on
your file system which is really "/private/tmp". You compile code in that
directory and end up with debug info that mentions "/tmp/file.c". Then you 
type:

(lldb) breakpoint set --file file.c --line 5

If your current working directory is "/tmp", then "file.c" would be turned 
into "/private/tmp/file.c" which won't match anything in the debug info.
Also, it should have been just a FileSpec with no directory and a filename
of "file.c" which could (and should) potentially match any instances of "file.c"
in the debug info.

So I removed the constructor that just takes a path:

FileSpec::FileSpec (const char *path); // REMOVED

You must now use the other constructor that has a "bool resolve" parameter that you must always supply:

FileSpec::FileSpec (const char *path, bool resolve);

I also removed the default parameter to SetFile():

void FileSpec::SetFile(const char *pathname, bool resolve);

And fixed all of the code to use the right settings.

llvm-svn: 116944
2010-10-20 20:54:39 +00:00
Jim Ingham b15bfc753c Don't cache the public stop reason, since it can change as plan completion gets processed. That means GetStopReason needs to return a shared pointer, not a pointer to the thread's cached version. Also allow the thread plans to get and set the thread private stop reason - that is usually more appropriate for the logic the thread plans need to do.
llvm-svn: 116892
2010-10-20 00:39:53 +00:00
Sean Callanan 104a6e9baa Fixed a silly bug that was causing the "this" pointer
to be passed improperly to expressions in certain
cases.

llvm-svn: 116884
2010-10-19 23:57:21 +00:00
Greg Clayton 913c4fa15b Ok, last commit for the running processes in a new window. Now you can
optionally specify the tty you want to use if you want to use an existing
terminal window by giving a partial or full path name:

(lldb) process launch --tty=ttys002

This would find the terminal window (or tab on MacOSX) that has ttys002 in its
tty path and use it. If it isn't found, it will use a new terminal window.

llvm-svn: 116878
2010-10-19 23:16:00 +00:00
Greg Clayton 3fcbed6bda Stop the driver from handling SIGPIPE in case we communicate with stale
sockets so the driver doesn't just crash.

Added support for connecting to named sockets (unix IPC sockets) in
ConnectionFileDescriptor.

Modified the Host::LaunchInNewTerminal() for MacOSX to return the process
ID of the inferior process instead of the process ID of the Terminal.app. This
was done by modifying the "darwin-debug" executable to connect to lldb through
a named unix socket which is passed down as an argument. This allows a quick
handshake between "lldb" and "darwin-debug" so we can get the process ID
of the inferior and then attach by process ID and avoid attaching to the 
inferior by process name since there could be more than one process with 
that name. This still has possible race conditions, those will be fixed
in the near future. This fixes the SIGPIPE issues that were sometimes being
seen when task_for_pid was failing.

llvm-svn: 116792
2010-10-19 03:25:40 +00:00
Caroline Tice c0dbdfb6c2 Combine eArgTypeSignalName and eArgTypeUnixSignalNumber into a single
argument type, eArgTypeUnixSignal.

llvm-svn: 116764
2010-10-18 22:56:57 +00:00
Greg Clayton dd36defda7 Added a new Host call to find LLDB related paths:
static bool
    Host::GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec);
    
This will fill in "file_spec" with an appropriate path that is appropriate
for the current Host OS. MacOSX will return paths within the LLDB.framework,
and other unixes will return the paths they want. The current PathType
enums are:

typedef enum PathType
{
    ePathTypeLLDBShlibDir,          // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists
    ePathTypeSupportExecutableDir,  // Find LLDB support executable directory (debugserver, etc)
    ePathTypeHeaderDir,             // Find LLDB header file directory
    ePathTypePythonDir              // Find Python modules (PYTHONPATH) directory
} PathType;

All places that were finding executables are and python paths are now updated
to use this Host call.

Added another new host call to launch the inferior in a terminal. This ability
will be very host specific and doesn't need to be supported on all systems.
MacOSX currently will create a new .command file and tell Terminal.app to open
the .command file. It also uses the new "darwin-debug" app which is a small
app that uses posix to exec (no fork) and stop at the entry point of the 
program. The GDB remote plug-in is almost able launch a process and attach to
it, it currently will spawn the process, but it won't attach to it just yet.
This will let LLDB not have to share the terminal with another process and a
new terminal window will pop up when you launch. This won't get hooked up
until we work out all of the kinks. The new Host function is:

    static lldb::pid_t
    Host::LaunchInNewTerminal (
        const char **argv,   // argv[0] is executable
        const char **envp,
        const ArchSpec *arch_spec,
        bool stop_at_entry,
        bool disable_aslr);

Cleaned up FileSpec::GetPath to not use strncpy() as it was always zero 
filling the entire path buffer.

Fixed an issue with the dynamic checker function where I missed a '$' prefix
that should have been added.

llvm-svn: 116690
2010-10-17 22:03:32 +00:00
Greg Clayton d5687aea93 Fixed the UnixSignals class to be able to get a signal by name, short name, or signal number when using:
int32_t UnixSignals::GetSignalNumberFromName (const char *name) const;

llvm-svn: 116641
2010-10-15 23:16:40 +00:00
Greg Clayton 7b462cc18a Made many ConstString functions inlined in the header file.
Changed all of our synthesized "___clang" functions, types and variables
that get used in expressions over to have a prefix of "$_lldb". Now when we
do name lookups we can easily switch off of the first '$' character to know
if we should look through only our internal (when first char is '$') stuff,
or when we should look through program variables, functions and types.

Converted all of the clang expression code over to using "const ConstString&" 
values for names instead of "const char *" since there were many places that
were converting the "const char *" names into ConstString names and them
throwing them away. We now avoid making a lot of ConstString conversions and
benefit from the quick comparisons in a few extra spots.

Converted a lot of code from LLVM coding conventions into LLDB coding 
conventions.

llvm-svn: 116634
2010-10-15 22:48:33 +00:00
Greg Clayton 8dbc336da9 Added short names and descriptions to the UnixSignals class. Also cleaned up
the code a bit.

llvm-svn: 116561
2010-10-15 02:39:01 +00:00
Jim Ingham 36f3b369d2 Added support for breakpoint conditions. I also had to separate the "run the expression" part of ClangFunction::Execute from the "Gather the expression result" so that in the case of the Breakpoint condition I can move the condition evaluation into the normal thread plan processing.
Also added support for remembering the "last set breakpoint" so that "break modify" will act on the last set breakpoint.

llvm-svn: 116542
2010-10-14 23:45:03 +00:00
Greg Clayton 8f92f0a35c Fixed an expression parsing issue where if you were stopped somewhere without
debug information and you evaluated an expression, a crash would occur as a
result of an unchecked pointer.

Added the ability to get the expression path for a ValueObject. For a rectangle
point child "x" the expression path would be something like: "rect.top_left.x".
This will allow GUI and command lines to get ahold of the expression path for
a value object without having to explicitly know about the hierarchy. This
means the ValueObject base class now has a "ValueObject *m_parent;" member.
All ValueObject subclasses now correctly track their lineage and are able
to provide value expression paths as well.

Added a new "--flat" option to the "frame variable" to allow for flat variable
output. An example of the current and new outputs:

(lldb) frame variable 
argc = 1
argv = 0x00007fff5fbffe80
pt = {
  x = 2
  y = 3
}
rect = {
  bottom_left = {
    x = 1
    y = 2
  }
  top_right = {
    x = 3
    y = 4
  }
}
(lldb) frame variable --flat 
argc = 1
argv = 0x00007fff5fbffe80
pt.x = 2
pt.y = 3
rect.bottom_left.x = 1
rect.bottom_left.y = 2
rect.top_right.x = 3
rect.top_right.y = 4


As you can see when there is a lot of hierarchy it can help flatten things out.
Also if you want to use a member in an expression, you can copy the text from
the "--flat" output and not have to piece it together manually. This can help
when you want to use parts of the STL in expressions:

(lldb) frame variable --flat
argc = 1
argv = 0x00007fff5fbffea8
hello_world._M_dataplus._M_p = 0x0000000000000000
(lldb) expr hello_world._M_dataplus._M_p[0] == '\0'

llvm-svn: 116532
2010-10-14 22:52:14 +00:00
Caroline Tice 357313573e Add new argument type, eArgSignalName,
Add missing break statment to case statement in Process::ShouldBroadcastEvent.

Add new command, "process handle" to allow users to control process behavior on
the receipt of various Unix signals (whether the process should stop; whether the
process should be passed the signal; whether the debugger user should be notified
that the signal came in).

llvm-svn: 116430
2010-10-13 20:44:39 +00:00
Greg Clayton e02b850483 Modified the "breakpoint set --name NAME" to be the auto breakpoint set
function. It will inspect NAME and do the following:
- if the name contains '(' or starts with "-[" or "+[" then a full name search
  will happen to match full function names with args (C++ demangled names) or
  full objective C method prototypes.
- if the name contains "::" and no '(', then it is assumed to be a qualified
  function name that is in a namespace or class. For "foo::bar::baz" we will
  search for any functions with the basename or method name of "baz", then
  filter the results to only those that contain "foo::bar::baz". This allows
  setting breakpoint on C++ functions and methods without having to fully
  qualify all of the types that would appear in C++ mangled names.
- if the name contains ":" (not "::"), then NAME is assumed to be an ObjC
  selector.
_ otherwise, we assume just a plain function basename.

Now that "--name" is our "auto" mode, I introduced the new "--basename" option
("breakpoint set --basename NAME") to allow for function names that aren't 
methods or selectors, just basenames. This can also be used to ignore C++
namespaces and class hierarchies for class methods.

Fixed clang enumeration promotion types to be correct.

llvm-svn: 116293
2010-10-12 04:29:14 +00:00
Jim Ingham 30f9b21bf4 Add a way to temporarily divert events from a broadcaster to a private listener.
llvm-svn: 116271
2010-10-11 23:53:14 +00:00
Greg Clayton 6eee5aa067 Added a "--no-lldbinit" option (-n for short (which magically matches
what gdb uses)) so we can tell our "lldb" driver program to not automatically
parse any .lldbinit files. 

llvm-svn: 116179
2010-10-11 01:05:37 +00:00
Greg Clayton 46747022d2 Added the ability to get error strings back from failed
lldb_private::RegularExpression compiles and matches with:

    size_t
    RegularExpression::GetErrorAsCString (char *err_str, 
                                          size_t err_str_max_len) const;
    
Added the ability to search a variable list for variables whose names match
a regular expression:

    size_t
    VariableList::AppendVariablesIfUnique (const RegularExpression& regex, 
                                           VariableList &var_list, 
                                           size_t& total_matches);


Also added the ability to append a variable to a VariableList only if it is 
not already in the list:

    bool
    VariableList::AddVariableIfUnique (const lldb::VariableSP &var_sp);

Cleaned up the "frame variable" command:
- Removed the "-n NAME" option as this is the default way for the command to
  work.
- Enable uniqued regex searches on variable names by fixing the "--regex RE"
  command to work correctly. It will match all variables that match any
  regular expressions and only print each variable the first time it matches.
- Fixed the option type for the "--regex" command to by eArgTypeRegularExpression
  instead of eArgTypeCount

llvm-svn: 116178
2010-10-10 23:55:27 +00:00
Greg Clayton 864174e100 Added a new test case to test signals with.
Added frame relative frame selection to "frame select". You can now select
frames relative to the current frame (which defaults to zero if the current
frame hasn't yet been set for a thread):

The gdb "up" command can be done as:
(lldb) frame select -r 1
The gdb "down" command can be done as:
(lldb) frame select -r -1

Place the following in your ~/.lldbinit file for "up" and "down":

command alias up frame select -r 1
command alias down frame select -r -1

llvm-svn: 116176
2010-10-10 22:28:11 +00:00
Greg Clayton 8087ca2160 Added mutex protection to the Symtab class.
Added a new SortOrder enumeration and hooked it up to the "image dump symtab"
command so we can dump symbol tables in the original order, sorted by address, 
or sorted by name.

llvm-svn: 116049
2010-10-08 04:20:14 +00:00
Greg Clayton 8941142af8 Hooked up ability to look up data symbols so they show up in disassembly
if the address comes from a data section. 

Fixed an issue that could occur when looking up a symbol that has a zero
byte size where no match would be returned even if there was an exact symbol
match.

Cleaned up the section dump output and added the section type into the output.

llvm-svn: 116017
2010-10-08 00:21:05 +00:00
Greg Clayton 05faeb7135 Cleaned up the SWIG stuff so all includes happen as they should, no pulling
tricks to get types to resolve. I did this by correctly including the correct
files: stdint.h and all lldb-*.h files first before including the API files.
This allowed me to remove all of the hacks that were in the lldb.swig file
and it also allows all of the #defines in lldb-defines.h and enumerations
in lldb-enumerations.h to appear in the lldb.py module. This will make the
python script code a lot more readable.

Cleaned up the "process launch" command to not execute a "process continue"
command, it now just does what it should have with the internal API calls
instead of executing another command line command.

Made the lldb_private::Process set the state to launching and attaching if
WillLaunch/WillAttach return no error respectively.

llvm-svn: 115902
2010-10-07 04:19:01 +00:00
Johnny Chen 0ed37c9615 o SBtarget.cpp/.h:
Temporarily commenting out the deprecated LaunchProcess() method.
  SWIG is not able to handle the overloaded functions.

o dotest.py/lldbtest.py:

  Add an '-w' option to insert some wait time between consecutive test cases.

o TestClassTypes.py:

  Make the breakpoint_creation_by_filespec_python() test method more robust and
  more descriptive by printing out a more insightful assert message.

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

llvm-svn: 115899
2010-10-07 02:04:14 +00:00
Greg Clayton 524e60b4e4 Expose the error contained within an SBValue.
Move anything that creates a new process into SBTarget. Marked some functions
as deprecated. I will remove them after our new API changes make it through
a build cycle.

llvm-svn: 115854
2010-10-06 22:10:17 +00:00
Greg Clayton b4fb2a991c Leaving in deprecated functions until we can get a clean build with the new APIs in place before removing the deprecated functions.
llvm-svn: 115815
2010-10-06 18:44:26 +00:00
Greg Clayton 5d5028b54e Added the first of hopefully many python example scripts that show how to
use the python API that is exposed through SWIG to do some cool stuff.

Also fixed synchronous debugging so that all process control APIs exposed
through the python API will now wait for the process to stop if you set
the async mode to false (see disasm.py).

llvm-svn: 115738
2010-10-06 03:53:16 +00:00
Greg Clayton 1d27316606 Added the ability to get the disassembly instructions from the function and
symbol.

llvm-svn: 115734
2010-10-06 03:09:58 +00:00
Greg Clayton 32c4085ba2 Restored the ability to set the format for expressions after changing the expression results over to ValueObjectSP objects.
llvm-svn: 115733
2010-10-06 03:09:11 +00:00
Sean Callanan 85a0a83a26 Added handling for external variables in function
arguments to the expression parser.  This means that
structs can be returned from the "expr" command.

llvm-svn: 115698
2010-10-05 22:26:43 +00:00
Greg Clayton b71f384455 Added the notion that a value object can be constant by adding:
bool ValueObject::GetIsConstant() const;
    void ValueObject::SetIsConstant();

This will stop anything from being re-evaluated within the value object so
that constant result value objects can maintain their frozen values without
anything being updated or changed within the value object.

Made it so the ValueObjectConstResult can be constructed with an 
lldb_private::Error object to allow for expression results to have errors.

Since ValueObject objects contain error objects, I changed the expression
evaluation in ClangUserExpression from 

    static Error
    ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, 
                                  const char *expr_cstr, 
                                  lldb::ValueObjectSP &result_valobj_sp);

to:

    static lldb::ValueObjectSP
    Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr);
    
Even though expression parsing is borked right now (pending fixes coming from
Sean Callanan), I filled in the implementation for:
    
    SBValue SBFrame::EvaluateExpression (const char *expr);
    
Modified all expression code to deal with the above changes.

llvm-svn: 115589
2010-10-05 03:13:51 +00:00
Greg Clayton 0184f01936 Moved expression evaluation from CommandObjectExpression into
ClangUserExpression::Evaluate () as a public static function so anyone can
evaluate an expression.

llvm-svn: 115581
2010-10-05 00:31:29 +00:00
Greg Clayton 1d3afba3a3 Added a new ValueObject type that will be used to freeze dry expression
results. The clang opaque type for the expression result will be added to the
Target's ASTContext, and the bytes will be stored in a DataBuffer inside
the new object. The class is named: ValueObjectConstResult

Now after an expression is evaluated, we can get a ValueObjectSP back that
contains a ValueObjectConstResult object.

Relocated the value object dumping code into a static function within
the ValueObject class instead of being in the CommandObjectFrame.cpp file
which is what contained the code to dump variables ("frame variables").

llvm-svn: 115578
2010-10-05 00:00:42 +00:00
Jim Ingham 3bcdb29cab Add an "auto-confirm" setting to the debugger so you can turn off the confirmations if you want to.
llvm-svn: 115572
2010-10-04 22:44:14 +00:00
Caroline Tice 405fe67f14 Modify existing commands with arguments to use the new argument mechanism
(for standardized argument names, argument help, etc.)

llvm-svn: 115570
2010-10-04 22:28:36 +00:00
Jim Ingham 97a6dc7e16 Add a "Confirm" function to the CommandInterpreter so you can confirm potentially dangerous operations in a generic way.
llvm-svn: 115546
2010-10-04 19:49:29 +00:00
Jim Ingham 4b9395ca82 Have to friend SBFrame or it can't make symbols for the frame.
llvm-svn: 115543
2010-10-04 19:38:50 +00:00
Greg Clayton 3b06557e4f Added GetSymbol to the frame.
llvm-svn: 115535
2010-10-04 18:37:52 +00:00
Greg Clayton 0603aa9dc8 There are now to new "settings set" variables that live in each debugger
instance:

settings set frame-format <string>
settings set thread-format <string>

This allows users to control the information that is seen when dumping
threads and frames. The default values are set such that they do what they
used to do prior to changing over the the user defined formats.

This allows users with terminals that can display color to make different
items different colors using the escape control codes. A few alias examples
that will colorize your thread and frame prompts are:

settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n'

settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n'

A quick web search for "colorize terminal output" should allow you to see what
you can do to make your output look like you want it.

The "settings set" commands above can of course be added to your ~/.lldbinit
file for permanent use.

Changed the pure virtual 
    void ExecutionContextScope::Calculate (ExecutionContext&);
To:
    void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&);
    
I did this because this is a class that anything in the execution context
heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell
you what it was really trying to do unless you look at the parameter.

llvm-svn: 115485
2010-10-04 01:05:56 +00:00
Greg Clayton c93237c991 Fixed an issue where if a method funciton was asked to be parsed before
its containing class was parsed, we would crash.

llvm-svn: 115343
2010-10-01 20:48:32 +00:00
Caroline Tice deaab2220e Modify command options to use the new arguments mechanism. Now all command option
arguments are specified in a standardized way, will have a standardized name, and
have functioning help.

The next step is to start writing useful help for all the argument types.

llvm-svn: 115335
2010-10-01 19:59:14 +00:00
Caroline Tice e139cf2320 Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.

Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism.  Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).

Help command now works for all argument types, although the help may not
be very helpful yet.

Those commands that take "raw" command strings now indicate it in their
help text.

llvm-svn: 115318
2010-10-01 17:46:38 +00:00
Greg Clayton f51de67640 Make C++ constructors and destructors correctly within the clang types we
generate from DWARF.

llvm-svn: 115268
2010-10-01 02:31:07 +00:00
Greg Clayton 16c880f080 Fixed an issue where byte sizes were not able to be calculated for forward
declarations because we lost the original context which was needed to be
able to figure out the byte size.

llvm-svn: 115223
2010-09-30 22:25:09 +00:00
Greg Clayton 4957bf69e5 Cleaned up a unused member variable in Debugger.
Added the start of Host specific launch services, though it currently isn't
hookup up to anything. We want to be able to launch a process and use the
native launch services to launch an app like it would be launched by the
user double clicking on the app. We also eventually want to be able to run
a command line app in a newly spawned terminal to avoid terminal sharing.

Fixed an issue with the new DWARF forward type declaration stuff. A crasher
was found that was happening when trying to properly expand the forward
declarations.

llvm-svn: 115213
2010-09-30 21:49:03 +00:00
Sean Callanan 038df50315 Switched the expression parser from using TargetData
to using Clang to get type sizes.  This fixes a bug
where the type size for a double[2] was being wrongly
reported as 8 instead of 16 bytes, causing problems
for IRForTarget.

Also improved logging so that the next bug in this
area will be easier to find.

llvm-svn: 115208
2010-09-30 21:18:25 +00:00
Jim Ingham 6c68fb4549 Add "-o" option to "expression" which prints the object description if available.
llvm-svn: 115115
2010-09-30 00:54:27 +00:00
Greg Clayton 1be10fca5f Fixed the forward declaration issue that was present in the DWARF parser after
adding methods to C++ and objective C classes. In order to make methods, we
need the function prototype which means we need the arguments. Parsing these
could cause a circular reference that caused an  assertion.

Added a new typedef for the clang opaque types which are just void pointers:
lldb::clang_type_t. This appears in lldb-types.h.

This was fixed by enabling struct, union, class, and enum types to only get
a forward declaration when we make the clang opaque qual type for these
types. When they need to actually be resolved, lldb_private::Type will call
a new function in the SymbolFile protocol to resolve a clang type when it is
not fully defined (clang::TagDecl::getDefinition() returns NULL). This allows
us to be a lot more lazy when parsing clang types and keeps down the amount
of data that gets parsed into the ASTContext for each module. 

Getting the clang type from a "lldb_private::Type" object now takes a boolean
that indicates if a forward declaration is ok:

    clang_type_t lldb_private::Type::GetClangType (bool forward_decl_is_ok);
    
So function prototypes that define parameters that are "const T&" can now just
parse the forward declaration for type 'T' and we avoid circular references in
the type system.

llvm-svn: 115012
2010-09-29 01:12:09 +00:00
Jim Ingham 5a369128f6 Replace the vestigial Value::GetOpaqueCLangQualType with the more correct Value::GetValueOpaqueClangQualType.
But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes.

llvm-svn: 114935
2010-09-28 01:25:32 +00:00
Sean Callanan 8fd3244af3 Added type lookup, so variables with user-defined types
can be allocated and manipulated.

llvm-svn: 114928
2010-09-27 23:54:58 +00:00
Caroline Tice 18474c933c Automatically wrap *all* Python code entered for a breakpoint command inside
an auto-generated Python function, and pass the stoppoint context frame and
breakpoint location as parameters to the function (named 'frame' and 'bp_loc'),
to be used inside the breakpoint command Python code, if desired.

llvm-svn: 114849
2010-09-27 18:00:20 +00:00
Caroline Tice 1559a46b3e Create more useful instance names for target, process and thread instances.
Change default 'set' behavior so that all instance settings for the specified variable will be
updated, unless the "-n" ("--no_override") command options is specified.

llvm-svn: 114808
2010-09-27 00:30:10 +00:00
Greg Clayton 5573fde342 Cleaned a few build related things up:
Added a virtual destructor to ClangUtilityFunction with a body to it cleans
itself up.

Moved our SharingPtr into the lldb_private namespace to keep it easy to make
an exports file that exports only what is needed ("lldb::*").

llvm-svn: 114771
2010-09-24 23:07:41 +00:00
Greg Clayton 0fffff5816 Added the ability to create an objective C method for an objective C
interface in ClangASTContext. Also added two bool returning functions that
indicated if an opaque clang qual type is a CXX class type, and if it is an
ObjC class type.

Objective C classes now will get their methods added lazily as they are
encountered. The reason for this is currently, unlike C++, the 
DW_TAG_structure_type and owns the ivars, doesn't not also contain the
member functions. This means when we parse the objective C class interface
we either need to find all functions whose names start with "+[CLASS_NAME"
or "-[CLASS_NAME" and add them all to the class, or when we parse each objective
C function, we slowly add it to the class interface definition. Since objective
C's class doesn't change internal bits according to whether it has certain types
of member functions (like C++ does if it has virtual functions, or if it has
user ctors/dtors), I currently chose to lazily populate the class when each
functions is parsed. Another issue we run into with ObjC method declarations
is the "self" and "_cmd" implicit args are not marked as artificial in the
DWARF (DW_AT_artifical), so we currently have to look for the parameters by
name if we are trying to omit artificial function args if the language of the
compile unit is ObjC or ObjC++.

llvm-svn: 114722
2010-09-24 05:15:53 +00:00
Jim Ingham e4284b719c Add GetSP to the StackFrame.
llvm-svn: 114674
2010-09-23 17:40:12 +00:00
Sean Callanan e2ef6e380b Updated to latest LLVM. Major LLVM changes:
- Sema is now exported (and there was much rejoicing.)

 - Storage classes are now centrally defined.

Also fixed some bugs that the new LLVM picked up.

llvm-svn: 114622
2010-09-23 03:01:22 +00:00
Jim Ingham 2277701c7b Committing the skeleton of Language runtime plugin classes.
llvm-svn: 114620
2010-09-23 02:01:19 +00:00
Greg Clayton a51ed9bb49 Added motheds to C++ classes as we parse them to keep clang happy.
llvm-svn: 114616
2010-09-23 01:09:21 +00:00
Caroline Tice dac97f31a3 Remove all the __repr__ methods from the API/*.h files, and put them
into python-extensions.swig, which gets included into lldb.swig, and
adds them back into the classes when swig generates it's C++ file.  This
keeps the Python stuff out of the general API classes.

Also fixed a small bug in the copy constructor for SBSymbolContext.

llvm-svn: 114602
2010-09-22 23:01:29 +00:00
Caroline Tice 7740412f2b Remove SBCommandContext which was not needed or doing anything.
Add SBValueList.h & SBStream.h to build-swig-Python.sh; add SBValueList.h to lldb.swig

llvm-svn: 114549
2010-09-22 16:41:52 +00:00
Jason Molenda 0c7cc85649 Add a new ArchVolatileRegs plugin class to identify
whether a given register number is treated as volatile
or not for a given architecture/platform.

approx 450 lines of boilerplate, 50 lines of actual code. :)

llvm-svn: 114537
2010-09-22 07:37:07 +00:00
Sean Callanan fc55f5d1b0 Removed the hacky "#define this ___clang_this" handler
for C++ classes.  Replaced it with a less hacky approach:

 - If an expression is defined in the context of a
   method of class A, then that expression is wrapped as
   ___clang_class::___clang_expr(void*) { ... }
   instead of ___clang_expr(void*) { ... }.

 - ___clang_class is resolved as the type of the target
   of the "this" pointer in the method the expression
   is defined in.

 - When reporting the type of ___clang_class, a method
   with the signature ___clang_expr(void*) is added to
   that class, so that Clang doesn't complain about a
   method being defined without a corresponding
   declaration.

 - Whenever the expression gets called, "this" gets
   looked up, type-checked, and then passed in as the
   first argument.

This required the following changes:

 - The ABIs were changed to support passing of the "this"
   pointer as part of trivial calls.

 - ThreadPlanCallFunction and ClangFunction were changed
   to support passing of an optional "this" pointer.

 - ClangUserExpression was extended to perform the
   wrapping described above.

 - ClangASTSource was changed to revert the changes
   required by the hack.

 - ClangExpressionParser, IRForTarget, and
   ClangExpressionDeclMap were changed to handle
   different manglings of ___clang_expr flexibly.  This
   meant no longer searching for a function called
   ___clang_expr, but rather looking for a function whose
   name *contains* ___clang_expr.

 - ClangExpressionParser and ClangExpressionDeclMap now
   remember whether "this" is required, and know how to
   look it up as necessary.

A few inheritance bugs remain, and I'm trying to resolve
these.  But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.

llvm-svn: 114384
2010-09-21 00:44:12 +00:00
Caroline Tice 12cecd741d Make GetInstanceSettingsValue methods take an Error * rather than an Error &,
and have them return a bool to indicate success or not.

llvm-svn: 114361
2010-09-20 21:37:42 +00:00
Caroline Tice daccaa9e83 Add UserSettings to Target class, making Target settings
the parent of Process settings;   add 'default-arch' as a
class-wide setting for Target.    Replace            lldb::GetDefaultArchitecture
with Target::GetDefaultArchitecture & Target::SetDefaultArchitecture.

Add 'use-external-editor' as user setting to Debugger class & update
code appropriately.

Add Error parameter to methods that get user settings, for easier
reporting of bad requests.

Fix various other minor related bugs.

Fix test cases to work with new changes.

llvm-svn: 114352
2010-09-20 20:44:43 +00:00
Caroline Tice dde9cff32a Add GetDescription() and __repr__ () methods to most API classes, to allow
"print" from inside Python to print out the objects in a more useful
manner.

llvm-svn: 114321
2010-09-20 05:20:02 +00:00
Greg Clayton 1b65488229 Added code that will allow completely customizable prompts for use in
replacing the "(lldb)" prompt, the "frame #1..." displays when doing
stack backtracing and the "thread #1....". This will allow you to see 
exactly the information that you want to see where you want to see it.
This currently isn't hookup up to the prompts yet, but it will be soon.

So what is the format of the prompts? Prompts can contain variables that
have access to the current program state. Variables are text that appears
in between a prefix of "${" and ends with a "}". Some of the interesting
variables include:

// The frame index (0, 1, 2, 3...)
${frame.index}

// common frame registers with generic names
${frame.pc}
${frame.sp}
${frame.fp}
${frame.ra}
${frame.flags}

// Access to any frame registers by name where REGNAME is any register name:
${frame.reg.REGNAME}

// The current compile unit file where the frame is located
${file.basename}
${file.fullpath}

// Function information
${function.name}
${function.pc-offset}

// Process info
${process.file.basename}
${process.file.fullpath}
${process.id}
${process.name}

// Thread info
${thread.id}
${thread.index}
${thread.name}
${thread.queue}
${thread.stop-reason}

// Target information
${target.arch}

// The current module for the current frame (the shared library or executable
// that contains the current frame PC value):
${module.file.basename}
${module.file.fullpath}

// Access to the line entry for where the current frame is when your thread
// is stopped:
${line.file.basename}
${line.file.fullpath}
${line.number}
${line.start-addr}
${line.end-addr}

Many times the information that you might have in your prompt might not be
available and you won't want it to print out if it isn't valid. To take care
of this you can enclose everything that must resolve into a scope. A scope
is starts with '{' and ends with '}'. For example in order to only display
the current file and line number when the information is available the format
would be:

"{ at {$line.file.basename}:${line.number}}"

Broken down this is:

start the scope: "{"

format whose content will only be displayed if all information is available:
        "at {$line.file.basename}:${line.number}"

end the scope: "}"

We currently can represent the infomration we see when stopped at a frame:

frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19

with the following format:

"frame #${frame.index}: ${frame.pc} {${module.file.basename}`}{${function.name}{${function.pc-offset}}{ at ${line.file.basename}:${line.number}}\n"

This breaks down to always print:

        "frame #${frame.index}: ${frame.pc} "

only print the module followed by a tick if we have a valid module:

        "{${module.file.basename}`}"
        
print the function name with optional offset:
        "{${function.name}{${function.pc-offset}}"

print the line info if it is available:
        
        "{ at ${line.file.basename}:${line.number}}"

then finish off with a newline:

        "\n"

Notice you can also put newlines ("\n") and tabs and everything else you
are used to putting in a format string when desensitized with the \ character.

Cleaned up some of the user settings controller subclasses. All of them 
do not have any global settings variables and were all implementing stubs
for the get/set global settings variable. Now there is a default version
in UserSettingsController that will do nothing.

llvm-svn: 114306
2010-09-19 02:33:57 +00:00
Greg Clayton ed8a705cea General command line help cleanup:
- All single character options will now be printed together
- Changed all options that contains underscores to contain '-' instead
- Made the help come out a little flatter by showing the long and short
  option on the same line.
- Modified the short character for "--ignore-count" options to "-i"

llvm-svn: 114265
2010-09-18 03:37:20 +00:00
Greg Clayton a701509229 Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't
very usable and made for a lot of unnecessary code just to access variables
that were already owned by the objects.

While I fixed those things, I saw that CommandObject objects should really
have a reference to their command interpreter so they can access the terminal
with if they want to output usaage. Fixed up all CommandObjects to take
an interpreter and cleaned up the API to not need the interpreter to be
passed in.

Fixed the disassemble command to output the usage if no options are passed
down and arguments are passed (all disassebmle variants take options, there
are no "args only").

llvm-svn: 114252
2010-09-18 01:14:36 +00:00
Johnny Chen aec0c322d3 Fixed build error of LLDBWrapPython.cpp by removing the "protected" access modifier.
llvm-svn: 114194
2010-09-17 18:39:57 +00:00
Greg Clayton e2ae97f267 We now have SBStream that mirrors the generic stream classes we
use inside lldb (lldb_private::StreamFile, and lldb_private::StreamString).

llvm-svn: 114188
2010-09-17 17:42:16 +00:00
Sean Callanan 61da09bbc8 Re-committed AddMethodToCXXRecordType, now that
the bug I introduced to ClangASTContext is
resolved.

llvm-svn: 114157
2010-09-17 02:58:26 +00:00
Sean Callanan 6fe64b528d Added a static function to get the void type for
an ASTContext; also added a function to get the
Clang-style CVR qualifiers for a type as an
unsigned int.

llvm-svn: 114152
2010-09-17 02:24:29 +00:00
Johnny Chen 4a0a048cf8 Reverted r114125, r114124, and r114123 as it broke the test suite - segfaults
when running test/class_types.

llvm-svn: 114132
2010-09-16 23:51:14 +00:00
Sean Callanan f07c52621e GetBuiltInType_void(clang::ASTContext*) should be
static.

llvm-svn: 114125
2010-09-16 22:40:36 +00:00
Sean Callanan d24a7c893b Well, it shouldn't be quite *that* obviously broken.
Quick fix to AddMethodToCXXRecordType's non-static
definition.

llvm-svn: 114124
2010-09-16 22:32:47 +00:00
Sean Callanan e44f1fbb4b Added AddMethodToCXXRecordType. This is not yet
tested, but I'm committing because it's not used
anywhere and I want to avoid conflicts.

llvm-svn: 114123
2010-09-16 22:31:19 +00:00
Sean Callanan c81256a595 Made CreateFunctionType static. Also fixed the spelling
for CreateParameterDeclaration.

llvm-svn: 114111
2010-09-16 20:40:25 +00:00
Sean Callanan 6e6a7c7160 Made AddFieldToRecordType a static method on
ClangASTContext.

llvm-svn: 114110
2010-09-16 20:01:08 +00:00
Caroline Tice 9e41c15d84 Fix issues with CreateInstanceName, a virtual function, being called
in an initializer.

llvm-svn: 114107
2010-09-16 19:05:55 +00:00
Johnny Chen 9b1e320c27 Undo 114084 and 114087 to unbreak the build for the time being.
llvm-svn: 114095
2010-09-16 17:37:05 +00:00
Benjamin Kramer 3e9e2fcadd Turns out CreateInstanceName is duplicated in two other places. Make them static too, sigh.
llvm-svn: 114087
2010-09-16 16:23:16 +00:00
Benjamin Kramer b12ec91a3d Make this method static. Bad things(tm) happen when a non-static method is called in a constructor's initializer list.
llvm-svn: 114084
2010-09-16 16:07:31 +00:00
Benjamin Kramer 7309e6c7f1 Unbreak build, you can't take a pointer from a "register" variable. Most compilers ignore this keyword anyways.
Also remove a typedef that typedefs nothing.

llvm-svn: 114083
2010-09-16 16:07:21 +00:00
Jim Ingham 7ce490c6b5 Step past prologues when we step into functions.
llvm-svn: 114055
2010-09-16 00:58:09 +00:00
Jim Ingham 0909e5f4df Add the ability to not resolve the name passed to FileSpec. Then don't resolve the names of compilation units found in DWARF.
llvm-svn: 114054
2010-09-16 00:57:33 +00:00
Caroline Tice 3f12e8efc1 Remove unnecessary/inappropriate output-printing functions from
the API.

llvm-svn: 113993
2010-09-15 18:29:06 +00:00
Greg Clayton d88d759a74 15-20% speed improvement when parsing DWARF. I used instruments to
find the hotspots in our code when indexing the DWARF. A combination of
using SmallVector to avoid collection allocations, using fixed form
sizes when possible, and optimizing the hot loops contributed to the
speedup.

llvm-svn: 113961
2010-09-15 08:33:30 +00:00
Caroline Tice 7d9edf670b Modify "settings list" so you can specify a particular instance setting name,
or a settings prefix, and it will list information about the subset of settings
you requested.  Also added tab-completion (now that it takes an optional argument).

llvm-svn: 113952
2010-09-15 06:56:39 +00:00
Greg Clayton 6dbd39838d Fixed a missing newline when dumping mixed disassembly.
Added a "bool show_fullpaths" to many more objects that were
previously always dumping full paths.

Fixed a few places where the DWARF was not indexed when we
we needed it to be when making queries. Also fixed an issue
where the DWARF in .o files wasn't searching all .o files
for the types.

Fixed an issue with the output from "image lookup --type <TYPENAME>"
where the name and byte size might not be resolved and might not
display. We now call the accessors so we end up seeing all of the
type info.

llvm-svn: 113951
2010-09-15 05:51:24 +00:00
Caroline Tice ded2fa3991 Remove all visible uses of "[DEFAULT]" instance name.
Add ability to rename UserSettingsInstances after they have been created
(via UserSettingsController::RenameInstanceSettings.

llvm-svn: 113950
2010-09-15 05:35:14 +00:00
Greg Clayton 17f692087a Clear the section list when a our current process is destroyed.
Add missing files that I forgot to checkin.

llvm-svn: 113902
2010-09-14 23:52:43 +00:00
Greg Clayton f5e56de080 Moved the section load list up into the target so we can use the target
to symbolicate things without the need for a valid process subclass.

llvm-svn: 113895
2010-09-14 23:36:40 +00:00
Jim Ingham 08b87e0ded Add the ability for "ThreadPlanRunToAddress" to run to multiple addresses.
Added the ability to specify a preference for mangled or demangled to Mangled::GetName.
Changed one place where mangled was prefered in GetName.
The Dynamic loader should look up the target of a stub by mangled name if it exists.

llvm-svn: 113869
2010-09-14 22:03:00 +00:00
Sean Callanan 44096b1a7e Added code to support use of "this" and "self" in
expressions.  This involved three main changes:

 - In ClangUserExpression::ClangUserExpression(),
   we now insert the following lines into the
   expression:
     #define this ___clang_this
     #define self ___clang_self

 - In ClangExpressionDeclMap::GetDecls(), we
   special-case ___clang_(this|self) and instead
   look up "this" or "self"

 - In ClangASTSource, we introduce the capability
   to generate Decls with a different, overridden,
   name from the one that was requested, e.g.
   this for ___clang_this.

llvm-svn: 113866
2010-09-14 21:59:34 +00:00
Greg Clayton 6f00abd546 Fixed the implementation of "bool Block::Contains (const Block *block) const"
to return the correct result.

Fixed "bool Variable::IsInScope (StackFrame *frame)" to return the correct
result when there are no location lists.

Modified the "frame variable" command such that:
- if no arguments are given (dump all frame variables), then we only show
  variables that are currently in scope
- if some arguments are given, we show an error if the variable is out of 
  scope

llvm-svn: 113830
2010-09-14 03:16:58 +00:00
Greg Clayton 016a95eb04 Looking at some of the test suite failures in DWARF in .o files with the
debug map showed that the location lists in the .o files needed some 
refactoring in order to work. The case that was failing was where a function
that was in the "__TEXT.__textcoal_nt" in the .o file, and in the 
"__TEXT.__text" section in the main executable. This made symbol lookup fail
due to the way we were finding a real address in the debug map which was
by finding the section that the function was in in the .o file and trying to
find this in the main executable. Now the section list supports finding a
linked address in a section or any child sections. After fixing this, we ran
into issue that were due to DWARF and how it represents locations lists. 
DWARF makes a list of address ranges and expressions that go along with those
address ranges. The location addresses are expressed in terms of a compile
unit address + offset. This works fine as long as nothing moves around. When
stuff moves around and offsets change between the remapped compile unit base
address and the new function address, then we can run into trouble. To deal
with this, we now store supply a location list slide amount to any location
list expressions that will allow us to make the location list addresses into
zero based offsets from the object that owns the location list (always a
function in our case). 

With these fixes we can now re-link random address ranges inside the debugger
for use with our DWARF + debug map, incremental linking, and more.

Another issue that arose when doing the DWARF in the .o files was that GCC
4.2 emits a ".debug_aranges" that only mentions functions that are externally
visible. This makes .debug_aranges useless to us and we now generate a real
address range lookup table in the DWARF parser at the same time as we index
the name tables (that are needed because .debug_pubnames is just as useless).
llvm-gcc doesn't generate a .debug_aranges section, though this could be 
fixed, we aren't going to rely upon it.

Renamed a bunch of "UINT_MAX" to "UINT32_MAX".

llvm-svn: 113829
2010-09-14 02:20:48 +00:00
Sean Callanan 9e6ed53ea5 Bugfixes to the expression parser. Fixes include:
- If you put a semicolon at the end of an expression,
   this no longer causes the expression parser to
   error out.  This was a two-part fix: first,
   ClangExpressionDeclMap::Materialize now handles
   an empty struct (such as when there is no return
   value); second, ASTResultSynthesizer walks backward
   from the end of the ASTs until it reaches something
   that's not a NullStmt.

 - ClangExpressionVariable now properly byte-swaps when
   printing itself.

 - ClangUtilityFunction now cleans up after itself when
   it's done compiling itself.

 - Utility functions can now use external functions just
   like user expressions.

 - If you end your expression with a statement that does
   not return a value, the expression now runs correctly
   anyway.

Also, added the beginnings of an Objective-C object
validator function, which is neither installed nor used
as yet.

llvm-svn: 113789
2010-09-13 21:34:21 +00:00
Greg Clayton 737b932995 Added the summary values for function pointers so we can show where they
point to.

llvm-svn: 113735
2010-09-13 03:32:57 +00:00
Greg Clayton 83ff3898f7 Fixed a crash that would happen when using "frame variables" on any struct,
union, or class that contained an enumeration type. When I was creating
the clang enumeration decl, I wasn't calling "EnumDecl::setIntegerType (QualType)" 
which means that if the enum decl was ever asked to figure out it's bit width
(getTypeInfo()) it would crash. We didn't run into this with enum types that 
weren't inside classes because the DWARF already told us how big the type was
and when we printed an enum we would never need to calculate the size, we
would use the pre-cached byte size we got from the DWARF. When the enum was 
in a struct/union/class and we tried to layout the struct, the layout code
would attempt to get the type info and segfault.

llvm-svn: 113729
2010-09-12 23:17:56 +00:00
Greg Clayton fd26915742 Bug #: 8408441
Fixed an issue where LLDB would fail to set a breakpoint by
file and line if the DWARF line table has multiple file entries
in the support files for a source file.

llvm-svn: 113721
2010-09-12 06:24:05 +00:00
Caroline Tice 391a9603a0 Remove Host::ResolveExecutableLocation (very recent addition); replace use of
it with llvm::sys::Program::FindProgramByName.

llvm-svn: 113709
2010-09-12 00:10:52 +00:00
Greg Clayton bcf2cfbdc5 Remove the eSymbolTypeFunction, eSymbolTypeGlobal, and eSymbolTypeStatic.
They will now be represented as:
eSymbolTypeFunction: eSymbolTypeCode with IsDebug() == true
  eSymbolTypeGlobal: eSymbolTypeData with IsDebug() == true and IsExternal() == true
  eSymbolTypeStatic: eSymbolTypeData with IsDebug() == true and IsExternal() == false

This simplifies the logic when dealing with symbols and allows for symbols
to be coalesced into a single symbol most of the time.

Enabled the minimal symbol table for mach-o again after working out all the
kinks. We now get nice concise symbol tables and debugging with DWARF in the
.o files with a debug map in the binary works well again. There were issues
where the SymbolFileDWARFDebugMap symbol file parser was using symbol IDs and
symbol indexes interchangeably. Now that all those issues are resolved 
debugging is working nicely.

llvm-svn: 113678
2010-09-11 03:13:28 +00:00
Johnny Chen 4550154d31 Fixed some comments.
llvm-svn: 113673
2010-09-11 00:23:59 +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
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 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
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
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 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
Chris Lattner 311adf3d5b eliminate some clang warnings.
llvm-svn: 113438
2010-09-08 23:01:14 +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
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
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 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
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
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