Commit Graph

2522 Commits

Author SHA1 Message Date
Greg Clayton 9b72eb7101 ABI plug-ins must implement the following pure virtual functions:
virtual bool
ABI::StackUsesFrames () = 0;

Should return true if your ABI uses frames when doing stack backtraces. This
means a frame pointer is used that points to the previous stack frame in some
way or another.

virtual bool
ABI::CallFrameAddressIsValid (lldb::addr_t cfa) = 0;

Should take a look at a call frame address (CFA) which is just the stack
pointer value upon entry to a function. ABIs usually impose alignment
restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
This function should return true if "cfa" is valid call frame address for
the ABI, and false otherwise. This is used by the generic stack frame unwinding
code to help determine when a stack ends.

virtual bool
ABI::CodeAddressIsValid (lldb::addr_t pc) = 0;    

Validates a possible PC value and returns true if an opcode can be at "pc".
Some ABIs or architectures have fixed width instructions and must be aligned
to a 2 or 4 byte boundary. "pc" can be an opcode or a callable address which
means the load address might be decorated with extra bits (such as bit zero
to indicate a thumb function call for ARM targets), so take this into account
when returning true or false. The address should also be validated to ensure
it is a valid address for the address size of the inferior process. 32 bit
targets should make sure the address is less than UINT32_MAX.

Modified UnwindLLDB to use the new ABI functions to help it properly terminate
stacks.


Modified the mach-o function that extracts dependent files to not resolve the
path as the paths inside a binary might not match those on the current
host system.

llvm-svn: 132021
2011-05-24 23:06:02 +00:00
Johnny Chen 624ddf2f20 Added comment.
llvm-svn: 132019
2011-05-24 22:57:42 +00:00
Johnny Chen 2f1ee9a09c Comment change.
llvm-svn: 132018
2011-05-24 22:53:03 +00:00
Johnny Chen 93e7b3a8bd Fix a potential bug resulting from the wrong assumption that SWIG puts out the __init__
method definition before other method definitions.  Instead, do without it and process
the class with IsValid() method definition in all possible states.

llvm-svn: 132016
2011-05-24 22:29:49 +00:00
Johnny Chen 685b2b080f Update comment.
llvm-svn: 132002
2011-05-24 21:05:16 +00:00
Johnny Chen c731848a05 Add comment.
llvm-svn: 131998
2011-05-24 20:36:40 +00:00
Jim Ingham 0a042ced97 Fix a thinko in converting to ReadCStringFromMemory.
llvm-svn: 131984
2011-05-24 19:08:00 +00:00
Johnny Chen 4ebd019b97 Now that we have added a post-processing step for adding truth value testing to
those lldb objects which implement the IsValid() method, let's change the rest of
the test suite to use the more compact truth value testing pattern (the Python way).

llvm-svn: 131970
2011-05-24 18:22:45 +00:00
Charles Davis 1a4f5123dd Link in the MCJIT. Fixes makefile build.
llvm-svn: 131949
2011-05-24 01:54:03 +00:00
Johnny Chen 0084527b82 Refactor InstructionLLVM::Dump() a little bit to reduce the entropy by introducing
a new file static utility function AddSymbolicInfo() which is called from places
within InstructionLLVM::Dump().

llvm-svn: 131937
2011-05-23 23:29:23 +00:00
Greg Clayton 49c0fe24d6 Don't resolve the path when we extract the path from the dyld info or we
can end up with an invalid path if the path resolves to something different
on the local machine. It is very important not to since remote debugging will
mention paths that might exist on the current machine (like 
"/System/Library/Frameworks/CoreFoundation/CoreFoundation" which on the desktop
systems is a symlink to "/System/Library/Frameworks/CoreFoundation/Versions/A/CoreFoundation").

We will let the platform plug-ins resolve the paths in a later stage.

llvm-svn: 131934
2011-05-23 23:14:34 +00:00
Johnny Chen a542f10092 Fix usage comment.
llvm-svn: 131925
2011-05-23 21:56:08 +00:00
Johnny Chen b5aa97ecc5 Add a Python utility to help convert the Mail.app saved 'Raw Message Source' .eml file to a git-am friendly file.
llvm-svn: 131924
2011-05-23 21:50:12 +00:00
Sean Callanan 79763a42ab This commit integrates support for the LLVM MCJIT
into the mainline LLDB codebase.  MCJIT introduces
API improvements and better architectural support.

This commit adds a new subsystem, the
ProcessDataAllocator, which is responsible for
performing static data allocations on behalf of the
IR transformer.  MCJIT currently does not support
the relocations required to store the constant pool
in the same allocation as the function body, so we
allocate a heap region separately and redirect
static data references from the expression to that
heap region in a new IR modification pass.

This patch also fixes bugs in the IR
transformations that were exposed by the transition
to the MCJIT.  Finally, the patch also pulls in a
more recent revision of LLVM so that the MCJIT is
available for use.

llvm-svn: 131923
2011-05-23 21:40:23 +00:00
Greg Clayton cdbf866727 Calculate the dyld slide from all in memory info without having to use the
lldb module.

llvm-svn: 131914
2011-05-23 20:06:52 +00:00
Johnny Chen 54dc300653 Add more workarounds for "bl #..." and "blx #..." where the ARMAsmParser fails to parse/recognize
the (PC-relative) immediate operand.

llvm-svn: 131913
2011-05-23 19:41:31 +00:00
Greg Clayton 8d400e1750 Fixed an issue in the EmulateInstructionARM there the IT opcode was trying to
parse NOP instructions. I added the new table entries for the NOP for the
plain NOP, Yield, WFE, WFI, and SEV variants. Modified the opcode emulation
function EmulateInstructionARM::EmulateMOVRdSP(...) to notify us when it is
creating a frame. Also added an abtract way to detect the frame pointer 
register for both the standard ARM ABI and for Darwin.

Fixed GDBRemoteRegisterContext::WriteAllRegisterValues(...) to correctly be
able to individually write register values back if case the 'G' packet is
not implemented or returns an error.

Modified the StopInfoMachException to "trace" stop reasons. On ARM we currently
use the BVR/BCR register pairs to say "stop when the PC is not equal to the 
current PC value", and this results in a EXC_BREAKPOINT mach exception that
has 0x102 in the code.

Modified debugserver to create the short option string from long option
definitions to make sure it doesn't get out of date. The short option string
was missing many of the newer short option values due to a modification of
the long options defs, and not modifying the short option string.

llvm-svn: 131911
2011-05-23 18:04:09 +00:00
Johnny Chen feb961b86a Fix the Align() utility which tries to align the raw disassembly with the edis'ed disassembly
so that both the opcode and the operands are aligned with the rest of output.

Comment out the code related to force_raw mode when disassembling arm or thumb for now.
It testing goes ok, we will remove the section of code related to force_raw.

llvm-svn: 131910
2011-05-23 18:00:40 +00:00
Greg Clayton f3ef3d2af9 Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:

lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);

bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);

size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);

size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);

in lldb_private::Process the following functions were renamed:

From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr, 
                              size_t byte_size,
                              Error &error);

To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, 
                                        size_t byte_size,
                                        uint64_t fail_value, 
                                        Error &error);

Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.

Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):

uint32_t 
Scalar::GetAsMemoryData (void *dst,
                        uint32_t dst_len, 
                        lldb::ByteOrder dst_byte_order,
                        Error &error) const;

The "dst_len" can be smaller that the size of the scalar and the least 
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes. 

Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:

lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;

lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;

All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.

Fixed up a lot of places that were calling :

addr_t
Address::GetLoadAddress(Target*);

to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.

llvm-svn: 131878
2011-05-22 22:46:53 +00:00
Jim Ingham a86046935b Change the m_update_state to an int, and only trigger the "on removal"
action the second time the event is removed (the first is the internal -> 
external transition, the second when it is pulled off the public event
queue, and further times when it is put back because we are faking a
stop reason to hide the expression evaluation stops.

llvm-svn: 131869
2011-05-22 21:45:01 +00:00
Caroline Tice 93e0f19f1d Change the command 'breakpoint command remove' to 'breakpoint command delete',
to be more consistent with other commands.

llvm-svn: 131848
2011-05-22 07:14:46 +00:00
Greg Clayton cff851ab33 Added functions to lldb_private::Address to set an address from a load address
and set the address as an opcode address or as a callable address. This is
needed in various places in the thread plans to make sure that addresses that
might be found in symbols or runtime might already have extra bits set (ARM/Thumb).
The new functions are:

bool
Address::SetCallableLoadAddress (lldb::addr_t load_addr, Target *target);

bool
Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target);

SetCallableLoadAddress will initialize a section offset address if it can,
and if so it might possibly set some bits in the address to make the address
callable (bit zero might get set for ARM for Thumb functions).

SetOpcodeLoadAddress will initialize a section offset address using the
specified target and it will strip any special address bits if needed 
depending on the target.

Fixed the ABIMacOSX_arm::GetArgumentValues() function to require arguments
1-4 to be in the needed registers (previously this would incorrectly fallback
to the stack) and return false if unable to get the register values. The
function was also modified to first look for the generic argument registers
and then fall back to finding the registers by name.

Fixed the objective trampoline handler to use the new Address::SetOpcodeLoadAddress
function when needed to avoid address mismatches when trying to complete 
steps into objective C methods. Make similar fixes inside the
AppleThreadPlanStepThroughObjCTrampoline::ShouldStop() function.

Modified ProcessGDBRemote::BuildDynamicRegisterInfo(...) to be able to deal with
the new generic argument registers.

Modified RNBRemote::HandlePacket_qRegisterInfo() to handle the new generic
argument registers on the debugserver side.

Modified DNBArchMachARM::NumSupportedHardwareBreakpoints() to be able to 
detect how many hardware breakpoint registers there are using a darwin sysctl.
Did the same for hardware watchpoints in 
DNBArchMachARM::NumSupportedHardwareWatchpoints().

llvm-svn: 131834
2011-05-22 04:32:55 +00:00
Johnny Chen 1c464d4961 A little refactoring.
llvm-svn: 131779
2011-05-21 00:55:57 +00:00
Johnny Chen e7faaa6688 When in non-raw mode and edis fails to parse the tokens of the instruction, output
the raw disassembly so that the opcode aligns with the edis'ed disassembly.

llvm-svn: 131773
2011-05-21 00:44:42 +00:00
Greg Clayton 21c5ab4fe1 Lock the target API mutex correctly in all cases and make sure m_opaque_sp
contains a valid pointer before trying to access the target.

llvm-svn: 131771
2011-05-20 23:51:26 +00:00
Greg Clayton adc00cb2ba Centralize the code that gathers the thread ID list from the remote GDB
server so that it happens in command sequence where no other packets can
sneak between.

llvm-svn: 131769
2011-05-20 23:38:13 +00:00
Peter Collingbourne f5c22943eb Fix build error - strstr returns a const char *
llvm-svn: 131766
2011-05-20 22:42:59 +00:00
Greg Clayton 43479731c0 Now that we have dynamic values, we need to protect the GetChildAtIndex()
calls with the target API mutex.

llvm-svn: 131762
2011-05-20 22:07:17 +00:00
Charles Davis 0b96522758 Better way to build the CFCPP sources as part of liblldbHostMacOSX.
llvm-svn: 131742
2011-05-20 18:18:09 +00:00
Charles Davis dae31daf64 When installing the binary part of the LLDB Python modules, symlink to the
installed liblldb instead of the built one. Now Python support won't break if
you clean your build directories.

llvm-svn: 131741
2011-05-20 18:14:37 +00:00
Johnny Chen 02cefc2c23 Workaround the issue of llvm:tB (A8.6.16 B Encoding T2) not being processed as
a branch instruction and therefore the symbolic information is not being dumped for
non-raw mode.

The problem is that the ARMAsmParser is not recognizing the "#274" in "b	#274"
as a valid operand when doing disassembly in non-raw mode.

llvm-svn: 131738
2011-05-20 17:27:37 +00:00
Stephen Wilson 8063a4a47a Do not parse DIE's outside a compilation units range.
In DWARFCompileUnit::ExtractDIEsIfNeeded we are relying on a compilation units
DIEs to be terminated by a null entry.  I think the standard is fairly clear
that all sibling chains are to be terminated by null, but at least gcc 4.5.2
disagrees -- the top level chain drops the final entry.  This results in us
interpreting the next compilation unit header as a DIE.

Regardless of whether gcc is right or wrong, we should not overstep a
compilation units extent.  This patch ensures that we do not attempt to extract
a DIE beyond the length specified for a given DWARFCompileUnit by ensuring our
current offset is strictly less than the start of the next CU.

llvm-svn: 131721
2011-05-20 04:27:12 +00:00
Charles Davis f663741db0 Fix typo. Stupid 'n' key...
llvm-svn: 131720
2011-05-20 04:22:48 +00:00
Charles Davis 53c976d9e5 Some makefile fixes for the Interpreter:
- Make the generation of LLDBWrapPython.cpp respect the VERBOSE setting.
- Use -classic mode when generating. LLDPWrapPython.cpp #errors out if -classic
  wasn't set when it was generated with recent Swig.
- Install the Python modules. Now we shouldn't get loads of Python errors
  trying to run LLDB.

Last of my build fixes. The LLDB that I built works, except that I can't debug
anything with it until debugserver gets built.

llvm-svn: 131719
2011-05-20 04:09:55 +00:00
Charles Davis 3134148059 Fix the Host library build on Mac OS X with makefiles.
llvm-svn: 131718
2011-05-20 04:04:17 +00:00
Greg Clayton 5fe15d2d52 Fixed an issue in GDBRemoteCommunicationClient where we weren't listening to
the "payload_length" argument for the "payload" packet data. This meant we 
could end up sending random extra data with a packet depending on how the 
packet was constructed.

Fixed GDBRemoteRegisterContext to properly save and restore all registers. 
Previous fixes had been added to work around the "payload_length" issues fixed
above and aren't needed anymore.

Fix logging in GDBRemoteCommunication to make sure we log the correct packet
data being sent by using the packet length when dumping the packet contents.

Added register definitions for 'arm-lldb' in the "disasm-gdb-remote.pl" script
so if you have a register dump from the GDB remote that doesn't include the
qRegisterInfo packets, you can manually tell the script which registers are
which.

llvm-svn: 131715
2011-05-20 03:15:54 +00:00
Greg Clayton e51dc6f32a Added a perl script to disassemble, into human readable form, the GDB remote
packet output from "log enable gdb-remote packets". This should help people
track down and see what is going wrong more easily when you have log output
that includes GDB remote packets.

llvm-svn: 131713
2011-05-20 02:00:47 +00:00
Charles Davis 48abe3ee0c Add the LanguageRuntime plugins to liblldb. Fixes link errors for me; if this
breaks it for you (or if the LanguageRuntime plugins break the build on your
machine), please let me know and I'll revert.

Also, link to CoreServices and Carbon on Mac. Yep, LLDB needs these ancient
frameworks.

llvm-svn: 131707
2011-05-19 23:53:23 +00:00
Charles Davis 51be6b5dfa Add the LanguageRuntime plugins to the makefile build, and remove the
Mac OS X Process plugin from the build.

I'm surprised no one caught this earlier. Am I the only one who builds with
the makefiles on Mac?

llvm-svn: 131704
2011-05-19 23:44:09 +00:00
Charles Davis 2b395ed01a Fix a tag type mismatch (i.e. class vs. struct) warning.
llvm-svn: 131699
2011-05-19 23:37:13 +00:00
Charles Davis 8c444c407e Use a SmallVector here instead of a VLA.
llvm-svn: 131698
2011-05-19 23:33:46 +00:00
Johnny Chen c569c1651d python-config in Makefiles
Replace python static settings of compiler flags with invocation of
python-config.

Signed-off-by: Johnny Chen <johnny.chen@apple.com>
llvm-svn: 131697
2011-05-19 23:09:48 +00:00
Johnny Chen c25433f3d2 A bit of clean up.
Removed ifdeffed out functions and added the implementation of
WriteRegister for x86_64 architecture.

Signed-off-by: Johnny Chen <johnny.chen@apple.com>
llvm-svn: 131696
2011-05-19 23:08:41 +00:00
Johnny Chen c18a538646 API fix and missing headers.
Host.cpp was missing Error.h and the implementation of
LaunchProcess. Once againg I have added a "fake" implementation
waiting for a real one.

Fixed the call GetAddressRange to reflect the new interface in
DynamicLoaderLinuxDYLD.cpp.

Added string.h to ARM_DWARF_Registers.cpp that is needed for ::memset.

Signed-off-by: Johnny Chen <johnny.chen@apple.com>
llvm-svn: 131695
2011-05-19 23:07:19 +00:00
Charles Davis c9c24af6f2 Fix trailing commas at the end of enumerator lists.
Seriously, I have no idea how you guys managed to build LLDB before.

llvm-svn: 131684
2011-05-19 21:59:12 +00:00
Johnny Chen de303ad4cd Add radar info.
llvm-svn: 131681
2011-05-19 21:31:35 +00:00
Johnny Chen b146ad5cd3 Add TestCallStdStringFunction.py which calls std::string member functions while stopped on a breakpoint.
llvm-svn: 131680
2011-05-19 21:28:24 +00:00
Peter Collingbourne 1b27dac253 Build and initialise the Darwin ABI plugins on all platforms
llvm-svn: 131661
2011-05-19 18:32:34 +00:00
Greg Clayton 92bb12ca3e Moved a lot of simple functions from StoppointLocation.cpp to be inlined in
StoppointLocation.h.

Added a new lldb_private::Address function:

addr_t
Address::GetOpcodeLoadAddress (Target *target) const;

This will strip any special bits from an address to make sure it is suitable
for use in addressing an opcode. Often ARM addresses have an extra bit zero 
that can be set to indicate ARM vs Thumb addresses (gotten from return address
registers, or symbol addresses that may be marked up specially). We need to 
strip these bits off prior to setting breakpoints, so we can centralized the
place to do this inside the Address class.

llvm-svn: 131658
2011-05-19 18:17:41 +00:00
Peter Collingbourne 34ed48001d Link to LLVM instrumentation lib
llvm-svn: 131651
2011-05-19 17:35:01 +00:00