Commit Graph

788 Commits

Author SHA1 Message Date
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
Greg Clayton 6f35f5cf5d Got the ARM version of debugserver up to date.
Renamed the "dispatchqaddr" setting that was coming back for stop reply packets
to be named "qaddr" so that gdb doesn't thing it is a register number. gdb
was checking the first character and assuming "di" was a hex register number
because 'd' is a hex digit. It has been shortened so gdb can safely ignore it.

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

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

            import lldbutil
            lldbutil.PrintStackTrace(thread)

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

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

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

OK

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Added an accessor the StackFrame:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Modified the test cases to take advantage of the refactoring.

llvm-svn: 112863
2010-09-02 21:23:12 +00:00
Johnny Chen 979e796692 (query-replace "variable list" "frame variable")
llvm-svn: 112824
2010-09-02 15:59:20 +00:00
Greg Clayton 288bdf9c1d StackFrame objects now own ValueObjects for any frame variables (locals, args,
function statics, file globals and static variables) that a frame contains. 
The StackFrame objects can give out ValueObjects instances for
each variable which allows us to track when a variable changes and doesn't
depend on variable names when getting value objects.

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

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

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

llvm-svn: 112785
2010-09-02 00:37:32 +00:00
Jim Ingham 6d56d2ce84 Move "variable list" to "frame variable"
llvm-svn: 112782
2010-09-02 00:18:39 +00:00
Johnny Chen b92555c334 Fixed comment.
llvm-svn: 112750
2010-09-01 22:10:09 +00:00
Johnny Chen 13639089c6 Put the little dances done after SBTarget.LaunchProcess() into the base class.
llvm-svn: 112749
2010-09-01 22:08:51 +00:00
Johnny Chen cbb4be0c93 Changed the test case class names to be noun-like instead of verb-like.
llvm-svn: 112732
2010-09-01 19:59:58 +00:00
Jim Ingham 91b9383b76 Stream::Printf doesn't add a newline, so it needs to be added to all the error messages in CommandObjectExpression::EvaluateExpression.
llvm-svn: 112731
2010-09-01 19:53:33 +00:00
Sean Callanan 63c2f65ffc Fixed a comment.
llvm-svn: 112725
2010-09-01 19:04:01 +00:00
Sean Callanan 6961e87847 Added support for dynamic sanity checking in
expressions.  Values used by the expression are
checked by validation functions which cause the
program to crash if the values are unsafe.

Major changes:

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

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

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

llvm-svn: 112690
2010-09-01 00:58:00 +00:00
Johnny Chen db3d874351 Updated to add plugins directory to PYTHONPATH.
llvm-svn: 112688
2010-09-01 00:55:36 +00:00
Johnny Chen 63dfb27647 Avoid killing the inferior process twice by passing a setCookie=False keyword
argument when issuing a "run" lldb command within the test case meant to
exercise the Python APIs, but is using the command interface due to certain
reason (such as target.LaunchProcess() does not reliably bring up the inferior).

llvm-svn: 112682
2010-09-01 00:15:19 +00:00
Jim Ingham 680e177833 Don't re-look up the symbol in ResolveSymbolContextForAddress.
llvm-svn: 112679
2010-08-31 23:51:36 +00:00
Johnny Chen 11c34a0488 Converted TestDeadStrip.py to Dsym/Dwarf combination.
llvm-svn: 112670
2010-08-31 23:12:15 +00:00
Johnny Chen 9129998061 Converted TestClassTypes.py to Dsym/Dwarf combination. Marked one test case as
expectedFailure because in dwarf format, "variable list this" returns an error.

llvm-svn: 112660
2010-08-31 22:26:16 +00:00
Johnny Chen 65a6524d00 Converted TestBitfields.py to Dsym/Dwarf combination.
llvm-svn: 112646
2010-08-31 21:49:24 +00:00
Greg Clayton bda8065107 Cleaned up my previous submission which had some header search paths that
were not needed and fixed a merge issue.

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

(lldb) set disable-aslr 0

llvm-svn: 112616
2010-08-31 18:35:14 +00:00
Jim Ingham b4dcbaeec2 Add a "lldb host" logging channel, and put logging in the Host::OpenInExternalEditor code.
llvm-svn: 112614
2010-08-31 18:05:13 +00:00
Johnny Chen 517210b0f3 Updated to reflect the "plugins" directory.
llvm-svn: 112607
2010-08-31 17:51:08 +00:00
Johnny Chen 8d55a34a34 Changed the buildDsym()/buildDwarf() TestBase methods to use a plugin framework
to delegate the building of binaries to a sys.platform-sepcific plugin.

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

darwin.py is the Mac OS X plugin module.

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

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

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

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

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

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

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

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

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

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

Also improved some logging as I diagnosed the
bug.

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

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

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

o test_with_dsym_and_run_command
o test_with_dwarf_and_process_launch_api

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

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

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

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

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

llvm-svn: 112495
2010-08-30 18:11:35 +00:00
Greg Clayton 73b953bc1f Detect when ValueObject values change each time they are evaluated.
llvm-svn: 112331
2010-08-28 00:08:07 +00:00
Johnny Chen 269457515a Fail early, fail fast.
llvm-svn: 112328
2010-08-27 23:53:00 +00:00
Johnny Chen 5ee881948a Added a test case test_breakpoint_creation_by_filespec_python() which creates a
breakpoint by FileSpec and line number and exercises some FileSpec APIs.

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

llvm-svn: 112327
2010-08-27 23:47:36 +00:00
Sean Callanan e71d553cd4 Added a ClangUtilityFunction class that allows the
debugger to insert self-contained functions for use by
expressions (mainly for error-checking).

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

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

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

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

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

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

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

llvm-svn: 112277
2010-08-27 18:24:16 +00:00
Johnny Chen 82d404c886 Added TestHelloWorld.py which exercises the Python APIs for target, breakpoint,
and process.  Added comment within the file about issues of using LaunchProcess
of SBTarget to launch a process (rdar://problem/8364687).

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

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

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

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

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

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

Side effects include:

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

- the header file for ClangFunction is now fully
  documented,

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

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

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

llvm-svn: 112249
2010-08-27 01:01:44 +00:00