Commit Graph

2283 Commits

Author SHA1 Message Date
Sean Callanan e6935b6bdf Updated LLVM/Clang to the latest release, to pick
up AVX disassembly support.

llvm-svn: 127695
2011-03-15 20:57:04 +00:00
Greg Clayton 1a37ae40e1 Now that we have the debug map issues fixed, change the Xcode project to
build lldb, LLDB.framework and debugserver all with just DWARF (no dSYM).

llvm-svn: 127686
2011-03-15 18:51:42 +00:00
Greg Clayton 3690964ca1 Added a fix that should help incorrect type uniquing. There was an issue
for templatized types that could cause parts of a std::vector (and I am sure
other STL types) to be incorrectly uniqued to each other wreaking havoc on 
variable display for types within the same executable module.

llvm-svn: 127662
2011-03-15 04:38:20 +00:00
Greg Clayton 3ad0572d2e Make the first vector of "long" instead of "int" so we can tell the difference
easier since "short" ends up with "short int" in the template allocators.

llvm-svn: 127661
2011-03-15 04:29:42 +00:00
Greg Clayton 8f67fd10e9 Added a test case for unique types. In the test case there are two std::vector
types that have different contents. Currently LLDB is incorrectly uniquing,
on MacOSX, the std::vector _VectorImpl class from the two different vector
templates. The DWARF looks like:

0x0000008e:         DW_TAG_structure_type [7] *
                     DW_AT_name( "_Vector_base<int,std::allocator<int> >" )
                     DW_AT_declaration( 0x01 )
                     DW_AT_sibling( {0x00000103} )

0x00000098:             DW_TAG_structure_type [8] *
                         DW_AT_name( "_Vector_impl" )
                         DW_AT_byte_size( 0x18 )
                         DW_AT_decl_file( "/usr/include/c++/4.2.1/bits/stl_vector.h" )
                         DW_AT_decl_line( 83 )

0x000000a0:                 DW_TAG_inheritance [9]  
                             DW_AT_type( {0x000006fa} ( allocator<int> ) )
                             DW_AT_data_member_location( +0 )
                             DW_AT_accessibility( DW_ACCESS_public )



0x0000011b:         DW_TAG_structure_type [7] *
                     DW_AT_name( "_Vector_base<short int,std::allocator<short int> >" )
                     DW_AT_declaration( 0x01 )
                     DW_AT_sibling( {0x00000190} )

0x00000125:             DW_TAG_structure_type [8] *
                         DW_AT_name( "_Vector_impl" )
                         DW_AT_byte_size( 0x18 )
                         DW_AT_decl_file( "/usr/include/c++/4.2.1/bits/stl_vector.h" )
                         DW_AT_decl_line( 83 )

0x0000012d:                 DW_TAG_inheritance [9]  
                             DW_AT_type( {0x00000f75} ( allocator<short int> ) )
                             DW_AT_data_member_location( +0 )
                             DW_AT_accessibility( DW_ACCESS_public )


In this case it using DIE 0x00000098 for both 0x00000098 and 0x00000125.

This test will help detect this issue once I have a fix for it. I have a fix
that I am testing.

llvm-svn: 127660
2011-03-15 04:25:12 +00:00
Greg Clayton 616f490777 Added a fix to not re-use object files when doing DWARF with debug map.
llvm-svn: 127659
2011-03-15 03:56:33 +00:00
Sean Callanan fb0b7583a7 Updated to LLVM/Clang revision 127600.
llvm-svn: 127634
2011-03-15 00:17:19 +00:00
Stephen Wilson d7b15bd6b7 Fix makefile builds when llvm is configured with -enable-shared.
We were dropping the expansion of -rpath=$(LibDir) on linux, which resulted in
the build not being able to resolve libLLVM.so.  Bring in the definition before
expanding the values hanging off LD.Flags.

Thanks to Jason E. Aten for reporting this!

llvm-svn: 127570
2011-03-13 18:17:16 +00:00
Benjamin Kramer 489ac96fcd Turn labels into actual switch cases.
llvm-svn: 127558
2011-03-13 00:14:32 +00:00
Stephen Wilson 28c16d9a7e Add a missing include.
This change is needed to fix the build on Linux. 

llvm-svn: 127557
2011-03-13 00:00:32 +00:00
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
Caroline Tice 8678f2a192 Add code to emulate SXTH Arm instruction.
llvm-svn: 126951
2011-03-03 18:04:49 +00:00
Caroline Tice 67735bf069 Add code to emulate SXTB Arm instruction.
llvm-svn: 126949
2011-03-03 17:42:58 +00:00
Johnny Chen d61816b5b8 Add TestTargetAPI.py:
// When stopped on breakppint 1, and then 2, we can get the line entries using
// SBFrame API SBFrame.GetLineEntry().  We'll get the start addresses for the
// two line entries; with the start address (of SBAddress type), we can then
// resolve the symbol context using the SBTarget API
// SBTarget.ResolveSymbolContextForAddress().
//
// The two symbol context should point to the same symbol, i.e., 'a' function.


Add two utility functions to lldbutil.py:

o get_stopped_threads(process, reason):

  return the list of threads with the specified stop reason or an empty list if not found

o get_stopped_thread(process, reason):

  return the first thread with the given stop reason or None if not found

llvm-svn: 126916
2011-03-03 01:41:57 +00:00
Caroline Tice edc103e253 Fix bug where bitwise-AND was being used and it should have been bitwise-OR.
llvm-svn: 126904
2011-03-03 00:07:02 +00:00
Caroline Tice 30f40c6850 Add code to emulate ADD (immediate, Thumb) Arm instruction.
Add addition context to EmulateInstruction contexts.

llvm-svn: 126903
2011-03-02 23:57:02 +00:00
Greg Clayton 93d00df578 Export the ability to get the start and end addresses for functions
and symbols, and also allow clients to get the prologue size in bytes:

    SBAddress
    SBFunction::GetStartAddress ();
    
    SBAddress
    SBFunction::GetEndAddress ();
    
    uint32_t
    SBFunction::GetPrologueByteSize ();

    SBAddress
    SBSymbol::GetStartAddress ();
    
    SBAddress
    SBSymbol::GetEndAddress ();
    
    uint32_t
    SBSymbol::GetPrologueByteSize ();

llvm-svn: 126892
2011-03-02 23:01:18 +00:00
Caroline Tice 1a234ff46f Add code to emulate MUL Arm instruction.
Add new context type & info structure for  mul instruction.

llvm-svn: 126891
2011-03-02 22:43:54 +00:00
Greg Clayton 5f2a4f999d Added a missing API call in SBTarget that enables one to get
anything in a SBSymbolContext filled in given an SBAddress:

SBSymbolContext
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope);

Also did a little cleanup on the ProcessGDBRemote stdio file handle
code.

llvm-svn: 126885
2011-03-02 21:34:46 +00:00
Caroline Tice a0d3b67572 Add code to emulate LDRSH (register) Arm instruction.
llvm-svn: 126881
2011-03-02 21:13:44 +00:00
Johnny Chen 43e587c1f6 Clarified the docstrings for int_to_bytearray() and bytearray_to_int().
llvm-svn: 126877
2011-03-02 20:54:22 +00:00
Jim Ingham 843d20aa7a Add some function docs.
llvm-svn: 126868
2011-03-02 19:58:15 +00:00
Johnny Chen 4e90a7e503 Add some comments.
llvm-svn: 126867
2011-03-02 19:49:27 +00:00
Caroline Tice 1cd4459b21 Add code to emulate LDRSH (literal) Arm instruction.
llvm-svn: 126866
2011-03-02 19:45:34 +00:00
Johnny Chen 43766d6f12 Add two utility functions to lldbutil.py:
o int_to_bytearray()
o bytearray_to_int()

They return/interpret the bytearray in the little endian format.
For big endian, simply perform ba.reverse() on the bytearray object.

And modify TestProcessAPI.py to take advantage of the functions.

llvm-svn: 126813
2011-03-02 01:36:45 +00:00
Caroline Tice d3e57ee4fc Add code to emulate LDRSH (immediate) Arm instruction.
llvm-svn: 126807
2011-03-02 00:39:42 +00:00
Caroline Tice 4776fbbd72 Add code to emulate LDRSB (register) Arm instruction.
llvm-svn: 126802
2011-03-01 23:55:59 +00:00
Johnny Chen cf386e24ab Add an API SBProcess::GetByteOrder() and add test cases which utilizes GetByteOrder(),
among other SBProcess APIs, to write (int)256 into a memory location of a global variable
(int)my_int and reads/checks the variable afterwards.

llvm-svn: 126792
2011-03-01 22:56:31 +00:00
Caroline Tice 4947ffc80d Add code to emulate LDRSB (literal) Arm instruction.
llvm-svn: 126789
2011-03-01 22:25:17 +00:00
Caroline Tice 28c3fcccb2 Add code to emulate LDRSB (immediate) Arm instruction.
llvm-svn: 126783
2011-03-01 21:53:03 +00:00
Johnny Chen 0dd049204c Fix wrong placement of skipUnless() decorator.
llvm-svn: 126774
2011-03-01 19:53:43 +00:00
Johnny Chen 90aa594c5e Add test methods for SBProcess.WriteMemory() API to the TestProcessAPI.py file.
This makes the number of total tests equal to 201.

llvm-svn: 126769
2011-03-01 18:51:47 +00:00
Caroline Tice 4f0e5f8852 Add code to emulate LDRH (register) Arm instruction.
llvm-svn: 126758
2011-03-01 18:00:42 +00:00
Johnny Chen 37f99fdb73 Add TestProcessAPI.py which exercises some Python SBProcess API. In particular, this tests
the SBProcess.ReadMemory() API, which, due to SWIG typemap'ing, expects 3 arguments (the location
to read from, the size in bytes to read, and an SBError object), and returns the result as a
Python string object.

On SnowLeopard where this has been tested, the SWIG script needs to be pampered (use the exact
same parameter names as in SBProcess.h) in order for this to work.

llvm-svn: 126736
2011-03-01 02:20:14 +00:00
Jim Ingham 6b90ba414a Look for swig in /usr/bin and /usr/local/bin.
llvm-svn: 126732
2011-03-01 01:39:04 +00:00
Caroline Tice 6261d240e1 Add code to emulate LDRH (literal) Arm instruction.
llvm-svn: 126709
2011-02-28 23:15:24 +00:00
Stephen Wilson bbb7e06ad3 Add register context for i386 on Linux.
Patch by Marco Minutoli!

llvm-svn: 126696
2011-02-28 22:52:38 +00:00
Caroline Tice adef8fb003 Add code to emulate LDRH (immediate, Thumb) arm instruction.
llvm-svn: 126692
2011-02-28 22:39:58 +00:00
Johnny Chen 725269a0b4 If the user sets a working directory path using "process launch -w <path>", honor that dir path;
otherwise, use the thing the debugserver is started with.

Fixed rdar://problem/9056462
The process launch flag '-w' for setting the current working directory not working?

llvm-svn: 126537
2011-02-26 01:36:13 +00:00
Johnny Chen 4899420f17 Simplify the dictionary setting for test_set_working_dir_* methods.
llvm-svn: 126531
2011-02-25 23:24:25 +00:00
Johnny Chen d08df5b016 Call self.setTearDownCleanup() and pass a proper dictionay to properly cleanup
the intermediate files built with the same dictionary during test execution.

llvm-svn: 126530
2011-02-25 23:22:59 +00:00
Johnny Chen 90eb2cbaee Add a test case to exercise the process launch flag of '-w <path>' which sets the
current working directory when running the inferior.  Radar filed:

    # rdar://problem/9056462
    # The process launch flag '-w' for setting the current working directory not working?

llvm-svn: 126529
2011-02-25 23:15:09 +00:00
Johnny Chen 51433bf688 Renamed the Python test file to be TestProcessLaunch.py.
llvm-svn: 126517
2011-02-25 21:37:56 +00:00
Johnny Chen 80180e1257 Renamed the test class to be ProcessLaunchTestCase.
llvm-svn: 126516
2011-02-25 21:36:35 +00:00
Johnny Chen 40b328ca48 Simplified the code a little bit.
llvm-svn: 126515
2011-02-25 21:32:36 +00:00
Johnny Chen f85c0eb65d Renamed test/process_io directory to test/process_launch, in preparation to add additional tests
related to 'process launch' command.

llvm-svn: 126514
2011-02-25 21:21:21 +00:00
Johnny Chen 0e65ce3de8 Add readme on the version of emacs that works with lldb-enhanced gud.el,
for Stuart Hastings. :-)

llvm-svn: 126469
2011-02-25 01:51:25 +00:00
Johnny Chen 699ac0e967 Add emulation for Encoding A1 of A8.6.97 MOV (register).
llvm-svn: 126456
2011-02-25 00:23:25 +00:00
Johnny Chen e1e020dc29 The lldb-enhanced gud.el does not work on emacs 22.1.1 (dumb terminal).
This is the error I got:

Debugger entered--Lisp error: (void-function split-string-and-unquote)
  (split-string-and-unquote command-line)
  (let* ((words ...) (program ...) (dir default-directory) (file-word ...) (file-subst ...) (args ...) (file ...) (filepart ...) (existing-buffer ...)) (pop-to$
  gud-common-init("/Volumes/data/lldb/svn/trunk/build/Debug/lldb" nil gud-lldb-marker-filter)
  lldb("/Volumes/data/lldb/svn/trunk/build/Debug/lldb")
  call-interactively(lldb)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

The gud-common-init elisp function references split-string-and-unquote function
which is not defined there.

llvm-svn: 126449
2011-02-24 23:13:28 +00:00
Greg Clayton 7133762232 Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.
Modifed lldb_private::Process to be able to handle connecting to a remote 
target that isn't running a process. This leaves lldb_private::Process in the
eStateConnected state from which we can then do an attach or launch.

Modified ProcessGDBRemote to be able to set stdin, stdout, stderr, working
dir, disable ASLR and a few other settings down by using new GDB remote 
packets. This allows us to keep all of our current launch flags and settings
intact and still be able to communicate them over to the remote GDB server.
Previously these were being sent as arguments to the debugserver binary that
we were spawning. Also modified ProcessGDBRemote to handle losing connection
to the remote GDB server and always exit immediately. We do this by watching
the lldb_private::Communication event bit for the read thread exiting in the
ProcessGDBRemote async thread.

Added support for many of the new 'Q' packets for setting stdin, stdout,
stderr, working dir and disable ASLR to the GDBRemoteCommunication class for
easy accesss.

Modified debugserver for all of the new 'Q' packets and also made it so that
debugserver always exists if it loses connection with the remote debugger.

llvm-svn: 126444
2011-02-24 22:24:29 +00:00
Johnny Chen a517bae73c Fix typos in the opcode entries for branch instructions.
llvm-svn: 126442
2011-02-24 21:54:22 +00:00
Jim Ingham f6ea93fbab When making a DataExtractor from a Value that's got a ClangType, set the AddressByteSize from the AST Context.
llvm-svn: 126433
2011-02-24 21:23:14 +00:00
Johnny Chen 3c970dc50d Add emulation for BXJ (Branch and Exchange Jazelle), assuming that the attempt to
switch to Jazelle state fails, thus treating BXJ as a BX operation.

llvm-svn: 126423
2011-02-24 21:01:20 +00:00
Stephen Wilson 17e3d193e1 linux: Use ArchSpec::GetCore and the ArchSpec::Core enums.
llvm-svn: 126406
2011-02-24 19:17:09 +00:00
Stephen Wilson 3f4200fd9d linux: Remove a local ObjectFileELF version of GetArchitecture.
Also fix a bug where we were not lazily parsing the ELF header and thus
returning an ArchSpec with invalid cpu type components.  Initialize the cpu
subtype as LLDB_INVALID_CPUTYPE for compatibility with the new ArchSpec
implementation.

llvm-svn: 126405
2011-02-24 19:16:15 +00:00
Stephen Wilson bd58871d96 Host: linux: Use llvm::sys::getHostTriple for the default host ArchSpec.
Previously we were using a set of preprocessor defines and returning an ArchSpec
without any OS/Vendor information.  This fixes an issue with plugin resolution
on Linux where a valid OS component is needed.

llvm-svn: 126404
2011-02-24 19:15:09 +00:00
Stephen Wilson facebfc354 ArchSpec: Do not depend on Host::GetArchitecture.
The major issue this patch solves is that ArchSpec::SetTriple no longer depends
on the implementation of Host::GetArchitecture.  On linux, Host::GetArchitecture
calls ArchSpec::SetTriple, thus blowing the stack.

A second smaller point is that SetTriple now defaults to Host defined components
iff all OS, vendor and environment fields are not set.

llvm-svn: 126403
2011-02-24 19:13:58 +00:00
Johnny Chen bf4afa8796 Add emulation methods for Bitwise Bit Clear (immediate and register) operations.
llvm-svn: 126355
2011-02-24 01:15:17 +00:00
Johnny Chen 132548df62 Add emulation methods for "SUB (immediate, Thumb)" and "SUB (immediate, ARM)" operations.
llvm-svn: 126343
2011-02-23 23:47:56 +00:00
Johnny Chen d88d96cac9 Add emulation for "ADR" operations. Add a ThumbImm8Scaled() convenience function
and rename the original ThumbImmScaled() function to ThumbImm7Scaled().

llvm-svn: 126335
2011-02-23 21:24:25 +00:00
Johnny Chen 5278cd11ba Modify EmulateSUBSPImm() to handle the cases with generic Rd value instead of
Rd == 13.  Add opcode entries for the generic "sub (sp minus immediate)" operations.

llvm-svn: 126293
2011-02-23 01:55:07 +00:00
Johnny Chen 187b0e37c1 Add emulation methods for "SBC (immediate)" and "SBC (register)" operations.
llvm-svn: 126283
2011-02-23 01:01:21 +00:00
Greg Clayton 64195a2c8b Abtracted all mach-o and ELF out of ArchSpec. This patch is a modified form
of Stephen Wilson's idea (thanks for the input Stephen!). What I ended up
doing was:
- Got rid of ArchSpec::CPU (which was a generic CPU enumeration that mimics
  the contents of llvm::Triple::ArchType). We now rely upon the llvm::Triple 
  to give us the machine type from llvm::Triple::ArchType.
- There is a new ArchSpec::Core definition which further qualifies the CPU
  core we are dealing with into a single enumeration. If you need support for
  a new Core and want to debug it in LLDB, it must be added to this list. In
  the future we can allow for dynamic core registration, but for now it is
  hard coded.
- The ArchSpec can now be initialized with a llvm::Triple or with a C string
  that represents the triple (it can just be an arch still like "i386").
- The ArchSpec can still initialize itself with a architecture type -- mach-o
  with cpu type and subtype, or ELF with e_machine + e_flags -- and this will
  then get translated into the internal llvm::Triple::ArchSpec + ArchSpec::Core.
  The mach-o cpu type and subtype can be accessed using the getter functions:
  
  uint32_t
  ArchSpec::GetMachOCPUType () const;

  uint32_t
  ArchSpec::GetMachOCPUSubType () const;
  
  But these functions are just converting out internal llvm::Triple::ArchSpec 
  + ArchSpec::Core back into mach-o. Same goes for ELF.

All code has been updated to deal with the changes.

This should abstract us until later when the llvm::TargetSpec stuff gets
finalized and we can then adopt it.

llvm-svn: 126278
2011-02-23 00:35:02 +00:00
Johnny Chen 673badf292 Renamed macro definition of CPSR_C to be CPSR_C_POS to avoid confusions and subtle bugs.
llvm-svn: 126271
2011-02-23 00:15:56 +00:00
Johnny Chen 7deb7422bc Add emulation methods for "RSC (immediate)" and "RSC (register)" operations.
llvm-svn: 126267
2011-02-23 00:07:09 +00:00
Johnny Chen 447c001048 Add emulation methods for "RSB (immediate)" and "RSB (register)".
Plus add missing break stmts for "case" blocks.

llvm-svn: 126265
2011-02-22 23:42:58 +00:00
Greg Clayton 1971900fdc Don't enable thread safe logging as it currently deadlocks logging.
llvm-svn: 126260
2011-02-22 23:08:31 +00:00
Greg Clayton 76b436e21d Make logs threadsafe (add the -t option) when logging API stuff.
llvm-svn: 126257
2011-02-22 22:59:30 +00:00
Sean Callanan 2d1f4be47a Fixed a hang in the expression parser's result synthesizer that occurs when the function generated for the expression is completely empty except for a NULL_STMT. This happens sometimes when the parser returns errors.
llvm-svn: 126251
2011-02-22 21:52:56 +00:00
Johnny Chen 5f88bcc16a Add two convenience functions: DecodeImmShiftThumb() and DecodeImmShiftARM() to ARMUtils.h.
Use them within EmulateInstructionARM.cpp to save repetitive typing.

llvm-svn: 126247
2011-02-22 21:17:52 +00:00
Johnny Chen 83a4ddd0cb Add "cmp<c>.w <Rn>, #<const>" emulation to EmulateCMPImm() method,
and implement EmulateCMNImm() and EMulateCMNReg() methods.

llvm-svn: 126236
2011-02-22 19:48:22 +00:00
Greg Clayton 681254c830 Remove an assertion that was causing a crash.
llvm-svn: 126235
2011-02-22 19:32:07 +00:00
Johnny Chen aebcfc86df Fix the 'variants' field of "CMN (immediate)" Encoding T1 entry, it should be ARMV6T2_ABOVE, not ARMvAll.
llvm-svn: 126234
2011-02-22 19:01:11 +00:00
Johnny Chen 01ceff367a Add ARM encoding entries for "CMN (immediate)" and "CMN (register)" operations.
llvm-svn: 126179
2011-02-22 02:00:12 +00:00
Johnny Chen 5ea119468a Add ARM encoding entries for "CMP (immediate)" and "CMP (register)" operations.
Add ARM/Thumb encoding entries for "CMN (immediate)" and "CMN (register)" operations,
with the EmulateCMNImm()/Reg() methods not implemented yet for now.

llvm-svn: 126178
2011-02-22 01:56:31 +00:00
Johnny Chen c2fa8fafde Add emulation methods for "MVN (immediate)" and "MVN (register)".
llvm-svn: 126172
2011-02-22 01:01:03 +00:00
Johnny Chen e69108a78f Add emulation methods for "EOR (Immediate)", "EOR (register)",
"TEQ (immediate)", and "TEQ (register)" operations.

llvm-svn: 126160
2011-02-21 23:42:44 +00:00
Johnny Chen 28c5882cb5 Add emulation methods for "TST (immediate)" and "TST (register)".
Plus modified EmulateANDImm/Reg to delegate to TSTImm/Reg for Thumb2
32-bit instructions when Rd == '1111' and setflags is true.

llvm-svn: 126144
2011-02-21 21:24:49 +00:00
Greg Clayton 9d0402b1eb Don't limit StreamTee to just two streams. It now can contain
N streams by making the stream a vector of stream shared pointers
that is protected by a mutex. Streams can be get/set by index which
allows indexes to be defined as stream indentifiers. If a stream is
set at index 3 and there are now streams in the collection, then
empty stream objects are inserted to ensure that stream at index 3
has a valid stream. There is also an append method that allows a stream
to be pushed onto the stack. This will allow our streams to be very
flexible in where the output goes.

Modified the CommandReturnObject to use the new StreamTee functionality.
This class now defines two StreamTee indexes: 0 for the stream string
stream, and 1 for the immediate stream. This is used both on the output
and error streams.

Added the ability to get argument types as strings or as descriptions.
This is exported through the SBCommandInterpreter API to allow external
access.

Modified the Driver class to use the newly exported argument names from
SBCommandInterpreter::GetArgumentTypeAsCString().

llvm-svn: 126067
2011-02-20 02:15:07 +00:00
Jim Ingham 85e8b81492 - Changed all the places where CommandObjectReturn was exporting a StreamString to just exporting
a Stream, and then added GetOutputData & GetErrorData to get the accumulated data.
- Added a StreamTee that will tee output to two provided lldb::StreamSP's.
- Made the CommandObjectReturn use this so you can Tee the results immediately to
the debuggers output file, as well as saving up the results to return when the command
is done executing.
- HandleCommands now uses this so that if you have a set of commands that continue the target
you will see the commands come out as they are processed.
- The Driver now uses this to output the command results as you go, which makes the interface
more reactive seeming.

llvm-svn: 126015
2011-02-19 02:53:09 +00:00
Johnny Chen ce0dec7597 Make the helper method ReadCoreReg(uint32_t reg, bool *success) more generic
which now handles R0-R12, SP, LR, as well as PC.  And refactored a lot of
calls to ReadRegisterUnsigned() to now funnel through ReadCoreReg(), instead.

llvm-svn: 126010
2011-02-19 01:36:13 +00:00
Caroline Tice 55532be31f Add code to emulate LDRB (register) Arm instruction.
llvm-svn: 125994
2011-02-18 23:52:21 +00:00
Johnny Chen ce4e629fdf Add emulation methods for "ORR (immediate)" and "ORR (register)".
Add Encoding T3 of "MOV (register)" to EmulateMOVRdRm() method and fixed
some bugs in EmulateMOVRdImm() and EmulateMOVRdRm() methods.

llvm-svn: 125992
2011-02-18 23:41:11 +00:00
Caroline Tice 27d1032b60 Add code to emulate LDRB (literal) Arm instruction.
llvm-svn: 125975
2011-02-18 22:24:22 +00:00
Johnny Chen d1fd6963f5 Add emulation methods for "ADC (immediate)" and "ADC (register)".
Plus add a helper method ReadCoreReg(uint32_t regnum, bool *success) to simplify
coding a bit.

llvm-svn: 125961
2011-02-18 21:13:05 +00:00
Caroline Tice 489517c4a4 Add code to emulate LDRB (immediate, Thumb) instruction.
llvm-svn: 125959
2011-02-18 21:06:04 +00:00
Johnny Chen faba5dd4ae Add emulation methods for "AND (immediate)" and "AND (register)".
Plus add macro definitions for APSR_C and APSR_V to simplify code.

llvm-svn: 125947
2011-02-18 19:32:20 +00:00
Caroline Tice a1bf8db478 Add code to emulate LDR (register) Arm instruction.
llvm-svn: 125945
2011-02-18 18:52:37 +00:00
Greg Clayton bfe5f3bf06 Added new target instance settings for execution settings:
Targets can now specify some additional parameters for when we debug 
executables that can help with plug-in selection:

target.execution-level = auto | user | kernel
target.execution-mode  = auto | dynamic | static
target.execution-os-type = auto | none | halted | live

On some systems, the binaries that are created are the same wether you use
them to debug a kernel, or a user space program. Many times inspecting an 
object file can reveal what an executable should be. For these cases we can
now be a little more complete by specifying wether to detect all of these
things automatically (inspect the main executable file and select a plug-in
accordingly), or manually to force the selection of certain plug-ins.

To do this we now allow the specficifation of wether one is debugging a user
space program (target.execution-level = user) or a kernel program 
(target.execution-level = kernel).

We can also specify if we want to debug a program where shared libraries
are dynamically loaded using a DynamicLoader plug-in 
(target.execution-mode = dynamic), or wether we will treat all symbol files
as already linked at the correct address (target.execution-mode = static).

We can also specify if the inferior we are debugging is being debugged on 
a bare board (target.execution-os-type = none), or debugging an OS where
we have a JTAG or other direct connection to the inferior stops the entire
OS (target.execution-os-type = halted), or if we are debugging a program on
something that has live debug services (target.execution-os-type = live).

For the "target.execution-os-type = halted" mode, we will need to create 
ProcessHelper plug-ins that allow us to extract the process/thread and other
OS information by reading/writing memory.

This should allow LLDB to be used for a wide variety of debugging tasks and
handle them all correctly.

llvm-svn: 125815
2011-02-18 01:44:25 +00:00
Johnny Chen f401d69c85 Fix typo.
llvm-svn: 125812
2011-02-18 01:26:39 +00:00
Johnny Chen fc9d00beb7 Add emulation of Encoding A1 "A8.6.6 ADD (register)" and "A8.6.5 ADD (immediate, ARM)".
llvm-svn: 125809
2011-02-18 01:22:22 +00:00
Caroline Tice 29c9b64096 Add code to emulate LDR (immediate,ARM) instruction.
llvm-svn: 125808
2011-02-18 00:55:53 +00:00
Jim Ingham e16c50a11a Factor all the code that does "Execute a list of lldb command interpreter commands" into a single function in the Interpreter, and then use that in all the places that used to do this by hand.
llvm-svn: 125807
2011-02-18 00:54:25 +00:00
Johnny Chen ae147cafa9 Finished renamings to make the emulation method names consistent case-wise.
llvm-svn: 125801
2011-02-18 00:07:39 +00:00
Johnny Chen a18ae1ffde Some renamings to make the emulation method names consistent case-wise.
llvm-svn: 125800
2011-02-18 00:02:28 +00:00
Johnny Chen d4926266f3 Removed redundant entry EmulateTBB() (there's an existing one EmulateTB()) and fixed some typos
in section headings.

llvm-svn: 125796
2011-02-17 23:44:53 +00:00
Johnny Chen 2a7e05a3d7 Fix a bug in EmulateTB() (TBB, TBH) where the branch length should be "twice"
the value of the byte/halfword returned from the table.

llvm-svn: 125793
2011-02-17 23:27:44 +00:00
Caroline Tice 16443905f3 Add header declarations for the remaining instructions we need to
emulate, to cover those that can change the PC.

llvm-svn: 125791
2011-02-17 23:09:13 +00:00
Johnny Chen 34dd9ba9c7 Refactoring. Abstracted the set flags operation into its own helper method
WriteFlags() and renamed WriteCoreRegisterWithFlags() to WriteCoreRegOptionalFlags().
Modified the call sites to use the helper methods.

llvm-svn: 125788
2011-02-17 22:37:12 +00:00
Johnny Chen fc5c19dec5 A8.6.6 ADD (register)
Renamed EmulateAddRdnRm() to EmulateAddReg(), and added Encoding T1 to it.
Where Encoding T2 can potentially modify the PC, causing a brnach.

llvm-svn: 125782
2011-02-17 22:03:29 +00:00
Johnny Chen 2789706059 Add EmulateTB() method to emulate "Table Branch Byte" and "Table Branch Halfword"
operations for Thumb2.

llvm-svn: 125767
2011-02-17 19:34:27 +00:00
Caroline Tice 032d2dd576 Add stubs for pseudocode functions "MemA[]" amd "MemU[]", corresponding to aligned
and unaligned memory accesses.  The new stub functions are MemARead, MemAWrite,
MemURead, and MemUWrite.  At the moment these stubs just call ReadMemoryUnsigned or
WriteMemoryUnsigned, but we can fill them out further later if we decide we need
more accurate emulation of the memory system.

Replaced all the direct calls to ReadMemoryUnsigned and WriteMemoryUnsigned in
EmulateInstructionARM.cpp with calls to the appropriate new stub function.

llvm-svn: 125766
2011-02-17 19:20:40 +00:00
Johnny Chen 0f60574fd7 Move Align(val, alignment) utility function to ARMUtils.h.
llvm-svn: 125753
2011-02-17 17:31:08 +00:00
Greg Clayton 4796c4feb1 Modified version of Marco Minutoli's host arch patch.
llvm-svn: 125706
2011-02-17 02:05:38 +00:00
Johnny Chen e19e4fc8dc Add comment for the helper method WriteCoreRegisterWithFlags().
llvm-svn: 125703
2011-02-17 01:49:00 +00:00
Johnny Chen 0c64b5bbb6 Refactoring. Wrap the following pseudocode from the ARM Architecture Reference Manul:
// if d == 15 then         // Can only occur for encoding A1
//     ALUWritePC(result); // setflags is always FALSE here
// else
//     R[d] = result;
//     if setflags then
//         APSR.N = result<31>;
//         APSR.Z = IsZeroBit(result);
//         APSR.C = carry;
//         // APSR.V unchanged

into a helper method WriteCoreRegisterWithFlags, and modified the existing methods
to take advantage of it.

Plus add two emulation methods (declaration only for now) for ORR (immediate) and ORR (register).

llvm-svn: 125701
2011-02-17 01:35:27 +00:00
Stephen Wilson bc15eb1736 Do not use constants from stdint.h that we cannot portably provide on all platforms.
llvm-svn: 125695
2011-02-17 00:01:47 +00:00
Greg Clayton f4ecaa576c Clean up a bit of the type getting code where lldb_private:Type now has
clang_type_t
    GetClangFullType(); // Get a completely defined clang type

    clang_type_t
    GetClangLayoutType(); // Get a clang type that can be used for type layout
    
    clang_type_t
    GetClangForwardType(); // A type that can be completed if needed, but is more efficient.
    

llvm-svn: 125691
2011-02-16 23:00:21 +00:00
Johnny Chen 4890c85e0a Add emulation methods for ROR (immediate), ROR (register), and RRX.
Turns out that they can be funneled through the helper methods
EmulateShiftImm()/ EmulateShiftReg() as well.

Modify EmulateShiftImm() to handle SRType_ROR and SRType_RRX.
And fix a typo in the impl of utility Shift_C() in ARMUtils.h.

llvm-svn: 125689
2011-02-16 22:14:44 +00:00
Caroline Tice eaf2e4fdf1 Add code to emulate STRB (Thumb) instruction.
llvm-svn: 125686
2011-02-16 20:22:22 +00:00
Johnny Chen 14571f4b67 Add encoding entries for LSL (immediate and register) and LSR (immediate and register) to
ARM and Thumb opcode tables.

llvm-svn: 125683
2011-02-16 19:27:43 +00:00
Johnny Chen f8cd4889ec Fix clang++ warning building the executable for testing.
llvm-svn: 125682
2011-02-16 19:22:52 +00:00
Johnny Chen 4b22e7e67a Add tagging for EmulateLDRRtRnImm().
llvm-svn: 125671
2011-02-16 18:35:47 +00:00
Jim Ingham d0a3e12b05 Destroy the dynamic loader plugin in Process::Finalize. If you wait till the auto_ptr gets deleted in the normal course of things the real process class will have been destroyed already, and it's hard to shut down the dynamic loader without accessing some process pure virtual method.
llvm-svn: 125668
2011-02-16 17:54:55 +00:00
Stephen Wilson 7a86fcdd8f Make declaration of DynamicLoaderLinuxDYLD::CreateInstance match its definition.
llvm-svn: 125656
2011-02-16 05:38:31 +00:00
Stephen Wilson dd9ec590c6 Expose includes for the socket layer on all platforms.
This patch reverts a portion of r125199 to allow the tree to build again on
linux.  The specific mingw issues that revision intended to address can be
sorted out at a later time.

llvm-svn: 125655
2011-02-16 05:36:26 +00:00
Stephen Wilson de049291fd linux: Set ArchSpec m_type correctly from object file.
An ArchSpec's type defaults to MachO.  Ensure the type is properly set
on ELF systems.

llvm-svn: 125654
2011-02-16 05:25:13 +00:00
Stephen Wilson d879a4d12a Use SIZE_MAX instead of SIZE_T_MAX for portability.
llvm-svn: 125653
2011-02-16 05:24:31 +00:00
Greg Clayton 93d3c8339c The DynamicLoader plug-in instance now lives up in lldb_private::Process where
it should live and the lldb_private::Process takes care of managing the 
auto pointer to the dynamic loader instance.

Also, now that the ArchSpec contains the target triple, we are able to 
correctly set the Target architecture in DidLaunch/DidAttach in the subclasses,
and then the lldb_private::Process will find the dynamic loader plug-in 
by letting the dynamic loader plug-ins inspect the arch/triple in the target.

So now the ProcessGDBRemote plug-in is another step closer to be purely 
process/platform agnostic.

I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly.

llvm-svn: 125650
2011-02-16 04:46:07 +00:00
Johnny Chen 0f03baa539 Minor comment change.
llvm-svn: 125634
2011-02-16 01:31:20 +00:00
Johnny Chen 22deaa5a1a Add emulation methods for LSL (immediate), LSL (register), LSR (immediate), and LSR (register).
Create two helper methods EmulateShiftImm() and EmulateShiftReg() and have ASR, LSL, and LSR
delegate to the helper methods which take an extra ARM_ShifterType parameter.

The opcodes tables have not been updated yet to reflect these new entries.

llvm-svn: 125633
2011-02-16 01:27:54 +00:00
Caroline Tice 5b5396ba77 Add documentation tags for LDM/STM instruction families.
Add code to emulate STR (register) Arm instruction.

llvm-svn: 125623
2011-02-16 00:33:43 +00:00
Johnny Chen a79703db79 Section heading for EmulateB().
llvm-svn: 125620
2011-02-16 00:17:18 +00:00
Johnny Chen 7484e4e337 Add section headings corresponding to some of the ARM/Thumb emulation methods for better documentation.
llvm-svn: 125618
2011-02-16 00:06:18 +00:00
Greg Clayton bdda58377f Fixed an issue where detection of vCont support wasn't being done correctly.
Fixed how the LLDBDisassembler computes and uses a target triple.

llvm-svn: 125617
2011-02-16 00:00:43 +00:00
Johnny Chen 531dbfa5d8 A8.6.14 ASR (register)
Add EmulateASRReg() Encodings T1, T2, and A1 to the opcodes tables.

llvm-svn: 125614
2011-02-15 23:22:46 +00:00
Caroline Tice f199eea579 Add eContextRegisterLoad instruction emulation context.
Add code to emulate STR (Immediate, Thumb) instruction.

llvm-svn: 125610
2011-02-15 22:53:54 +00:00
Johnny Chen f35024b087 Modify the various shift routines to handle cases where the shift amount comes
from the bottom byte of a register.

llvm-svn: 125606
2011-02-15 22:21:33 +00:00
Greg Clayton b841ff5da5 Removed my specific binaires from the xcscheme.
llvm-svn: 125603
2011-02-15 22:00:20 +00:00
Greg Clayton 514487e806 Made lldb_private::ArchSpec contain much more than just an architecture. It
now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
  selection.

llvm-svn: 125602
2011-02-15 21:59:32 +00:00
Johnny Chen f976896b83 Remove the "Register &reg" parameter from the BXWritePC(), LoadWritePC(), and ALUWritePC()
methods of EmulateInstructionARM class.  The context data structure should provide sufficient
information already.

llvm-svn: 125596
2011-02-15 21:08:58 +00:00
Johnny Chen 6f93f63955 Fix wrong mask and encoding for T2 of ASR (immediate).
llvm-svn: 125593
2011-02-15 20:14:02 +00:00
Johnny Chen a4afff97ad A8.6.14 ASR (immediate)
Add EmulateASRImm() Encodings T1, T2, and A1 to the opcodes tables.

llvm-svn: 125592
2011-02-15 20:10:55 +00:00
Johnny Chen ffb3b51ba8 Refactored the test driver to abstract out the Python sys.path specification for
different build configurations.

llvm-svn: 125584
2011-02-15 18:50:19 +00:00
Caroline Tice 6e12e117d4 Add code to emulate STMIB Arm instruction.
llvm-svn: 125580
2011-02-15 18:42:15 +00:00
Caroline Tice 5e38f35fe3 Add code to emulate STMDB Arm instruction.
Add some bit-mask fixes to code for getting register bits for various LDM and STM instructions.

llvm-svn: 125578
2011-02-15 18:10:01 +00:00
Johnny Chen 7a03c852d0 Add a bunch of utilities and an enum (ARM_ShifterType) for shift and rotate operations pertaining to:
o A2.2.1 Pseudocode details of shift and rotate operations
o A8.4.3 Pseudocode details of instruction-specified shifts and rotates

llvm-svn: 125575
2011-02-15 17:52:22 +00:00
Johnny Chen ef55e4c174 Remove the unnecessary assignment of m_inst_cpsr inside EvaluateInstruction(),
because it's already been done within ReadInstruction().

llvm-svn: 125569
2011-02-15 17:31:33 +00:00
Caroline Tice efb309619a Add code to emulate the STMDA Arm instruction.
llvm-svn: 125542
2011-02-15 00:19:42 +00:00
Greg Clayton e576ab2996 All UnwindPlan objects are now passed around as shared pointers.
ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture 
instead of being leaked for every frame.

Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and
ArchDefaultUnwindPlan_i386 interfaces.

There were sporadic crashes that were due to something leaking or being 
destroyed when doing stack crawls. This patch should clear up these issues.

llvm-svn: 125541
2011-02-15 00:19:15 +00:00
Johnny Chen 557520b996 Add missing logic (if BadReg(d) then UNPREDICTABLE;) for Encoding T2 of EmulateMovRdImm().
llvm-svn: 125533
2011-02-14 23:33:58 +00:00
Johnny Chen 5623dc3559 Fix build warning (unused variable).
llvm-svn: 125531
2011-02-14 23:21:24 +00:00
Caroline Tice eccad4d005 - Rearrange instruction emulation contexts to use a union for the
various types and numbers of arguments rather than trying to keep a
  constant number of arguments for all the types.

- Also create a Register type within the instructions, to hold
  register type and number.

- Modify EmulateInstructionArm.cpp to use the new register and context
  types in all the instruction emulation functions.

- Add code to emulate the STM Arm instruction.

llvm-svn: 125528
2011-02-14 23:03:21 +00:00
Johnny Chen dacc14c995 Updated README file.
llvm-svn: 125527
2011-02-14 22:25:44 +00:00
Johnny Chen c3ba12d8e8 Add entries for EmulateMovRdImm() -- "MOV (immediate)" -- Encodings T1 & T2 into g_thumb_opcodes
table.  Modify EmulateInstructionARM::EvaluateInstruction() so that if the cpsr has changed
during evaluate instruction, we flush out the change into m_inst_cpsr in preparation for the next
instruction.

llvm-svn: 125524
2011-02-14 22:04:25 +00:00
Greg Clayton c2448f6175 Added support for Xcode 4 build directories.
llvm-svn: 125522
2011-02-14 21:17:06 +00:00
Johnny Chen 86776147ff Add impl for EmulateMvnRdImm() -- "MVN (immediate)". Plus zero out the arg0 field of
the context of eContextImmediate type, since the immediate value is known from the
argument value to WriteRegisterUnsigned() callback already.

llvm-svn: 125518
2011-02-14 20:39:01 +00:00
Johnny Chen ac407594c2 Add comment.
llvm-svn: 125509
2011-02-14 19:09:36 +00:00
Johnny Chen e2b86a3a83 Enhanced the existing ARMExpandImm() and ThumbExpandImm() functions which expand
an imm12 into imm32 for ARM or Thumb so that they now handle carry_in/carry_out.
Funnel ARMExpandImm()/ThumbExpandImm() to the enhanced ARMExpandImm_C()/ThumbExpandImm_C()
functions.

llvm-svn: 125508
2011-02-14 19:08:41 +00:00
Greg Clayton 71fc2a33b5 Added the ability to detect which vCont packets (using the "vCont?") packet
are supported by the remote GDB target. We can also now deal with the lack of
vCont support and send packets that the remote GDB stub can use. We also error
out of the continue if LLDB tries to do something too complex when vCont isn't
supported.

llvm-svn: 125433
2011-02-12 06:28:37 +00:00
Johnny Chen b3b8e0ffc2 Add entries for Encodings T1 and A1 of "MVN (immediate)" to g_arm_opcodes and g_thumb_opcodes
tables.  The corresponding EmulateMvnRdImm() method impl is empty for now.

llvm-svn: 125425
2011-02-12 01:27:26 +00:00
Johnny Chen 61938f795f Changed comments of some functions to be consistent with existing ones.
llvm-svn: 125423
2011-02-12 01:01:40 +00:00
Johnny Chen 1173fbdc4b Add helper methods InITBlock() and LastInITBlock() to EmulateInstructionARM class
instead of calling out to m_it_session.InITBlock()/LastInITBlock(), which simplifies
the coding a bit.

llvm-svn: 125421
2011-02-12 00:50:05 +00:00
Johnny Chen a222c04588 Add EmulateBXRm() ("Branch and Exchange") to both g_arm_opcodes and g_thumb_opcodes table.
llvm-svn: 125418
2011-02-12 00:10:51 +00:00
Johnny Chen 722d4e4aa0 Add a couple of utility functions plus some comments.
llvm-svn: 125416
2011-02-11 23:29:14 +00:00
Caroline Tice 7b37670d56 - Add three more instruction contexts to EmulateInstruction:
eContextAdjustBaseRegister, eContextRegisterStore and
eContextWriteMemoryRandomBits.

- Implement a version of WriteBits32UnknownToMemory for writing to memory.

- Modify EmulateLDM, EmulateLDMDA, EmulateLDMDB and EmulateLDMIB to use the
eContextAdjustBaseRegister context when appropriate.

- Add code to emulate the STM/STMIA/STMEA Arm instruction.

llvm-svn: 125414
2011-02-11 22:49:54 +00:00
Johnny Chen a61541663c Add EmulateCmpRnRm() for Encodings T1 & T2 to the g_thumb_opcodes table to emulate
CMP (register) operations.

llvm-svn: 125413
2011-02-11 21:53:58 +00:00
Johnny Chen c6ca7bb67a Rearraned some emulate instruction entries under the appropriate category.
llvm-svn: 125405
2011-02-11 21:23:32 +00:00
Johnny Chen 259326c821 Instead of self.runCmd(), do a stronger self.expect("process status") which also
checks that the process is stopped due to breakpoint at the specified line no.

llvm-svn: 125400
2011-02-11 20:11:06 +00:00
Johnny Chen f1075ce0e6 Handle the case of interworking branch for EmulateLDMDA.
llvm-svn: 125392
2011-02-11 19:37:03 +00:00
Johnny Chen 298251cd9b Add Thumb2 LDR (literal) instruction into the g_thumb_opcodes table.
Change the method name from *LDRRdPCRelative to *LDRRtPCRelative to be compliant
with the ARM Arch Manual which uses Rt for the destination register.

llvm-svn: 125390
2011-02-11 19:12:30 +00:00
Johnny Chen bce7ad6b48 Fix build.
llvm-svn: 125379
2011-02-11 18:11:22 +00:00
Caroline Tice 485b4d8352 Add new instruction context, eContextWriteRegisterRandomBits.
Add new utility function, WriteBits32Unknown

Modify the LDM* instruction emulation functions to call WriteBits32Unknown.
Add missing overview comments to the LDM* instruction emulation functions.

Add code to emulate LDMDA Arm instruction.

llvm-svn: 125377
2011-02-11 17:59:55 +00:00
Johnny Chen c7af6fe3bd Add an entry for CMP (immediate) (Encoding T1) to the g_thumb_opcodes table.
llvm-svn: 125333
2011-02-11 02:02:56 +00:00
Johnny Chen 37c48b02a4 Add a helper method AddWithCarry() to the EmulateInstructionARM class.
llvm-svn: 125329
2011-02-11 01:29:53 +00:00
Johnny Chen 0061ff20d8 Fix another typo.
llvm-svn: 125323
2011-02-11 00:07:26 +00:00
Johnny Chen b18528df84 Fix a typo.
llvm-svn: 125322
2011-02-11 00:06:48 +00:00
Johnny Chen b500ffe071 Add TestConstStrings.py under foundation dir for testing expression parser on objective-c strings
and constant strings.

llvm-svn: 125320
2011-02-10 23:58:37 +00:00
Sean Callanan 229ce2d5b1 Fixes for two bugs:
- Objective-C constant strings were being
  NULL-terminated erroneously.

- Empty Objective-C constant strings were not
  being generated correctly.

Also added the template for a test of these
fixes.

llvm-svn: 125314
2011-02-10 22:17:53 +00:00
Johnny Chen 9524110d98 Cleaned up some parameter types and names.
llvm-svn: 125313
2011-02-10 21:49:16 +00:00
Johnny Chen c843a78efc Namings are important. Renamed Bits32(const uint32_t val, uint32_t bit) to Bit32(val, bit) and
SetBits32(uint32_t &bits, uint32_t bit, uint32_t val) to SetBit32(bits, bit, val).

llvm-svn: 125312
2011-02-10 21:39:01 +00:00
Johnny Chen 101f6efb8a Some refactorings to use the convenience function: Bits32(const uint32_t value, const uint32_t bit).
llvm-svn: 125303
2011-02-10 19:54:05 +00:00
Johnny Chen 992b48c4be Add some comment markers.
llvm-svn: 125302
2011-02-10 19:40:42 +00:00
Johnny Chen 0cfda5bbb5 Add a generic EmulateMovRdRm() method and modify/add entries to the g_thumb_opcodes
table.  Also add some more defines and convenience functions.

llvm-svn: 125300
2011-02-10 19:29:03 +00:00
Johnny Chen 77224a5422 Rearrange the order of g_thumb_opcodes entries.
llvm-svn: 125295
2011-02-10 18:13:23 +00:00
Greg Clayton 1117795eaf Fixed a crasher when enabling logging that is due to the new hijack listener stack changes.
llvm-svn: 125269
2011-02-10 06:51:22 +00:00
Johnny Chen cc13e4c62e Add EmulateLDRRtRnImm() for EncodingT1 of LDR (immediate, Thumb) to the g_thumb_opcodes table,
and a helper method UnalignedSupport().

llvm-svn: 125258
2011-02-10 01:52:38 +00:00
Caroline Tice b44880cadd Add a new function to Debugger for finding the top/current
input reader.

Always make sure the input reader stack is not empty before
trying to get the top element from the stack.

llvm-svn: 125255
2011-02-10 01:15:13 +00:00
Johnny Chen 1cabebe7bc Add a new member variable m_new_inst_cpsr to catch the to-be-updated state
of the CPSR during the course of executing an opcode, and modified SelectInstrSet()
to update this variable instead of the original m_inst_cpsr, which should be
the cached copy of the CPSR at the beginning of executing the opcode.

llvm-svn: 125244
2011-02-09 23:59:17 +00:00
Johnny Chen edf55ae52a Add EmulateAddRdnRm() for EncodingT2 of ADD(register) to the g_thumb_opcodes table,
and a helper method ALUWritePC(Context&, uint32_t).

llvm-svn: 125241
2011-02-09 23:43:29 +00:00
Greg Clayton 7bd65b9fae Modified version of a patch from Warren Paul that takes care of issues with
indirect forms, deals with empty DW_AT_comp_dir attributes, and fixups for
handling other signed integer types.

llvm-svn: 125240
2011-02-09 23:39:34 +00:00
Johnny Chen 0ce4a83c44 Modified existing Emulate* methods to call LoadWritePC(context, data) where appropriate to
effect an interworking branch if the ArchVersion() is ARMv5T and above.

llvm-svn: 125227
2011-02-09 22:02:17 +00:00
Greg Clayton f4dd543d92 Missed part of a patch from Stephen Wilson.
llvm-svn: 125220
2011-02-09 21:12:40 +00:00
Stephen Wilson d4182f4b01 linux: use IS_VALID_LLDB_HOST_THREAD.
Update the linux plugin code to use the new check for a valid host
thread introduced in r125067.

llvm-svn: 125213
2011-02-09 20:10:35 +00:00
Johnny Chen 8bba644bf4 Modified EmulatePop impl to use the helper method LoadWritePC(context, data) since if PC
is in the list of registers to be load and we're in ARMv5T and above, this is an interworking branch.

llvm-svn: 125212
2011-02-09 19:30:49 +00:00
Johnny Chen cc707657f9 If the CPSR is changed due to switching between ARM and Thumb ISETSTATE,
we want to record it and issue a WriteRegister callback so the clients
can track the mode changes accordingly.

llvm-svn: 125209
2011-02-09 19:11:32 +00:00
Greg Clayton 1c9e5acd27 Added the DWARF unique type map such that we only create a type once in the
module's AST context. Prior to this fix, with gcc binaries, we end up with
a full class definition for any used classes in each compile unit due to the
one definition rule. This would result in us making N copies of class T, where
N is the number of compile units that use class T, in the module AST. When
an expression would then try and use any types that were duplicated, it would
quickly confuse clang and make expression evaluation fail due to all of the
duplicate types that got copied over. This is now fixed by making a map of
types in the DWARF that maps type names to a collection of types + declaration
(file + line number) + DIE. Then later when we find a type we look in this
module map and find any already cached types that we can just use.

8935777

llvm-svn: 125207
2011-02-09 19:06:17 +00:00
Greg Clayton 000aeb89ae Patch from Kirk Beitz to make things compile on MinGW minus the putenv part.
llvm-svn: 125199
2011-02-09 17:41:27 +00:00
Greg Clayton 94d086262a File::GetFileSpec() support for linux patch from Stephen Wilson.
llvm-svn: 125181
2011-02-09 07:19:18 +00:00
Greg Clayton 9f5abd8e44 Fix comment text.
llvm-svn: 125162
2011-02-09 03:12:09 +00:00
Greg Clayton 0d0c12ab61 <rdar://problem/8972204> Test failure: ./dotest.py -v -t -f UniversalTestCase.test_process_launch_for_universal
Fix for bad architecture settings that were being used from the qHostInfo.

llvm-svn: 125161
2011-02-09 03:09:55 +00:00
Greg Clayton 925137cf84 Pull support for the shared and exclusive lock since this wasn't available
on linux. And conditionalize the availablility of the fcntl() command 
F_GETPATH.

llvm-svn: 125152
2011-02-09 01:16:43 +00:00
Greg Clayton 51b1e2d271 Use Host::File in lldb_private::StreamFile and other places to cleanup host
layer a bit more.

llvm-svn: 125149
2011-02-09 01:08:52 +00:00
Johnny Chen 7eaacc517b Add some helper methods to the EmulateInstructionARM class as a first step in the
refactorings of EmulateInstructionARM.cpp file, which will be modified later to
take advantage of these helper methods.

llvm-svn: 125148
2011-02-09 01:00:31 +00:00
Caroline Tice 123b89b67f Add code to emulate the LDMIB Arm instruction.
Modify code for LDM and LDMDB instructions to only
create one context and to reuse it, rather than 
creating multiple contexts.

llvm-svn: 125139
2011-02-08 23:56:10 +00:00
Johnny Chen 108a363318 Fix typos.
llvm-svn: 125138
2011-02-08 23:49:37 +00:00
Jim Ingham 843630781a Add FileSpec::ResolvePartialUsername, and use it in CommandCompletions to isolate pwd.h in the Host layer.
llvm-svn: 125135
2011-02-08 23:24:09 +00:00
Johnny Chen 03feace9d0 Add EmulateCB() entry to the g_thumb_opcodes table to represent "Compare and Branch
on NonZero and Compare and Branch on Zero" operations.

llvm-svn: 125134
2011-02-08 23:21:57 +00:00
Caroline Tice cdb58e1236 Add code to emulate LDMDB Arm instruction.
llvm-svn: 125133
2011-02-08 23:16:02 +00:00
Caroline Tice 7aa01cfd64 Add code to emulate the LDM ARM instruction.
llvm-svn: 125118
2011-02-08 22:24:38 +00:00
Johnny Chen 181376f29f Add missing implementation for "BL, BLX (immediate)" Encoding T1 and an entry for "bl <label>"
into g_thumb_opcodes table.

llvm-svn: 125112
2011-02-08 20:36:34 +00:00