Commit Graph

951 Commits

Author SHA1 Message Date
Caroline Tice dc8f777f6b Prevent Python script interpreter initialization from changing
the termios settings on the debugger's input handle.

llvm-svn: 116725
2010-10-18 18:24:17 +00:00
Johnny Chen 3e9c50c7c0 Add a case to test that after 'set auto-confirm true', manual confirmation should not kick in.
Also add a more useful assert message for test_set_output_path(), which is currently decorated
with @expectedFailure.

llvm-svn: 116718
2010-10-18 17:51:45 +00:00
Johnny Chen 8b6b189422 Also change the utility functions in lldbutil.py, too, to correspond to the StateType representation change.
llvm-svn: 116706
2010-10-18 15:46:54 +00:00
Johnny Chen 0c724effb8 The StateType representation has been changed. Modify the test cases to accommodate.
llvm-svn: 116705
2010-10-18 15:44:42 +00:00
Greg Clayton 58d1c9a44f Still trying to get detach to work with debugserver. Got a bit closer,
but something is still killing our inferior.

Fixed an issue with darwin-debug where it wasn't passing all needed arguments
to the inferior.

Fixed a race condition with the attach to named process code.

llvm-svn: 116697
2010-10-18 04:14:23 +00:00
Greg Clayton 19388cfc6e Fixed debugserver to properly attach to a process by name with the
"vAttachName;<PROCNAME>" packet, and wait for a new process by name to launch 
with the "vAttachWait;<PROCNAME>".

Fixed a few issues with attaching where if DoAttach() returned no error, yet
there was no valid process ID, we would deadlock waiting for an event that
would never happen.

Added a new "process launch" option "--tty" that will launch the process 
in a new terminal if the Host layer supports the "Host::LaunchInNewTerminal(...)"
function. This currently works on MacOSX and will allow the debugging of 
terminal applications that do complex operations with the terminal. 

Cleaned up the output when the process resumes, stops and halts to be 
consistent with the output format.

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

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

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

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

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

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

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

llvm-svn: 116690
2010-10-17 22:03:32 +00:00
Greg Clayton d59cea2d23 prefix more stuff with '$' to make sure we don't go trying to lookup anything
we don't need to.

llvm-svn: 116676
2010-10-16 21:09:32 +00:00
Greg Clayton 556658c79e Fixed an issue with MachTask::TaskResume () where if the task was already
suspended, we would call "int ::task_resume (task_t task);" as many times as
it took to resume the task which isn't what we want to do.

llvm-svn: 116674
2010-10-16 18:11:41 +00:00
Johnny Chen 24d6ea25f8 Missed this spot where module.cleanup() can be passed a test instance to
facilitate session recording.  This happens inside an instance method where the
test instance is well known.

llvm-svn: 116649
2010-10-16 00:08:49 +00:00
Johnny Chen 690fcef762 Some re-achitecturing of the plugins interface. The caller is now required to
pass in a 'sender' arg to the buildDefault(), buildDsym(), buildDwarf(), and
cleanup() functions.  The sender arg will be the test instance itself (i.e.,
an instance of TestBase).  This is so that the relevant command execution can be
recorded in the TestBase.session object if sender is available.

The lldbtest.system() command has been modified to pop the 'sender' arg out of
the keyword arguments dictionary and use it as the test instance to facilitate
seesion recordings.  An example is in test/types/AbstractBase.py:

    def generic_type_tester(self, atoms, quotedDisplay=False):
        """Test that variables with basic types are displayed correctly."""

        # First, capture the golden output emitted by the oracle, i.e., the
        # series of printf statements.
        go = system("./a.out", sender=self)

There are cases when sender is None.  This is the case when the @classmethod is
involved in the use of these APIs.  When this happens, there is no recording
into a session object, but printing on the sys.stderr is still honored if the
trace flag is ON.

An example is in test/settings/TestSettings.py:

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

llvm-svn: 116648
2010-10-15 23:55:05 +00:00
Johnny Chen ad5f98a9b2 Use line_number() utility function to find the number from main.c to test against
instead of using hard-coded line number.

llvm-svn: 116646
2010-10-15 23:38:15 +00:00
Johnny Chen 2769a42731 Remove the @expectedFailure decorators, as rdar://problem/8542091 is supposed to be fixed.
Also change the expected matching pattern of the 'expr -o -- my' output.

llvm-svn: 116645
2010-10-15 23:35:32 +00:00
Johnny Chen d5d6facc64 Don't wrap StringIO inside a with statement. It is not a context manager.
llvm-svn: 116643
2010-10-15 23:33:18 +00:00
Greg Clayton d5687aea93 Fixed the UnixSignals class to be able to get a signal by name, short name, or signal number when using:
int32_t UnixSignals::GetSignalNumberFromName (const char *name) const;

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

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

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

llvm-svn: 116634
2010-10-15 22:48:33 +00:00
Jim Ingham e2f8841d34 Mark a ValueObjectConstResult as valid if it is created with some data, don't wait till it gets updated.
llvm-svn: 116633
2010-10-15 22:47:36 +00:00
Caroline Tice 43a8c39b9c Disable "process.macosx" plugin, since it is not being actively supported
at the moment, and no longer works properly (bit rot).

llvm-svn: 116626
2010-10-15 21:52:38 +00:00
Johnny Chen 2f66619004 Make sure to close the string buffer when finished.
llvm-svn: 116621
2010-10-15 21:18:07 +00:00
Johnny Chen 7987c6188a Remove the @skip("Skip due to deadlock?") decorators. Change the command to
'breakpoint delete 1' from 'breakpoint delete'.  With 'breakpoint delete', the
command interpreter was asking for a confirmation from the user, which there
isn't any.

llvm-svn: 116610
2010-10-15 19:29:15 +00:00
Johnny Chen 7c2a28eba0 Add two @expectedFailure decorators for:
# rdar://problem/8557478
    # test/class_types test failures: runCmd: expr this->m_c_int

llvm-svn: 116609
2010-10-15 19:06:16 +00:00
Johnny Chen 27b107b800 Add a test case for exercising breakpoint conditions using the lldb command:
breakpoint modify -c 'val == 3' 1

after:

    breakpoint set -n c

which sets a breakpoint on function 'c'.  The breakpoint should only stop if
expression 'val == 3' evaluates to true.

llvm-svn: 116607
2010-10-15 18:52:22 +00:00
Johnny Chen 164f1e18b1 Add a const string for assert message. Remove extra printing of newlines from
the session recordings.

llvm-svn: 116596
2010-10-15 18:07:09 +00:00
Johnny Chen 8f6fca7f30 There's no need to explicitly call lldb.SBDebugger.Initialize() now. It is done
when importing the lldb module.

llvm-svn: 116585
2010-10-15 16:33:17 +00:00
Johnny Chen fd64df4f92 Add more comments.
llvm-svn: 116583
2010-10-15 16:22:10 +00:00
Johnny Chen ab254f5da4 Be more specific about cases whenthe runCmd() check flag is False, meaning there
is no need to check the return status of the command execution, and an error
status is not deemed a failure in the test.

llvm-svn: 116582
2010-10-15 16:13:00 +00:00
Greg Clayton ee4b5dd664 Skip checking for a bunch of built-ins when evaluating an expression.
llvm-svn: 116565
2010-10-15 03:36:13 +00:00
Greg Clayton 9476d957ef Did a bit of parameter renaming.
llvm-svn: 116562
2010-10-15 02:45:05 +00:00
Greg Clayton 8dbc336da9 Added short names and descriptions to the UnixSignals class. Also cleaned up
the code a bit.

llvm-svn: 116561
2010-10-15 02:39:01 +00:00
Johnny Chen 56f7939cdc Simply use the TestBase.markFailure() callback method to set the __failed__ flag.
llvm-svn: 116559
2010-10-15 02:28:13 +00:00
Greg Clayton 69b0488d7a Separated the DWARF index for types from that the index of the namespaces
since we can't parse DW_TAG_namespace DIEs as types. They are only decls in
clang. All of the types we handle right now have both clang "XXXType" classes
to go with the "XXXDecl" classes which means they can be used within the 
lldb_private::Type class. I need to check to see which other decls that don't
have associated type objects need to float around the debugger and possibly
make a lldb_private::Decl class to manage them.

llvm-svn: 116558
2010-10-15 02:03:22 +00:00
Johnny Chen 150c3cc825 This is an initial version of test driver enhanceent to be able to dump the
session info after a test case failure, allowing more direct inspection of
debugger session which leads to the test failure.

For a simple usage scenario:

[18:06:26] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log 

...

[18:14:43] johnny:/Volumes/data/lldb/svn/trunk/test $ ls -l .session-*
-rw-r--r--  1 johnny  admin  1359 Oct 14 18:06 .session-TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command
-rw-r--r--  1 johnny  admin  2054 Oct 14 18:07 .session-TestClassTypes.ClassTypesTestCase.test_with_dsym_and_expr_parser
-rw-r--r--  1 johnny  admin  2055 Oct 14 18:07 .session-TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_expr_parser
-rw-r--r--  1 johnny  admin  1351 Oct 14 17:57 .session-TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_run_command
[18:14:51] johnny:/Volumes/data/lldb/svn/trunk/test $ 

The test case which failed will have its recorded session info dumped to a
.session-* file in the current working directory.  For test suite using
relocated directory, expect to find the .session-* files there.

In this checkin, I also add @skip decorator to the two test methods in
test/foundation/TestObjCMethods.py as it looks like the test suite is
deadlocking when running the tests.  More investigations are needed.

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

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

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

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

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


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

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

llvm-svn: 116532
2010-10-14 22:52:14 +00:00
Caroline Tice 10ad799386 Modify "process handle" so that if no signals are specified it lists/updates them all,
if no update commands are specified it just lists the current values, and show that
it always shows the new values for a signal after it has been updated.  Also updated
the help text to match the new functionality.

llvm-svn: 116520
2010-10-14 21:31:13 +00:00
Johnny Chen aadcef54de Make calling the super class's setUp() method less fragile.
llvm-svn: 116490
2010-10-14 17:31:24 +00:00
Johnny Chen 7518ff0dda Wrap the file writing operations inside a with statement to simplify code.
llvm-svn: 116486
2010-10-14 16:57:08 +00:00
Johnny Chen cd8b2bbed2 Change the call within lldb.py to 'SBDebugger.Initialize()' from 'lldb.SBDebugger.Initialize()'.
Inside the lldb module, there's no need (and as a matter of fact, incorrect) to specify the 'lldb'
module name.

Comment out the call to lldb.SBDebugger.Initialize() within the test driver itself, since it is
already done when we import the lldb.py module.

llvm-svn: 116485
2010-10-14 16:36:49 +00:00
Johnny Chen b7fd763369 Add more comments and wait a little bit after resuming the inferior process before
sending it a signal.

llvm-svn: 116481
2010-10-14 15:58:53 +00:00
Johnny Chen c066ab4385 Add an initial version of test that exercise the lldb commands: 'process signal'
and 'process handle'.  The test suite would like to control the asynch/sync
execution of the interpreter during the middle of the test method, so the
CommandInterpreter::SetSynchronous(bool value) is modified to allow the mode to
be changed more than once.

In practice, it would be advisable to control the process and to set the
async/sync mode from a single thread, too.

llvm-svn: 116467
2010-10-14 01:22:03 +00:00
Johnny Chen 3c230654a7 Fix a regression introduced in r116430 with the added 'break' statement,
which broke test/breakpoint_locations.

Add a comment about intentional fall-through in the case statement.

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

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

llvm-svn: 116430
2010-10-13 20:44:39 +00:00
Johnny Chen 6e8ab6496a Fix these comments and the commented out code about 'frame variable -t', too.
llvm-svn: 116420
2010-10-13 19:25:42 +00:00
Johnny Chen 456c9c343e Apply (query-replace "frame variable" "frame variable -t") and fix a comment about 'expr var',
not 'frame variable var'.

llvm-svn: 116419
2010-10-13 19:22:50 +00:00
Greg Clayton b6e8cf9663 Default "frame variable" to not show types before values by default. You now enable type display with --show-types or -t (instead of disabling it with --no-types or -t).
llvm-svn: 116418
2010-10-13 18:56:36 +00:00
Johnny Chen 1fd394170a Add a test case for the test/forward directory with @expectedFailure decorator
for test_with_dwarf_and_run_command(self).

llvm-svn: 116416
2010-10-13 18:47:36 +00:00
Greg Clayton 247399230d Fixed C++ class clang type creation and display by making sure we omit
artifical members (like the vtable pointer member that shows up in the DWARF).
We were adding this to each class which was making all member variables be off
by a pointer size.

Added a test case so we can track this with "test/forward".

Fixed the type name index in DWARF to include all the types after finding
some types were being omitted due to the DW_AT_specification having the
DW_AT_declaration attribute which was being read into the real type instances
when there were forward declarations in the DWARF, causing the type to be
omitted. We now check to make sure any DW_AT_declaration values are only
respected when parsing types if the attribute is from the current DIE.

After fixing the missing types, we ran into some issues with the expression
parser finding duplicate entries for __va_list_tag since they are built in
types and would result in a "duplicate __va_list_tag definition" error. We
are now just ignoring this name during lookup, but we will need to see if
we can get the name lookup function to not get called in these cases.

Fixed an issue that would cause an assertion where DW_TAG_subroutine_types
that had no children, would not properly make a clang function type of:
"void (*) (void)".

llvm-svn: 116392
2010-10-13 03:15:28 +00:00
Johnny Chen ff1b28f3ab Avoid using hardcoded line number to break on. Use the line_number() utility
function to get the line numbers for breakpoints 1-5 during setUp().

Use a pattern to match the output from both gcc-compiled and clang-compiled binary.

This finishes the conversion of the test suite to avoid hardcoded line numbers
when setting breakpoints with either the lldb command:

    breakpoint set -f filename -l lineno

or the Python API:

    target.BreakpointCreateByLocation(filename, lineno)

llvm-svn: 116378
2010-10-12 23:53:59 +00:00
Johnny Chen da349bab8a Avoid using hardcoded line number to break on. Use the line_number() utility
function to get the line number to break on during setUp().

Use a pattern to match the output from both gcc-compiled and clang-compiled binary.

llvm-svn: 116374
2010-10-12 23:33:57 +00:00