Commit Graph

10342 Commits

Author SHA1 Message Date
Jason Molenda 250b1b8902 Small fix for the "memory write -i filename" command -- if the user fails to specify the
number of bytes to write into the inferior process, the "default byte size" will be 1.
In that case, we want to copy the entire file into memory.  The code was looking for
a default byte size of 0 to indicate that the user had not provided a specific # of
bytes to copy; adjust that to 1 to match the actual default value.
<rdar://problem/18074973>

llvm-svn: 228067
2015-02-03 23:39:47 +00:00
Stephane Sezer 765fcc0d5b Use basename of main executable in POSIX-DYLD on Android.
Summary:
The Android dynamic linker reports only the basename of each SO entry, so for
the above check to be successful, we need to compare it to the basename of the
main executable.

This also has a nasty side-effect when working with older version of
Android (verified on platform version 16), and debugging PIE
executables: the dynamic linker has a bug and reports the load address
of the main executable (which is a shared object, because PIE) to be 0.
We then try to update the list of loaded sections for all shared
objects, including the main executable, and set the load address to 0,
which breaks everything that relies on resolving addresses in the main
executable (breakpoints, stepping, etc). This commit also fixes that broken
behavior when debugging on older Androids. This bug doesn't happen on newer
Android versions (verified for Android L).

Test Plan: Run test suite on linux.

Reviewers: clayborg, tfiala, richard.mitton

Subscribers: lldb-commits

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

llvm-svn: 228057
2015-02-03 22:48:34 +00:00
Zachary Turner 02624e4154 Fix compilation failure on Windows.
llvm-svn: 227998
2015-02-03 18:26:00 +00:00
Hafiz Abid Qadeer 9a0d572750 Restore the signal handler for Windows as it is not presistent there.
On windows, signal handler is reset to default once a signal is received. 
This causes doing ctrl-c twice on console (or pressing suspend button twice
in eclipse ide which uses SIGINT to stop the debuggee) to crash lldb-mi on 
windows. Although there is very tiny window (after signal handler is called
and before we restore the handler) where default handler will be in place.
But this is hardly a problem in practice as IDEs generally disable their suspend
button once it has been presses.

llvm-svn: 227964
2015-02-03 11:20:00 +00:00
Pavel Labath 1702eb1840 Test commit. No changes.
llvm-svn: 227960
2015-02-03 10:38:21 +00:00
Hafiz Abid Qadeer 0d51c1563b Fix CLI commands in lldb-mi.
This patch fixes execution of CLI commands in MI mode. The CLI commands are 
executed using "-interpreter-exec" command. The bug was in the 
CMICmnLLDBDebugSessionInfo class which contained the following members: 
SBProcess, SBTarget, SBDebugger and SBListener, but CLI commands don't affect
them and they aren't updated. Therefore some members can contain incorrect 
(or obsolete) reference and it can cause an error. My patch removes these 
members and uses getters that provides the updated instance every time it is used.

Patch from Ilia K ki.stfu@gmail.com. Approved by Greg.

llvm-svn: 227958
2015-02-03 10:05:54 +00:00
Bruce Mitchener 991b5966a3 Change void* name_token to const void* to address warnings.
Reviewers: granata.enrico, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 227952
2015-02-03 08:01:34 +00:00
Bruce Mitchener fd3cd13af5 Cast to (const OptionPermissions*) to avoid warning.
Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 227951
2015-02-03 07:59:26 +00:00
Enrico Granata decf03b68f Add an expectall() API that allows you to pass a list of patterns and have pexpect match *ALL* of them instead of just picking one
llvm-svn: 227938
2015-02-03 03:11:59 +00:00
Enrico Granata 3ea3b39319 Make it easier to see what's going on by tracing the test case
llvm-svn: 227936
2015-02-03 02:46:36 +00:00
Greg Clayton ff48e4bea0 Fixed bugs in the multi-threaded access in HostInfoBase. Prior to this fix, static bool variables were used but this is not sufficient. We now use std::call_once in all places where the previous static bool code was used to try to implement thread safety.
This was causing code that opened multiple targets to try and get a path to debugserver from the GDB remote communication class, and it would get the LLDB path and some instances would return empty strings and it would cause debugserver to not be found.

<rdar://problem/18756927>

llvm-svn: 227935
2015-02-03 02:05:44 +00:00
Chaoren Lin 6a196ce691 Fix TestThreadStepOut on Linux with LLGS
Remove implicit stop action on $vCont package for threads where no
explicit action or default action specified based on the specification
(they have to stay in there original state).

llvm-svn: 227933
2015-02-03 01:51:56 +00:00
Chaoren Lin 2ce7627807 Fix compilation error and cleanup in ThreadStateCoordinatorTest
llvm-svn: 227932
2015-02-03 01:51:54 +00:00
Chaoren Lin 0be9ebbfbd Add missing switch cases to silence warnings.
llvm-svn: 227931
2015-02-03 01:51:50 +00:00
Chaoren Lin 18fe6404f9 Implement setting and clearing watchpoints.
llvm-svn: 227930
2015-02-03 01:51:47 +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
Chaoren Lin 37c768ca58 Make ThreadStateCoordinator to handle properly failed stop/resume operations.
llvm-svn: 227928
2015-02-03 01:51:30 +00:00
Chaoren Lin a1f0ba7d38 Mark TestProcessLaunch.test_set_working_dir_with_dwarf as expected to fail in LLGS mode due llvm.org/pr20265
llvm-svn: 227927
2015-02-03 01:51:28 +00:00
Chaoren Lin 28e57429fc Share crash information between LLGS and local POSIX debugging with
CrashReason class. Deliver crash information from LLGS to lldb via
description field of thread stop packet.

llvm-svn: 227926
2015-02-03 01:51:25 +00:00
Chaoren Lin 72b8f05878 Mark several tests as XFAIL with new expectedFailureLLGS decorator since they are failing in Darwin for the same reason.
llvm-svn: 227925
2015-02-03 01:51:18 +00:00
Chaoren Lin 86fd8e45f4 Modify ThreadStateCoodrinator in order to resume threads if stop wasn't requested.
llvm-svn: 227924
2015-02-03 01:51:15 +00:00
Chaoren Lin 97ccc294da Refactor ptrace commands in NativeProcessLinux to use Error as result return type.
llvm-svn: 227923
2015-02-03 01:51:12 +00:00
Chaoren Lin ef1585ea7c added some missing ABIs
llvm-svn: 227922
2015-02-03 01:51:10 +00:00
Chaoren Lin 20433ae11b Fixed TestInferiorChanged
replaced expected stop reason 'address invalid' with 'signal SIGSEGV'

llvm-svn: 227921
2015-02-03 01:51:06 +00:00
Chaoren Lin 0c1463d4ea Fixed TestInferiorCrashing failures
LLGS debugging is outputting different thread stop reasons than
local linux debugging.  The stop reasons are reasonable so I've left
left them alone.  Might update them to match darwin in the future.

llvm-svn: 227920
2015-02-03 01:51:05 +00:00
Chaoren Lin 6626b5c25e Added support for writing registers larger than 64 bits
llvm-svn: 227919
2015-02-03 01:51:03 +00:00
Chaoren Lin 911a6dcaa9 LLGS local - signal stops inferior in debugger
NativeProcessLinux::MonitorSignal was automatically resuming threads
that stopped due to a signal.  This is inconsistent with the
behavior of lldb and gdb.  This change removes the automatic resume.

Fixes
TestSendSignal.py
TestSignalsAPI.py
if PLATFORM_LINUX_FORCE_LLGS_LOCAL is in the environment vars.

llvm-svn: 227918
2015-02-03 01:51:02 +00:00
Chaoren Lin e9547b8052 Fix up NativeProcessLinux::Interrupt() to use thread state coordinator mechanism.
llvm-svn: 227917
2015-02-03 01:51:00 +00:00
Chaoren Lin aab58633b7 Added code to prevent "administrative stop" from overwriting a real stop reason.
Note this code path should not happen - it implies a bug in another part of
the code.  For the thread to receive the stop signal as it is handled, the
and for it to already have a stop reason, it implies the kernel was able to
tell the thread that it stopped while it was stopped.  More likely this
seems to indicate a bug where an actual thread start was not getting correctly
logged.  If it does get hit, we'll want to understand the sequence to figure
out if it is truly legitimate or if it implies another bug.

llvm-svn: 227916
2015-02-03 01:50:57 +00:00
Chaoren Lin c0e5ac84b0 Fix step commands that mix running threads and stepping threads.
This fixes https://github.com/tfiala/lldb/issues/62.

llvm-svn: 227915
2015-02-03 01:50:56 +00:00
Chaoren Lin 9d617ba613 Disabled local-llgs hijacking of state on startup; passed along signo to killed process.
It looks like Shawn's fix addresses what the initial hijacking was trying
to accomplish per conversations with Greg and Jim.  The hijacking was
causing several tests to hang (#61, #62, #63, #64, #67, possibly more).
These tests now just fail rather than hang with this modification.

llvm-svn: 227914
2015-02-03 01:50:54 +00:00
Chaoren Lin b8af31d4b6 Fix some bugs in llgs thread state handling.
* When the thread state coordinator is told to skip sending a stop request
  for a running thread that is ignored (e.g. the thread that steps in a
  step operation is technically running and should not have a stop sent
  to it, since it will stop of its own accord per the kernel step operation),
  ensure the deferred signal notification logic still waits for the
  skipped thread.  (i.e. we want to defer the notification until the
  stepping thread is indeed stopped, we just don't want to send it a tgkill).

* Add ThreadStateCoordinator::RequestResumeAsNeeded().  This variant of the
  RequestResume() method does not call the error function when the thread
  is already running.  Instead, it just logs that the thread is already
  running and skips the resume operation.  This is useful for the case of
  vCont;c handling, where we tell all threads that they should be running.
  At the place we're calling, all we know is "we want this thread running if
  it isn't already," and that's exactly what this command does.

* Formatting change (minor) in NativeThreadLinux logging.

llvm-svn: 227913
2015-02-03 01:50:51 +00:00
Chaoren Lin 03f12d6b22 llgs: more work on thread stepping.
See https://github.com/tfiala/lldb/issues/75.  Not fixed yet but
continuing to push this further.

Fixes:
* Resume() now skips doing deferred notifications if we're doing a
  vCont;{c,C}.  In this case, we're trying to start something up,
  not defer a stop notification.  The default thread action stop
  mode pickup was triggering a stop because it had at least one
  stop, which was wrong in the case of a continue.  (Bug introduced
  by previous change.)

* Added a variant to ThreadStateCoordinator to specify a set of
  thread ids to be skipped when triggering stop notifications to
  non-stopped threads on a deferred signal call.  For the case of
  a stepping thread, it is actually told to step (and is running)
  for a brief moment, but the thread state coordinator would think
  it needed to send the stepping thread a stop, which id doesn't
  need to do.  This facility allows me to get around that cleanly.

With this change, behavior is now reduced to something I think is
essentially a different bug:

* Doing a step into libc code from my code crashes llgs.
* Doing a next out of a function in my own code crashes llgs.

llvm-svn: 227912
2015-02-03 01:50:49 +00:00
Chaoren Lin ae29d39570 llgs: fix up some handling of stepping.
Tracked down while working on https://github.com/tfiala/lldb/issues/75.
This is not a complete fix for that issue, but moves us farther along.

Fixes:
* When a thread step is requested via vCont:{s,S}, Resume() now marks
  the stepping thread as (1) currently stepping and (2) does trigger
  the deferred signal for the stepped thread.  This fixes a bug where
  we were actually triggering a deferred stop cycle here for the non-stepping
  thread since the single step thread was not part of the Resume()
  deferred signal mechanism.  The stepping thread is also marked in
  the thread state coordinator as running (via a resume callback).

* When we get the SIGTRAP signal for the step completion, we don't
  do a deferred signal call - that happened during the vCont:{s,S}
  processing in Resume() already.  Now we just need to mark that
  the stepping thread is now stopped.  If this is the last thread
  in the set that needs to stop, it will trigger the process/delegate
  stop call that will notify lldb.  Otherwise, that'll happen when
  the final thead we're waiting for stops.

Misc:
* Fixed up thread stop logging to use a leading 0 (0x%PRIx32) so
  we don't get log lines like 0x5 for 0x05 SIGTRAP.

llvm-svn: 227911
2015-02-03 01:50:46 +00:00
Chaoren Lin 938fcf63ed llgs: fixed a bug in deferred signal thread id; added coordinator enqueue logging.
The deferred signal thread id was being set with the process id
unintentionally in NativeProcessLinux::CallAfterRunningThreadsStop().

llvm-svn: 227910
2015-02-03 01:50:44 +00:00
Chaoren Lin fa03ad2ebc Get initial thread state coordinator integration working.
* Fixed bug in run loop where run loop return enum was being treated
  erroneously like an int, causing the TSC event loop to terminate
  prematurely.

* Added an explicit scope in NativeProcessLinux::Resume() for the
  threads lock lifetime.  (This was likely unnecessary but is
  more explicit.)

* Fixed a bug in ThreadStateCoordinator where resume execution was
  not updating the internal state about the thread assumed to be
  running now.  I'll add a test and upstream this in a moment.

* Added a verbose logging mechanism to event processing within
  ThreadStateCoordinator.  It is currently enabled when the
  'log enable lldb thread' is true upon inferior launch/attach.

llvm-svn: 227909
2015-02-03 01:50:42 +00:00
Chaoren Lin 56f981bfce Added remote-build.py and wired it into Xcode for Linux and MacOSX+Linux builds.
llvm-svn: 227908
2015-02-03 01:50:39 +00:00
Enrico Granata 9c3a07984f Allow customizing the timeout of the inferior
llvm-svn: 227906
2015-02-03 01:06:35 +00:00
Enrico Granata 9c58e8aac4 And, do not define arguments twice
llvm-svn: 227905
2015-02-03 01:00:44 +00:00
Enrico Granata 35dd52cf3e Allow pexpect exact matches
llvm-svn: 227904
2015-02-03 00:59:28 +00:00
Oleksiy Vyalov 926af0cdcb Make "process attach" command to support attaching to remote process in case if selected platform allows this.
http://reviews.llvm.org/D7358

llvm-svn: 227899
2015-02-03 00:04:35 +00:00
Enrico Granata 18cf8e018a Some cleanup in lldbpexpect
llvm-svn: 227889
2015-02-02 23:03:37 +00:00
Enrico Granata 15c752f9fa Nice syntax typo in lldbpexpect
llvm-svn: 227887
2015-02-02 22:55:46 +00:00
Enrico Granata 78b7d5fab2 Add an helper class to write pexpect-based test cases
Over time, we should improve this class and port all pexpect based testing over to using this

llvm-svn: 227875
2015-02-02 22:12:39 +00:00
Greg Clayton e89941b3bb Lock the Platform mutex in PlatformDarwin::GetDeveloperDirectory().
Partial fix for: <rdar://problem/19575304>

llvm-svn: 227863
2015-02-02 21:18:46 +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
Zachary Turner 6fd3f34d1f Make SBTarget::Launch() respect the stop_at_entry argument.
Patch by Ilia K
Differential Revision: http://reviews.llvm.org/D7271

llvm-svn: 227833
2015-02-02 18:50:01 +00:00
Hafiz Abid Qadeer 6a4ea636f3 Fix log file generation in lldb-mi.
When it runs, lldb-mi creates a log file. There is an option --noLog
to disable the creation but it does not work and you end up with log 
file. This happens as log is enabled in a few places in the code 
although it has been disabled by this option.

This commit tried to fix the problem in the following way.

Log file generation is disabled by default.
You can enable it by giving --log option. It is the only way to enable
it. Rest of the call have been removed.

So the code basically remove the calls that enable the log 
unconditionally and changes the option --noLog to --log.

llvm-svn: 227810
2015-02-02 17:08:25 +00:00
Hafiz Abid Qadeer 54ba124098 Make --thread argument optional for various commands.
Currently it was marked as mandatory for many commands. Although it
is recommended that fronends generate this argument, it is not
mandatory. GDB seems to treat it as optional too.

llvm-svn: 227798
2015-02-02 12:17:33 +00:00
Ed Maste 655b59854f Adapt test for tid format on non-Darwin platforms
llvm-svn: 227580
2015-01-30 16:45:24 +00:00