Commit Graph

628 Commits

Author SHA1 Message Date
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
Caroline Tice 3df9a8dfd7 This is a very large commit that completely re-does the way lldb
handles user settable internal variables (the equivalent of set/show
variables in gdb).  In addition to the basic infrastructure (most of
which is defined in UserSettingsController.{h,cpp}, there are examples
of two classes that have been set up to contain user settable
variables (the Debugger and Process classes).  The 'settings' command
has been modified to be a command-subcommand structure, and the 'set',
'show' and 'append' commands have been moved into this sub-commabnd
structure.  The old StateVariable class has been completely replaced
by this, and the state variable dictionary has been removed from the
Command Interpreter.  Places that formerly accessed the state variable
mechanism have been modified to access the variables in this new
structure instead (checking the term-width; getting/checking the
prompt; etc.)

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

llvm-svn: 113041
2010-09-04 00:03:46 +00:00
Greg Clayton e41e58997c Improved name demangling performance by 20% on darwin.
llvm-svn: 113032
2010-09-03 23:26:12 +00:00
Greg Clayton 2cad65a595 Fixed the StackFrame to correctly resolve the StackID's SymbolContextScope.
Added extra logging for stepping.

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

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

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

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

llvm-svn: 112867
2010-09-02 21:44:10 +00:00
Greg Clayton 288bdf9c1d StackFrame objects now own ValueObjects for any frame variables (locals, args,
function statics, file globals and static variables) that a frame contains. 
The StackFrame objects can give out ValueObjects instances for
each variable which allows us to track when a variable changes and doesn't
depend on variable names when getting value objects.

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

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

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

llvm-svn: 112785
2010-09-02 00:37:32 +00:00
Sean Callanan 63c2f65ffc Fixed a comment.
llvm-svn: 112725
2010-09-01 19:04:01 +00:00
Sean Callanan 6961e87847 Added support for dynamic sanity checking in
expressions.  Values used by the expression are
checked by validation functions which cause the
program to crash if the values are unsafe.

Major changes:

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

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

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

llvm-svn: 112690
2010-09-01 00:58:00 +00:00
Greg Clayton f681b94f90 Added the ability to disable ASLR (Address Space Layout Randomization). ASLR
is disabled by default, and can be enabled using:

(lldb) set disable-aslr 0

llvm-svn: 112616
2010-08-31 18:35:14 +00:00
Jim Ingham b4dcbaeec2 Add a "lldb host" logging channel, and put logging in the Host::OpenInExternalEditor code.
llvm-svn: 112614
2010-08-31 18:05:13 +00:00
Sean Callanan f912a8e568 Removed documentation for a non-existent function
parameter.

llvm-svn: 112548
2010-08-30 23:10:43 +00:00
Sean Callanan 823bb4cc24 Fixed a bug where the parser-specific members of
persistent variables were staying around too long.
This caused the following problem:

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

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

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

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

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

Also improved some logging as I diagnosed the
bug.

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

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

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

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

llvm-svn: 112495
2010-08-30 18:11:35 +00:00
Sean Callanan e71d553cd4 Added a ClangUtilityFunction class that allows the
debugger to insert self-contained functions for use by
expressions (mainly for error-checking).

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

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

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

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

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

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

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

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

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

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

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

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

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

Side effects include:

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

- the header file for ClangFunction is now fully
  documented,

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

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

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

llvm-svn: 112249
2010-08-27 01:01:44 +00:00
Greg Clayton 12fc3e0f3e Changed the StackID to store its start PC address as a load address instead of
a section offset address.

Fixed up some very inefficient STL code.

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

llvm-svn: 112152
2010-08-26 02:28:22 +00:00
Greg Clayton a45533defa The destructor for StackFrameList doesn't need to be virtual as we aren't
subclassing it anywhere.

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

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

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

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

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

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

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

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

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

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

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

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

A quick example:

% cat main.cpp

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

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

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

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

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

llvm-svn: 111706
2010-08-21 02:22:51 +00:00
Jim Ingham 64b931c1e1 Add an accessor to get the Declaration for a type.
llvm-svn: 111607
2010-08-20 01:15:38 +00:00
Jim Ingham 9976033698 Add methods to Function to get the first and last source lines of the function, and to get whether this Function is an inlined instance or not.
llvm-svn: 111606
2010-08-20 01:15:01 +00:00
Sean Callanan d0ef0eff61 First step of refactoring variable handling in the
expression parser.  There shouldn't be four separate
classes encapsulating a variable.

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

ClangPersistentVariable has been removed; we now
use ClangExpressionVariable instead.

llvm-svn: 111600
2010-08-20 01:02:30 +00:00
Sean Callanan eaacbc9da6 Patch by Bill Lynch fixing handling of the pid
in the IR transformation passes.

llvm-svn: 111388
2010-08-18 18:50:51 +00:00
Greg Clayton 52d64d9ea9 Added a Thread accessor to the register context.
llvm-svn: 111378
2010-08-18 18:25:47 +00:00
Greg Clayton ddfda9d7a2 Allow the SBDebugger to construct itself with the default constructor so
objects can own one of these objects and assign a valid value at a later point.

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

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

llvm-svn: 111323
2010-08-17 23:18:59 +00:00
Sean Callanan f346a3dd68 Documented IRForTarget
llvm-svn: 111313
2010-08-17 22:36:13 +00:00
Sean Callanan 2cdbc722fc Documented DWARFExpression.
llvm-svn: 111276
2010-08-17 20:24:29 +00:00
Sean Callanan 6dce6de80c Documented ClangResultSynthesizer and added very minor
API fixes.

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

llvm-svn: 111194
2010-08-16 22:14:59 +00:00
Sean Callanan df4581f1c5 Documented ClangExpressionVariable(List), and
cleaned up its API slightly.

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

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

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

llvm-svn: 110980
2010-08-12 23:45:38 +00:00
Sean Callanan 384cae6e06 Fixed copyright notice on ClangASTSource.h.
llvm-svn: 110977
2010-08-12 23:08:37 +00:00
Sean Callanan 35053747cc Removed the ClangStmtVisitor, which is old code
that translates Clang ASTs straight to DWARF.  We
are now using IR instead.

llvm-svn: 110957
2010-08-12 21:29:03 +00:00
Johnny Chen 03b5a8a9ab Applied Pawel Wodnicki's fix for "missing" lldb-forward-rtti.h header file.
llvm-svn: 110943
2010-08-12 19:42:59 +00:00
Jim Ingham 87c1191e0e Now that we are using the Unwinder (or Jason's new unwinder when that comes about) all the plugin-specific details of getting stack frames
should be hidden behind that, and the "GetStackFrameAtIndex" and "GetStackFrameCount" algorithms become generic.  So I moved them to Thread.cpp.

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

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

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

llvm-svn: 110896
2010-08-12 01:56:52 +00:00
Sean Callanan 2235f32bbd Added support for persistent variables to the
expression parser.  It is now possible to type:

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

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

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

llvm-svn: 110777
2010-08-11 03:57:18 +00:00
Jim Ingham 3ebcf7f09b Make breakpoint commands work again. Added a PerformAction to the stop info - actions are run when the
stop event is pulled from the event queue.  Then made the StopInfoBreakpoint's PerformAction do the 
breakpoint command.
Also fixed the StopInfoBreakpoint's GetDescription so it gets the breakpoint location info, not the breakpoint
site info.

llvm-svn: 110637
2010-08-10 00:59:59 +00:00
Jim Ingham 5aee162f97 Change Target & Process so they can really be initialized with an invalid architecture.
Arrange that this then gets properly set on attach, or when a "file" is set.
Add a completer for "process attach -n".

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

llvm-svn: 110624
2010-08-09 23:31:02 +00:00
Sean Callanan fc16cc0a0c Removed the -i option from the expr command, and
made IR-based expression evaluation the default.

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

llvm-svn: 110415
2010-08-06 00:35:32 +00:00
Sean Callanan c503e784c7 Fixed namespace issues that were breaking the
SWIG wrappers on a non-internal SnowLeopard
system.

llvm-svn: 110413
2010-08-06 00:33:35 +00:00
Greg Clayton c86103d4d6 More missing files from my previous checkin.
llvm-svn: 110299
2010-08-05 01:57:25 +00:00
Greg Clayton 7620000aa6 Added functionality to our API for SBType. This will allow users to eventually find and peruse static type information from modules.
llvm-svn: 110298
2010-08-05 01:56:48 +00:00
Greg Clayton ba9fbbb880 Added functionality to our API for SBType. This will allow users to eventually find and peruse static type information from modules.
llvm-svn: 110297
2010-08-05 01:56:31 +00:00
Greg Clayton f4b47e1579 Abtracted the old "lldb_private::Thread::StopInfo" into an abtract class.
This will allow debugger plug-ins to make any instance of "lldb_private::StopInfo"
that can completely describe any stop reason. It also provides a framework for
doing intelligent things with the stop info at important times in the lifetime
of the inferior. 

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


StopInfo subclasses must override the following functions:

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

    virtual const char *
    GetDescription () = 0;


StopInfo subclasses can override the following functions:


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

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

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


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

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

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

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

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

    image lookup --type <TYPENAME>

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

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

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

Updated to latest LLVM to get a few needed fixes.

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

Also documented things maybe a bit better.

llvm-svn: 109938
2010-07-31 01:32:05 +00:00
Johnny Chen 7dc2e4784e We can do better when reporting the status of one-liner script execution.
Change the prototype of ScriptInterpreter::ExecuteOneLine() to return bool
instead of void and take one additional parameter as CommandReturnObject *.

Propagate the status of one-liner execution back appropriately.

llvm-svn: 109899
2010-07-30 22:33:14 +00:00
Greg Clayton 48e4254989 Added "void Clear();" methods to SBDebugger, SBTarget and SBThread so they can release their shared pointers.
llvm-svn: 109882
2010-07-30 20:12:55 +00:00
Greg Clayton 9e40956aea Created lldb::LanguageType by moving an enumeration from the
lldb_private::Language class into the enumerations header so it can be freely
used by other interfaces.

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

llvm-svn: 109574
2010-07-28 02:04:09 +00:00
Sean Callanan cc54bd3cef Added and improved logging. This is helping us as we
diagnose a problem where we're not correctly emitting
PIC code.

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

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

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

Rewrote the clients of SymbolContext to use this
SymbolContextList.

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

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

llvm-svn: 109476
2010-07-27 00:55:47 +00:00
Sean Callanan ddb46efcca Updated the IR converter for the target to eliminate
spurious guard variables on expression statics.

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

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

llvm-svn: 109317
2010-07-24 01:37:44 +00:00
Greg Clayton 9fed0d85b2 Added needed breakpoint functionality to the public API that includes:
SBTarget:
    - get breakpoint count
    - get breakpoint at index
  SBBreakpoint:
    - Extract data from breakpoint events

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

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

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

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

llvm-svn: 109239
2010-07-23 17:42:15 +00:00
Greg Clayton 896dff661a Centralized the Mach exception stop info code by adding it as a first
class citizen on the StopInfo class. 

llvm-svn: 109235
2010-07-23 16:45:51 +00:00
Greg Clayton 19503a2a78 Warnings cleanup patch from Jean-Daniel Dupas.
llvm-svn: 109226
2010-07-23 15:37:46 +00:00
Sean Callanan 6dde30e964 Added extensive logging of the code that is actually going
to be executed by the inferior.  This required explicit support
from RecordingMemoryManager for finding the address range
belonging to a particular function.

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

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

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

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

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

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

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

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

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

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

llvm-svn: 109046
2010-07-21 22:12:05 +00:00
Greg Clayton 8c920840a4 Add new SectionType enumerations for all DWARF sections. ObjectFile parsers should start properly setting the section types for DWARF sections, then we can move the DWARF SymbolFile parser over to finding the sections by the appropriate SectionType.
llvm-svn: 109041
2010-07-21 21:51:36 +00:00
Greg Clayton 70e33eb06e Allow searching for a section by SectionType.
llvm-svn: 109040
2010-07-21 21:49:46 +00:00
Sean Callanan b3706e6dd2 Whoops, forgot to guard ASTType.h. Fixed.
llvm-svn: 108970
2010-07-20 23:53:01 +00:00
Sean Callanan 1d18066411 Added functionality to dematerialize values that were
used by the JIT compiled expression, including the
result of the expression.

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

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

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

llvm-svn: 108957
2010-07-20 22:52:08 +00:00
Stephen Wilson 645767aeca Add missing include.
llvm-svn: 108878
2010-07-20 18:40:23 +00:00
Stephen Wilson 50bd94f961 Have Process::CreateBreakpointSite return a break_id_t instead of a user_id_t.
Also, update BreakpointLocation::ResolveBreakpointSite to check for invalid
breakpoint ID's using the proper magic constant.

llvm-svn: 108598
2010-07-17 00:56:13 +00:00
Sean Callanan 6b4067c14e Added the necessary code to copy variables used by
an expression into the struct prepared for the JIT
compiled code to use.

llvm-svn: 108596
2010-07-17 00:43:37 +00:00
Sean Callanan ea22d4288a Wrote the code that looks at a context to see
if the variables in that context allow a particular
JIT compiled expression to run in that context.

llvm-svn: 108485
2010-07-16 00:09:46 +00:00
Sean Callanan 4dcca262f4 Added a function to test whether two types are
the same.

llvm-svn: 108467
2010-07-15 22:30:52 +00:00
Greg Clayton b132097b45 I enabled some extra warnings for hidden local variables and for hidden
virtual functions and caught some things and did some general code cleanup.

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

llvm-svn: 108279
2010-07-13 21:41:46 +00:00
Jim Ingham a56c800607 Add an "Avoid Frames matching this regular expression" to ThreadPlanStepInRange.
This relies on ThreadPlanStepOut working correctly, which it doesn't currently for Inlined functions, so this feature is only partially useful until we take care of Stepping Out of inlined functions.
Added an option to "thread step-in" to set the avoid regular expression.  This is mostly for testing, once the Setting code is redone, we'll move this to a general setting.

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

llvm-svn: 108009
2010-07-09 20:39:50 +00:00