Commit Graph

2073 Commits

Author SHA1 Message Date
Johnny Chen b877f1efe9 Add a test directory stop-hook to test the newly added "target stop-hook" command.
This uses pexpect module to spawn a 'lldb' program and uses pseudo-TTY to talk to
the child application.

The test cases test setting breakpoints, adding a stop-hook with line range, and
verifies that when the inferior stops, the stop-hook will fire off when it is
within range and will not fire off when it is out of range.

llvm-svn: 127519
2011-03-12 01:18:19 +00:00
Johnny Chen b7cfba4cb1 Add pexpect-2.4 (a pure Python module for controlling and automating other programs) to the test directory.
http://pypi.python.org/pypi/pexpect/

llvm-svn: 127484
2011-03-11 20:13:06 +00:00
Johnny Chen 7fdf1d13f0 Discover the 'lldb' executable in the setUp() hook of the base test class.
llvm-svn: 127481
2011-03-11 19:55:31 +00:00
Johnny Chen cd29b050b7 Add a mechanism to discover the full path of the 'lldb' program into the test driver.
This provides a way to potentially provide conversational interactions with 'lldb' in the test suite.

llvm-svn: 127479
2011-03-11 19:47:23 +00:00
Jim Ingham 9575d8446c Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.

llvm-svn: 127457
2011-03-11 03:53:59 +00:00
Jim Ingham bad87feca2 CommandInterpreter::HandleCommands should take its commands as a "const StringList &" since it doesn't modify it...
Also, don't turn on the immediate output in the temporary result, or you'll get doubled output.

llvm-svn: 127452
2011-03-11 01:51:49 +00:00
Jim Ingham e1e96027a6 Fix a few things in the CommandArguments table.
llvm-svn: 127451
2011-03-11 01:50:30 +00:00
Jim Ingham b2605bc96d Declare some const functions as const.
llvm-svn: 127450
2011-03-11 01:48:52 +00:00
Jim Ingham 17de754181 Fix a typo in a comment.
llvm-svn: 127449
2011-03-11 01:48:09 +00:00
Johnny Chen fdc94ff97e Add test cases to exercise the SBThread.GetProcess() API. We launch the process using the
SBTarget.Launch() API, stop at a breakpoint, get the stopped thread, and verify that the
pid of the stopped thread's process is equal to the pid of the process returned by
SBTarget.Launch().

llvm-svn: 127444
2011-03-11 01:16:03 +00:00
Johnny Chen 24e99aa833 Minor typo fix and TAB removals.
llvm-svn: 127439
2011-03-11 00:28:50 +00:00
Caroline Tice c288e8ca0c Add some explanatory comments.
llvm-svn: 127438
2011-03-11 00:21:55 +00:00
Johnny Chen 2d799cca03 Add a test case test_run_to_address() to exercise the SBThread.RunToAddress(lldb::addr_t addr) API.
The test itself is not working yet.

llvm-svn: 127436
2011-03-11 00:00:15 +00:00
Sean Callanan b3396b226e Fixed the -r parameter to the disassemble command
so that it actually triggers raw output.

llvm-svn: 127433
2011-03-10 23:35:12 +00:00
Johnny Chen f93286f20c Add test cases to TestThreadAPI.py to exercise SBThread.StepOver() by stopping at a breakpoint,
doing three step-over's, then verifying that the correct source line number is reached.

llvm-svn: 127432
2011-03-10 22:32:47 +00:00
Caroline Tice b904ca5015 Add a test case to make sure that all the settings that currently ought to
exist are actually there.

llvm-svn: 127431
2011-03-10 22:29:54 +00:00
Caroline Tice 20bd37f747 The UserSettings controllers must be initialized & terminated in the
correct order.  Previously this was tacitly implemented but not
enforced, so it was possible to accidentally do things in the wrong
order and cause problems.  This fixes that problem.

llvm-svn: 127430
2011-03-10 22:14:10 +00:00
Johnny Chen d9f2c08a0a Test cleanup. Check for the full caller symbol of malloc -- b(int).
llvm-svn: 127421
2011-03-10 19:18:04 +00:00
Stephen Wilson 1636265248 Add Makefile support for the Platform plugins.
This patch supports building the Linux platform plugin, and should also support
the MacOSX plugin as well (the MacOSX side has not been tested, unfortunately).
A small typo was corrected in lldb.cpp to initialize the new platform code on
Linux.

llvm-svn: 127393
2011-03-10 03:08:28 +00:00
Greg Clayton c574ede632 Centralize the GDB remote timeout value into the GDBRemoteCommunication as a
member variable (m_packet_timeout which is a value in seconds). This value is
then used for all packets sent to/from the remote GDB server.

llvm-svn: 127392
2011-03-10 02:26:48 +00:00
Johnny Chen a460316d81 Add test cases for Python SBThread.StepOut() API by stepping out of a malloc call where the call site is at function b().
Verifies that after the thread.StepOut(), we are at the correct line within function b.

llvm-svn: 127374
2011-03-09 23:45:56 +00:00
Sean Callanan b8205b1588 Fixed a bug where the disassembly syntax specified for the
ARM disassembler was wrong, causing the disassembler to fail
to initialize.

llvm-svn: 127302
2011-03-09 01:02:51 +00:00
Johnny Chen 40fa548ee7 There's no sense checking for < 0 with a return type of size_t:
size_t
SBProcess::ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);

llvm-svn: 127292
2011-03-08 23:46:33 +00:00
Johnny Chen af4ab4231f Add an expectedFailure decorator to the test_connect_remote() test case.
It fails when running within the context of the test suite, but succeeds
when running alone.

llvm-svn: 127290
2011-03-08 23:35:45 +00:00
Greg Clayton e996fd30be LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS
that supports LLDB should be registering a "default" platform that will be
used unless a new platform is selected. Platforms are responsible for things
such as:
- getting process information by name or by processs ID
- finding platform files. This is useful for remote debugging where there is 
  an SDK with files that might already or need to be cached for debug access.
- getting a list of platform supported architectures in the exact order they
  should be selected. This helps the native x86 platform on MacOSX select the
  correct x86_64/i386 slice from universal binaries.
- Connect to remote platforms for remote debugging
- Resolving an executable including finding an executable inside platform
  specific bundles (macosx uses .app bundles that contain files) and also
  selecting the appropriate slice of universal files for a given platform.

So by default there is always a local platform, but remote platforms can be
connected to. I will soon be adding a new "platform" command that will support
the following commands:
(lldb) platform connect --name machine1 macosx connect://host:port
Connected to "machine1" platform.
(lldb) platform disconnect macosx

This allows LLDB to be well setup to do remote debugging and also once 
connected process listing and finding for things like:
(lldb) process attach --name x<TAB>

The currently selected platform plug-in can now auto complete any available
processes that start with "x". The responsibilities for the platform plug-in
will soon grow and expand.

llvm-svn: 127286
2011-03-08 22:40:15 +00:00
Stephen Wilson d126c8cc5a Fix ObjectFileElf::GetEntryPointAddress()
ELF object files do not implicitly have a symbol named "start" as an entry
point.  For example, on Linux it is often named "_start", but can be trivially
set to any symbol by passing an --entry argument to the linker.

Use the ELF header to determine the entry point and resolve the associated
section based on that address.

Also, update the linux dynamic loader to call GetEntryPointAddress instead of
GetEntryPoint.

llvm-svn: 127218
2011-03-08 04:12:15 +00:00
Stephen Wilson 8f0daa28d4 Add Makefile support for the new DynamicLoaderStatic plugin.
llvm-svn: 127215
2011-03-08 03:57:00 +00:00
Jim Ingham bd3f260698 I didn't notice there was already an ObjectFile::GetEntryPoint. Move that over to GetEntryPointAddress 'cause that's more consistent with other functions in ObjectFile, do the mutatis mutandi and also in the ELF case I return a section offset address rather than a bare load address.
llvm-svn: 127205
2011-03-08 01:54:01 +00:00
Jim Ingham 5ca40258ea Reverting the part of the debug-in-ofile patch from earlier today that removes them from the shared module list. That was causing a bunch of asserts. Greg is working on a better fix.
llvm-svn: 127201
2011-03-08 01:49:10 +00:00
Jim Ingham 672e6f59c5 Add a method "GetEntryPoint" to the ObjectFile class, and implement it on MachO & ELF - though the ELF implementation is probably a little weak. Then use this method in place of directly looking for "start" in the ThreadPlanCallFunction constructor to find the stopping point for our function evaluation.
llvm-svn: 127194
2011-03-07 23:44:08 +00:00
Caroline Tice 6258c53e12 Add thread state initialization to the thread where the interactive
interpreter is run (which is separate from the thread where
Py_Initialize is called, where this normally gets set up).

llvm-svn: 127191
2011-03-07 23:24:28 +00:00
Johnny Chen d648135902 Add an extra twist of stopping the inferior in a breakpoint, and then continue till it's done.
We should still see the entire stdout redirected once the process is finished.

llvm-svn: 127184
2011-03-07 22:46:30 +00:00
Johnny Chen 75625aa118 Add test cases for SBTarget.Launch() API with the stdout of the inferior redirected to a file.
llvm-svn: 127179
2011-03-07 22:29:04 +00:00
Johnny Chen 2f6f7ba879 Add TestThreadAPI.py file to house the Python SBThread API test cases.
Currently it has only test cases for SBThread.GetStopDescription() API.

Also modified lldb.swig to add typemap for (char *dst, size_t dst_len)
which occurs for SBThread::GetStopDescription() C++ API.  For Python
scripting:

    # Due to the typemap magic (see lldb.swig), we pass in an (int)length to GetStopDescription
    # and expect to get a Python string as the result object!
    # The 100 is just an arbitrary number specifying the buffer size.
    stop_description = thread.GetStopDescription(100)

llvm-svn: 127173
2011-03-07 21:28:57 +00:00
Greg Clayton 0bb165a7a7 Don't cache .o files in the debug map + DWARF in .o files. If we cache them
then we end up using older .o files with out of date section remappings if
we debug, compile + fix, and debug again.

llvm-svn: 127166
2011-03-07 18:51:54 +00:00
Johnny Chen 930e3ad51e Add a test case ProcessAPITestCase.test_remote_launch() which tests SBProcess.RemoteLaunch()
API with a process not in eStateConnected, and checks that the remote launch failed.

Modify SBProcess::RemoteLaunch()/RemoteAttachToProcessWithID()'s log statements to fix a
crasher when logging is turned on.

llvm-svn: 127055
2011-03-05 01:20:11 +00:00
Greg Clayton fc7117ae93 Added a DynamicLoaderStatic plug-in that will act as a static dynamic loader.
It will just load all files exactly where the files state they are (file
addresses == load addresses). This is used when the llvm::Triple::OSType is
set to llvm::Triple::UnknownOS or llvm::Triple::NoOS.

llvm-svn: 127053
2011-03-05 01:04:56 +00:00
Johnny Chen 05178f6e54 Add a test case for the lldb command 'process connect'.
We start a fake debugserver listening on localhost:12345 and issue the command
'process connect connect://localhost:12345' to connect to it.

llvm-svn: 127048
2011-03-04 23:40:06 +00:00
Greg Clayton 874472584d Allow the macosx frame backchain to use 32/64 bit as the selector when
chosing which FP back-chain methods to use since we can rely upon generic 
register numbers after that.

llvm-svn: 127044
2011-03-04 22:59:14 +00:00
Johnny Chen 3ef86dc7da Add docstrings for unittest framework's test methods.
llvm-svn: 127025
2011-03-04 19:47:52 +00:00
Johnny Chen 5f45f6c014 Change the CFLAGS variable assignment operator to ?= (conditional variable assignment operator).
This allows us to override CFLAGS on the command line:

$ CFLAGS='-arch $(ARCH) -gdwarf-2 -O0' ./dotest.py -C clang -A i386 -v objc-optimized

Session logs for test failures/errors will go into directory '2011-03-04-10_33_57'
Command invoked: python ./dotest.py -C clang -A i386 -v objc-optimized
----------------------------------------------------------------------
Collected 2 tests

1: test_break_with_dsym (TestObjcOptimized.ObjcOptimizedTestCase)
   Test 'expr member' continues to work for optimized build. ... ok
2: test_break_with_dwarf (TestObjcOptimized.ObjcOptimizedTestCase)
   Test 'expr member' continues to work for optimized build. ... ok

----------------------------------------------------------------------
Ran 2 tests in 1.902s

OK
$

llvm-svn: 127011
2011-03-04 18:31:00 +00:00
Johnny Chen 3b83d63a17 Add TestObjcOptimized.py under the objc-optimized directory to
test that objective-c expression parser continues to work for optimized build.

Radar filed:
# rdar://problem/9087739
# test failure: objc_optimized does not work for "-C clang -A i386"

llvm-svn: 127009
2011-03-04 18:17:49 +00:00
Johnny Chen 60a084a24d Add objc source file and Makefile. Test case to follow.
llvm-svn: 126980
2011-03-04 01:54:19 +00:00
Johnny Chen e0ec9ea5ce Add the ability for the test suite to specify a list of compilers and a list of architectures
on the command line.  For example, use '-A x86_64^i386' to launch the inferior use both x86_64
and i386.

This is an example of building the debuggee using both clang and gcc compiers:

[17:30:46] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -C clang^gcc -v -f SourceManagerTestCase.test_modify_source_file_while_debugging

Session logs for test failures/errors will go into directory '2011-03-03-17_31_39'
Command invoked: python ./dotest.py -C clang^gcc -v -f SourceManagerTestCase.test_modify_source_file_while_debugging

Configuration:  compiler=clang
----------------------------------------------------------------------
Collected 1 test

1: test_modify_source_file_while_debugging (TestSourceManager.SourceManagerTestCase)
   Modify a source file while debugging the executable. ... Command 'run' failed!

original content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

new content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello lldb.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after writing new content: 1299202305.0
content restored to: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after restore: 1299202307.0
ok

----------------------------------------------------------------------
Ran 1 test in 8.259s

OK

Configuration:  compiler=gcc
----------------------------------------------------------------------
Collected 1 test

1: test_modify_source_file_while_debugging (TestSourceManager.SourceManagerTestCase)
   Modify a source file while debugging the executable. ... original content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

new content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello lldb.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after writing new content: 1299202307.0
content restored to: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after restore: 1299202309.0
ok

----------------------------------------------------------------------
Ran 1 test in 2.301s

OK
[17:31:49] johnny:/Volumes/data/lldb/svn/trunk/test $ 

llvm-svn: 126979
2011-03-04 01:35:22 +00:00
James McIlree 9631aae211 Expose ConnectRemote API through SBTarget and SBProcess.
Patch verified by Greg Clayton prior to checkin.

llvm-svn: 126974
2011-03-04 00:31:13 +00:00
Sean Callanan 54366f12cb Fixed a bug in the expression parser where the 'this'
or 'self' variable was not properly read if the compiler
optimized it into a register.

llvm-svn: 126973
2011-03-04 00:23:47 +00:00
Caroline Tice 94f87e37c8 Add code to emulate RFE Arm instruction.
Add new instruction context for RFE instruction.

Add several new helper functions to help emulate RFE instruction
(including CurrentModeIsPrivileged, BadMode, and CPSRWriteByInstr).

llvm-svn: 126965
2011-03-03 22:37:46 +00:00
Johnny Chen ed4019802d Add TestDisasmAPI.py which exercises the newly added SBFunction/SBSymbol.GetStartAddress(),
among other things:

// When stopped on breakppint 1, we can get the line entry using SBFrame API
// SBFrame.GetLineEntry().  We'll get the start address for the the line entry
// with the SBAddress type, resolve the symbol context using the SBTarget API
// SBTarget.ResolveSymbolContextForAddress() in order to get the SBSymbol.
//
// We then stop at breakpoint 2, get the SBFrame, and the the SBFunction object.
//
// The address from calling GetStartAddress() on the symbol and the function
// should point to the same address, and we also verify that.

And add one utility function disassemble(target, function_or_symbol) to lldbutil.py:

    """Disassemble the function or symbol given a target.

    It returns the disassembly content in a string object.
    """

TestDisasm.py uses the disassemble() function to do disassembly on the SBSymbol, and
then the SBFunction object.

llvm-svn: 126955
2011-03-03 19:14:00 +00:00
Caroline Tice c8d0d3ae0b Add code to emulate UXTH Arm instruction.
llvm-svn: 126954
2011-03-03 18:48:58 +00:00
Caroline Tice 9c35f321c6 Add code to emulate UXTB Arm instruction.
llvm-svn: 126953
2011-03-03 18:27:17 +00:00