Commit Graph

713 Commits

Author SHA1 Message Date
Jim Ingham 61be0903e5 Adding support for fetching the Dynamic Value for ObjC Objects.
llvm-svn: 130701
2011-05-02 18:13:59 +00:00
Greg Clayton 2289fa4820 Added the ability to set the Platform path for a module through the SBModule
interface.

Added a quick way to set the platform though the SBDebugger interface. I will
actually an a SBPlatform support soon, but for now this will do.

ConnectionFileDescriptor can be passed a url formatted as: "fd://<fd>" where
<fd> is a file descriptor in the current process. This is handy if you have
services, deamons, or other tools that can spawn processes and give you a
file handle.

llvm-svn: 130565
2011-04-30 01:09:13 +00:00
Greg Clayton e5b3498eef Added the start of the CFI row production using the
emulate instruction classes.

llvm-svn: 130556
2011-04-29 22:50:31 +00:00
Greg Clayton 84c39663a9 Added a new OptionValue subclass for lldb::Format: OptionValueFormat. Added
new OptionGroup subclasses for:
- output file for use with options: 
        long opts: --outfile <path> --append--output
        short opts: -o <path> -A
        
- format for use with options:
        long opts: --format <format>

- variable object display controls for depth, pointer depth, wether to show
  types, show summary, show location, flat output, use objc "po" style summary.
  
Modified ValueObjectMemory to be able to be created either with a TypeSP or
a ClangASTType.

Switched "memory read" over to use OptionGroup subclasses: one for the outfile
options, one for the command specific options, and one for the format.

llvm-svn: 130334
2011-04-27 22:04:39 +00:00
Greg Clayton 79ea878bf9 Got the EmulateInstruction CFI code a lot closer to producing CFI data.
Switch the EmulateInstruction to use the standard RegisterInfo structure
that is defined in the lldb private types intead of passing the reg kind and
reg num everywhere. EmulateInstruction subclasses also need to provide
RegisterInfo structs given a reg kind and reg num. This eliminates the need
for the GetRegisterName() virtual function and allows more complete information
to be passed around in the read/write register callbacks. Subclasses should
always provide RegiterInfo structs with the generic register info filled in as
well as at least one kind of register number in the RegisterInfo.kinds[] array.

llvm-svn: 130256
2011-04-26 23:48:45 +00:00
Johnny Chen a85bf380ba Modify EmulateInstructionARM::SetArchitecture() to treat "arm" and "thumb" as wild card architectures
for now, in order to fix the test failure for the 'arm_emulation' directory.
There might be a better way.

llvm-svn: 130227
2011-04-26 18:51:57 +00:00
Greg Clayton 2ed751bd47 Changed the emulate instruction function to take emulate options which
are defined as enumerations. Current bits include:

        eEmulateInstructionOptionAutoAdvancePC
        eEmulateInstructionOptionIgnoreConditions

Modified the EmulateInstruction class to have a few more pure virtuals that
can help clients understand how many instructions the emulator can handle:

        virtual bool
        SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0;


Where instruction types are defined as:

//------------------------------------------------------------------
/// Instruction types
//------------------------------------------------------------------    
typedef enum InstructionType
{
    eInstructionTypeAny,                // Support for any instructions at all (at least one)
    eInstructionTypePrologueEpilogue,   // All prologue and epilogue instructons that push and pop register values and modify sp/fp
    eInstructionTypePCModifying,        // Any instruction that modifies the program counter/instruction pointer
    eInstructionTypeAll                 // All instructions of any kind

}  InstructionType;


This allows use to tell what an emulator can do and also allows us to request
these abilities when we are finding the plug-in interface.

Added the ability for an EmulateInstruction class to get the register names
for any registers that are part of the emulation. This helps with being able
to dump and log effectively.

The UnwindAssembly class now stores the architecture it was created with in
case it is needed later in the unwinding process.

Added a function that can tell us DWARF register names for ARM that goes
along with the source/Utility/ARM_DWARF_Registers.h file: 

        source/Utility/ARM_DWARF_Registers.c
        
Took some of plug-ins out of the lldb_private namespace.

llvm-svn: 130189
2011-04-26 04:39:08 +00:00
Greg Clayton 7be2542fc9 Renamed UnwindAssemblyProfiler to UnwindAssembly along with its source files.
llvm-svn: 130156
2011-04-25 21:14:26 +00:00
Greg Clayton 078daac55d Even more renaming.
llvm-svn: 130155
2011-04-25 21:07:40 +00:00
Greg Clayton ffc922e389 More moving things around for the unwind plan and assembly unwind plug-ins.
llvm-svn: 130154
2011-04-25 21:05:07 +00:00
Greg Clayton dc5eb693bd Put plug-ins into the correct directories as they were incorrectly located
in a Utility directory.

llvm-svn: 130135
2011-04-25 18:36:36 +00:00
Greg Clayton 7e14f91dbd Fixed the SymbolContext::DumpStopContext() to correctly indent and dump
inline contexts when the deepest most block is not inlined.

Added source path remappings to the lldb_private::Target class that allow it
to remap paths found in debug info so we can find source files that are elsewhere
on the current system.

Fixed disassembly by function name to disassemble inline functions that are
inside other functions much better and to show enough context before the
disassembly output so you can tell where things came from.

Added the ability to get more than one address range from a SymbolContext 
class for the case where a block or function has discontiguous address ranges.

llvm-svn: 130044
2011-04-23 02:04:55 +00:00
Caroline Tice de2fb9cf76 Change code for reading emulation data files to read the new file
format.  (The newly formatted files will go in as a separate commit in a
few minutes).

llvm-svn: 129981
2011-04-22 05:08:45 +00:00
Greg Clayton 2048ea5eba Fixed a case where if a function, inlined function, or global with a mangled
name had a DW_AT_name that was the same string as the DW_AT_MIPS_linkage_name,
then it would get added twice to the DWARF index.

llvm-svn: 129942
2011-04-21 21:41:13 +00:00
Caroline Tice 3ac6711aec Add the infrastructure to test instruction emulations automatically.
The idea is that the instruction to be emulated is actually executed
on the hardware to be emulated, with the before and after state of the
hardware being captured and 'freeze-dried' into .dat files.  The
emulation testing code then loads the before & after state from the
.dat file, emulates the instruction using the before state, and
compares the resulting state to the 'after' state.  If they match, the
emulation is accurate, otherwise there is a problem.

The final format of the .dat files needs a bit more work; the plan is
to generalize them a bit and to convert the plain values to key-value pairs. 
But I wanted to get this first pass committed.

This commit adds arm instruction emulation testing to the testsuite, along with
many initial .dat files.

It also fixes a bug in the llvm disassembler, where 32-bit thumb opcodes
were getting their upper & lower 16-bits reversed.

There is a new Instruction sub-class, that is intended to be loaded
from a .dat file rather than read from an executable.  There is also a
new EmulationStateARM class, for handling the before & after states.
EmulationStates for other architetures can be added later when we
emulate their instructions.

llvm-svn: 129832
2011-04-19 23:30:03 +00:00
Johnny Chen a6ca9fb407 Rename some variables, no functionality change.
llvm-svn: 129724
2011-04-18 22:11:31 +00:00
Greg Clayton 7260f6206f Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the 
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example). 

Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.

We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:

(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000) 
(lldb) target list
Current targets:
  target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
  target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
  frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
  frame #1: 0x0000000100000b64 a.out`start + 52

Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.

llvm-svn: 129695
2011-04-18 08:33:37 +00:00
Jim Ingham 78a685aa2d Add support for "dynamic values" for C++ classes. This currently only works for "frame var" and for the
expressions that are simple enough to get passed to the "frame var" underpinnings.  The parser code will
have to be changed to also query for the dynamic types & offsets as it is looking up variables.

The behavior of "frame var" is controlled in two ways.  You can pass "-d {true/false} to the frame var
command to get the dynamic or static value of the variables you are printing.

There's also a general setting:

target.prefer-dynamic-value (boolean) = 'true'

which is consulted if you call "frame var" without supplying a value for the -d option.

llvm-svn: 129623
2011-04-16 00:01:13 +00:00
Jim Ingham 337030f556 Work around a llvm gcc bug where the name of a reference doesn't include the "&".
llvm-svn: 129620
2011-04-15 23:41:23 +00:00
Johnny Chen b57edcab3b Get rid the of set membership test (log(m)) and, instead, use an index variable 'i'
which advances when src collides with a purged slot.
Hi Stephen, you're welcome to overwrite/or improve upon this version.  Thanks.

llvm-svn: 129611
2011-04-15 21:45:12 +00:00
Johnny Chen fec280e750 Update both the src and dst pointers at the end of the loop.
Stephen Wilson is working on a better performing patch in the meantime.

llvm-svn: 129605
2011-04-15 20:59:46 +00:00
Johnny Chen d2ddabac20 Optimize address range coalescing.
DWARFDebugAranges::Sort() calls std::stable_sort() over a set of address ranges
and then proceeds to collapse neighboring ranges together.

One problem with the current implementation is that it does an incomplete job.
When a pair of ranges are merged the next pair considered does not include the
just-merged range.  IOW, three consecutive ranges are never collapsed into one.

Another problem is that for each range merged we are calling
std::vector::erase() which "shifts" all remaining elements of the vector by one
position on every merge.  The end result (in the worst case) is a quadratic
algorithm -- not good when the input vector is large.

The following patch merges all consecutive ranges and removes the quadratic
behavior.  The implementation uses an auxiliary vector of indices in order to
remember all ranges that can be dropped, then performs the coalescing of ranges
in a single pass.

Patch from Stephen Wilson with some minor modification by me.

llvm-svn: 129595
2011-04-15 19:56:24 +00:00
Greg Clayton ab65b34fdc Added auto completion for architecture names and for platforms.
Modified the OptionGroupOptions to be able to specify only some of the options
that should be appended by using the usage_mask in the group defintions and
also provided a way to remap them to a new usage mask after the copy. This 
allows options to be re-used and also targetted for specific option groups.

Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration.
Taught the option parser to be able to automatically use the appropriate
auto completion for a given options if nothing is explicitly specified
in the option definition. So you don't have to specify it in the option
definition tables.

Renamed the default host platform name to "host", and the default platform
hostname to be "localhost".

Modified the "file" and "platform select" commands to make sure all options
and args are good prior to creating a new platform. Also defer the computation
of the architecture in the file command until all options are parsed and the
platform has either not been specified or reset to a new value to avoid
computing the arch more than once.

Switch the PluginManager code over to using llvm::StringRef for string
comparisons and got rid of all the AccessorXXX functions in lieu of the newer
mutex + collection singleton accessors.

llvm-svn: 129483
2011-04-13 22:47:15 +00:00
Caroline Tice 17f5fa2b1c Fix bug where source & target registers were swapped in an
emulation function.

llvm-svn: 129474
2011-04-13 21:49:04 +00:00
Caroline Tice 69955f6cdc Fix various minor bugs in the ARM instruction emulation code.
llvm-svn: 129422
2011-04-13 00:42:12 +00:00
Greg Clayton 8b82f087a0 Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.

Make sure that Modules can track their object file offsets correctly to
allow opening of sub object files (like the "__commpage" on darwin).

Modified the Platforms to be able to launch processes. The first part of this
move is the platform soon will become the entity that launches your program
and when it does, it uses a new ProcessLaunchInfo class which encapsulates
all process launching settings. This simplifies the internal APIs needed for
launching. I want to slowly phase out process launching from the process
classes, so for now we can still launch just as we used to, but eventually
the platform is the object that should do the launching.

Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able
to launch processes with all of the new eLaunchFlag settings. Modified any
code that was manually launching processes to use the Host::LaunchProcess
functions.

Fixed an issue where lldb_private::Args had implicitly defined copy 
constructors that could do the wrong thing. This has now been fixed by adding
an appropriate copy constructor and assignment operator.

Make sure we don't add empty ModuleSP entries to a module list.

Fixed the commpage module creation on MacOSX, but we still need to train
the MacOSX dynamic loader to not get rid of it when it doesn't have an entry
in the all image infos.

Abstracted many more calls from in ProcessGDBRemote down into the 
GDBRemoteCommunicationClient subclass to make the classes cleaner and more
efficient.

Fixed the default iOS ARM register context to be correct and also added support
for targets that don't support the qThreadStopInfo packet by selecting the
current thread (only if needed) and then sending a stop reply packet.

Debugserver can now start up with a --unix-socket (-u for short) and can 
then bind to port zero and send the port it bound to to a listening process
on the other end. This allows the GDB remote platform to spawn new GDB server
instances (debugserver) to allow platform debugging.

llvm-svn: 129351
2011-04-12 05:54:46 +00:00
Stephen Wilson 71c21d18c3 Order of initialization lists.
This patch fixes all of the warnings due to unordered initialization lists.

Patch by Marco Minutoli.

llvm-svn: 129290
2011-04-11 19:41:40 +00:00
Caroline Tice 88544c5f2c Implement ARM emulation function to handle "SUBS PC, LR and related instructions".
llvm-svn: 129279
2011-04-11 15:51:10 +00:00
Caroline Tice 25d61ac2ed Fix various things in the instruction emulation code:
- Add ability to control whether or not the emulator advances the
    PC register (in the emulation state), if the instruction itself
    does not change the pc value..

    - Fix a few typos in asm description strings.

    - Fix bug in the carry flag calculation.

llvm-svn: 129168
2011-04-08 23:33:06 +00:00
Stephen Wilson 8acdbb8a75 Add missing headers.
Something changed in commit r129112 where a few standard headers vanished from
the include chain when building on Linux.  Fix up by including limits.h for
INT_MAX and PATH_MAX where needed, and stdio.h for printf().

llvm-svn: 129130
2011-04-08 13:36:44 +00:00
Stephen Wilson 05459c8269 Add the ARM instruction emulation makefile.
I forgot to 'svn add' this file in r129119.

llvm-svn: 129120
2011-04-08 02:11:29 +00:00
Stephen Wilson d5adc9185c Add makefile support for the ARM instruction emulation plugin.
llvm-svn: 129119
2011-04-08 02:01:35 +00:00
Stephen Wilson 3f588d3f50 linux: add missing arguments to FindFirstModuleForFileSpec
Specifying the new arguments as NULL is appropriate for now as this is
backwards-compatible with the old invocation. 

llvm-svn: 129118
2011-04-08 02:00:23 +00:00
Greg Clayton eb0103f2d0 Modified the ArchSpec to take an optional "Platform *" when setting the triple.
This allows you to have a platform selected, then specify a triple using
"i386" and have the remaining triple items (vendor, os, and environment) set
automatically.

Many interpreter commands take the "--arch" option to specify an architecture
triple, so now the command options needed to be able to get to the current
platform, so the Options class now take a reference to the interpreter on
construction.

Modified the build LLVM building in the Xcode project to use the new
Xcode project level user definitions:

LLVM_BUILD_DIR - a path to the llvm build directory
LLVM_SOURCE_DIR - a path to the llvm sources for the llvm that will be used to build lldb
LLVM_CONFIGURATION - the configuration that lldb is built for (Release, 
Release+Asserts, Debug, Debug+Asserts).

I also changed the LLVM build to not check if "lldb/llvm" is a symlink and
then assume it is a real llvm build directory versus the unzipped llvm.zip
package, so now you can actually have a "lldb/llvm" directory in your lldb
sources.

llvm-svn: 129112
2011-04-07 22:46:35 +00:00
Stephen Wilson f6e259049d Removed use of NSEC_PER_SEC.
NSEC_PER_SEC is not defined in sys/time.h on Linux. Replaced that macro with a
static constant inside TimeValue.

Patch by Marco Minutoli.

llvm-svn: 129071
2011-04-07 10:27:22 +00:00
Stephen Wilson 0682ba2f2e linux: remove ProcessLinux::FindProcesses
This method only needs to be overridden in the remote debugging case,  the
base class handles the host case.  Since we do not do remote debugging on
Linux yet and there is a typo that causes a build issue, just remove this
method for now.
 

llvm-svn: 129069
2011-04-07 10:16:53 +00:00
Greg Clayton 15eb2558ef Update the linux platform to use the new Host::FindProcesses functionality.
llvm-svn: 129018
2011-04-06 18:50:36 +00:00
Caroline Tice 7c9dd3ce3c Add Emulate and DumpEmulation to Instruction class.
Move InstructionLLVM out of DisassemblerLLVM class.

Add instruction emulation function calls to SBInstruction and SBInstructionList APIs.

llvm-svn: 128956
2011-04-05 23:22:54 +00:00
Caroline Tice ad379efc86 Add the rest of the mechanisms to make ARM instruction emulation usable/possible.
llvm-svn: 128907
2011-04-05 18:46:00 +00:00
Greg Clayton 9b1e1cdf23 Added a speed test to the GDBRemoteCommunicationClient and
GDBRemoteCommunicationServer classes. This involved adding a new packet
named "qSpeedTest" which can test the speed of a packet send/response pairs
using a wide variety of send/recv packet sizes.

Added a few new connection classes: one for shared memory, and one for using
mach messages (Apple only). The mach message stuff is experimental and not 
working yet, but added so I don't lose the code. The shared memory stuff
uses pretty standard calls to setup shared memory.

llvm-svn: 128837
2011-04-04 18:18:57 +00:00
Greg Clayton 95bf0fd3ab Added the ability to get a broadcaster event name for a given broadcaster
event.

Modified the ProcessInfo structure to contain all process arguments. Using the
new function calls on MacOSX allows us to see the full process name, not just
the first 16 characters. 

Added a new platform command: "platform process info <pid> [<pid> <pid> ...]"
that can be used to get detailed information for a process including all 
arguments, user and group info and more.

llvm-svn: 128694
2011-04-01 00:29:43 +00:00
Jim Ingham 8d543de400 Remove unneeded ExecutionContextScope variables.
llvm-svn: 128685
2011-03-31 23:01:21 +00:00
Caroline Tice d20c8d1a17 Fix a few typos in the previous commit.
llvm-svn: 128671
2011-03-31 21:31:50 +00:00
Caroline Tice 028b8b7bb7 Add code to emulate VLD1 (single element to all lanes) ARM instruction.
llvm-svn: 128669
2011-03-31 21:15:29 +00:00
Caroline Tice 5901ea7e67 Add code to emulate VST1 (single element from one lane) ARM
instruction (more floating point stores).

llvm-svn: 128661
2011-03-31 19:17:12 +00:00
Caroline Tice d64a08144c Add code to emulate VST1 (multiple single elements) ARM
instruction (floating point store).

llvm-svn: 128656
2011-03-31 18:44:04 +00:00
Caroline Tice bc2b96b699 Add code to emulate VLD1 (single element to one lane) floating point
register load instruction (ARM) .

llvm-svn: 128646
2011-03-31 17:58:23 +00:00
Caroline Tice 31d8498f6f Add code to emulate VLD1 (multiple single elements) ARM instruction.
llvm-svn: 128637
2011-03-31 16:41:19 +00:00
Caroline Tice 8e4ed85520 Add code to emulate VSTR ARM instruction (store a floating point register).
llvm-svn: 128614
2011-03-31 05:38:36 +00:00
Caroline Tice df6dec754b Add code to emulate the VLDR Arm instruction (load a floating poitn register).
llvm-svn: 128613
2011-03-31 05:05:30 +00:00
Caroline Tice b5c6a3e50a Add "Bits64" utility function.
Add code to emulate VSTM ARM instruction (store multiple floating point registers).

llvm-svn: 128609
2011-03-31 03:26:23 +00:00
Greg Clayton 05d2b7f741 Added some functions to our API related to classifying symbols as code, data,
const data, etc, and also for SBAddress objects to classify their type of
section they are in and also getting the module for a section offset address.

    lldb::SymbolType SBSymbol::GetType();
    
    lldb::SectionType SBAddress::GetSectionType ();
    lldb::SBModule SBAddress::GetModule ();

llvm-svn: 128602
2011-03-31 01:08:07 +00:00
Caroline Tice 920c6c9855 Modify ARM instruction tables to allow for specifying floating point variants.
Add code to emulate VLDM ARM instruction (loading multiplt floating point registers).

Add function declarations for other floating point instructions to emulate.

llvm-svn: 128589
2011-03-31 00:02:51 +00:00
Caroline Tice 55bff33b50 Fill in code for EmulateSTRDImm and EmulateSTRDReg, to emulate the
STRD (immediate) and STRD (register) instructions.

llvm-svn: 128570
2011-03-30 19:02:56 +00:00
Greg Clayton 32e0a7509c Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make 
sense by default so that subclasses can check:

int
PlatformSubclass::Foo ()
{
    if (IsHost())
        return Platform::Foo (); // Let the platform base class do the host specific stuff
    
    // Platform subclass specific code...
    int result = ...
    return result;
}

Added new functions to the platform:

    virtual const char *Platform::GetUserName (uint32_t uid);
    virtual const char *Platform::GetGroupName (uint32_t gid);

The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.

Added the parent process ID to the ProcessInfo class. 

Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value, 
    euid == value, egid == value, arch == value, parent == value.
    
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class 
implements the process lookup routines, you can now lists processes on 
your local machine:

machine1.foo.com % lldb
(lldb) platform process list 
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                   NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538  1      username   usergroup  username   usergroup  x86_64-apple-darwin      FileMerge
94943  1      username   usergroup  username   usergroup  x86_64-apple-darwin      mdworker
94852  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Safari
94727  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Xcode
92742  92710  username   usergroup  username   usergroup  i386-apple-darwin        debugserver


This of course also works remotely with the lldb-platform:

machine1.foo.com % lldb-platform --listen 1234

machine2.foo.com % lldb
(lldb) platform create remote-macosx
  Platform: remote-macosx
 Connected: no
(lldb) platform connect connect://localhost:1444
  Platform: remote-macosx
    Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
    Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
  Hostname: machine1.foo.com
 Connected: yes
(lldb) platform process list 
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                   NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556  244    username   usergroup  username   usergroup  x86_64-apple-darwin      trustevaluation
99548  65539  username   usergroup  username   usergroup  x86_64-apple-darwin      lldb
99538  1      username   usergroup  username   usergroup  x86_64-apple-darwin      FileMerge
94943  1      username   usergroup  username   usergroup  x86_64-apple-darwin      mdworker
94852  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Safari

The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.

Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:

% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out

Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.

Modified the disassembly to show the current PC value. Example output:

(lldb) disassemble --frame
a.out`main:
   0x1eb7:  pushl  %ebp
   0x1eb8:  movl   %esp, %ebp
   0x1eba:  pushl  %ebx
   0x1ebb:  subl   $20, %esp
   0x1ebe:  calll  0x1ec3                   ; main + 12 at test.c:18
   0x1ec3:  popl   %ebx
-> 0x1ec4:  calll  0x1f12                   ; getpid
   0x1ec9:  movl   %eax, 4(%esp)
   0x1ecd:  leal   199(%ebx), %eax
   0x1ed3:  movl   %eax, (%esp)
   0x1ed6:  calll  0x1f18                   ; printf
   0x1edb:  leal   213(%ebx), %eax
   0x1ee1:  movl   %eax, (%esp)
   0x1ee4:  calll  0x1f1e                   ; puts
   0x1ee9:  calll  0x1f0c                   ; getchar
   0x1eee:  movl   $20, (%esp)
   0x1ef5:  calll  0x1e6a                   ; sleep_loop at test.c:6
   0x1efa:  movl   $12, %eax
   0x1eff:  addl   $20, %esp
   0x1f02:  popl   %ebx
   0x1f03:  leave
   0x1f04:  ret
   
This can be handy when dealing with the new --line options that was recently
added:

(lldb) disassemble --line
a.out`main + 13 at test.c:19
   18  	{
-> 19  		printf("Process: %i\n\n", getpid());
   20  	    puts("Press any key to continue..."); getchar();
-> 0x1ec4:  calll  0x1f12                   ; getpid
   0x1ec9:  movl   %eax, 4(%esp)
   0x1ecd:  leal   199(%ebx), %eax
   0x1ed3:  movl   %eax, (%esp)
   0x1ed6:  calll  0x1f18                   ; printf

Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.

Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two 
following functions to retrieve both paths:

const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;

llvm-svn: 128563
2011-03-30 18:16:51 +00:00
Caroline Tice 23443245e7 Fill in EmulateLDRDRegister to emulate LDRD (register) instruction.
Remove stubs for functions not-to-be-implemented at the moment.

llvm-svn: 128559
2011-03-30 17:54:52 +00:00
Caroline Tice f0901227e3 Fill in EmulateLDRLImmediate to emulate the LDRD (immediate) ARM instruction.
llvm-svn: 128556
2011-03-30 17:11:45 +00:00
Stephen Wilson 464280542b linux: create thread plans for stepping thru PLT entries
Using the new synthetic symbols generated by ObjectFileELF, have the Linux
dynamic loader plugin generate a thread plan that will take us thru a PLT entry
to the corresponding target function.

llvm-svn: 128552
2011-03-30 16:11:36 +00:00
Stephen Wilson 499b40e8a7 elf: synthesize symbols for PLT entries
When populating symbol tables ObjectFileELF now generates a set of synthetic
trampoline symbols.  These new symbols correspond to entries in the program
linkage table and have a (possibly mangled) name identifying the corresponding
symbol in some DSO.  These symbols will be used by the DynamicLoader loader
plugin on Linux to provide thread plans when execution flows from one DSO to
another.

llvm-svn: 128550
2011-03-30 16:07:05 +00:00
Caroline Tice e746dbf83b Fix typo in previous check-in.
llvm-svn: 128549
2011-03-30 16:05:23 +00:00
Stephen Wilson 43fe645b62 elf: add support for ELF relocation entries
llvm-svn: 128548
2011-03-30 15:59:12 +00:00
Stephen Wilson 84ffe7033c linux: initial support for 'real' signal handling
This patch upgrades the Linux process plugin to handle a larger range of signal
events.  For example, we can detect when the inferior has "crashed" and why,
interrupt a running process, deliver an arbitrary signal, and so on.

llvm-svn: 128547
2011-03-30 15:55:52 +00:00
Caroline Tice 527637d64a Fill in EmulateSTRImmARM to emulate the STR (immediate,ARM) instruction.
llvm-svn: 128528
2011-03-30 06:03:24 +00:00
Caroline Tice a0e8cd5e89 Fill in EmulateSTRBImmARM to emulate the STRB (immediate, ARM) instruction.
llvm-svn: 128527
2011-03-30 05:40:56 +00:00
Caroline Tice 4cee4bd9f4 Fill in EmulateSTREX to emulate the STREX ARM instruction.
llvm-svn: 128525
2011-03-30 05:15:46 +00:00
Stephen Wilson dc91686f48 Unfortunately, sranddev() is not available on all platforms so seed using the
current time instead.

llvm-svn: 128514
2011-03-30 00:12:40 +00:00
Caroline Tice 799e203894 Fill in code in EmulateSUBReg to emulate the SUB (register) ARM instruction.
llvm-svn: 128508
2011-03-29 23:44:20 +00:00
Caroline Tice c5bcda4619 Fill in code in EmulateADDRegShift, to emulate the ADD
(register-shifted register) ARM instruction.

llvm-svn: 128500
2011-03-29 23:03:16 +00:00
Jim Ingham 7572fa75cf Can't just call "rand" to get a random port, 'cause then you'll get the same sequence in two lldb's. This makes running lldb on lldb not work very well.
llvm-svn: 128493
2011-03-29 21:45:47 +00:00
Caroline Tice eba8f83479 Add subtraction context.
Add code to emulate SUB (SP minus register) ARM instruction.

Add stubs for other ARM emulation functions that need to be written.

llvm-svn: 128491
2011-03-29 21:24:06 +00:00
Caroline Tice 3f0bfdacc1 Add missing encodings for EmulateMOVRdImm (MOV register) function.
llvm-svn: 128479
2011-03-29 19:53:44 +00:00
Caroline Tice 87c19f61d4 Fix single quote characters throughout the ARM emulation stuff.
Fix bugs in various ARM istruction emulation functions:

EmulateVPUSH
   - Fix context.
   - Fix bug calculating register numbers.

EmulateVPOP
   - Fix context.
   - Fix bug calculating register numbers.

EmulateShiftIMM
   - Fix bug in assert statement.

EmulateLDMDA
   - Fix context.

EmulateLDMDB
   - Fix context.

EmulateLDMIB
   - Fix context.     

EmulateSTM
   - Fix bug calculating lowest_set_bit.     

EmulateSTMDA
   - Fix context.
   - Fix bug calculating lowest_set_bit.

EmulateSTMDB
   - Fix context.
   - Fix bug calculating lowest_set_bit.

EmulateSTMIB
   - FIx context     

EmulateLDRSBImmed
   - Fix test to match correction in corrected manual 

llvm-svn: 128409
2011-03-28 16:10:45 +00:00
Greg Clayton 357132eb9a Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:

uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;

uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;

Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than 
once.

Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.

Changed:

	bool
	SymbolContextList::AppendIfUnique (const SymbolContext& sc);

To:
	bool
	SymbolContextList::AppendIfUnique (const SymbolContext& sc, 
									   bool merge_symbol_into_function);

This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.

Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").

Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump 
them and show the opcode bytes, we can format the output more 
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.

Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported 
architecture. I also added the ability to specify "thumb" as an 
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:

(lldb) disassemble --arch thumb --name main

You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080:  0xb580 push   {r7, lr}
0x100001082:  0xaf00 add    r7, sp, #0

Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.

llvm-svn: 128347
2011-03-26 19:14:58 +00:00
Stephen Wilson 78decfd025 linux: minor updates to account for recent namespace changes
llvm-svn: 128313
2011-03-26 00:34:57 +00:00
Stephen Wilson 63f37bba1a Add PlatformGDBServer and ProcessGDBRemote to the build system.
llvm-svn: 128312
2011-03-26 00:32:59 +00:00
Stephen Wilson a78867b899 Simple fixes for the gdb remote process plugin on Linux.
llvm-svn: 128291
2011-03-25 18:16:28 +00:00
Greg Clayton 1080edbcdd Cleaned up the Disassembler code a bit more. You can now request a disassembler
plugin by name on the command line for when there is more than one disassembler
plugin.

Taught the Opcode class to dump itself so that "disassembler -b" will dump
the bytes correctly for each opcode type. Modified all places that were passing
the opcode bytes buffer in so that the bytes could be displayed to just pass
in a bool that indicates if we should dump the opcode bytes since the opcode
now lives inside llvm_private::Instruction.

llvm-svn: 128290
2011-03-25 18:03:16 +00:00
Greg Clayton 0ae962735f Made the lldb_private::Opcode struct into a real boy... I mean class.
Modified the Disassembler::Instruction base class to contain an Opcode 
instance so that we can know the bytes for an instruction without needing
to keep the data around.

Modified the DisassemblerLLVM's instruction class to correctly extract the
opcode bytes if all goes well.

llvm-svn: 128248
2011-03-24 23:53:38 +00:00
Greg Clayton e0d378b334 Fixed the LLDB build so that we can have private types, private enums and
public types and public enums. This was done to keep the SWIG stuff from
parsing all sorts of enums and types that weren't needed, and allows us to
abstract our API better.

llvm-svn: 128239
2011-03-24 21:19:54 +00:00
Caroline Tice 466327d604 Fix small bug in ThumbExpandImm_C; arguments to a call to 'bits' were
in the wrong order.

llvm-svn: 128237
2011-03-24 21:11:26 +00:00
Caroline Tice 9b281e2214 Add missing encodings for EmulateLDRRtRnImm (ARM insn emulation funciton).
llvm-svn: 128229
2011-03-24 19:23:45 +00:00
Greg Clayton 1cb6496eb0 Did a lot more work on abtracting and organizing the platforms.
On Mac OS X we now have 3 platforms:
PlatformDarwin - must be subclassed to fill in the missing pure virtual funcs
                 but this implements all the common functionality between
                 remote-macosx and remote-ios. It also allows for another
                 platform to be used (remote-gdb-server for now) when doing
                 remote connections. Keeping this pluggable will allow for
                 flexibility.
PlatformMacOSX - Now implements both local and remote macosx desktop platforms.
PlatformRemoteiOS - Remote only iOS that knows how to locate SDK files in the
                    cached SDK locations on the host.

A new agnostic platform has been created:
PlatformRemoteGDBServer - this implements the platform using the GDB remote 
                          protocol and uses the built in lldb_private::Host
                          static functions to implement many queries.

llvm-svn: 128193
2011-03-24 04:28:38 +00:00
Stephen Wilson 26977167bc linux: simple support for process input and output
llvm-svn: 128137
2011-03-23 02:14:42 +00:00
Stephen Wilson ecc114745e linux: PlatformLinux improvements
Add a few missing virtual methods to PlatformLinux and have it register itself
with PluginManager.

llvm-svn: 128128
2011-03-23 00:57:47 +00:00
Greg Clayton d314e810a7 Added new platform commands:
platform connect <args>
platform disconnect

Each platform can decide the args they want to use for "platform connect". I 
will need to add a function that gets the connect options for the current
platform as each one can have different options and argument counts.

Hooked up more functionality in the PlatformMacOSX and PlatformRemoteiOS.
Also started an platform agnostic PlatformRemoteGDBServer.cpp which can end
up being used by one or more actual platforms. It can also be specialized and
allow for platform specific commands.

llvm-svn: 128123
2011-03-23 00:09:55 +00:00
Caroline Tice 3e1fa1ad09 More fixes for ARM instruction emulation code:
- Remove duplicate write from EmulateLDRRtPCRelative.
  - Add a missing encoding to EmulateADDSPImm.
  - Fix minor problems in Thumb instruction tables.

llvm-svn: 128115
2011-03-22 22:38:28 +00:00
Greg Clayton 576d8834fe Split the GDBRemoteCommunication class into three classes:
GDBRemoteCommunication - The base GDB remote communication class
GDBRemoteCommunicationClient - designed to be used for clients the connect to
                               a remote GDB server
GDBRemoteCommunicationServer - designed to be used on the server side of a
                               GDB server implementation.

llvm-svn: 128070
2011-03-22 04:00:09 +00:00
Jim Ingham 37023b06bd Add the ability to disassemble "n" instructions from the current PC, or the first "n" instructions in a function.
Also added a "-p" flag that disassembles from the current pc.

llvm-svn: 128063
2011-03-22 01:48:42 +00:00
Greg Clayton 7a5388bf75 Split all of the core of LLDB.framework/lldb.so into a
static archive that can be linked against. LLDB.framework/lldb.so
exports a very controlled API. Splitting the API into a static
library allows other tools (debugserver for now) to use the power
of the LLDB debugger core, yet not export it as its API is not
portable or maintainable. The Host layer and many of the other
internal only APIs can now be statically linked against.

Now LLDB.framework/lldb.so links against "liblldb-core.a" instead
of compiling the .o files only for the shared library. This fix
is only for compiling with Xcode as the Makefile based build already
does this.

The Xcode projecdt compiler has been changed to LLVM. Anyone using
Xcode 3 will need to manually change the compiler back to GCC 4.2,
or update to Xcode 4.

llvm-svn: 127963
2011-03-20 04:57:14 +00:00
Greg Clayton ded470d31a Added more platform support. There are now some new commands:
platform status -- gets status information for the selected platform
platform create <platform-name> -- creates a new instance of a remote platform
platform list -- list all available platforms
platform select -- select a platform instance as the current platform (not working yet)

When using "platform create" it will create a remote platform and make it the
selected platform. For instances for iPhone OS debugging on Mac OS X one can 
do:

(lldb) platform create remote-ios --sdk-version=4.0
Remote platform: iOS platform
SDK version: 4.0
SDK path: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0"
Not connected to a remote device.
(lldb) file ~/Documents/a.out
Current executable set to '~/Documents/a.out' (armv6).
(lldb) image list
[  0] /Volumes/work/gclayton/Documents/devb/attach/a.out
[  1] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/dyld
[  2] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.B.dylib


Note that this is all happening prior to running _or_ connecting to a remote
platform. Once connected to a remote platform the OS version might change which
means we will need to update our dependecies. Also once we run, we will need
to match up the actualy binaries with the actualy UUID's to files in the
SDK, or download and cache them locally.

This is just the start of the remote platforms, but this modification is the
first iteration in getting the platforms really doing something.

llvm-svn: 127934
2011-03-19 01:12:21 +00:00
Caroline Tice 77c13fe304 Fix various small problems with EmulateInstructionARM::EmulateSTRRtSP.
llvm-svn: 127898
2011-03-18 19:41:00 +00:00
Jim Ingham b7603bb48d Relax the constraint on the types of ValueObjects that we'll by default try the
ObjC runtime for print object to Pointer AND Integer (from just pointer.)

llvm-svn: 127841
2011-03-18 00:05:18 +00:00
Caroline Tice 4c753376cb Make all the codee that attempts to read the PC consistently use
ReadCoreReg (which 'does the right thing', adding to pc when needed);
fixed places in code where extra addition was being passed along.

Fix bug in insn tables.

llvm-svn: 127838
2011-03-17 23:50:16 +00:00
Jim Ingham 8268ccab60 Fix a problem where we were looking up the class pointer in the {class/sel -> implementation} cache for a objc_msgSendSuper call - where we should have looked up the class's super-class.
llvm-svn: 127830
2011-03-17 21:04:33 +00:00
Jim Ingham 35944dda10 Get ObjC stepping working again when the process is not the default host architecture.
llvm-svn: 127825
2011-03-17 20:02:56 +00:00
Caroline Tice aaf5ddcf82 Add code to emulate STRH (Register) Arm instruction.
Remove inaccurate comments from EmulateInstruction::Context definition.

Fix contexts in a few arm instruction emulation routines.

llvm-svn: 127770
2011-03-16 22:46:55 +00:00
Caroline Tice fe28f1bff9 Fix various small bugs found in the instruction emulation functions.
llvm-svn: 127712
2011-03-16 00:06:12 +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 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 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
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
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
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
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
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
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
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
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
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
Caroline Tice 1cd4459b21 Add code to emulate LDRSH (literal) Arm instruction.
llvm-svn: 126866
2011-03-02 19:45:34 +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
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
Caroline Tice 4f0e5f8852 Add code to emulate LDRH (register) Arm instruction.
llvm-svn: 126758
2011-03-01 18:00:42 +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 699ac0e967 Add emulation for Encoding A1 of A8.6.97 MOV (register).
llvm-svn: 126456
2011-02-25 00:23:25 +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
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
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
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