2014-06-30 21:05:18 +00:00
|
|
|
//===-- NativeThreadLinux.h ----------------------------------- -*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#ifndef liblldb_NativeThreadLinux_H_
|
|
|
|
|
#define liblldb_NativeThreadLinux_H_
|
|
|
|
|
|
|
|
|
|
#include "lldb/lldb-private-forward.h"
|
2015-02-03 01:51:38 +00:00
|
|
|
#include "lldb/Host/common/NativeThreadProtocol.h"
|
2014-06-30 21:05:18 +00:00
|
|
|
|
Work around a stepping bug in arm64 android M
Summary:
On arm64, linux<=4.4 and Android<=M there is a bug, which prevents single-stepping from working when
the system comes back from suspend, because of incorrectly initialized CPUs. This did not really
affect Android<M, because it did not use software suspend, but it is a problem for M, which uses
suspend (doze) quite extensively. Fortunately, it seems that the first CPU is not affected by
this bug, so this commit implements a workaround by forcing the inferior to execute on the first
cpu whenever we are doing single stepping.
While inside, I have moved the implementations of Resume() and SingleStep() to the thread class
(instead of process).
Reviewers: tberghammer, ovyalov
Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines, lldb-commits
Differential Revision: http://reviews.llvm.org/D17509
llvm-svn: 261636
2016-02-23 13:56:30 +00:00
|
|
|
#include <sched.h>
|
|
|
|
|
|
2015-02-03 01:51:47 +00:00
|
|
|
#include <map>
|
2015-08-20 09:06:12 +00:00
|
|
|
#include <memory>
|
2015-03-22 23:18:46 +00:00
|
|
|
#include <string>
|
2015-02-03 01:51:47 +00:00
|
|
|
|
2015-03-31 09:52:22 +00:00
|
|
|
namespace lldb_private {
|
|
|
|
|
namespace process_linux {
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
class NativeProcessLinux;
|
|
|
|
|
|
|
|
|
|
class NativeThreadLinux : public NativeThreadProtocol
|
|
|
|
|
{
|
|
|
|
|
friend class NativeProcessLinux;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid);
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
// NativeThreadProtocol Interface
|
|
|
|
|
// ---------------------------------------------------------------------
|
2014-09-12 22:51:49 +00:00
|
|
|
std::string
|
2014-06-30 21:05:18 +00:00
|
|
|
GetName() override;
|
|
|
|
|
|
|
|
|
|
lldb::StateType
|
|
|
|
|
GetState () override;
|
|
|
|
|
|
|
|
|
|
bool
|
2015-02-03 01:51:25 +00:00
|
|
|
GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
|
2014-06-30 21:05:18 +00:00
|
|
|
|
|
|
|
|
NativeRegisterContextSP
|
|
|
|
|
GetRegisterContext () override;
|
|
|
|
|
|
|
|
|
|
Error
|
|
|
|
|
SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
|
|
|
|
|
|
|
|
|
|
Error
|
|
|
|
|
RemoveWatchpoint (lldb::addr_t addr) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
// Interface for friend classes
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
Work around a stepping bug in arm64 android M
Summary:
On arm64, linux<=4.4 and Android<=M there is a bug, which prevents single-stepping from working when
the system comes back from suspend, because of incorrectly initialized CPUs. This did not really
affect Android<M, because it did not use software suspend, but it is a problem for M, which uses
suspend (doze) quite extensively. Fortunately, it seems that the first CPU is not affected by
this bug, so this commit implements a workaround by forcing the inferior to execute on the first
cpu whenever we are doing single stepping.
While inside, I have moved the implementations of Resume() and SingleStep() to the thread class
(instead of process).
Reviewers: tberghammer, ovyalov
Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines, lldb-commits
Differential Revision: http://reviews.llvm.org/D17509
llvm-svn: 261636
2016-02-23 13:56:30 +00:00
|
|
|
/// Resumes the thread. If @p signo is anything but
|
|
|
|
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
|
|
|
|
|
Error
|
|
|
|
|
Resume(uint32_t signo);
|
|
|
|
|
|
|
|
|
|
/// Single steps the thread. If @p signo is anything but
|
|
|
|
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
|
|
|
|
|
Error
|
|
|
|
|
SingleStep(uint32_t signo);
|
2014-06-30 21:05:18 +00:00
|
|
|
|
|
|
|
|
void
|
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 10:13:03 +00:00
|
|
|
SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
|
2014-06-30 21:05:18 +00:00
|
|
|
|
2014-09-11 23:29:14 +00:00
|
|
|
/// Return true if the thread is stopped.
|
|
|
|
|
/// If stopped by a signal, indicate the signo in the signo argument.
|
|
|
|
|
/// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
|
|
|
|
|
bool
|
|
|
|
|
IsStopped (int *signo);
|
|
|
|
|
|
2014-08-28 15:46:54 +00:00
|
|
|
void
|
|
|
|
|
SetStoppedByExec ();
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
void
|
|
|
|
|
SetStoppedByBreakpoint ();
|
|
|
|
|
|
2015-02-03 01:51:47 +00:00
|
|
|
void
|
2015-03-19 23:28:10 +00:00
|
|
|
SetStoppedByWatchpoint (uint32_t wp_index);
|
2015-02-03 01:51:47 +00:00
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
bool
|
|
|
|
|
IsStoppedAtBreakpoint ();
|
|
|
|
|
|
2015-02-03 01:51:47 +00:00
|
|
|
bool
|
|
|
|
|
IsStoppedAtWatchpoint ();
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
void
|
2015-02-03 01:51:25 +00:00
|
|
|
SetStoppedByTrace ();
|
|
|
|
|
|
|
|
|
|
void
|
2015-07-23 09:09:29 +00:00
|
|
|
SetStoppedWithNoReason ();
|
2014-06-30 21:05:18 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SetExited ();
|
|
|
|
|
|
2015-05-11 10:03:10 +00:00
|
|
|
Error
|
|
|
|
|
RequestStop ();
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
// Private interface
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
void
|
|
|
|
|
MaybeLogStateChange (lldb::StateType new_state);
|
|
|
|
|
|
Work around a stepping bug in arm64 android M
Summary:
On arm64, linux<=4.4 and Android<=M there is a bug, which prevents single-stepping from working when
the system comes back from suspend, because of incorrectly initialized CPUs. This did not really
affect Android<M, because it did not use software suspend, but it is a problem for M, which uses
suspend (doze) quite extensively. Fortunately, it seems that the first CPU is not affected by
this bug, so this commit implements a workaround by forcing the inferior to execute on the first
cpu whenever we are doing single stepping.
While inside, I have moved the implementations of Resume() and SingleStep() to the thread class
(instead of process).
Reviewers: tberghammer, ovyalov
Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines, lldb-commits
Differential Revision: http://reviews.llvm.org/D17509
llvm-svn: 261636
2016-02-23 13:56:30 +00:00
|
|
|
NativeProcessLinux &
|
|
|
|
|
GetProcess();
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SetStopped();
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
|
MaybePrepareSingleStepWorkaround();
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
|
MaybeCleanupSingleStepWorkaround();
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
// Member Variables
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
lldb::StateType m_state;
|
|
|
|
|
ThreadStopInfo m_stop_info;
|
|
|
|
|
NativeRegisterContextSP m_reg_context_sp;
|
2015-02-03 01:51:25 +00:00
|
|
|
std::string m_stop_description;
|
2015-02-03 01:51:47 +00:00
|
|
|
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
|
|
|
|
|
WatchpointIndexMap m_watchpoint_index_map;
|
Work around a stepping bug in arm64 android M
Summary:
On arm64, linux<=4.4 and Android<=M there is a bug, which prevents single-stepping from working when
the system comes back from suspend, because of incorrectly initialized CPUs. This did not really
affect Android<M, because it did not use software suspend, but it is a problem for M, which uses
suspend (doze) quite extensively. Fortunately, it seems that the first CPU is not affected by
this bug, so this commit implements a workaround by forcing the inferior to execute on the first
cpu whenever we are doing single stepping.
While inside, I have moved the implementations of Resume() and SingleStep() to the thread class
(instead of process).
Reviewers: tberghammer, ovyalov
Subscribers: aemerson, rengolin, tberghammer, danalbert, srhines, lldb-commits
Differential Revision: http://reviews.llvm.org/D17509
llvm-svn: 261636
2016-02-23 13:56:30 +00:00
|
|
|
cpu_set_t m_original_cpu_set; // For single-step workaround.
|
2014-06-30 21:05:18 +00:00
|
|
|
};
|
2015-03-31 09:52:22 +00:00
|
|
|
|
2015-08-20 09:06:12 +00:00
|
|
|
typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP;
|
2015-03-31 09:52:22 +00:00
|
|
|
} // namespace process_linux
|
|
|
|
|
} // namespace lldb_private
|
2014-06-30 21:05:18 +00:00
|
|
|
|
|
|
|
|
#endif // #ifndef liblldb_NativeThreadLinux_H_
|