Commit Graph

2290 Commits

Author SHA1 Message Date
Johnny Chen 1ee61a7f3b Add a test script for exercising the "taregt create", "target list", and "target select" commands.
llvm-svn: 129717
2011-04-18 21:08:05 +00:00
Johnny Chen d28977c7c2 Add header comment.
llvm-svn: 129710
2011-04-18 18:50:24 +00:00
Johnny Chen 238de9a804 Add docstring.
llvm-svn: 129707
2011-04-18 18:34:09 +00:00
Johnny Chen 72f51aafe7 Modify some docstrings.
llvm-svn: 129706
2011-04-18 18:32:09 +00:00
Greg Clayton 7260f6206f Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the 
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example). 

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

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

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

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

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

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

There's also a general setting:

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

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

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

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

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

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

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

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

Patch from Stephen Wilson with some minor modification by me.

llvm-svn: 129595
2011-04-15 19:56:24 +00:00
Johnny Chen 1691a1676c Forgot to check in this change with http://llvm.org/viewvc/llvm-project?view=rev&revision=129542.
llvm-svn: 129574
2011-04-15 16:44:48 +00:00
Johnny Chen eb0e0b19b0 Rewording of assert message.
llvm-svn: 129543
2011-04-14 22:24:12 +00:00
Johnny Chen 2c40561743 Add a test to check that lldb reliably catches a crashing inferior (both command and Python API).
llvm-svn: 129542
2011-04-14 22:20:36 +00:00
Sean Callanan 1b1bf6e982 Updated LLVM to pick up fixes to the ARM instruction
tables.

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

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

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

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

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

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

llvm-svn: 129474
2011-04-13 21:49:04 +00:00
Jim Ingham 5d3e822926 Have "-h" print just the command arguments, and "-h -v" print the examples as well.
llvm-svn: 129470
2011-04-13 21:11:41 +00:00
Caroline Tice 69955f6cdc Fix various minor bugs in the ARM instruction emulation code.
llvm-svn: 129422
2011-04-13 00:42:12 +00:00
Greg Clayton 38068ca35f Revert newer xcscheme project file to avoid conflict with older Xcode
versions.

llvm-svn: 129416
2011-04-13 00:20:52 +00:00
Greg Clayton f6b8b58184 Added two new classes for command options:
lldb_private::OptionGroup
    lldb_private::OptionGroupOptions

OptionGroup lets you define a class that encapsulates settings that you want
to reuse in multiple commands. It contains only the option definitions and the
ability to set the option values, but it doesn't directly interface with the
lldb_private::Options class that is the front end to all of the CommandObject
option parsing. For that the OptionGroupOptions class can be used. It aggregates
one or more OptionGroup objects and directs the option setting to the 
appropriate OptionGroup class. For an example of this, take a look at the 
CommandObjectFile and how it uses its "m_option_group" object shown below
to be able to set values in both the FileOptionGroup and PlatformOptionGroup
classes. The members used in CommandObjectFile are:

    OptionGroupOptions m_option_group;
    FileOptionGroup m_file_options;
    PlatformOptionGroup m_platform_options;

Then in the constructor for CommandObjectFile you can combine the option
settings. The code below shows a simplified version of the constructor:

CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) :
    CommandObject (...),
    m_option_group (interpreter),
    m_file_options (),
    m_platform_options(true)
{
    m_option_group.Append (&m_file_options);
    m_option_group.Append (&m_platform_options);
    m_option_group.Finalize();
}

We append the m_file_options and then the m_platform_options and then tell
the option group the finalize the results. This allows the m_option_group to
become the organizer of our prefs and after option parsing we end up with
valid preference settings in both the m_file_options and m_platform_options
objects. This also allows any other commands to use the FileOptionGroup and
PlatformOptionGroup classes to implement options for their commands.

Renamed:
    virtual void Options::ResetOptionValues();
to:
    virtual void Options::OptionParsingStarting();

And implemented a new callback named:

    virtual Error Options::OptionParsingFinished();
    
This allows Options subclasses to verify that the options all go together
after all of the options have been specified and gives the chance for the
command object to return an error. It also gives a chance to take all of the
option values and produce or initialize objects after all options have
completed parsing.

Modfied:

    virtual Error
    SetOptionValue (int option_idx, const char *option_arg) = 0;
    
to be:

    virtual Error
    SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;

(option_idx is now unsigned).

llvm-svn: 129415
2011-04-13 00:18:08 +00:00
Greg Clayton 8b82f087a0 Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.

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

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

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

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

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

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

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

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

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

llvm-svn: 129351
2011-04-12 05:54:46 +00:00
Greg Clayton 471257c132 Added a few more commands, but I mainly wanted to include how to run lldb
with the same program arguments for a process over and over without having
to specify them (like you can with gdb with the "--args" option).

llvm-svn: 129332
2011-04-12 00:43:35 +00:00
Stephen Wilson 71c21d18c3 Order of initialization lists.
This patch fixes all of the warnings due to unordered initialization lists.

Patch by Marco Minutoli.

llvm-svn: 129290
2011-04-11 19:41:40 +00:00
Stephen Wilson 2b899767e1 Fix struct vs. class warning.
ParserVars is declared using the class keyword. This solves the warning.

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

    - Fix a few typos in asm description strings.

    - Fix bug in the carry flag calculation.

llvm-svn: 129168
2011-04-08 23:33:06 +00:00
Johnny Chen f16066e842 Really fix the test suite crasher this time.
llvm-svn: 129165
2011-04-08 22:39:17 +00:00
Johnny Chen 1f1b269bbe Fix a test suite crasher.
llvm-svn: 129161
2011-04-08 22:15:29 +00:00
Stephen Wilson 8acdbb8a75 Add missing headers.
Something changed in commit r129112 where a few standard headers vanished from
the include chain when building on Linux.  Fix up by including limits.h for
INT_MAX and PATH_MAX where needed, and stdio.h for printf().

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

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

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

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

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

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

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

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

Patch by Marco Minutoli.

llvm-svn: 129071
2011-04-07 10:27:22 +00:00
Stephen Wilson 78709173d2 Add a missing header
strtoul() is defined in stdlib.h and the header was missing in
StringExtractor.cpp.

Patch by Marco Minutoli!

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

llvm-svn: 129069
2011-04-07 10:16:53 +00:00
Caroline Tice c1bcafd8c1 Translate dwarf register numbers to internal register numbers
before trying to look them up in register contexts, in the 
emulation callback functions that read & write the frame registers.

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

Add instruction emulation function calls to SBInstruction and SBInstructionList APIs.

llvm-svn: 128956
2011-04-05 23:22:54 +00:00
Greg Clayton 0cb4acfc8d Use the same colors in the LLDB/GDB table as the sidebar so things look
consistent and also to lighten up the page a bit.

llvm-svn: 128939
2011-04-05 21:44:24 +00:00
Greg Clayton d5a395aa9c Removed a stray '\' character.
llvm-svn: 128934
2011-04-05 21:40:10 +00:00
Caroline Tice 3d50b2f7a6 Convert "process" read/write callback functions to "frame" read/write callback functions.
llvm-svn: 128917
2011-04-05 20:18:48 +00:00
Caroline Tice ad379efc86 Add the rest of the mechanisms to make ARM instruction emulation usable/possible.
llvm-svn: 128907
2011-04-05 18:46:00 +00:00
Greg Clayton 9b1e1cdf23 Added a speed test to the GDBRemoteCommunicationClient and
GDBRemoteCommunicationServer classes. This involved adding a new packet
named "qSpeedTest" which can test the speed of a packet send/response pairs
using a wide variety of send/recv packet sizes.

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

llvm-svn: 128837
2011-04-04 18:18:57 +00:00
Johnny Chen 511e8c0d36 Add a Python script which launches a program from within lldb and loop until the
process stops for some reason.  main.c (compiled into a.out) is used as an example in
the README-run-until-faulted file.

llvm-svn: 128755
2011-04-02 01:20:28 +00:00
Greg Clayton 2b4d9b7f11 Some OpenBSD patches from Amit Kulkarni.
llvm-svn: 128721
2011-04-01 18:18:34 +00:00
Greg Clayton ac4827fe05 Get rid of LONG_LONG_MAX and ULONG_LONG_MAX, and use LLONG_MAX and ULLONG_MAX
respectively.

llvm-svn: 128720
2011-04-01 18:14:08 +00:00
Johnny Chen 7d90b1f883 Modify test_process_list()'s expect sub-strings to be up-to-date.
llvm-svn: 128697
2011-04-01 00:48:40 +00:00
Johnny Chen df2963ed46 Add TestSymbolAPI.py to test the newly added SBSymbol and SBAddress APIs:
lldb::SymbolType SBSymbol::GetType();

  lldb::SectionType SBAddress::GetSectionType ();
  lldb::SBModule SBAddress::GetModule ();

Also add an lldb::SBModule::GetUUIDString() API which is easier for Python
to work with in the test script.

llvm-svn: 128695
2011-04-01 00:35:55 +00:00
Greg Clayton 95bf0fd3ab Added the ability to get a broadcaster event name for a given broadcaster
event.

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

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

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

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

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

llvm-svn: 128646
2011-03-31 17:58:23 +00:00
Caroline Tice 8071f11208 Revert changes that caused this scheme to be hidden in certain cases.
llvm-svn: 128638
2011-03-31 16:45:59 +00:00
Caroline Tice 31d8498f6f Add code to emulate VLD1 (multiple single elements) ARM instruction.
llvm-svn: 128637
2011-03-31 16:41:19 +00:00
Caroline Tice 8e4ed85520 Add code to emulate VSTR ARM instruction (store a floating point register).
llvm-svn: 128614
2011-03-31 05:38:36 +00:00
Caroline Tice df6dec754b Add code to emulate the VLDR Arm instruction (load a floating poitn register).
llvm-svn: 128613
2011-03-31 05:05:30 +00:00
Caroline Tice b5c6a3e50a Add "Bits64" utility function.
Add code to emulate VSTM ARM instruction (store multiple floating point registers).

llvm-svn: 128609
2011-03-31 03:26:23 +00:00
Johnny Chen d16c105c3d Take advantage of the newly added SBSymbol.GetType() API to check whether we
have a Code symbol and do disassembly on it.

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

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

llvm-svn: 128602
2011-03-31 01:08:07 +00:00
Johnny Chen 0e43f321b6 Add a generator to iterate through the code symbols for a given target.
To be modified to take advantage of the new SBSymbol API which checks a symbol for its type.

llvm-svn: 128601
2011-03-31 01:06:28 +00:00
Jim Ingham 6035b67d2c Convert ValueObject to explicitly maintain the Execution Context in which they were created, and then use that when they update themselves. That means all the ValueObject evaluate me type functions that used to require a Frame object now do not. I didn't remove the SBValue API's that take this now useless frame, but I added ones that don't require the frame, and marked the SBFrame taking ones as deprecated.
llvm-svn: 128593
2011-03-31 00:19:25 +00:00
Jim Ingham 3a195b7e78 Add GetFrameWithStackID to the StackFrameList and the Thread (which routes to its StackFrameList.)
llvm-svn: 128592
2011-03-31 00:15:49 +00:00
Caroline Tice 920c6c9855 Modify ARM instruction tables to allow for specifying floating point variants.
Add code to emulate VLDM ARM instruction (loading multiplt floating point registers).

Add function declarations for other floating point instructions to emulate.

llvm-svn: 128589
2011-03-31 00:02:51 +00:00
Jim Ingham 270684de6e Add a LaunchSimple API that is nicer to use for quick scripts.
llvm-svn: 128588
2011-03-31 00:01:24 +00:00
Johnny Chen 10889e6cd6 Modify self.expect() patterns to react to API change for SourceManager.DisplaySourceLinesWithLineNumbers().
llvm-svn: 128581
2011-03-30 22:28:50 +00:00
Johnny Chen c640179166 A a simple test file for some lldb 'platform' commands.
Add a missing result.SetStatus() stmt to the CommandObjectPlatformList::Execute() impl.

llvm-svn: 128575
2011-03-30 21:19:59 +00:00
Caroline Tice 55bff33b50 Fill in code for EmulateSTRDImm and EmulateSTRDReg, to emulate the
STRD (immediate) and STRD (register) instructions.

llvm-svn: 128570
2011-03-30 19:02:56 +00:00
Johnny Chen 318e7ba65d Add an option to specify the symbols to disassemble instead of the existing 'num of symbols to disassemble'
option.  If both are present, the 'symbols to disassemble' overrides the 'num of symbols to disassemble'.

An example usage:

$ ./lldb-disasm.py -C 'platform create remote-ios' -e /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib -o '-r -n' -s vprintf -s acosf_special

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

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

Added new functions to the platform:

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

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

Added the parent process ID to the ProcessInfo class. 

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

llvm-svn: 128547
2011-03-30 15:55:52 +00:00
Stephen Wilson 2298dee87a give subclasses access to UnixSignals::m_signals
Allow subclasses of UnixSignals to access m_signals by marking the member
protected instead of private.  This enables a subclass to provide a default
signal set as appropriate on construction.

llvm-svn: 128544
2011-03-30 15:33:24 +00:00
Caroline Tice 527637d64a Fill in EmulateSTRImmARM to emulate the STR (immediate,ARM) instruction.
llvm-svn: 128528
2011-03-30 06:03:24 +00:00
Caroline Tice a0e8cd5e89 Fill in EmulateSTRBImmARM to emulate the STRB (immediate, ARM) instruction.
llvm-svn: 128527
2011-03-30 05:40:56 +00:00
Caroline Tice 4cee4bd9f4 Fill in EmulateSTREX to emulate the STREX ARM instruction.
llvm-svn: 128525
2011-03-30 05:15:46 +00:00
Jim Ingham 406ef962d9 The example had gotten stale, so I made it work again, and for fun printed out the frame registers as well.
llvm-svn: 128523
2011-03-30 01:55:23 +00:00
Greg Clayton efcb603008 Updated the web site with a getting started with LLDB and also some resources
to help GDB users figure out the equivalent commands in LLDB.

llvm-svn: 128518
2011-03-30 01:02:37 +00:00
Stephen Wilson dc91686f48 Unfortunately, sranddev() is not available on all platforms so seed using the
current time instead.

llvm-svn: 128514
2011-03-30 00:12:40 +00:00
Caroline Tice 799e203894 Fill in code in EmulateSUBReg to emulate the SUB (register) ARM instruction.
llvm-svn: 128508
2011-03-29 23:44:20 +00:00
Jim Ingham dedfac0b95 Can't count on the particular number of modules loaded into a basic C executable.
llvm-svn: 128505
2011-03-29 23:22:29 +00:00
Caroline Tice c5bcda4619 Fill in code in EmulateADDRegShift, to emulate the ADD
(register-shifted register) ARM instruction.

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

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

llvm-svn: 128491
2011-03-29 21:24:06 +00:00
Caroline Tice 3f0bfdacc1 Add missing encodings for EmulateMOVRdImm (MOV register) function.
llvm-svn: 128479
2011-03-29 19:53:44 +00:00
Johnny Chen 6454e15f49 Add the ability to invoke lldb's disassemble command on the symbols digested from
the 'image dump symtab' command.  The number of symbols to disassemble can be
specified by the '-n Num' option, or unlimited if not specified.

llvm-svn: 128442
2011-03-29 01:07:00 +00:00
Johnny Chen 4044fdccfc Doc string change.
llvm-svn: 128429
2011-03-28 22:48:25 +00:00
Johnny Chen 5e28aa5d9b Add an initial version of lldb-disasm.py script whose purpose is to iterate through
all the symbols for an executable image and to issue the lldb 'disassemble' command
on each symbol.  The initial version just dumps the symbol table.

llvm-svn: 128428
2011-03-28 22:40:32 +00:00
Caroline Tice 87c19f61d4 Fix single quote characters throughout the ARM emulation stuff.
Fix bugs in various ARM istruction emulation functions:

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

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

EmulateShiftIMM
   - Fix bug in assert statement.

EmulateLDMDA
   - Fix context.

EmulateLDMDB
   - Fix context.

EmulateLDMIB
   - Fix context.     

EmulateSTM
   - Fix bug calculating lowest_set_bit.     

EmulateSTMDA
   - Fix context.
   - Fix bug calculating lowest_set_bit.

EmulateSTMDB
   - Fix context.
   - Fix bug calculating lowest_set_bit.

EmulateSTMIB
   - FIx context     

EmulateLDRSBImmed
   - Fix test to match correction in corrected manual 

llvm-svn: 128409
2011-03-28 16:10:45 +00:00