Commit Graph

4938 Commits

Author SHA1 Message Date
Jason Molenda 4a4b5dcb7d sys/stat.h needed for mkdir, chmod, stat.
llvm-svn: 195305
2013-11-21 02:45:55 +00:00
Greg Clayton 29b8fc4da9 Added new options to lldb-platform:
--gdbserver-port PORT
    --min-gdbserver-port PORT
    --max-gdbserver-port PORT
    
The --gdbserver-port option can be specified multiple times to tell lldb-platform which ports it can use when launching child GDB server processes.
The --min-gdbserver-port and --max-gdbserver-port options allow a range of ports to be specified for use when launching child GDB server processes.

Fixed the code to manage these ports correctly in GDBRemoteCommunicationServer.

Also changed GDBRemoteCommunicationClient to not set a port when sending the "qLaunchGDBServer" packet so that the remote lldb-platform can decide which ports to use. If the lldb-platform was launched with no --gdbserver-port or --min-gdbserver-port/--max-gdbserver-port options, then port 0 is always used and a unix socket is used between the lldb-platform and child GDB server process to coordinate the use of valid port.

llvm-svn: 195300
2013-11-21 01:44:58 +00:00
Enrico Granata 5383e81a7f <rdar://problem/15449837>
Change the NSSet data formatter to not use the expression parser to produce synthetic children
In small-scale experimentation with lldb-perf, this improves our performance by around 25%

llvm-svn: 195294
2013-11-21 01:08:05 +00:00
Greg Clayton fbb7634934 Expose SBPlatform through the public API.
Example code:

remote_platform = lldb.SBPlatform("remote-macosx"); 
remote_platform.SetWorkingDirectory("/private/tmp")
debugger.SetSelectedPlatform(remote_platform)

connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); 
err = remote_platform.ConnectRemote(connect_options)
if err.Success():
    print >> result, 'Connected to remote platform:'
    print >> result, 'hostname: %s' % (remote_platform.GetHostname())
    src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False)
    dst = lldb.SBFileSpec()
    # copy src to platform working directory since "dst" is empty
    err = remote_platform.Install(src, dst);
    if err.Success():
        print >> result, '%s installed successfully' % (src)
    else:
        print >> result, 'error: failed to install "%s": %s' % (src, err)


Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories.

The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform.

The API in SBPlatform is subject to change and will be getting many new functions.

llvm-svn: 195273
2013-11-20 21:07:01 +00:00
Colin Riley 61979ccad6 Fix MSVC build
The demangler added in r193708 from cxa_demangle.cpp uses language features which are not supported by the latest visual studio. In order to preserve the msvc build, this patch restores the previous (non)functionality in windows under msvc by disabling the demangler. 

llvm-svn: 195254
2013-11-20 15:19:08 +00:00
Jason Molenda 4ff132610a Flush the Process' cache of extended threads every time the
natural stop id is updated.
<rdar://problem/15496603> 

llvm-svn: 195177
2013-11-20 00:31:38 +00:00
Jason Molenda a6e9130d52 Add logging for the SB API which creates extended
threads.

Take a stab at fixing the too-soon freeing of the extended
backtrace thread list in Process.
<rdar://problem/15496603> 

llvm-svn: 195104
2013-11-19 05:44:41 +00:00
Jason Molenda 8ee9cb5891 Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() method
(and same thing to Thread base class) which can be used when looking
at an ExtendedBacktrace thread; it will try to find the IndexID() of
the original thread that was executing this backtrace when it was
recorded.  If lldb can't find a record of that thread, it will return
the same value as IndexID() for the ExtendedBacktrace thread.

llvm-svn: 194912
2013-11-16 01:24:22 +00:00
Sylvestre Ledru f0f2d58086 Improve the set of the Python libraries during the cmake build.
Thanks to Kal Conley for the patch

llvm-svn: 194815
2013-11-15 14:15:10 +00:00
Jason Molenda a7b5afa91b Commit a work-in-progress system runtime for Mac OS X which won't
do anything right now.  Add a few new methods to the Thread base
class which HistoryThread needs.  I think I updated all the 
CMakeLists files correctly for the new plugin.

llvm-svn: 194756
2013-11-15 00:17:32 +00:00
Greg Clayton f74cf86bc5 <rdar://problem/15172417>
Added two new GDB server packets to debugserver: "QSaveRegisterState" and "QRestoreRegiterState".

"QSaveRegisterState" makes the remote GDB server save all register values and it returns a save identifier as an unsigned integer. This packet can be used prior to running expressions to save all registers.

All registers can them we later restored with "QRestoreRegiterState:SAVEID" what SAVEID is the integer identifier that was returned from the call to QSaveRegisterState.

Cleaned up redundant code in lldb_private::Thread, lldb_private::ThreadPlanCallFunction.
Moved the lldb_private::Thread::RegisterCheckpoint into its own header file and it is now in the lldb_private namespace. Trimmed down the RegisterCheckpoint class to omit stuff that wasn't used (the stack ID).

Added a few new virtual methods to lldb_private::RegisterContext that allow subclasses to efficiently save/restore register states and changed the RegisterContextGDBRemote to take advantage of these new calls.

llvm-svn: 194621
2013-11-13 23:28:31 +00:00
Enrico Granata 8d81a843fa Minor improvement to the "memory find" command
Remove the --do-read option, and always provide a small dump of memory at each match spot
Add a --dump-offset (-o) option, to specify a byte offset from which to start dumping relative to the matching address

The real solution is to actually provide the format options found on "memory read" and use those as the key to actually printing memory upon each find
That, however, requires a little refactoring work, so put this in for now until I get a chance to do the required shuffling around of moving parts

llvm-svn: 194600
2013-11-13 20:08:30 +00:00
Greg Clayton 3ebae49748 Fixed printf warnings. The GetByteSize() results return uint64_t values, not size_t values.
llvm-svn: 194587
2013-11-13 18:01:16 +00:00
Enrico Granata 6e49c48f97 Small typos in previous commit
llvm-svn: 194546
2013-11-13 02:22:24 +00:00
Enrico Granata 534684372d <rdar://problem/14322677>
Implement a "memory find" command for LLDB

This is still fairly rough around the edges but works well enough for simple scenarios where a chunk of text or a number are to be found within a certain range of memory, as in
mem find `buffer` `buffer+0x1000` -s "me" -c 5 -r

llvm-svn: 194544
2013-11-13 02:18:44 +00:00
Jason Molenda 008c45f1a1 Change SBThread::GetExtendedBacktrace to
SBThread::GetExtendedBacktraceThread to make it more clear what is
being returned.

llvm-svn: 194531
2013-11-12 23:33:32 +00:00
Ed Maste 7b24e95e69 Log failure to restore thread state in ThreadPlanCallFunction::DoTakedown
In order to help track down llvm.org/pr17226.

llvm-svn: 194487
2013-11-12 16:47:08 +00:00
Jason Molenda 750ea692e8 Add initial --extended / -e support to thread backtrace.
llvm-svn: 194455
2013-11-12 07:02:07 +00:00
Jason Molenda ee87e75090 Add object logging to HistoryThread. Call the DoDestroy() method from
the HistoryThread dtor.

llvm-svn: 194436
2013-11-12 00:09:58 +00:00
Ed Maste d23dcbfb53 Increase log detail for size mismatch in EntityVariable::Materialize
llvm-svn: 194413
2013-11-11 19:40:51 +00:00
Ed Maste eefd43f331 Fix header comment line length
llvm-svn: 194397
2013-11-11 18:30:28 +00:00
Ed Maste 2138d18a08 Add generic ARGn register IDs for FreeBSD and Linux x86
These were previously missing in g_register_infos_x86_64 and so arg
lookup failed on FreeBSD and Linux after r194035.

llvm-svn: 194392
2013-11-11 17:02:33 +00:00
Jason Molenda 864f1cc065 The Threads created when requesting extended backtraces need to be owned by
something; add a new ExtendedThreadList to Process where they can be retained
for the duration of a public stop.
<rdar://problem/15314068> 

llvm-svn: 194367
2013-11-11 05:20:44 +00:00
Jason Molenda 7a2f7904bf The Threads created when requesting extended backtraces need to be owned by
something; add a new ExtendedThreadList to Process where they can be retained
for the duration of a public stop.
<rdar://problem/15314068> 

llvm-svn: 194366
2013-11-11 05:19:34 +00:00
Peter Collingbourne 19676ac58f Fix CMake standalone build.
llvm-svn: 194363
2013-11-11 04:46:09 +00:00
Greg Clayton b35db6399d Fixed the the breakpoint test case failures.
There were 6 on darwin. All of these were related to the recent changes for exec.

llvm-svn: 194298
2013-11-09 00:03:31 +00:00
Greg Clayton c28ce7828b Fixed a build warning for a missing switch case.
llvm-svn: 194295
2013-11-08 23:38:26 +00:00
Jason Molenda 02706c3216 Add History subclasses for Thread, Unwind, RegisterContext.
Still working out some of the details of these classes but 
I wanted to get the overall structure checked in.
<rdar://problem/15314068> 

llvm-svn: 194245
2013-11-08 04:59:54 +00:00
Sean Callanan a464f3d43a Changed the ABIs and ClangFunction to take a
llvm::ArrayRef of arguments rather than taking
a fixed number of possibly-NULL pointers to
arguments.

Also changed ClangFunction::GetThreadPlanToCallFunction
to take the address of the argument struct by value
instead of by reference, since it doesn't actually
modify the value passed into it.

llvm-svn: 194232
2013-11-08 01:14:26 +00:00
Jim Ingham 6fbc48bc42 This patch does a couple of things.
It completes the job of using EvaluateExpressionOptions consistently throughout
the inferior function calling mechanism in lldb begun in Greg's patch r194009. 

It removes a handful of alternate calls into the ClangUserExpression/ClangFunction/ThreadPlanCallFunction which
were there for convenience.  Using the EvaluateExpressionOptions removes the need for them.

Using that it gets the --debug option from Greg's patch to work cleanly.

It also adds another EvaluateExpressionOption to not trap exceptions when running expressions.  You shouldn't
use this option unless you KNOW your expression can't throw beyond itself.  This is:

<rdar://problem/15374885>

At present this is only available through the SB API's or python.

It fixes a bug where function calls would unset the ObjC & C++ exception breakpoints without checking whether
they were set by somebody else already.

llvm-svn: 194182
2013-11-07 00:11:47 +00:00
Sean Callanan 2a0e663fbd Spelling fix.
llvm-svn: 194163
2013-11-06 19:56:05 +00:00
Sean Callanan 5c19eac1c8 Added Iterable, a class that vends standard C++
iterators for LLDB's container data structures.
Iterable abstracts over the backing data structure,
ignoring keys for maps for example.  It also provides
locking as a service so that the code

for (ThreadSP thread_sp : process->Threads())
{
  // ... use thread_sp
}

takes the appropriate locks once, without having to
do anything else.

The salient advantages of this system are:

- Much simpler and idiomatic loop code
- Lock once instead of each time an element is fetched
- Less boilerplate to produce the iterators

The intent is that Iterable will replace Get...AtIndex
in most places, and that ForEach(), which solves the
same problem in a less-idiomatic way, be phased out in
favor of this approach.

I've added Iterables to ThreadList, TypeList, and
Process (which is really just forwarding to ThreadList).

llvm-svn: 194159
2013-11-06 19:28:40 +00:00
Jason Molenda 95d005c789 Rename extended backtrace methods to take out the "ThreadOrigin"
bit from the method names.
<rdar://problem/15314369> 

llvm-svn: 194122
2013-11-06 03:07:33 +00:00
Greg Clayton cae5652838 Improve lldb_private::Address to detect when section was deleted and not return bogus values for GetLoadAddress() and GetFileAddress().
llvm-svn: 194120
2013-11-06 02:29:13 +00:00
Jason Molenda 5dd4916f63 Add a new GetThreadOriginExtendedBacktrace method to the
SystemRuntime and SBThread classes.
<rdar://problem/15314369> 

llvm-svn: 194111
2013-11-06 00:04:44 +00:00
Greg Clayton 095eeaa025 <rdar://problem/15367122>
Fixed the test case for "test/functionalities/exec/TestExec.py" on Darwin.

The issue was breakpoints were persisting and causing problems. When we exec, we need to clear out the process and target and start fresh with nothing and let the breakpoints populate themselves again. This patch correctly clears out the breakpoints and also flushes the process so that the objects (process/thread/frame) give out valid information.

llvm-svn: 194106
2013-11-05 23:28:00 +00:00
Jim Ingham afbb0af827 Give a better error when the index argument for “frame select” can’t be parsed.
<rdar://problem/15390829>

llvm-svn: 194087
2013-11-05 18:25:23 +00:00
Jason Molenda 8c71337abc Add the GetNumThreadOriginExtendedBacktraceTypes and
GetThreadOriginExtendedBacktraceTypeAtIndex methods to
SBProcess.

Add documentation for the GetQueueName and GetQueueID methods
to SBThread.
<rdar://problem/15314369> 

llvm-svn: 194063
2013-11-05 11:00:35 +00:00
Jason Molenda b4db43fad6 Add a GetThreadOriginExtendedBacktraceTypes method to the
SystemRuntime class.
<rdar://problem/15314369> 

llvm-svn: 194045
2013-11-05 04:25:57 +00:00
Jason Molenda eef510667b Add a new system runtime plugin type - just the top level
class, not any actual plugin implementation yet.
<rdar://problem/15314068> 

llvm-svn: 194044
2013-11-05 03:57:19 +00:00
Greg Clayton bb3a9b74e7 Update ABISysV_x86_64.cpp to use more efficient register finding calls.
Instead of looking up registers by name, we use the generic ID when we can.

Also added code that creates an extra frame when running expressions by pushing the current PC and FP and then hooking up the FP backchain. This code is "#if 0" out for now until we can pair it with unwinder fixes.

llvm-svn: 194035
2013-11-05 01:24:05 +00:00
Jason Molenda 8065867ff7 Fix the architectural default unwind plan's settings for restoring
the stack pointer.

llvm-svn: 194029
2013-11-05 00:19:09 +00:00
Jason Molenda 00ec491fc6 Fix a bug in the x86_64 architectural default unwindplan
where it was using the wrong register numbering scheme
to express where the rbp could be retrieved from.

llvm-svn: 194023
2013-11-04 22:57:40 +00:00
Greg Clayton bc3122ead3 <rdar://problem/15367406>
Fixed a case where on darwin, after recent compiler changes a few months ago, we could not execute dlopen() in an expression, or use "process load".

The issue was some compiler option default values changed. We now override these settings to get the old behavior back.

llvm-svn: 194012
2013-11-04 19:50:49 +00:00
Greg Clayton 62afb9f663 Added a "--debug" option to the "expression" command.
Cleaned up ClangUserExpression::Evaluate() to have only one variant that takes a "const EvaluateExpressionOptions& options" instead of taking many arguments.

The "--debug" option is designed to allow you to debug your expression by stopping at the first instruction (it enables --ignore-breakpoints=true and --unwind-on-error=false) and allowing you to step through your JIT code. It needs to be more integrated with the thread plan, so I am checking this in so Jim Ingham can make it happen.

llvm-svn: 194009
2013-11-04 19:35:17 +00:00
Jason Molenda 99618476ad Add new ivars to StackFrame so it can represent a stack collected
at some point in the past.  We may have nothing more than a pc value
for this type of stack frame -- hopefully we'll have a pc and a
stop_id so we can track module loads and unloads over time and
symbolicate the pc at the correct point in time.

Also add a flag to indicate if the CFA for the frame is available
(a bit different from a CFA of LLDB_INVALID_ADDRESS) and also an
overall setting to indicate whether this is a history stack frame
or not.  A history stack frame may not have a CFA, it may not have
a register context, it may not have variables, it may not have a
frame pointer or a stack pointer.

<rdar://problem/15314068>

llvm-svn: 193987
2013-11-04 11:02:52 +00:00
Jason Molenda b57e4a1bc6 Roll back the changes I made in r193907 which created a new Frame
pure virtual base class and made StackFrame a subclass of that.  As
I started to build on top of that arrangement today, I found that it
wasn't working out like I intended.  Instead I'll try sticking with
the single StackFrame class -- there's too much code duplication to
make a more complicated class hierarchy sensible I think.

llvm-svn: 193983
2013-11-04 09:33:30 +00:00
Filip Pizlo 8677577395 It is no longer necessary to opt out of pretty stack traces.
llvm-svn: 193972
2013-11-04 02:25:07 +00:00
Jason Molenda f23bf7432c Add a new base class, Frame. It is a pure virtual function which
defines a protocol that all subclasses will implement.  StackFrame
is currently the only subclass and the methods that Frame vends are
nearly identical to StackFrame's old methods.

Update all callers to use Frame*/Frame& instead of pointers to
StackFrames.

This is almost entirely a mechanical change that touches a lot of
the code base so I'm committing it alone.  No new functionality is
added with this patch, no new subclasses of Frame exist yet.

I'll probably need to tweak some of the separation, possibly moving
some of StackFrame's methods up in to Frame, but this is a good
starting point.

<rdar://problem/15314068>

llvm-svn: 193907
2013-11-02 02:23:02 +00:00
Sylvestre Ledru 779f921311 Fix the format warnings.
In almost all cases, the misuse is about "%lu" being used instead of the correct "%zu" (even though these are compatible on 64-bit platforms in practice). There are even a couple of cases where "%ld" (ie., signed int) is used instead of "%zu", and one where "%lu" is used instead of "%" PRIu64.

Fixes bug #17551.

Patch by "/dev/humancontroller"

llvm-svn: 193832
2013-10-31 23:55:19 +00:00