Commit Graph

1179 Commits

Author SHA1 Message Date
Tamas Berghammer 04e6314cf4 Set error status when failed to catch stop after launch
Process::Launch try to catch a stop signal after launching a process. If
it is unsuccessful it destroy the process but previously still reported
that the process launched successfully. This behavior caused a
deadlock. With thic change the process launch error reported correctly.

Differential revision: http://reviews.llvm.org/D7784

llvm-svn: 230212
2015-02-23 10:59:54 +00:00
Enrico Granata b38ef8c2b6 Rename the "glob arguments" feature to "shell expand arguments"
This should not bring any feature change, except changing names of things here and there

llvm-svn: 230077
2015-02-20 22:20:30 +00:00
Greg Clayton 338d0bdc96 Make sure the public state is eStateStopped when we return from SBTarget::LoadCore() by hijacking the public event queue so we can ensure that the event gets consumed and the public state of the process (StateType SBProcess::GetState()) returns eStateStopped.
llvm-svn: 230066
2015-02-20 21:51:06 +00:00
Enrico Granata 83a1437646 Start the refactoring of globbing
- Add Host::GlobArguments() to perform local-globbing
I implemented this on OSX and Windows in terms of argdumper (Windows implementation is essentially the same as the OSX version + a change in binary name and some string magic)
Other platforms did not specifically chime in, so I left it unimplemented for them for the time being. Please feel free to fill in the blanks

- Add Platform::GlobArguments() to support remote-globbing
For now, no feature change here - but now we have infrastructure to help GDBRemote targets to support globbing - and patches to that effect will follow

No visible feature change

llvm-svn: 230065
2015-02-20 21:48:38 +00:00
Greg Clayton 35824e36f5 Avoid a race condition when loading core files where the process might still be handling the eStateStopped event we post to the private state thread causing us to return from SBTarget::LoadCore() before the process is ready to have API calls used on it.
This fixes a crasher that could happen when loading core files from scripts.

llvm-svn: 230060
2015-02-20 20:59:47 +00:00
Zachary Turner ee69a4bcd0 A few minor path fixes for Windows.
When launching argdumper, there are a few problems with the
current logic.  First, on Windows, the file is called
argdumper.exe, not argdumper.  Second, Windows paths have
backslashes in them, and JSON treats <backslash><char> as an
escape sequence.  To fix the second problem, on Windows we
convert backslashes to forward slashes, since backslash isn't
a valid filename character anyway this shouldn't be a problem.

llvm-svn: 229784
2015-02-18 23:59:11 +00:00
Pavel Labath 646b064543 Use CloseOnExec in Platform::PutFile
Summary:
This does not fix any outstanding issue that I know of, but there is no reason these files should
_not_ have CloseOnExec.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7694

llvm-svn: 229506
2015-02-17 16:07:52 +00:00
Jason Molenda c980fa92eb Change the default disassembly format again. First attempt at
changing it was in r219544 - after living on that for a few 
months, I wanted to take another crack at this.

The disassembly-format setting still exists and the old format
can be user specified with a setting like

${current-pc-arrow}${addr-file-or-load}{ <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>}: 

This patch was discussed in http://reviews.llvm.org/D7578

<rdar://problem/19726421>

llvm-svn: 229186
2015-02-13 23:24:21 +00:00
Ilia K cc39d3f4bd Fix Arg0 argument after r229110. The problem was that Arg0ValueChangedCallback isn't twitching when Arg0 was updated, therefore target was launched with empty 1st argument or without it at all. In this patch I update Arg0 by hand.
llvm-svn: 229125
2015-02-13 17:07:55 +00:00
Ilia K 8f37ca56d6 Add -exec-arguments command
Summary:
This patch adds -exec-arguments command for lldb-mi. -exec-arguments command allows to specify arguments for executable file in MI mode. Also it contains tests for that command.

Btw, new added files was formatted by clang-format.

Reviewers: abidh, zturner, clayborg

Reviewed By: clayborg

Subscribers: zturner, emaste, clayborg, jingham, lldb-commits

Differential Revision: http://reviews.llvm.org/D6965

llvm-svn: 229110
2015-02-13 14:31:06 +00:00
Tamas Berghammer 3c4f89d702 Add Initialize/Terminate method to Platform base plugin
Platform holds a smart pointer to each platform object created in a
static variable what cause the platform destructors called only on
program exit when other static variables are not availables. With this
change the destructors are called on lldb_private::Terminate()

+ Fix DebuggerRefCount handling in ScriptInterpreterPython

Differential Revision: http://reviews.llvm.org/D7590

llvm-svn: 228944
2015-02-12 18:18:27 +00:00
Greg Clayton 526ae040ba Make a more complete fix for always supplying an execution context when getting byte sizes from types.
There was a test in the test suite that was triggering the backtrace logging output that requested that the client pass an execution context. Sometimes we need the process for Objective C types because our static notion of the type might not align with the reality when being run in a live runtime.

Switched from an "ExecutionContext *" to an "ExecutionContextScope *" for greater ease of use.

llvm-svn: 228892
2015-02-12 00:34:25 +00:00
Ilia K 333fc18ca6 Add extra check that target was stopped before the *stopped is sent.
This patch fixes r228417. It's required because eStateCrushed case wasn't investigated.

llvm-svn: 228824
2015-02-11 11:24:20 +00:00
Enrico Granata 560558eb7c Introduce the notion of "runtime support values"
A runtime support value is a ValueObject whose only purpose is to support some language runtime's operation, but it does not directly provide any user-visible benefit
As such, unless the user is working on the runtime support, it is mostly safe for them not to see such a value when debugging

It is a language runtime's job to check whether a ValueObject is a support value, and that - in conjunction with a target setting - is used by frame variable and target variable
SBFrame::GetVariables gets a new overload with yet another flag to dictate whether to return those support values to the caller - that which defaults to the setting's value

rdar://problem/15539930

llvm-svn: 228791
2015-02-11 02:35:39 +00:00
Enrico Granata 5e3fe047cd As part of the cleanup when a process dies, tell watchpoints to forget their previously recorded values
Because types are not reliably protected against the death of their owners, having ValueObjects lurking around like that past the useful lifetime of their owner processes is a potential source of crashes
That is - in itself - worth fixing at some point, but for this case, watchpoints holding on to old values don't offer enough value to make the larger fix worth

Fixes rdar://19788756

llvm-svn: 228777
2015-02-11 00:37:54 +00:00
Oleksiy Vyalov 37386143b8 Extract attach core logic from SBTarget::Attach* methods into unified SBTarget::AttachToProcess and make it work with platform for remote attach purposes.
http://reviews.llvm.org/D7471

llvm-svn: 228757
2015-02-10 22:49:57 +00:00
Vince Harron df3f00f30a Fix 'process launch -i' for remote processes
We want to forward stdin when stdio is not disabled and when we're not
redirecting stdin from a file.

renamed m_stdio_disable to m_stdin_forward and inverted value because
that's what we want to remember.

There was previously a bug that if you redirected stdin from a file,
stdout and stderr would also be redirected to /dev/null

Adds support for remote target to TestProcessIO.py

Fixes ProcessIOTestCase.test_stdin_redirection_with_dwarf for remote
Linux targets

llvm-svn: 228744
2015-02-10 21:09:04 +00:00
Enrico Granata d7a83a9c66 Add a "launch with globber" mode that lets you launch a process after having globbed the command line arguments via argdumper instead of routing via /bin/sh
llvm-svn: 228658
2015-02-10 03:06:24 +00:00
Vince Harron e0be425a53 Add support for SBProcess::PutSTDIN to remote processes
Processes running on a remote target can already send $O messages
to send stdout but there is no way to send stdin to a remote
inferior.

This allows processes using the API to pump stdin into a remote
inferior process.

It fixes a hang in TestProcessIO.py when running against a remote
target.

llvm-svn: 228419
2015-02-06 18:32:57 +00:00
Ilia K 6af632f93c Fix a missing "*stopped" notification in LLDB-MI after "process launch -s" in case of remote-macosx
Summary:
This patch fixes *stopped notification for remote target when started with eLaunchFlagStopAtEntry (for example, using "process launch -s").

See explanation below:
```
Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
...
if (state != eStateConnected && platform_sp && platform_sp->CanDebugProcess ())
{
   ...
}
else
{
   ...
   if (m_process_sp)
      error = m_process_sp->Launch (launch_info);
}

if (error.Success())
{
    if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
    {
        ....
    }
    -- missing event if eLaunchFlagStopAtEntry is set --
    m_process_sp->RestoreProcessEvents ();
}
...
return error
```

Also this patch contains tests and you can check how it works.

Reviewers: zturner, clayborg, abidh

Reviewed By: clayborg

Subscribers: clayborg, abidh, zturner, lldb-commits

Differential Revision: http://reviews.llvm.org/D7273

llvm-svn: 228417
2015-02-06 18:15:05 +00:00
Bruce Mitchener 2ba84a6af7 Add additional DWARF 5 language constants.
This also hooks up the new C++14 language constant to be treated
the same as the other C++ language constants.

Differential Revision: http://reviews.llvm.org/D7429

llvm-svn: 228386
2015-02-06 06:46:52 +00:00
Oleksiy Vyalov 1ef7b2c897 Extend SBPlatform with capability to launch/terminate a process remotely. Integrate this change into test framework in order to spawn processes on a remote target.
http://reviews.llvm.org/D7263

llvm-svn: 228230
2015-02-04 23:19:15 +00:00
Greg Clayton 554f68d385 Get rid of Debugger::FormatPrompt() and replace it with the new FormatEntity class.
Why? Debugger::FormatPrompt() would run through the format prompt every time and parse it and emit it piece by piece. It also did formatting differently depending on which key/value pair it was parsing. 

The new code improves on this with the following features:
1 - Allow format strings to be parsed into a FormatEntity::Entry which can contain multiple child FormatEntity::Entry objects. This FormatEntity::Entry is a parsed version of what was previously always done in Debugger::FormatPrompt() so it is more efficient to emit formatted strings using the new parsed FormatEntity::Entry.
2 - Allows errors in format strings to be shown immediately when setting the settings (frame-format, thread-format, disassembly-format
3 - Allows auto completion by implementing a new OptionValueFormatEntity and switching frame-format, thread-format, and disassembly-format settings over to using it.
4 - The FormatEntity::Entry for each of the frame-format, thread-format, disassembly-format settings only replaces the old one if the format parses correctly
5 - Combines all consecutive string values together for efficient output. This means all "${ansi.*}" keys and all desensitized characters like "\n" "\t" "\0721" "\x23" will get combined with their previous strings
6 - ${*.script:} (like "${var.script:mymodule.my_var_function}") have all been switched over to use ${script.*:} "${script.var:mymodule.my_var_function}") to make the format easier to parse as I don't believe anyone was using these format string power user features.
7 - All key values pairs are defined in simple C arrays of entries so it is much easier to add new entries.

These changes pave the way for subsequent modifications where we can modify formats to do more (like control the width of value strings can do more and add more functionality more easily like string formatting to control the width, printf formats and more).

llvm-svn: 228207
2015-02-04 22:00:53 +00:00
Zachary Turner 362a813736 Fix broken windows build due to use of O_CLOEXEC.
llvm-svn: 228171
2015-02-04 19:11:48 +00:00
Pavel Labath 493c3a127f Avoid leakage of file descriptors in LLDB and LLGS
Summary:
Both LLDB and LLGS are leaking file descriptors into the debugged process. This plugs the leak by
closing the unneeded descriptors. In one case I use O_CLOEXEC, which I hope is supported on
relevant platforms. I also added a regression test and plugged a fd leak in dosep.py.

Reviewers: vharron, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7372

llvm-svn: 228130
2015-02-04 10:36:57 +00:00
Chaoren Lin 2fe1d0abc2 Moving header files from source/Host/common to proper location.
llvm-svn: 227929
2015-02-03 01:51:38 +00:00
Greg Clayton 7597b353b3 Make one mutex for the lldb_private::Platform class that can be used to protect with modifying member variables. This mutex is designed to be used for simple modifications, so the lock should be taken, modify the member variable and released. We need to make sure this isn't used with any code that cause code to rely or reenter on another thread.
Partial fix for: <rdar://problem/19575304>

llvm-svn: 227855
2015-02-02 20:45:17 +00:00
Greg Clayton d26a1e5060 Fixed the failing test:
./dotest.py -A x86_64 -C clang -v -t  -f TestImageListMultiArchitecture.test_image_list_shows_multiple_architectures

The problem was that if the platform wasn't compatible with the current file in the "target create" command, it wasn't finding a platform that was like it used to.

Also, the currently selected platform was being used upload the file _before_ the target was created which was incorrect as "target create a.out" might switch platforms if its architecture doesn't match, so I moved the uploading to happen after the target was created so we use the right platform (the one in the target, not the selected one).

llvm-svn: 227380
2015-01-28 22:08:17 +00:00
Greg Clayton ccd2a6d958 Changes in 226712 needed some fixing as a platform is almost always selected and even if platform options are specified when doing a "target create" they would get ignored if a platform was already selected.
The change was made so we could re-use a platform if one was already created instead of creating a new one, but it would fail in the above case. To fix this, if we have a selected platform, we verify that the platform matches the current platform before we try to re-use it. We do this by asking the OptionGroupPlatform if the platform matches. If so, it returns true and we don't create a new platform, else we do.

llvm-svn: 227288
2015-01-28 01:33:37 +00:00
Jim Ingham d1f2536829 Use LLDB_INVALID_FRAME_ID for invalid frame ID's.
llvm-svn: 227283
2015-01-28 01:17:26 +00:00
Enrico Granata 3842b9ff8d More work for the dynamic type size feature
Namely, this commit provides an actual implementation of how to retrieve the byte size in a sane way for an ObjC class, by scanning ivar offsets and byte sizes, figuring out the farthest-from-base ivar, and adding its byte size to that

Still NFC

llvm-svn: 227277
2015-01-28 00:45:42 +00:00
Vince Harron d40ef9993e Fixing TestRegisters on Linux with LLGS
This patch fixes TestRegisters on Linux with LLGS

Introduce GetUserRegisterCount on RegisterInfoInterface to distinguish
lldb internal registers (e.g.: DR0-DR7) during register counting.

Update GDBRemoteCommunicationServer to skip lldb internal registers on
read/write register and on discover register.

Submitted for Tamas Berghammer

llvm-svn: 226959
2015-01-23 22:57:00 +00:00
Greg Clayton cd6bbba186 Fix the -*-version-min option to not try and use the current OS version for iOS and the simulator since llvm/clang will assert and kill LLDB.
llvm-svn: 226846
2015-01-22 18:25:49 +00:00
Vince Harron 1b5a74eea7 This patch gets remote-linux platform able to run processes
Make sure the selected platform is always used

Make sure that the host uses the connect://hostname to connect to both
the lldb-platform and the lldb-gdbserver rather than what the platform
reports as the hostname of the lldb-gdbserver

Make sure that lldb-platform uses the IP address on it's connection
back to the host instead of the hostname that the host sends to it
when launching lldb-gdbserver with the remote host information

Tested on OSX and Linux

llvm-svn: 226712
2015-01-21 22:42:49 +00:00
Greg Clayton 7bd4c60043 Abstract the details from regex.h a bit more by not allowing people to specify compile and execute flags for regular expressions. Also enable better regular expressions if they are available by check if the REG_ENHANCED is available and using it if it is.
Since REG_ENHANCED is available on MacOSX, this allow the use of \d (digits) \b (word boundaries) and much more without affecting other systems.

<rdar://problem/12082562>

llvm-svn: 226704
2015-01-21 21:51:02 +00:00
Jim Ingham d5ac1ab65d Fix a race condition where you could set the selected thread & target in the
CommandInterpreter's execution context AFTER the process had started running
and before it initially stopped.  Also fixed one test case that was implicitly
using this (and an abuse of the async mode) to accidentally succeed.

<rdar://problem/16814726>

llvm-svn: 226528
2015-01-19 23:51:51 +00:00
Vince Harron 5275aaa0cc Moved Args::StringToXIntYZ to StringConvert::ToXIntYZ
The refactor was motivated by some comments that Greg made
http://reviews.llvm.org/D6918

and also to break a dependency cascade that caused functions linking
in string->int conversion functions to pull in most of lldb

llvm-svn: 226199
2015-01-15 20:08:35 +00:00
Jim Ingham d762df8c24 Make sure that when a breakpoint is hit but its condition is not met,
the hit count is not updated.
Also, keep the hit count for the breakpoint in the breakpoint.  We were
using just the sum of the location's hit counts, but that was wrong since if a shared library is
unloaded, and the location goes away, the breakpoint hit count should not suddenly drop
by the number of hits there were on that location.

llvm-svn: 226074
2015-01-15 01:41:04 +00:00
Greg Clayton 332e8b1cd4 Fixed an issue where if the operating system python plug-in is changed at runtime, it wouldn't cause the process to reload the new operating system plug-in, now it does.
This is currently controlled by a setting:

(lldb) settings set target.process.python-os-plugin-path <path>

Or clearing it with:

(lldb) settings clear target.process.python-os-plugin-path 

The process will now reload the OperatingSystem plug-in.

This was implemented by:
- adding the ability to set a notify callback for when an option value is changed
- added the ability for the process plug-in to load the operating system plug-in on the fly
- fixed bugs in the Process::GetStatus() so all threads are displayed if their thread IDs are larger than 32 bits
- adding a callback in ProcessProperties to tell when the "python-os-plugin-path" is changed by the user
- fixing a crasher in ProcessMachCore that happens when updating the thread list when the OS plugin is reloaded

llvm-svn: 225831
2015-01-13 21:13:08 +00:00
Enrico Granata 9aa7e8e9ff Dynamic values have been around (and stable and reliable) for long enough that we can turn them on by default
Change the default of prefer-dynamic-value to eDynamicDontRunTarget (i.e. enable dynamic values, but do not run code to do so)

Of course, disable this for the test suite, since testing no-dynamic-values is actually valuable

Fixes rdar://17363061

llvm-svn: 225486
2015-01-09 00:47:24 +00:00
Jim Ingham 4af5961caa Audit uses of ConstString::AsCString() to make sure they weren't assuming
they would always get a non-NULL string back.

<rdar://problem/19298575>

llvm-svn: 224602
2014-12-19 19:20:44 +00:00
Zachary Turner 0b9d3eefdb Enhance the Pipe interface for better portability.
This patch makes a number of improvements to the Pipe interface.

1) An interface (PipeBase) is provided which exposes pure virtual
   methods for any implementation of Pipe to override.  While not
   strictly necessary, this helps catch errors where the interfaces
   are out of sync.

2) All methods return lldb_private::Error instead of returning bool
   or void.  This allows richer error information to be propagated
   up to LLDB.

3) A new ReadWithTimeout() method is exposed in the base class and
   implemented on Windows.

4) Support for both named and anonymous pipes is exposed through the
   base interface and implemented on Windows.  For creating a new
   pipe, both named and anonymous pipes are supported, and for
   opening an existing pipe, only named pipes are supported.

New methods described in points #3 and #4 are stubbed out on posix,
but fully implemented on Windows.  These should be implemented by
someone on the linux / mac / bsd side.

Reviewed by: Greg Clayton, Oleksiy Vyalov
Differential Revision: http://reviews.llvm.org/D6686

llvm-svn: 224442
2014-12-17 18:02:19 +00:00
Stephane Sezer f2ef94e770 Make the platform process connect path less chatty.
Summary:
If a stream contains an empty string, no need to append it to the output
(otherwise we end up with a blank line). Also, no need to print a status
message when the state changes to connected, as this string brings no
information -- "Process 0" does not mean anything to the user, and the
process being connected has no meaning either.

Test Plan:
Connect to a remote linux platform mode daemon with `platform select
remote-linux` followed by `platform connect ...`, create a target and
run it, observe the output. Also, run the full test suite (dosep.py).

Before:
    (lldb) [...] connect, etc.
    (lldb) r
    Process 0 connected

    Process 5635 launched: '/Users/sas/Source/test' (x86_64)
    Process 5635 stopped

After:
    (lldb) [...] connect, etc.
    (lldb) r
    Process 5635 launched: '/Users/sas/Source/test' (x86_64)
    Process 5635 stopped

Reviewers: tfiala, vharron, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D6593

llvm-svn: 224188
2014-12-13 05:23:51 +00:00
Eric Christopher 2325e38024 Fix a bunch of [-Werror,-Winconsistent-missing-override] warnings.
llvm-svn: 223973
2014-12-10 22:29:58 +00:00
Greg Clayton a97c4d2154 Handle thumb IT instructions correctly all the time.
The issue with Thumb IT (if/then) instructions is the IT instruction preceeds up to four instructions that are made conditional. If a breakpoint is placed on one of the conditional instructions, the instruction either needs to match the thumb opcode size (2 or 4 bytes) or a BKPT instruction needs to be used as these are always unconditional (even in a IT instruction). If BKPT instructions are used, then we might end up stopping on an instruction that won't get executed. So if we do stop at a BKPT instruction, we need to continue if the condition is not true.

When using the BKPT isntructions are easy in that you don't need to detect the size of the breakpoint that needs to be used when setting a breakpoint even in a thumb IT instruction. The bad part is you will now always stop at the opcode location and let LLDB determine if it should auto-continue. If the BKPT instruction is used, the BKPT that is used for ARM code should be something that also triggers the BKPT instruction in Thumb in case you set a breakpoint in the middle of code and the code is actually Thumb code. A value of 0xE120BE70 will work since the lower 16 bits being 0xBE70 happens to be a Thumb BKPT instruction. 

The alternative is to use trap or illegal instructions that the kernel will translate into breakpoint hits. On Mac this was 0xE7FFDEFE for ARM and 0xDEFE for Thumb. The darwin kernel currently doesn't recognize any 32 bit Thumb instruction as a instruction that will get turned into a breakpoint exception (EXC_BREAKPOINT), so we had to use the BKPT instruction on Mac. The linux kernel recognizes a 16 and a 32 bit instruction as valid thumb breakpoint opcodes. The benefit of using 16 or 32 bit instructions is you don't stop on opcodes in a IT block when the condition doesn't match. 

To further complicate things, single stepping on ARM is often implemented by modifying the BCR/BVR registers and setting the processor to stop when the PC is not equal to the current value. This means single stepping is another way the ARM target can stop on instructions that won't get executed.

This patch does the following:
1 - Fix the internal debugserver for Apple to use the BKPT instruction for ARM and Thumb
2 - Fix LLDB to catch when we stop in the middle of a Thumb IT instruction and continue if we stop at an instruction that won't execute
3 - Fixes this in a way that will work for any target on any platform as long as it is ARM/Thumb
4 - Adds a patch for ignoring conditions that don't match when in ARM mode (see below)

This patch also provides the code that implements the same thing for ARM instructions, though it is disabled for now. The ARM patch will check the condition of the instruction in ARM mode and continue if the condition isn't true (and therefore the instruction would not be executed). Again, this is not enable, but the code for it has been added.

<rdar://problem/19145455> 

llvm-svn: 223851
2014-12-09 23:31:02 +00:00
Zachary Turner 270e99ab0a Fix some posix assumptions related to running shell commands.
This is a resubmit of r223548, which was reverted due to breaking
tests on Linux and Mac.

This resubmit fixes the reason for the revert by adding back some
accidentally removed code which appends -c to the command line
when running /bin/sh.

This resubmit also differs from the original patch in that it sets
the architecture on the ProcessLaunchInfo.  A follow-up patch will
refactor this to separate the logic for different platforms.

Differential Revision: http://reviews.llvm.org/D6553

Reviewed By: Greg Clayton

llvm-svn: 223695
2014-12-08 21:36:42 +00:00
Jim Ingham 4623b9d3e2 Reverting r223548 which broke running in the shell on OS X.
llvm-svn: 223568
2014-12-06 01:41:10 +00:00
Jim Ingham 33df7cd345 Add the ability to set breakpoints with conditions, commands, etc,
in the "dummy-target".  The dummy target breakpoints prime all future
targets.  Breakpoints set before any target is created (e.g. breakpoints
in ~/.lldbinit) automatically get set in the dummy target.  You can also
list, add & delete breakpoints from the dummy target using the "-D" flag,
which is supported by most of the breakpoint commands.

This removes a long-standing wart in lldb...

<rdar://problem/10881487>

llvm-svn: 223565
2014-12-06 01:28:03 +00:00
Zachary Turner 00cdc98b7f Fix some posix assumptions related to running shell commands.
Differential Revision: http://reviews.llvm.org/D6553

Reviewed By: Greg Clayton

llvm-svn: 223548
2014-12-06 00:14:24 +00:00
Sean Callanan 9998acd004 This is the meat of the code to add Clang modules
support to LLDB.  It includes the following:

- Changed DeclVendor to TypeVendor.
- Made the ObjCLanguageRuntime provide a DeclVendor
  rather than a TypeVendor.
- Changed the consumers of TypeVendors to use
  DeclVendors instead.
- Provided a few convenience functions on
  ClangASTContext to make that easier.

llvm-svn: 223433
2014-12-05 01:21:59 +00:00
Sean Callanan 5dc2981cf8 Added support to Platform to indicate (1) whether the
current platform supports Clang modules, and (2) what
options to pass to Clang so it can load those Clang
modules.

llvm-svn: 223431
2014-12-05 01:16:31 +00:00
Jim Ingham 893c932acf This is the first step of making lldb able to create target-specific things
(e.g. breakpoints, stop-hooks) before we have any targets - for instance in 
your ~/.lldbinit file.  These will then get copied over to any new targets 
that get created.  So far, you can only make stop-hooks.

Breakpoints will have to learn to move themselves from target to target for
us to get them from no-target to new-target.

We should also make a command & SB API way to prime this ur-target.

llvm-svn: 222600
2014-11-22 01:42:44 +00:00
Jim Ingham c0b4d5a1f6 "nexti" should not step over inlined functions.
<rdar://problem/16705325>

llvm-svn: 222459
2014-11-20 22:04:45 +00:00
Oleksiy Vyalov 5d06474b29 Add test for denied process attach by pid and fix found bugs in Process/ProcessPOSIX.cpp
and FreeBSD/ProcessMonitor.

http://reviews.llvm.org/D6240

llvm-svn: 222372
2014-11-19 18:27:45 +00:00
Jason Molenda 557109377d Small tweaks to make the editline sources match the lldb
source layout.

llvm-svn: 222171
2014-11-17 20:10:15 +00:00
Greg Clayton 8012cadbf3 Fixed more fallout from running the test suite remotely on iOS devices.
Fixed include:
- Change Platform::ResolveExecutable(...) to take a ModuleSpec instead of a FileSpec + ArchSpec to help resolve executables correctly when we have just a path + UUID (no arch).
- Add the ability to set the listener in SBLaunchInfo and SBAttachInfo in case you don't want to use the debugger as the default listener. 
- Modified all places that use the SBLaunchInfo/SBAttachInfo and the internal ProcessLaunchInfo/ProcessAttachInfo to not take a listener as a parameter since it is in the launch/attach info now
- Load a module's sections by default when removing a module from a target. Since we create JIT modules for expressions and helper functions, we could end up with stale data in the section load list if a module was removed from the target as the section load list would still have entries for the unloaded module. Target now has the following functions to help unload all sections a single or multiple modules:

    size_t
    Target::UnloadModuleSections (const ModuleList &module_list);

    size_t
    Target::UnloadModuleSections (const lldb::ModuleSP &module_sp);

llvm-svn: 222167
2014-11-17 19:39:20 +00:00
Kate Stone e30f11d9ee Complete rewrite of interactive editing support for single- and multi-line input.
Improvements include:
* Use of libedit's wide character support, which is imperfect but a distinct improvement over ASCII-only
* Fallback for ASCII editing path
* Support for a "faint" prompt clearly distinguished from input
* Breaking lines and insert new lines in the middle of a batch by simply pressing return
* Joining lines with forward and backward character deletion
* Detection of paste to suppress automatic formatting and statement completion tests
* Correctly reformatting when lines grow or shrink to occupy different numbers of rows
* Saving multi-line history, and correctly preserving the "tip" of history during editing
* Displaying visible ^C and ^D indications when interrupting input or sending EOF
* Fledgling VI support for multi-line editing
* General correctness and reliability improvements

llvm-svn: 222163
2014-11-17 19:06:59 +00:00
Jason Molenda cf29675d95 Fix a corner case with the handling of noreturn functions.
If a noreturn function was the last function in a section,
we wouldn't correctly back up the saved-pc value into the
correct section leading to us showing the wrong function in
the backtrace.

Also add a backtrace test with an attempt to elicit this 
particular layout.  It happens to work out with clang -Os
but other compilers may not quite get the same layout I'm
getting at that opt setting.  We'll still be exercising the
basic noreturn handling in the unwinder even if we don't get
one function at the very end of a section.

<rdar://problem/16051613> 

llvm-svn: 221575
2014-11-08 05:38:17 +00:00
Greg Clayton 81eed943a3 Fixed the C++ method name class to be a bit more picky about what it identifies as a C++ method.
This was done by using regular expressions on any basename we find to ensure it is valid.

This fixed setting breakpoints by name with values like '[J]com.robovm.debug.server.apps.SleepLoop.startingUp()V'. This was previously triggering the C++ method name class to identify the string as C++ with a basename of '[J]com.robovm.debug.server.apps.SleepLoop.startingUp' which was obviously incorrect. 

The changes also fixed errors in templated function names like "void foo<int>(...)" where "void foo<int>" was being identified incorrectly as the basename. We also handle more C++ operators correctly now.

llvm-svn: 221416
2014-11-05 23:56:37 +00:00
Sean Callanan a330933f15 - Use "for_expression" rather than "allow_unknownanytype"
to indicate that we're doing stuff for the expression
  parser.

- When for_expression is true, look through @s and find
  the actual class rather than just returning id. 

- Rename BuildObjCObjectType to BuildObjCObjectPointerType
  since it's actually returning an object *pointer* type.

llvm-svn: 220979
2014-10-31 18:02:30 +00:00
Justin Hibbits db39cdfbb7 Fix some bugs from D5988
Summary:
Ed Maste found some problems with the commit in D5988.  Address most of these.
While here, also add floating point return handling.  This doesn't handle
128-bit long double yet.  Since I don't have any system that uses it, I don't
currently have plans to implement it.

Reviewers: emaste

Reviewed By: emaste

Subscribers: emaste, lldb-commits

Differential Revision: http://reviews.llvm.org/D6049

llvm-svn: 220963
2014-10-31 15:57:52 +00:00
Justin Hibbits 6256a0ea8f First cut of PowerPC(64) support in LLDB.
Summary:
This adds preliminary support for PowerPC/PowerPC64, for FreeBSD.  There are
some issues still:

 * Breakpoints don't work well on powerpc64.
 * Shared libraries don't yet get loaded for a 32-bit process on powerpc64 host.
 * Backtraces don't work.  This is due to PowerPC ABI using a backchain pointer
   in memory, instead of a dedicated frame pointer register for the backchain.
 * Breakpoints on functions without debug info may not work correctly for 32-bit
   powerpc.

Reviewers: emaste, tfiala, jingham, clayborg

Reviewed By: clayborg

Subscribers: emaste, lldb-commits

Differential Revision: http://reviews.llvm.org/D5988

llvm-svn: 220944
2014-10-31 02:34:28 +00:00
Enrico Granata 2206b48d6d Also port the C string reading code in ValueObject over to using StringPrinter API
llvm-svn: 220917
2014-10-30 18:27:31 +00:00
Jim Ingham fa39bb4a56 Setting breakpoints with name mask eFunctionNameTypeBase was broken for straight C names by 220432. Get
that working again.

llvm-svn: 220602
2014-10-25 00:33:55 +00:00
Greg Clayton c3795409c9 Fixed name lookups for names that contain "::" but aren't actually C++ qualified C++ names.
To do this, I fixed the  CPPLanguageRuntime::StripNamespacesFromVariableName() function to use a regular expression that correctly determines if the name passed to it is a qualfied C++ name like "a:🅱️:c" or "b::c". The old version of this function was treating '__54-[NSUserScriptTask executeWithInterpreter:arguments::]_block_invoke' as a match with a basename of ']_block_invoke'.

Also fixed a case in the by name lookup of functions where we wouldn't look for the full name if we actually tried to call CPPLanguageRuntime::StripNamespacesFromVariableName() and got an empty basename back.

<rdar://problem/18527866>

llvm-svn: 220432
2014-10-22 21:47:13 +00:00
Matthew Gardiner c928de3e8e Added functions to the C++ API, for the benefit of non-8-bit byte architectures.
New functions to give client applications to tools to discover target byte sizes
for addresses prior to ReadMemory. Also added GetPlatform and ReadMemory to the
SBTarget class, since they seemed to be useful utilities to have.

Each new API has had a test case added.

http://reviews.llvm.org/D5867

llvm-svn: 220372
2014-10-22 07:22:56 +00:00
Jim Ingham a672ecefef The breakpoint location hit counts were getting incremented in
BreakpointLocation::ShouldStop.  That worked but wasn't really right,
since there's nothing to guarantee that won't get called more than
once.  So this change moves that responsibility to the StopInfoBreakpoint
directly, and then it uses the BreakpointSite to actually do the bumping.

Also fix a test case that was assuming if you had many threads running some 
code with a breakpoint in it, the hit count when you stopped would always be
1.  Many of the threads could have hit it at the same time...

<rdar://problem/18577603>

llvm-svn: 220358
2014-10-22 01:54:17 +00:00
Enrico Granata 622be238eb Expose the type-info flags at the public API layer. These flags provide much more informational content to consumers of the LLDB API than the existing TypeClass. Part of the fix for rdar://18517593
llvm-svn: 220322
2014-10-21 20:52:14 +00:00
Eric Christopher f75b0ee2ab Remove unused variable.
llvm-svn: 220319
2014-10-21 20:36:17 +00:00
Greg Clayton dc6224e0a3 Make the "synchronous" mode actually work without race conditions.
There were many issues with synchronous mode that we discovered when started to try and add a "batch" mode. There was a race condition where the event handling thread might consume events when in sync mode and other times the Process::WaitForProcessToStop() would consume them. This also led to places where the Process IO handler might or might not get popped when it needed to be.

llvm-svn: 220254
2014-10-21 01:00:42 +00:00
Zachary Turner 10687b0ea5 Remove LLDB_DEFAULT_SHELL #define, and determine this at runtime.
Differential Revision: http://reviews.llvm.org/D5805
Reviewed by: Greg Clayton

llvm-svn: 220217
2014-10-20 17:46:43 +00:00
Jason Molenda 48c0440d97 Fix MemoryHistory plugin to check whether the plugin
was able to create itself before returning the shared
pointer to it.
clang warning.

llvm-svn: 219936
2014-10-16 16:59:23 +00:00
Jason Molenda 97e704b2af Add /* DISABLES CODE */ annotation before if (0) to mark it as intentional.
llvm-svn: 219913
2014-10-16 08:07:20 +00:00
Jason Molenda 60b5da6c3c Remove unused initialization.
clang static analyzer fixit.

llvm-svn: 219909
2014-10-16 07:53:46 +00:00
Jason Molenda 8b5f2cfc19 Remove dead store.
clang static analyzer fixit.

llvm-svn: 219907
2014-10-16 07:49:27 +00:00
Jason Molenda 1446881254 Ensure that user_exe_path is non-NULL before derferencing.
We've already created a FileSpec based on this local and 
this code path would never be executed if it is an invalid
FilePath - but the static analyzer doesn't know this and I
want to placate it.
clang static analyzer fixit.

llvm-svn: 219890
2014-10-16 01:42:11 +00:00
Jason Molenda 76513fd9bc Give old_state a default value so we won't try to restore
an uninitialized value.  In reality the code block that 
initializes it and the code block that restores it will always
match up - but the analyzer doesn't know that and I want to 
quiet it, so...
clang static analyzer fixit.

llvm-svn: 219869
2014-10-15 23:39:31 +00:00
Jason Molenda 4d9f3b0e50 Remove unneeded local var initialization.
clang static analyzer fixit.

llvm-svn: 219770
2014-10-15 03:06:23 +00:00
Greg Clayton b8e9b8b703 Fixed stdio redirection within LLDB to "do the right thing" in all cases.
The main issue was if you didn't specify all three (stdin/out/err), you would get file actions added to the launch that would always use the pseudo terminal. This is now fixed.

Also fixed the test suite test that handles IO to test redirecting things individually and all together and in other combinations to make sure we don't regress.

<rdar://problem/18638226>

llvm-svn: 219711
2014-10-14 20:18:05 +00:00
Todd Fiala 75f47c3a5d llgs: fixes to PTY/gdb-remote inferior stdout/stderr handling, logging addtions.
With this change, both local-process llgs and remote-target llgs stdout/stderr
handling from inferior work correctly.

Several log lines have been added around PTY and stdout/stderr redirection
logic on the lldb client side.

Regarding remote llgs execution, see the following:

With these changes, remote llgs with $O now works properly:

$ lldb
(lldb) platform select remote-linux
(lldb) target create ~/some/inferior/exe
(lldb) gdb-remote {some-target}:{port}
(lldb) run

The sequence above will correctly redirect stdout/stderr over gdb-remote $O,
as is needed for remote debugging.  That sequence assumes there is a lldb-gdbserver
exe running on the target with {some-host}:{port}.

You can replace the gdb-remote command with a '(lldb) platform connect
connect://{target-ip}:{target-port}'.  If you do this and have a
lldb-platform running on the remote end, it will go ahead and launch
llgs for lldb for each target instance that is run/attached.

For local debugging with llgs, the following sequence also works, and
uses local PTYs instead to avoid $O and extra gdb-remote messages:

$ lldb
(lldb) settings set platform.plugin.linux.use-llgs true
(lldb) target create ~/some/inferior/exe
(lldb) run

The above will run the inferior using llgs on the local host, and
will use PTYs rather than $O redirection.

This change also removes the logging that happened after the fork but
before the exec when llgs is launching a new inferior process.  Some
aspect of the file handling during that portion of code would not do
the right thing with log handling.  We might want to go back later
and have that communicate over a pipe from the child to parent to pass
along any messages that previously were logged in that section of code.

llvm-svn: 219578
2014-10-11 21:42:09 +00:00
Kuba Brecka 6392754839 Add a IsInstrumentationRuntimePresent SB API
Reviewed at http://reviews.llvm.org/D5738

This adds an SB API into SBProcess:
  bool SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
which simply tells whether a particular InstrumentationRuntime (read "ASan") plugin is present and active.

llvm-svn: 219560
2014-10-11 01:59:32 +00:00
Jim Ingham 26c7bf9312 Rework the way we pass "run multiple command" options to the various API's that
do that (RunCommandInterpreter, HandleCommands, HandleCommandsFromFile) to gather
the options into an options class.  Also expose that to the SB API's.

Change the way the "-o" options to the lldb driver are processed so:
1) They are run synchronously - didn't really make any sense to run the asynchronously.
2) The stop on error
3) "quit" in one of the -o commands will not quit lldb - not the command interpreter
that was running the -o commands.

I added an entry to the run options to stop-on-crash, but I haven't implemented that yet.

llvm-svn: 219553
2014-10-11 00:38:27 +00:00
Kuba Brecka afdf842b3f LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592

This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.

More precisely this patch...

adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.

Kuba

llvm-svn: 219546
2014-10-10 23:43:03 +00:00
Jason Molenda aff1b357b0 Add a new disassembly-format specification so that the disassembler
output style can be customized.  Change the built-in default to be
more similar to gdb's disassembly formatting.

The disassembly-format for a gdb-like output is

${addr-file-or-load} <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>: 

The disassembly-format for the lldb style output is

{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name-without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}: 

The two backticks in the lldb style formatter triggers the sub-expression evaluation in
CommandInterpreter::PreprocessCommand() so you can't use that one as-is ... changing to
use ' characters instead of ` would work around that.

<rdar://problem/9885398> 

llvm-svn: 219544
2014-10-10 23:07:36 +00:00
Todd Fiala 2c77a427ab Reverse out r219169 related to quote handling.
Addresses pr/21190 (http://llvm.org/bugs/show_bug.cgi?id=21190).

r219169 implemented this change list:
http://reviews.llvm.org/D5472 for more details.

llvm-svn: 219461
2014-10-10 01:11:39 +00:00
Todd Fiala 348fb385d5 Enable local llgs debugging on Linux when the use-llgs-for-local setting is enabled.
See http://reviews.llvm.org/D5695 for details.

This change does the following:

Enable lldb-gdbserver (llgs) usage for local-process Linux debugging.
To turn on local llgs debugging support, which is disabled by default, enable this setting:

(lldb) settings set platform.plugin.linux.use-llgs-for-local true
Adds a stream-based Dump() function to FileAction.
Pushes some platform methods that Linux (and FreeBSD) will want to share with MacOSX from PlatformDarwin into PlatformPOSIX.

Reviewed by Greg Clayton.

llvm-svn: 219457
2014-10-10 00:09:16 +00:00
Todd Fiala ac33cc9ce7 logging: added more logging to the Target/Platform launch & attach sequence.
llvm-svn: 219377
2014-10-09 01:02:08 +00:00
Shawn Best 1ded74a8c4 Minor comment change to test out svn access
llvm-svn: 219269
2014-10-08 01:50:37 +00:00
Jim Ingham 8b91d0cd01 Fix stepping over the inserted breakpoint trap when the NEXT instruction
also contains a breakpoint.

<rdar://problem/18519712>

llvm-svn: 219263
2014-10-08 01:03:54 +00:00
Todd Fiala f72fa67fc3 Fix spurious output to command line when launching a process on Linux.
See http://reviews.llvm.org/D5632 for details.

Change by Shawn Best.

llvm-svn: 219213
2014-10-07 16:05:21 +00:00
Todd Fiala a9ae365b2d Add "target.expr-parser-compiler-args" setting.
This setting contains the following:
A list containing all the arguments to be passed to the expression parser compiler.

This change also ensures quoted arguments are handled appropriately.

See http://reviews.llvm.org/D5472 for more details.

Change by Tong Shen.

llvm-svn: 219169
2014-10-06 23:13:30 +00:00
Zachary Turner 93a66fc13a Move ConnectionFileDescriptor to platform-specific Host directory.
As part of getting ConnectionFileDescriptor working on Windows,
there is going to be alot of platform specific work to be done.
As a result, the implementation is moving into Host.  This patch
performs the code move and fixes up call-sites appropriately.

Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5548

llvm-svn: 219143
2014-10-06 21:22:36 +00:00
Jason Molenda 6a35470563 Add a mutex lock to StackFrame to protect race conditions for
updating its ivars.  We've had a lot of crash reports and careful
analysis shows that we've got multiple threads operating on the
same StackFrame objects, changing their m_sc and m_flags ivars.
<rdar://problem/18406111> 

llvm-svn: 218845
2014-10-02 01:08:16 +00:00
Jim Ingham 89fd66813b Not all processes have a Dynamic Loader. Be sure to check that it exists before using it.
<rdar://problem/18491391>

llvm-svn: 218699
2014-09-30 20:33:25 +00:00
Todd Fiala 8a3716bfab Fix cmake build for new thread plan files.
llvm-svn: 218679
2014-09-30 15:58:56 +00:00
Jim Ingham 2bdbfd50d2 This checkin is the first step in making the lldb thread stepping mechanism more accessible from
the user level.  It adds the ability to invent new stepping modes implemented by python classes,
and to view the current thread plan stack and to some extent alter it.

I haven't gotten to documentation or tests yet.  But this should not cause any behavior changes
if you don't use it, so its safe to check it in now and work on it incrementally.

llvm-svn: 218642
2014-09-29 23:17:18 +00:00
Todd Fiala cacde7df6d Enable llgs to build against experimental Android AOSP lldb/llvm/clang/compiler-rt repos.
See http://reviews.llvm.org/D5495 for more details.

These are changes that are part of an effort to support building llgs, within the AOSP source tree, using the Android.mk
build system, when using the llvm/clang/lldb git repos from AOSP replaced with the experimental ones currently in
github.com/tfiala/aosp-{llvm,clang,lldb,compiler-rt}.

llvm-svn: 218568
2014-09-27 16:54:22 +00:00
Todd Fiala ad6eee6399 Change inline-breakpoint-strategy setting to default to eInlineBreakpointsAlways strategy.
See thread started here for motivation:
http://lists.cs.uiuc.edu/pipermail/lldb-dev/2014-September/005225.html

This change enables the ability to set breakpoints in ccache-based and executables that
make use of preprocessed source files.  This ability existed in lldb before, but was off
by default.

Change by Doug Snyder.

llvm-svn: 218405
2014-09-24 19:59:13 +00:00
Zachary Turner acee96ae52 Fix up the HostThread interface, making the interface simpler.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5417

llvm-svn: 218325
2014-09-23 18:32:09 +00:00
Greg Clayton 615eb7e609 Test suite runs better again after recent fixes that would select a platform if a "file a.out" auto selected a different platform than the selected one.
Changes include:
- fix it so you can select the "host" platform using "platform select host"
- change all callbacks that create platforms to returns shared pointers
- fix TestImageListMultiArchitecture.py to restore the "host" platform by running "platform select host"
- Add a new "PlatformSP Platform::Find(const ConstString &name)" method to get a cached platform
- cache platforms that are created and re-use them instead of always creating a new one

llvm-svn: 218145
2014-09-19 20:11:50 +00:00