Commit Graph

2139 Commits

Author SHA1 Message Date
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
Sean Callanan 6d5b79fc2a Updated LLDB to use a recent LLVM/Clang, pulling
in stability fixes for the ARM and Thumb disassemblers.

llvm-svn: 128316
2011-03-26 00:52:28 +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 743fe95b8e Add a missing include required on Linux
llvm-svn: 128311
2011-03-26 00:32:07 +00:00
Jim Ingham e5afbd422f Revert the scheme.
llvm-svn: 128302
2011-03-25 20:57:42 +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
Jim Ingham 9245e5ff77 Switch the "print" alias to "expression --".
llvm-svn: 128224
2011-03-24 18:23:12 +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
Caroline Tice ca1176aaee Add missing cases to switch statements & remove 'default'.
llvm-svn: 128177
2011-03-23 22:31:13 +00:00
Johnny Chen 74af4bc134 Silence clang warnings.
llvm-svn: 128167
2011-03-23 21:03:44 +00:00
Johnny Chen ac77f3b2ac Turns out that the test failure wrt:
rdar://problem/9173060 lldb hangs while running unique-types

disappears if running with clang version >= 3.  Modify the TestUniqueTypes.py
to detect if we are running with clang version < 3 and, if true, skip the test.

Update the lldbtest.system() function to return a tuple of (stdoutdata, stderrdata)
since we need the stderr data from "clang -v" command.  Modify existing clients of
lldbtest.system() to now use, for example:

         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of (variable, value) pairs extracted
         # from the golden output.
         gl = []

And add two utility functions to lldbutil.py.

llvm-svn: 128162
2011-03-23 20:28:59 +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 0c16aa6d39 Eliminate a pile of "type qualifiers ignored on function return type" warnings.
llvm-svn: 128136
2011-03-23 02:12:10 +00:00
Stephen Wilson e9b1491d49 Update autogen'd LLDB_vers.c.
The makefile build uses scripts/generate-vers.pl to build an appropriate
LLDB_vers.c file.  The declarations for these symbols now carry a liblldb_core
prefix so update the script to generate the correct names.

llvm-svn: 128135
2011-03-23 02:07:56 +00:00
Stephen Wilson ad65c0511f Add a missing include needed on Linux and remove a trailing comma.
llvm-svn: 128134
2011-03-23 02:02:29 +00:00
Stephen Wilson 3e2a18f61e linux: add Host/linux subdirectory
Start putting linux specific host code in its own directory.  For now, just
implement Host::GetOSVersion.

llvm-svn: 128133
2011-03-23 01:58:26 +00:00
Johnny Chen afa5ba7d50 Checked in a modified test script to go with rdar://problem/9173060:
test suite: lldb hangs while running unique-types

llvm-svn: 128131
2011-03-23 01:17:44 +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
Johnny Chen 468d6c4680 Fix test suite failures by modifying the script for testing abbreviations.
Failures were due to new commands introduced.

llvm-svn: 128125
2011-03-23 00:43:28 +00:00
Johnny Chen de8241c255 Fix compile warnings wrt LLDBWrapPython.cpp.
llvm-svn: 128124
2011-03-23 00:26:08 +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
Greg Clayton 678f396d20 Added Mac OS X build instructions and included the Linux build instructions
that Stephen Wilson sent out.

llvm-svn: 128116
2011-03-22 22:39:26 +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
Sean Callanan c530af05fe Added AVX support to the Intel portion of debugserver. AVX
autodetection is not yet implemented, but the structures and
register reading/writing code are there.

llvm-svn: 128111
2011-03-22 21:45:30 +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 ffba229d61 Add "up" and "down" aliases.
llvm-svn: 128066
2011-03-22 02:29:32 +00:00
Jim Ingham 0292f4a531 Clean up a few places where SetOptionValue was using the global optarg, rather than the option_arg value that was passed in.
llvm-svn: 128064
2011-03-22 01:53:33 +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
Jim Ingham 381e25b793 Tidy up the stop hook printing when only one thread matches, and there is only one hook.
llvm-svn: 128062
2011-03-22 01:47:27 +00:00
Greg Clayton b43767aff2 Added missing files.
llvm-svn: 128061
2011-03-22 01:34:44 +00:00
Greg Clayton fc36f79170 Abtracted the innards of lldb-core away from the SB interface. There was some
overlap in the SWIG integration which has now been fixed by introducing
callbacks for initializing SWIG for each language (python only right now).
There was also a breakpoint command callback that called into SWIG which has
been abtracted into a callback to avoid cross over as well.

Added a new binary: lldb-platform

This will be the start of the remote platform that will use as much of the 
Host functionality to do its job so it should just work on all platforms.
It is pretty hollowed out for now, but soon it will implement a platform
using the GDB remote packets as the transport.

llvm-svn: 128053
2011-03-22 01:14:58 +00:00
Johnny Chen 9d46337511 Add options to allow for specifying an option string when spawning gdb and for executing
command(s) right after starting up gdb.  Update the README file to show an example of
using these to pass '-arch armv7' to gdb and to execute gdb command to set shared library
path substitutions before loading iOS4.3 sdk's /usr/lib/libSystem.B.dylib and disassembling
the 'printf' function.

llvm-svn: 128040
2011-03-21 23:44:44 +00:00
Johnny Chen 31d446aa5c Fix a typo in the message string.
llvm-svn: 128034
2011-03-21 23:01:34 +00:00
Greg Clayton 45aea640a0 Added real user/group id, effective user/group id, and parent
process ID to the ProcessInfo.

llvm-svn: 128023
2011-03-21 21:25:07 +00:00
Greg Clayton 0f366ac3af Move the building of llvm/clang and the swig wrappers into the lldb-core
target.

llvm-svn: 128012
2011-03-21 18:46:11 +00:00
Greg Clayton e38a2556da Fixed a warning with gcc 4.2 when the Xcode project falls back to the
system compiler when clang isn't around to do the compiling.

llvm-svn: 128006
2011-03-21 18:35:40 +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
Johnny Chen 5c07daaa1d Modify disasm.py to better deal with the objc method name which has ':' in them.
Add a utility similar to disasm.py, but which provides a shell-like environment for invoking llvm-mc.

llvm-svn: 127936
2011-03-19 01:24:25 +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
Johnny Chen d3a4e7eee5 Add cases to test that two template instantiations of std::vector<long> and std::vector<short>
in the same compilation module show up as different types for lldb debugger.

llvm-svn: 127904
2011-03-18 20:51:13 +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