Commit Graph

713 Commits

Author SHA1 Message Date
Greg Clayton 9e00b6a654 Added the ability to get an abstract file type (executable, object file,
shared library, etc) and strata (user/kernel) from an object file. This will
help with plug-in and platform selection when given a new binary with the
"target create <file>" command.

llvm-svn: 134779
2011-07-09 00:41:34 +00:00
Greg Clayton df0b7d5c31 LLDB now has a Kernel dynamic linker that can detect where kexts are
loaded. It locks onto *-apple-darwin binaries where the binary has
a "__KLD" segment. Soon I will modify the lldb_private::ObjectFile
class to return an executable type which will be an enum with values
something like:
eObjectFileTypeUserExectable,
eObjectFileTypeUserSharedLibrary,
eObjectFileTypeKernelExectable,
eObjectFileTypeKernelSharedLibrary,
eObjectFileTypeObjectFile,
eObjectFileTypeCoreFile

But for now we look at the section since a user and kernel mach-o
executable have the same mach-o file type.

llvm-svn: 134682
2011-07-08 04:11:42 +00:00
Greg Clayton 0d9fc764d2 Make the kernel able to do its initial load from target memory with the
process being preferred for all memory reads.

llvm-svn: 134681
2011-07-08 03:21:57 +00:00
Greg Clayton 7b242381b8 Added the start of the darwin dynamic loader plug-in. It isn't hooked up to
be detected yet, but most of the initial code is there and needs to be 
debugged more.

llvm-svn: 134672
2011-07-08 00:48:09 +00:00
Greg Clayton 1d4313b261 Stop the lldb_private::RegularExpression class from implicitly
constructing itself and causing unexpected things to happen
in LLDB.

llvm-svn: 134598
2011-07-07 04:49:07 +00:00
Greg Clayton 644247c1dc Added "target variable" command that allows introspection of global
variables prior to running your binary. Zero filled sections now get
section data correctly filled with zeroes when Target::ReadMemory
reads from the object file section data.

Added new option groups and option values for file lists. I still need
to hook up all of the options to "target variable" to allow more complete
introspection by file and shlib.

Added the ability for ValueObjectVariable objects to be created with
only the target as the execution context. This allows them to be read
from the object files through Target::ReadMemory(...). 

Added a "virtual Module * GetModule()" function to the ValueObject
class. By default it will look to the parent variable object and
return its module. The module is needed when we have global variables
that have file addresses (virtual addresses that are specific to
module object files) and in turn allows global variables to be displayed
prior to running.

Removed all of the unused proxy object support that bit rotted in 
lldb_private::Value.

Replaced a lot of places that used "FileSpec::Compare (lhs, rhs) == 0" code
with the more efficient "FileSpec::Equal (lhs, rhs)".

Improved logging in GDB remote plug-in.

llvm-svn: 134579
2011-07-07 01:59:51 +00:00
Greg Clayton 34132754bd Fixed some issues with ARM backtraces by not processing any push/pop
instructions if they are conditional. Also fixed issues where the PC wasn't
getting bit zero stripped for ARM targets when a stack frame was thumb. We
now properly call through the GetOpcodeLoadAddress() functions to make sure
the addresses are properly stripped for any targets that may decorate up
their addresses.

We now don't pass the SIGSTOP signals along. We can revisit this soon, but
currently this was interfering with debugging some older ARM targets that
don't have vCont support in the GDB server.

llvm-svn: 134461
2011-07-06 04:07:21 +00:00
Greg Clayton 0c51ac3295 When we use the "fd://%u" for file descriptors, we need to detect if this is
a file or socket. We now make a getsockopt call to check if the fd is a socket.

Also, the previous logic in the GDB communication needs to watch for success
with an error so we can deal with EAGAIN and other normal "retry" error codes.

llvm-svn: 134359
2011-07-02 23:21:06 +00:00
Greg Clayton 197bacfffa Cleanup errors that come out of commands and make sure they all have newlines
_only_ in the resulting stream, not in the error objects (lldb_private::Error).
lldb_private::Error objects should always just have an error string with no 
terminating newline characters or periods.

Fixed an issue with GDB remote packet detection that could end up deadlocking
if a full packet wasn't received in one chunk. Also modified the packet 
checking function to properly toss one or more bytes when it detects bad
data. 

llvm-svn: 134357
2011-07-02 21:07:54 +00:00
Greg Clayton e305594277 Centralize all of the type name code so that we always strip the leading
"struct ", "class ", and "union " from the start of any type names that are
extracted from clang QualType objects. I had to fix test suite cases that
were expecting the struct/union/class prefix to be there.

llvm-svn: 134132
2011-06-30 02:28:26 +00:00
Greg Clayton a2721476e7 This commit adds broad architectural support for hierarchical
inspection of namespaces in the expression parser.

ClangExpressionDeclMap hitherto reported that namespaces had
been completely imported, even though the namespaces are
returned empty.  To deal with this situation, ClangASTSource
was recently extended with an API to complete incomplete type
definitions, and, for greater efficiency, to complete these
definitions partially, returning only those objects that have
a given name.

This commit supports these APIs on LLDB's side, and uses it
to provide information on types resident in namespaces.
Namespaces are now imported as they were -- that is to say,
empty -- but with minimal import mode on.  This means that
Clang will come back and request their contents by name as
needed.  We now respond with information on the contained
types; this will be followed soon by information on functions
and variables.

llvm-svn: 133852
2011-06-25 00:44:06 +00:00
Greg Clayton f58c269aa1 Removed an member variable "m_local_debugserver" that is no longer needed.
We now check with the platform to see if we are doing local or remote 
debugging and setup the stdio accordingly.

llvm-svn: 133835
2011-06-24 22:32:10 +00:00
Jim Ingham d555bacca3 Add support for looking up ivar offset from the ObjC runtime.
llvm-svn: 133831
2011-06-24 22:03:24 +00:00
Greg Clayton 0c74e78d63 Fixed SBTarget attach calls to properly deal with being connected to a remotely
connected process connection.

Also added support for more kinds of continue packet when multiple threads
need to continue where some want to continue with signals.

llvm-svn: 133785
2011-06-24 03:21:43 +00:00
Peter Collingbourne d155c0b451 Remove duplicate m_monitor field from LaunchArgs
Fixes segfault when launching process on Linux.

llvm-svn: 133484
2011-06-20 23:55:58 +00:00
Jim Ingham f72ce3a216 Use the dyld_mode, image_infos & image_infos_count passed into the shared library notification function
to update libraries rather than reading the whole all_imaage_infos structure every time we get notified.

llvm-svn: 133448
2011-06-20 17:32:44 +00:00
Greg Clayton 5cf21f5f06 Fixed a crasher where we were accessing a symbol with a bad index.
llvm-svn: 133377
2011-06-19 04:26:01 +00:00
Greg Clayton 5861d3e6f0 Make sure we have a valid object file before we try getting the symbol table
so we avoid crashing.

llvm-svn: 133376
2011-06-19 04:02:02 +00:00
Peter Collingbourne ba23ca085f Switch from USEC_PER_SEC/NSEC_PER_SEC/NSEC_PER_USEC to TimeValue constants
Fixes the Linux build.

llvm-svn: 133370
2011-06-18 23:52:14 +00:00
Greg Clayton c662ec8bd3 Fixed variable parsing to not parse block variables over and over due to an
issue in the way block variables are marked as parsed. In the DWARF parser we
always parse all blocks for a function at once, so we can mark all blocks as
having all variables parsed and avoid recursive function calls to try and
reparse things that have already been handled.

Fixed an issue with how variables get scoped into blocks. The DWARF parser can
now handle abtract class definitions that contain concrete static variables.
When the concrete instance of the class functions get instantiated, they will
track down the concrete block for the abtract block and add the variable to
each block.

llvm-svn: 133302
2011-06-17 22:10:16 +00:00
Greg Clayton f3dd93c888 Added the notion of an system root for SDKs. This is a directory where all
libraries and headers exist. This can be specified using the platform select
function:

platform select --sysroot /Volumes/remote-root remote-macosx

Each platform subclass is free to interpret the sysroot as needed.

Expose the new SDK root directory through the SBDebugger class. 

Fixed an issue with the GDB remote protocol where unimplemented packets were
not being handled correctly.

llvm-svn: 133231
2011-06-17 03:31:01 +00:00
Greg Clayton 73bf5dbd16 Improved the packet throughput when debugging with GDB remote by over 3x on
darwin (not sure about other platforms).

Modified the communication and connection classes to not require the
BytesAvailable function. Now the "Read(...)" function has a timeout in
microseconds.

Fixed a lot of assertions that were firing off in certain cases and replaced
them with error output and code that can deal with the assertion case.

llvm-svn: 133224
2011-06-17 01:22:15 +00:00
Johnny Chen 25e68e3c1b Primitive attach support for linux
This patch is a starting point for the attach functionality.

Signed-off-by: Johnny Chen <johnny.chen@apple.com>
llvm-svn: 133006
2011-06-14 19:19:50 +00:00
Peter Collingbourne 6a520222d0 Improve error reporting in ProcessMonitor::Launch
llvm-svn: 132972
2011-06-14 03:55:58 +00:00
Peter Collingbourne 6234320933 Fix mistakes relating to ProcessMonitor::DupDescriptor
llvm-svn: 132971
2011-06-14 03:55:54 +00:00
Peter Collingbourne 4aeb47e23c If ProcessMonitor::Launch fails, post semaphore to notify caller
llvm-svn: 132970
2011-06-14 03:55:49 +00:00
Peter Collingbourne 933f6f617d Add license header to InferiorCallPOSIX.cpp
llvm-svn: 132966
2011-06-14 03:55:34 +00:00
Greg Clayton c0094b1be3 Remove assert() calls that were firing off and crashing the LLDB framework.
llvm-svn: 132960
2011-06-14 01:53:36 +00:00
Greg Clayton b677cb893d Header file cleanup and moved an inline to the implementation file.
llvm-svn: 132828
2011-06-10 01:37:29 +00:00
Greg Clayton a658fd26c3 Created a std::string in the base StopInfo class for the description and
cleaned up all base classes that had their own copy. Added a SetDescription
accessor to the StopInfo class.

llvm-svn: 132615
2011-06-04 01:26:29 +00:00
Peter Collingbourne 10bc01032c Implement RegisterContextLinux_x86_64::{Read,Write}AllRegisterValues
llvm-svn: 132587
2011-06-03 20:41:02 +00:00
Peter Collingbourne 5a6fa540dc Move SaveFrameZeroState and RestoreSaveFrameZero implementations to Thread base class
llvm-svn: 132586
2011-06-03 20:40:54 +00:00
Peter Collingbourne 70969ef102 Implement ProcessLinux::Do{Allocate,Deallocate}Memory using inferior mmap/munmap calls
llvm-svn: 132585
2011-06-03 20:40:44 +00:00
Peter Collingbourne 99f9aa02c2 Move inferior mmap/munmap call code into their own functions in utility lib
llvm-svn: 132584
2011-06-03 20:40:38 +00:00
Peter Collingbourne b4aabeb8d7 Scan dynamic symbol table of ELF object files
llvm-svn: 132582
2011-06-03 20:39:58 +00:00
Johnny Chen b1fa6b466b Bail out if we have an invalid thumb instruction.
llvm-svn: 132511
2011-06-02 23:19:06 +00:00
Johnny Chen 8a71c0b771 Turn the commented-out assert()'s into appropriate bail-out actions.
llvm-svn: 132507
2011-06-02 23:07:03 +00:00
Johnny Chen 6ef2735631 When emulating an ill-formed instruction, we should bail out instead of asserting and bringing down the whole process.
llvm-svn: 132506
2011-06-02 22:50:51 +00:00
Greg Clayton 850cc8998c Remove asserts that will crash LLDB. These should be changed to return
true/false in an extra boolean parameter and not cause the the binary that
us using the LLDB framework to crash.

llvm-svn: 132501
2011-06-02 22:23:35 +00:00
Greg Clayton dd0e5a5258 Make sure we don't lose our stop reply packet in the case where the other
GDB server doesn't support the LLDB specific qThreadStopInfo packet.

llvm-svn: 132499
2011-06-02 22:22:38 +00:00
Johnny Chen 8a742f5f37 EmulateShiftReg() also accepts shifter type of SRType_ROR.
llvm-svn: 132484
2011-06-02 21:00:34 +00:00
Greg Clayton 007d5be653 lldb-59.
llvm-svn: 132304
2011-05-30 00:49:24 +00:00
Greg Clayton 1cbc52cd64 Added some comments.
llvm-svn: 132066
2011-05-25 17:56:20 +00:00
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 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 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
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