Commit Graph

2694 Commits

Author SHA1 Message Date
Greg Clayton c54dab63f2 Added an llvm::StringRef accessor.
llvm-svn: 132827
2011-06-10 01:32:06 +00:00
Greg Clayton 40df35ef1b Explicitly set the value to NULL when adding a string map entry.
llvm-svn: 132823
2011-06-10 00:00:19 +00:00
Greg Clayton c3ae1cefc0 I modified the StringMap that was being used to unique our debugger C strings
to have the value for the map be a "const char *" instead of an unused uint32_t.
This allows us to store the uniqued mangled/demangled counterpart in this map
for mangled names. This also speeds up the mangled/demangled counterpart lookup
that used to be maintained in a STL map by having direct access to the data.
If we eventually need to associate other strings to strings to more data, we
can make the value of the StringMap have a more complex value.

Added the start of a history source and history event class. It isn't being
used by anything yet, but might be shortly.

llvm-svn: 132813
2011-06-09 22:34:34 +00:00
Johnny Chen 4b6fed4bab Comment out the debug stmts.
llvm-svn: 132808
2011-06-09 22:09:52 +00:00
Johnny Chen e2b5cfd826 Add rich comparison methods for the SBAddress object.
If two SBAddress's have the same module and file address, they are considered equal.

Add a test snippet 'sa1 == sa2' to exercise the rich comparison methods for SBAddress.

llvm-svn: 132807
2011-06-09 22:04:56 +00:00
Johnny Chen f5fe34ff9c Remove extra whitespace.
llvm-svn: 132692
2011-06-06 21:36:56 +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
Greg Clayton 54e8ac5562 Make sure we are ok to stop in a thread plan and have no stop reason for
the thread we were running on (other thread crashed or had exceptional stop
reason).

llvm-svn: 132599
2011-06-03 22:12:42 +00:00
Greg Clayton 3b292a1ed3 Don't codesign with lldb_codesign for non MacOSX SDKs.
llvm-svn: 132597
2011-06-03 22:08:56 +00:00
Johnny Chen c95f5de211 Add InferiorCallPOSIX.cpp/.h into the xcode project file to fix build error.
llvm-svn: 132594
2011-06-03 21:27:28 +00:00
Peter Collingbourne 6b5f17a586 Fix some order-of-initialisation warnings
llvm-svn: 132588
2011-06-03 20:41:09 +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 1740be7cd9 Disable MCJIT on non-Darwin platforms
Currently the runtime dynamic linker lacks object file support for anything
other than Mach-O.

llvm-svn: 132583
2011-06-03 20:40:12 +00:00
Peter Collingbourne b4aabeb8d7 Scan dynamic symbol table of ELF object files
llvm-svn: 132582
2011-06-03 20:39:58 +00:00
Caroline Tice cbc0c247e1 Make a few minor changes/corrections to scripting
example on the web.

llvm-svn: 132554
2011-06-03 16:38:17 +00:00
Jim Ingham 5b52f0c785 Added Debugger::GetAsync{Output/Error}Stream, and use it to print parse errors when we go to run a breakpoint condition.
llvm-svn: 132517
2011-06-02 23:58:26 +00:00
Greg Clayton cbd2e3b001 Cleanup the sidebar and include a link to the new python scripting tutorial.
llvm-svn: 132515
2011-06-02 23:50:04 +00:00
Caroline Tice 54923eced3 Add the web page for the 'Using Python Scripting to
Debug a Program in LLDB' example.

llvm-svn: 132513
2011-06-02 23:40:56 +00:00
Caroline Tice 2e9dd93e26 Add source files for Python scripting example (coming soon).
llvm-svn: 132512
2011-06-02 23:23:47 +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 79884f3896 Bumped Xcode project version for lldb-60.
llvm-svn: 132502
2011-06-02 22:25:27 +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
Greg Clayton 8672996e4d Update the handle many of the packets that our current LLDB debugserver
handles. Also fixed a case where the packet wouldn't be dumped if it returned
the unimplemented packet.

llvm-svn: 132498
2011-06-02 22:21:38 +00:00
Caroline Tice c928f59c90 Use Py_InitializeEx(0) instead of Py_Initialize,
to prevent Python from installing its own signal 
handlers.

llvm-svn: 132492
2011-06-02 22:09:43 +00:00
Johnny Chen 8a742f5f37 EmulateShiftReg() also accepts shifter type of SRType_ROR.
llvm-svn: 132484
2011-06-02 21:00:34 +00:00
Caroline Tice d5a0a01b2d Create new class, InputReaderStack, to better handle
mutexes around input readers and prevent deadlocking; modify
Debugger to use the new class.

llvm-svn: 132475
2011-06-02 19:18:55 +00:00
Johnny Chen b5964212f4 Add comment about Thread::GetStatus(), which returns the number of frames shown.
llvm-svn: 132470
2011-06-02 18:02:15 +00:00
Greg Clayton a13ad2adcf Use the correct accessor on CXXRecordDecl to know when a C++ class is dynamic.
llvm-svn: 132449
2011-06-02 01:26:44 +00:00
Johnny Chen f7626eff37 Turn off printing of command sent to the pexpect-spawned child process to make the script more robotic.
llvm-svn: 132441
2011-06-01 23:53:57 +00:00
Jim Ingham 190b959273 If somebody has deleted the breakpoint while we are testing the condition, then just continue.
llvm-svn: 132440
2011-06-01 23:52:47 +00:00
Jim Ingham b7bac4a50e Remove the "a.out" argument from somewhere on Greg's machine in the lldb-tool run scheme.
llvm-svn: 132439
2011-06-01 23:52:04 +00:00
Johnny Chen 1dba2230b5 Exercise the 'thread backtrace all' command instead of the currently 'thread backtrace' command.
This serves as a regression test against rdar://problem/9530511.

llvm-svn: 132438
2011-06-01 23:35:20 +00:00
Johnny Chen f2ddc71310 The 'thread backtrace all' logical branch had the if (thread->GetStatus()) condition inverted.
rdar://problem/9530511

llvm-svn: 132435
2011-06-01 23:19:52 +00:00
Johnny Chen 8831e18b17 Make 'run-until-faulted.py' script more interesting by modifying the example main.c program
to seg fault randomly instead of deterministically.

Example:

[15:10:43] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ clang -g main.c
[15:10:46] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ ./run-until-faulted.py -l $PWD/../../build/Debug/lldb -e a.out
lldb command: /Volumes/data/lldb/svn/trunk/utils/test/../../build/Debug/lldb
executable: a.out
executable options: 
(lldb) sending 'file a.out' command...
file a.out
Current executable set to 'a.out' (x86_64).
(lldb) sending 'process launch -- ' command... (iteration: 0)
process launch -- 
Process 63630 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64)
Hello, fault!
val=9
Better luck next time!
Process 63630 exited with status = 0 (0x00000000) 
(lldb) sending 'process launch -- ' command... (iteration: 1)
process launch -- 
Process 63633 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64)
Process 63633 exited with status = 0 (0x00000000) 
sending 'process launch -- ' command... (iteration: 2)
Hello, fault!
val=0
Better luck next time!
(lldb) process launch -- 
Process 63637 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64)
Hello, fault!
val=15
Better luck next time!
Process 63637 exited with status = 0 (0x00000000) 
(lldb) sending 'process launch -- ' command... (iteration: 3)
process launch -- 
Process 63640 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64)
Hello, fault!
val=2
Better luck next time!
Process 63640 exited with status = 0 (0x00000000) 
sending 'process launch -- ' command... (iteration: 4)
(lldb) process launch -- 
Process 63643 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64)
Process 63643 stopped
* thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11
   8   	    u_int32_t val = (arc4random() & 0x0f);
   9   	    printf("val=%u\n", val);
   10  	    if (val == 0x07) // Lucky 7 :-)
-> 11  	        printf("Now segfault %d\n", *null_ptr);
   12  	    else
   13  	        printf("Better luck next time!\n");
   14  	}
(lldb) 
* thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11
   8   	    u_int32_t val = (arc4random() & 0x0f);
   9   	    printf("val=%u\n", val);
   10  	    if (val == 0x07) // Lucky 7 :-)
-> 11  	        printf("Now segfault %d\n", *null_ptr);
   12  	    else
   13  	        printf("Better luck next time!\n");
   14  	}
Hello, fault!
val=7
(lldb) 

llvm-svn: 132430
2011-06-01 22:12:27 +00:00
Johnny Chen 755faf7744 Make it clear that the Python script modify-python-lldb.py is responsible for post-processing
the SWIG-generated lldb.py module by adding comments in the post-processed file in order to
facilitate reading of the code.

llvm-svn: 132417
2011-06-01 19:21:08 +00:00
Johnny Chen 2ced507a1e Fix comment.
llvm-svn: 132412
2011-06-01 18:40:11 +00:00
Charles Davis 4ce288e3e4 Fix remaining Python issues leftover from my previous patch.
- The Swig post-processing scripts are now run.
- edit-swig-python-wrapper-file.py has been modified so it can be run
from the Makefile.
- The issue that prompted me to pass -classic to swig is fixed by this,
so -classic isn't passed anymore.

Python shouldn't complain anymore about a missing method 'FindDebuggerByID'
on the SBDebugger object whenever lldb is run.

llvm-svn: 132383
2011-06-01 02:33:12 +00:00
Johnny Chen 4533dada39 Fix out-dated module docstring for lldbtest.py. Also wrap some lldb attribute references
inside a try-except block in case the test is not invoked through the dotest.py test driver.

llvm-svn: 132372
2011-05-31 23:21:42 +00:00
Johnny Chen aacf92ebb4 Move some comments to the docstrings.
llvm-svn: 132367
2011-05-31 22:16:51 +00:00
Greg Clayton 5ad639415f Fix dynamic value objects to do the right thing when the
value fails to evaluate.

llvm-svn: 132354
2011-05-31 20:18:39 +00:00
Greg Clayton 21e69cef08 Revert previous changes.
llvm-svn: 132308
2011-05-30 01:18:45 +00:00
Greg Clayton 007d5be653 lldb-59.
llvm-svn: 132304
2011-05-30 00:49:24 +00:00
Greg Clayton 5d2fbfed4d Disable dynamic types being on by default until kinks get worked out when
they don't update correctly. Currently if a variable is unavailable due to
a register not being available in a higher frame or due to the PC value
not being a valid location list value, "<unknown type>" will get displayed
as the variable type. I am not sure what other things will fail, so I am 
disabling it for now just by letting the default enumeration value default
to it being disabled.

llvm-svn: 132303
2011-05-30 00:39:48 +00:00
Greg Clayton 15184db092 Protect the input reader stack with a recursive mutex.
llvm-svn: 132301
2011-05-29 23:07:38 +00:00
Greg Clayton 18d85eedda Make sure if an enumeration "settings" value has a valid default setting in
its definition, that the first enumeration doesn't always get used as the
default.

llvm-svn: 132289
2011-05-29 19:21:37 +00:00
Greg Clayton 71f96fef42 lldb-58
llvm-svn: 132281
2011-05-29 04:10:48 +00:00
Greg Clayton fc3f027d33 Don't have the debugger default to ignoring EOF. This is only what the driver
(or anything running in a terminal) wants. Not what a UI (Xcode) would want 
where it creates a debugger per debug window. The current code had an infinite
loop after a debug session ended. 

llvm-svn: 132280
2011-05-29 04:06:55 +00:00
Greg Clayton 2dfd12fb22 lldb-57
llvm-svn: 132271
2011-05-29 01:30:02 +00:00
Greg Clayton c0ea046a80 Fixed an issue that could cause LLDB to spin indefinitely.
llvm-svn: 132270
2011-05-29 00:45:15 +00:00
Johnny Chen 61c79c0ba4 Fix some comments.
llvm-svn: 132232
2011-05-27 23:42:45 +00:00
Johnny Chen f359cf2c84 Add comment headers describing some method groups of our TestBase class.
Remove an unnecessary __import__() function call.

llvm-svn: 132231
2011-05-27 23:36:52 +00:00
Johnny Chen bf9cf5ec1e Use the with statement to simplify the build script.
llvm-svn: 132221
2011-05-27 21:58:22 +00:00
Johnny Chen f5801f8d11 Remove extra '.' in the comment.
llvm-svn: 132160
2011-05-26 22:01:50 +00:00
Johnny Chen 75ec159da5 Add comment.
llvm-svn: 132152
2011-05-26 21:53:05 +00:00
Johnny Chen 792ed4c616 Comment change.
llvm-svn: 132150
2011-05-26 21:50:47 +00:00
Johnny Chen 0c0f977840 Simplify test setup; there's no need to pass a customized dictionary here.
llvm-svn: 132147
2011-05-26 21:43:19 +00:00
Jim Ingham 46fbc60f63 regexp-break -> _regexp-break in command string.
llvm-svn: 132141
2011-05-26 20:39:01 +00:00
Greg Clayton 6dc03b36d7 lldb-56 with codesign settings fixed in the Xcode projects.
llvm-svn: 132123
2011-05-26 16:54:13 +00:00
Johnny Chen b0b8853a2e Add a little spice to the script to allow us to specify a function name to break at and to disassemble.
Usage: disasm.py [-n name] executable-image
       By default, it breaks at and disassembles the 'main' function.
llvm-svn: 132090
2011-05-25 22:29:23 +00:00
Johnny Chen 2dda91690f Add a little twist to the disasm.py script so that it is possible to terminate the inferior process
by entering 'Ctrl-D' or 'quit'.

llvm-svn: 132088
2011-05-25 22:01:16 +00:00
Johnny Chen 2cf62497b3 Modified to use SBTarget.LaunchSimple() API.
llvm-svn: 132082
2011-05-25 20:56:32 +00:00
Johnny Chen 9a26f0f260 Use built-in truth value testing.
llvm-svn: 132079
2011-05-25 20:48:29 +00:00
Johnny Chen 26fc16b032 Use built-in truth value testing.
llvm-svn: 132078
2011-05-25 20:47:27 +00:00
Johnny Chen 3cd1e55103 Convert these two modules to use the compact truth value testing as well.
llvm-svn: 132072
2011-05-25 19:06:18 +00:00
Greg Clayton 60d4d9eb81 Bumping Xcode project versions for lldb-55 and debugserver-139.
llvm-svn: 132067
2011-05-25 17:59:00 +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 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
Peter Collingbourne 5e494f4fe9 Add UnwindAssembly plugins to makefile build
llvm-svn: 131650
2011-05-19 17:34:58 +00:00
Peter Collingbourne 6a94e50448 #include <string.h> for memset
llvm-svn: 131648
2011-05-19 17:34:51 +00:00
Peter Collingbourne ea384b4f85 Remove some old files which should have been removed in r131193
llvm-svn: 131647
2011-05-19 17:34:48 +00:00
Peter Collingbourne 1cbedd3ee0 Use the portable memchr function instead of the BSD-only strnstr
llvm-svn: 131646
2011-05-19 17:34:44 +00:00
Peter Collingbourne a09bfcaed4 Initialise the Darwin ABI plugins only on Darwin
llvm-svn: 131645
2011-05-19 17:34:40 +00:00
Greg Clayton af247d7b98 Fixed a crasher that was happened when a log shared pointer wasn't valid.
Fixed ThreadPlanCallFunction::ReportRegisterState(...) to only dump when
verbose logging is enabled and fixed the function to use the new
RegisterValue method of reading registers.

Fixed the GDB remote client to not send a continue packet after receiving
stdout or stderr from the inferior process.

llvm-svn: 131628
2011-05-19 03:54:16 +00:00
Johnny Chen d746478404 Make InstructionLLVM::Dump() more robust for edis in cases when all the
EDOperandIndexForToken(token) calls fail to return a meaningful operand index,
resulting in both operands and comment being empty.  We will use the raw disassembly
string as output in these cases.

There is still a known bug where llvm:tB (A8.6.16 B Encoding T2) is not being processed
as a branch instruction and therefore the symbolic information is not being dumped for
non-raw mode.

llvm-svn: 131615
2011-05-19 01:05:37 +00:00
Greg Clayton 316b460309 Fixed an issue with the sign extend code so it uses the correct m_data member.
llvm-svn: 131613
2011-05-19 00:55:50 +00:00
Greg Clayton e376938e93 Added the ability to sign extend a Scalar at any bit position for integer
types.

Added the abilty to set a RegisterValue type via accessor and enum.

Added the ability to read arguments for a function for ARM if you are on the
first instruction in ABIMacOSX_arm.

Fixed an issue where a file descriptor becoming invalid could cause an 
inifnite loop spin in the libedit thread.

llvm-svn: 131610
2011-05-19 00:17:26 +00:00
Johnny Chen 30243c74c0 Some refactorings with respect to setting of the 'printTokenized' flag.
Add some comments.

llvm-svn: 131594
2011-05-18 22:48:41 +00:00
Johnny Chen a5aab9ad58 Remove dead code which tests for boolan flag 'raw' and restore one indentation level.
llvm-svn: 131589
2011-05-18 22:08:52 +00:00
Greg Clayton 3f5c08f5c2 Added a function to lldb_private::Address:
addr_t
        Address::GetCallableLoadAddress (Target *target) const;
        
This will resolve the load address in the Address object and optionally
decorate the address up to be able to be called. For all non ARM targets, this
just essentially returns the result of "Address::GetLoadAddress (target)". But
for ARM targets, it checks if the address is Thumb, and if so, it returns
an address with bit zero set to indicate a mode switch to Thumb. This is how
we need function pointers to be for return addresses and when resolving 
function addresses for the JIT. It is also nice to centralize this in one spot
to avoid having multiple copies of this code.

llvm-svn: 131588
2011-05-18 22:01:49 +00:00
Greg Clayton 1c870d6e9f One more fix to:
bool SectionLoadList::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const;

Where if the address is in the last map entry, we need to look it up correctly.
My previous fix was incorrect where it looked in the first if there were
no addresses in the map that were > load_addr. Now we correctly look in the
last entry if our std::map::lower_bound search returns the end of the 
collection.

llvm-svn: 131550
2011-05-18 18:22:47 +00:00
Johnny Chen 5bee94ecab If the use_thumb is set, pass llvm::Triple::thumb to the InstructionLLVM.ctor() unconditionally.
Otherwise, pass m_arch.GetMachine().

Followup patch for rdar://problem/9170971.

llvm-svn: 131549
2011-05-18 18:22:16 +00:00
Jim Ingham 8c0ee21517 Symbol may not have a demangled name, use GetName to get the best name available in this case.
llvm-svn: 131527
2011-05-18 05:04:36 +00:00
Jim Ingham 832332d724 FindFunctions was skipping the include_symbols section if it found a SymbolVendor.
llvm-svn: 131526
2011-05-18 05:02:10 +00:00
Greg Clayton cd482e359e Added a way to resolve an load address from a target:
bool
Address::SetLoadAddress (lldb::addr_t load_addr, Target *target);

Added an == and != operator to RegisterValue.

Modified the ThreadPlanTracer to use RegisterValue objects to store the
register values when single stepping. Also modified the output to be a bit
less wide.

Fixed the ABIMacOSX_arm to not overwrite stuff on the stack. Also made the
trivial function call be able to set the ARM/Thumbness of the target 
correctly, and also sets the return value ARM/Thumbness.

Fixed the encoding on the arm s0-s31 and d16 - d31 registers when the default
register set from a standard GDB server register sets.

llvm-svn: 131517
2011-05-18 01:58:14 +00:00
Johnny Chen 81a9df5b22 Let's also stick the svn info for the base directory into a file under
the session directory, which also includes the command line used to invoke
the test suite.

llvm-svn: 131501
2011-05-17 22:58:50 +00:00
Jim Ingham 17e5c4e261 RunThreadPlan should set the plan to "not private" since it needs that,
and then reset it to the original value when done.

llvm-svn: 131498
2011-05-17 22:24:54 +00:00
Johnny Chen 112f5696fb Add truth value testing to those lldb Python objects with the IsValid() method definitions.
object.__nonzero__(self) is called to implement truth value testing and the built-in operation bool(),
via a simple delegation to self.IsValid().

Change tests under python_api/lldbutil to utilize this mechanism.

llvm-svn: 131494
2011-05-17 22:14:39 +00:00
Greg Clayton dc968d1665 Fixed an assert that could cause a crash when there was an
unrecognized DW_TAG_base_type. Now it is a error printed to
stderr.

llvm-svn: 131473
2011-05-17 18:15:05 +00:00
Greg Clayton c5e9a7dc2b Fixed an issue where addresses would not get resolved for the last
loaded section in the section load list.

llvm-svn: 131472
2011-05-17 18:13:59 +00:00
Greg Clayton 7a9ef8f11b Removed some assertions that could crash the controlling program
and turned them into warnings to stderr.

llvm-svn: 131470
2011-05-17 17:37:43 +00:00
Greg Clayton 5f5b2cad48 Fixed an issue that broke expression parsing related to backing up
all register values. There is some junk that was appearing at the end
of the result the 'g' packet (read all register values). This function
was being called in:

bool
GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)

Then the packet data for the 'G' packet (write all registers) was being 
placed into "data_sp" so the:

bool
GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)

could restore it. In attempting to clean up the extra junk at the end of this
packet data, the packet was getting truncated.

llvm-svn: 131468
2011-05-17 16:50:15 +00:00
Johnny Chen 314d07b51c Forgot to check in this patch for Marco Minutoli.
Update to Python2.7 from Python 2.6.

llvm-svn: 131465
2011-05-17 16:32:56 +00:00
Greg Clayton e6a9e439d4 Fixed the "mmap" to work on MacOSX/darwin by supplying the correct arguemnts.
Modified ClangUserExpression and ClangUtilityFunction to display the actual
error (if one is available) that made the JIT fail instead of a canned 
response.

Fixed the restoring of all register values when the 'G' packet doesn't work
to use the correct data.

llvm-svn: 131454
2011-05-17 03:51:29 +00:00
Greg Clayton d495c5340d Added an allocated memory cache to avoid having to allocate memory over and
over when running JITed expressions. The allocated memory cache will cache 
allocate memory a page at a time for each permission combination and divvy up
the memory and hand it out in 16 byte increments. 

llvm-svn: 131453
2011-05-17 03:37:42 +00:00
Jim Ingham d915e16f70 Set the default "break list" level back to full.
llvm-svn: 131449
2011-05-17 01:21:41 +00:00