Commit Graph

693 Commits

Author SHA1 Message Date
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
Johnny Chen ce65073696 Fixed wrong doc strings from cut-and-paste.
llvm-svn: 114120
2010-09-16 21:01:39 +00:00
Johnny Chen 6c17c0807e Added a simple test case to set breakpoints on objc class/instance methods.
Modified Makefile.rules to allow for overwriting the ARCH make variable.

llvm-svn: 114118
2010-09-16 20:54:06 +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 2fcc0e5555 Added a test case for the settings command which sets process.output-path and
checks that the launched process writes its standard output there.

llvm-svn: 114102
2010-09-16 18:26:06 +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
Johnny Chen df80a4cf25 Cleaned up the option processing logic and added a '-i' option to ignore the
build tree relative search path in order to locate the lldb.py module.  When
'-i' is present, the test driver relies on the PYTHONPATH environment variable
to locate the lldb.py module.

llvm-svn: 114094
2010-09-16 17:11:30 +00:00
Greg Clayton f94bddcc82 Added default more aliases to ease gdb converts:
"b" is now aliased to "regexp-break"
"p" is now aliased to "frame variable"
"print" is now aliased to "frame variable"

llvm-svn: 114092
2010-09-16 17:09:23 +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
Johnny Chen e9a1ef700b Added some comments.
llvm-svn: 114081
2010-09-16 15:44:23 +00:00
Johnny Chen 1a9f4dd5a0 Provided a mechanism for the test class to cleanup after itself once it's done.
This will remove the confusion experienced when previous test runs left some
files (both intermediate or by-product as a result of the test).

lldbtest.TestBase defines a classmethod tearDownClass(cls) which invokes the
platform-specific cleanup() function as defined by the plugin; after that, it
invokes a subclass-specific function classCleanup(cls) if defined; and, finally,
it restores the old working directory.

An example of classCleanup(cls) is in settings/TestSettings.py:

    @classmethod
    def classCleanup(cls):
        system(["/bin/sh", "-c", "rm output.txt"])

where it deletes the by-product "output.txt" as a result of running a.out.

llvm-svn: 114058
2010-09-16 01:53:04 +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
Johnny Chen f7f627104b Simplied main() and emits a message to the standard out.
llvm-svn: 114033
2010-09-15 22:48:40 +00:00
Johnny Chen d5e111c2c1 Added two test cases to TestSettings.py which exercise the lldb's:
(lldb) settings set process.run-args A B C
(lldb) settings set process.env-vars ["MY_ENV_VAR"]=YES

commands.  The main.cpp checks whether A, B, C is passed to main and whether
the $MY_ENV_VAR env variable is defined and outputs the findings to a file.

llvm-svn: 114031
2010-09-15 22:27:29 +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
Johnny Chen 73982b94e3 Also added BuildAndIntegration to the directories to search for an existing
lldb.py module.  The priorities to search for are Debug, Release, then
BuildAndIntegration.  You can always override this with a valid PYTHONPATH
environment variable before running the test driver.

For example:

$ PYTHONPATH=/Find/My/LLDB/Module/Here ./dotest.py -v .

Python runtime will try to locate the lldb.py module from
/Find/My/LLDB/Module/Here first before trying the Debug, Release, and then
BuildAndIntegration directories.

llvm-svn: 113991
2010-09-15 18:11:19 +00:00
Johnny Chen 9fa032173a Changed to a more informative message.
llvm-svn: 113989
2010-09-15 18:00:19 +00:00
Johnny Chen f7f0cabe9f We believed the intermittent process launch failure while running the test suite
has been fixed by r113947.  But just in case it still fails, emits a prominent
message always.

llvm-svn: 113986
2010-09-15 17:33:57 +00:00
Johnny Chen bce48fb06f Removed the @expectedFailure decorator for test_with_dwarf() test case. It has
been fixed.

llvm-svn: 113981
2010-09-15 16:59:20 +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 86c3f345c6 Fixed a race condition that was sometimes stopping our command line
interpreter from working. The communication read thread could
startup and immediately exit if m_read_thread_enabled was
checked in the thread function before it was set by the
thread that spawns the read thread. Now m_read_thread_enabled is set
to true prior to spawning the read thread to avoid this issue.

Hopefully this will clear up the sporatic failures in our test suite.

llvm-svn: 113947
2010-09-15 05:19:45 +00:00
Greg Clayton c685f8e540 So we can't use .debug_pubtypes as it, as designed, does not tell us about
all types in all compile units. I added a new kind of accelerator table to
the DWARF that allows us to index the DWARF compile units and DIEs in a way
that doesn't require the data to stay loaded. Currently when indexing the
DWARF we check if the compile unit had parsed its DIEs and if it hasn't we
index the data and free all of the DIEs so we can reparse later when we need
to after using one of our complete accelerator tables to determine we need
to reparse some DWARF. If the DIEs had already been parsed we leave them 
loaded. The new accelerator table uses the "const char *" pointers from our
ConstString class as the keys, and NameToDIE::Info as the value. This info
contains the compile unit index and the DIE index which means we are pointed
right to the DIE we need unlike the other DWARF accelerator tables that often
just point us to the compile unit we would find our answer in. 

llvm-svn: 113933
2010-09-15 04:15:46 +00:00
Jim Ingham 3a0b9cdf47 If you have already loaded a file into the debugger, "process attach" will attach to a process with the filename, unless you specify otherwise.
llvm-svn: 113916
2010-09-15 01:34:14 +00:00
Jim Ingham 89bf5e9105 The Mangled name comparision should prefer the mangled name.
llvm-svn: 113908
2010-09-15 00:13:44 +00:00
Jim Ingham af0f17596c Adding a bit more logging.
llvm-svn: 113907
2010-09-15 00:06:51 +00:00
Johnny Chen 93f336a203 Fixed typo in the doc strings.
llvm-svn: 113906
2010-09-15 00:02:30 +00:00
Johnny Chen ae74556ff6 Added two test cases to exercise 'expr this->m_c_int' with @expectedFailure
decorators for the time being.

llvm-svn: 113905
2010-09-15 00:00:54 +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
Johnny Chen 32a7044a84 Updated to add a printf() stmt.
llvm-svn: 113901
2010-09-14 23:49:44 +00:00
Greg Clayton d0b89f8cc2 Fixed a case where Mangled::GetName(...) could return a invalid demangled name when one could be calculated.
llvm-svn: 113900
2010-09-14 23:48:44 +00:00
Greg Clayton 8742543591 Fixed a compiler warning.
llvm-svn: 113899
2010-09-14 23:44:49 +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
Johnny Chen 1d8ab8a26b Test order file with both dsym and dwarf combination.
llvm-svn: 113884
2010-09-14 22:55:48 +00:00
Johnny Chen 6c3f6862cc Need to call self.buildDefault() before running the test logic.
llvm-svn: 113881
2010-09-14 22:50:50 +00:00
Caroline Tice e7e92b771a Remove help text that is no longer correct.
Fix Python script interpreter to not fail when the Debugger does
not have input/output file handles.

llvm-svn: 113880
2010-09-14 22:49:06 +00:00
Johnny Chen e049051e68 More appropriate headings for the traceoutput: stdout & stderr.
llvm-svn: 113879
2010-09-14 22:39:02 +00:00
Johnny Chen d0c40ddfc6 Added logging of an error message in GDBRemoteCommunication::SendPacketNoLock()
if sending of the packet fails for any reason.

llvm-svn: 113874
2010-09-14 22:10:43 +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
Johnny Chen 1aad5c61f8 Removed the expectedFailure decorator from test_with_dwarf_and_run_command() test case
as it now passes.  Added some extra tests to breakpoint_creation_by_filespec_python().

More clarification for the "os command" output and error as defined in
lldbtest.system() function.

Cleaned up the option processing of the test driver (dotest.py) and fixed the comment
about enabling gdb-remote logging.  Example:

$ GDB_REMOTE_LOG=/tmp/log.txt ./dotest.py -v -t enum_types

llvm-svn: 113868
2010-09-14 22:01:40 +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 95112df653 Fixed display for long double and cleaned up float and doubles as well.
llvm-svn: 113832
2010-09-14 04:09:57 +00:00
Greg Clayton a52c155e01 Fixed an issue that was always causing an extra empty argument to be sent
to any inferior process because the code was checking if no run args were
set and then adding and empty string. This was happening for environment
vars as well.

llvm-svn: 113831
2010-09-14 03:47:41 +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
Johnny Chen c13ee52c2f Fixed an error in Debugger::UpdateExecutionContext() where an invalid index ID 0
was used to set the selected thread if none was selected.  Use a more robust
API to accomplish the task.

Also fixed an error found, while investigating, in CommandObjectThreadSelect::
Execute() where the return status was not properly set if successful.

As a result, both the stl step-in test cases with expectedFailure decorators now
passed.

llvm-svn: 113825
2010-09-14 00:53:53 +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
Johnny Chen 1394a4b715 Extend the build mechanism to allow for specifying the compiler used to build
the binaries.

If the build* function is passed the compiler argument, for example, 'llvm-gcc',
it is passed as a make variable to the make command.  Otherwise, we check the
LLDB_CC environment variable; if it is defined, it is passed as a make variable
to the make command.

If neither the compiler keyword argument nor the LLDB_CC environment variable is
specified, no CC make variable is passed to the make command.  The Makefile gets
to define the default CC being used.

--------------------------------------------------------------------------------
Example usage follows:

o Via the keyword argument:

class ArrayTypesTestCase(TestBase):

    mydir = "array_types"

    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    def test_with_dsym_and_run_command(self):
        """Test 'frame variable var_name' on some variables with array types."""
        self.buildDsym(compiler='llvm-gcc')
        self.array_types()
...

o Via LLDB_CC environment variable:

$ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types
----------------------------------------------------------------------
Collected 4 tests

test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... 
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']]
output: rm -rf "a.out" "a.out.dSYM"  main.o main.d
llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0  -c -o main.o main.c
llvm-gcc -arch x86_64 -gdwarf-2 -O0  main.o -o "a.out"
/usr/bin/dsymutil  -o "a.out.dSYM" "a.out"

...

llvm-svn: 113781
2010-09-13 20:54:30 +00:00
Johnny Chen 9440d1c008 Updated the expected matching strings.
llvm-svn: 113756
2010-09-13 16:59:11 +00:00
Johnny Chen 661f8069c7 Updated the expected matching strings.
llvm-svn: 113755
2010-09-13 16:45:59 +00:00
Johnny Chen 8458405a36 Updated the expected matching strings, and added a radar comment.
llvm-svn: 113753
2010-09-13 16:31:46 +00:00
Johnny Chen e00234e0c7 Updated the expected matching strings.
llvm-svn: 113751
2010-09-13 16:19:09 +00:00
Johnny Chen eb1b8dabc0 Removed the two expectedFailure decorators from the test cases. They have been fixed.
llvm-svn: 113750
2010-09-13 16:14:55 +00:00
Johnny Chen 9aae728ef6 Updated the expected matching string after the recent flurry of check ins.
llvm-svn: 113748
2010-09-13 16:06:19 +00:00
Caroline Tice 8830091a1a Clean up help text.
llvm-svn: 113738
2010-09-13 05:27:16 +00:00
Greg Clayton ffc1d6672d Fixed an assertion that happened when debugging DWARF in .o files with debug
map on macosx.

llvm-svn: 113737
2010-09-13 04:34:30 +00:00
Greg Clayton 9df87c1706 Make sure we have a variable list so we don't crash when a frame has no
frame variables.

llvm-svn: 113736
2010-09-13 03:44:33 +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 5804fa4152 Removed unused variable.
llvm-svn: 113734
2010-09-13 02:54:20 +00:00
Greg Clayton a134cc1bf8 Added a work in the DWARF parser when we parse an array that ends up having
no elements so that they at least have 1 element. 

Added the ability to show the declaration location of variables to the 
"frame variables" with the "--show-declaration" option ("-c" for short).

Changed the "frame variables" command over to use the value object code
so that we use the same code path as the public API does when accessing and
displaying variable values.

llvm-svn: 113733
2010-09-13 02:37:44 +00:00
Greg Clayton 0c5550a998 A few modifications to the class arrays test case.
llvm-svn: 113732
2010-09-13 02:31:18 +00:00
Greg Clayton ac32b4ddc0 I made this example after noting that I was unable to display an unsized
static class array. It turns out that gcc 4.2 will emit DWARF that correctly
describes the PointType, but it will incorrectly emit debug info for the
"g_points" array where the following things are wrong:
 - the DW_TAG_array_type won't have a subrange info
 - the DW_TAG_variable for "g_points" won't have a valid byte size, so even
   though we know the size of PointType, we can't infer the actual size
   of the array by dividing the size of the variable by the number of
   elements.

We want to make sure clang and llvm-gcc handle this correctly.

llvm-svn: 113730
2010-09-13 00:50:27 +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
Greg Clayton 0c38b0deb8 Fixed an issue I found in the mach-o symbol table parsing where
we cached remapping information using the old nlist index to the
new symbol index, yet we tried to lookup the symbol stubs that
were for symbols that had been remapped by ID instead of using
the new symbol index. This is now fixed and the mach-o symbol tables
are fixed.

Use the delta between two vector entries to determine the stride
in case any padding is inserted by compilers for bsearch calls
on symbol tables when finding symbols by their original ID.

llvm-svn: 113719
2010-09-12 05:25:16 +00:00
Caroline Tice 86ddae50f6 Add 'unalias' to the commands sub-command dictionary.
llvm-svn: 113715
2010-09-12 04:56:10 +00:00
Caroline Tice 5172e6c35a Add missing result.SetStatus, to allow aliases to be created with
missing arguments for some of the command options.

llvm-svn: 113714
2010-09-12 04:48:45 +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
Jason Molenda 8f22a243b7 Minor copy edits.
llvm-svn: 113674
2010-09-11 00:37:21 +00:00
Johnny Chen 4550154d31 Fixed some comments.
llvm-svn: 113673
2010-09-11 00:23:59 +00:00
Johnny Chen 39d7d4f056 Added [-o <one-liner>] to the "breakpoint command add" lldb command to be able
to specify a one-liner (either scripting or lldb command) inline.

Refactored CommandObjectBreakpointCommandAdd::Execute() a little bit and added
some comments.

Sn now, we use:

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

to specify a Python one-liner as the callback for breakpoint #1.

llvm-svn: 113672
2010-09-11 00:18:09 +00:00
Jim Ingham a4601b6496 Don't use lldb syntax in the gdb examples...
llvm-svn: 113669
2010-09-11 00:03:03 +00:00
Jim Ingham bc7d7c8119 Few clarifications.
llvm-svn: 113661
2010-09-10 23:12:45 +00:00
Jim Ingham 53c47f1e2f Move the "Object Description" into the ValueObject, and the add an API to
SBValue to access it.  For now this is just the result of ObjC NSPrintForDebugger,
but could be extended.  Also store the results of the ObjC Object Printer in a
Stream, not a ConstString.

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

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

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

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

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

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

The ScriptInterpreter interface has an extra method:

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

to accomplish the above.

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

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

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

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

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

The ObjectFile class now has an UnwindTable object.

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

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

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

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

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

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

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

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

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

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

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

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

llvm-svn: 113496
2010-09-09 16:44:14 +00:00