2014-06-30 21:05:18 +00:00
|
|
|
//===-- NativeThreadLinux.h ----------------------------------- -*- C++ -*-===//
|
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-06-30 21:05:18 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#ifndef liblldb_NativeThreadLinux_H_
|
|
|
|
|
#define liblldb_NativeThreadLinux_H_
|
|
|
|
|
|
Clean up NativeRegisterContext
Summary:
This commit removes the concrete_frame_idx member from
NativeRegisterContext and related functions, which was always set to
zero and never used.
I also change the native thread class to store a NativeRegisterContext
as a unique_ptr (documenting the ownership) and make sure it is always
initialized (most of the code was already blindly dereferencing the
register context pointer, assuming it would always be present -- this
makes its treatment consistent).
Reviewers: eugene, clayborg, krytarowski
Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits
Differential Revision: https://reviews.llvm.org/D39837
llvm-svn: 317881
2017-11-10 11:05:49 +00:00
|
|
|
#include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
|
|
|
|
|
#include "Plugins/Process/Linux/SingleStepCheck.h"
|
2015-02-03 01:51:38 +00:00
|
|
|
#include "lldb/Host/common/NativeThreadProtocol.h"
|
2014-06-30 21:05:18 +00:00
|
|
|
#include "lldb/lldb-private-forward.h"
|
|
|
|
|
|
2020-11-09 13:36:26 -08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
|
|
2017-07-18 13:14:01 +00:00
|
|
|
#include <csignal>
|
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:
|
2017-07-18 09:24:48 +00:00
|
|
|
NativeThreadLinux(NativeProcessLinux &process, lldb::tid_t tid);
|
2014-06-30 21:05:18 +00:00
|
|
|
|
|
|
|
|
// NativeThreadProtocol Interface
|
|
|
|
|
std::string GetName() override;
|
|
|
|
|
|
|
|
|
|
lldb::StateType GetState() override;
|
|
|
|
|
|
2015-02-03 01:51:25 +00:00
|
|
|
bool GetStopReason(ThreadStopInfo &stop_info,
|
|
|
|
|
std::string &description) override;
|
2014-06-30 21:05:18 +00:00
|
|
|
|
Clean up NativeRegisterContext
Summary:
This commit removes the concrete_frame_idx member from
NativeRegisterContext and related functions, which was always set to
zero and never used.
I also change the native thread class to store a NativeRegisterContext
as a unique_ptr (documenting the ownership) and make sure it is always
initialized (most of the code was already blindly dereferencing the
register context pointer, assuming it would always be present -- this
makes its treatment consistent).
Reviewers: eugene, clayborg, krytarowski
Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits
Differential Revision: https://reviews.llvm.org/D39837
llvm-svn: 317881
2017-11-10 11:05:49 +00:00
|
|
|
NativeRegisterContextLinux &GetRegisterContext() override {
|
|
|
|
|
return *m_reg_context_up;
|
|
|
|
|
}
|
2014-06-30 21:05:18 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
|
|
|
|
|
bool hardware) override;
|
2014-06-30 21:05:18 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status RemoveWatchpoint(lldb::addr_t addr) override;
|
2014-06-30 21:05:18 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
|
2017-02-24 13:27:31 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override;
|
2017-02-24 13:27:31 +00:00
|
|
|
|
2021-03-31 23:01:38 +05:00
|
|
|
NativeProcessLinux &GetProcess();
|
|
|
|
|
|
2022-01-11 20:28:37 +01:00
|
|
|
const NativeProcessLinux &GetProcess() const;
|
|
|
|
|
|
|
|
|
|
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
|
|
|
|
|
GetSiginfo() const override;
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
private:
|
|
|
|
|
// Interface for friend classes
|
|
|
|
|
|
2019-03-11 17:09:29 +00:00
|
|
|
/// Resumes the thread. If \p signo is anything but
|
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
|
|
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
|
2017-05-12 04:51:55 +00:00
|
|
|
Status Resume(uint32_t signo);
|
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
|
|
|
|
2019-03-11 17:09:29 +00:00
|
|
|
/// Single steps the thread. If \p signo is anything but
|
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
|
|
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
|
2017-05-12 04:51:55 +00:00
|
|
|
Status SingleStep(uint32_t signo);
|
2014-06-30 21:05:18 +00:00
|
|
|
|
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
|
|
|
void 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-03-19 23:28:10 +00:00
|
|
|
void 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();
|
|
|
|
|
|
2015-02-03 01:51:25 +00:00
|
|
|
void SetStoppedByTrace();
|
|
|
|
|
|
2021-04-09 17:00:12 +02:00
|
|
|
void SetStoppedByFork(bool is_vfork, lldb::pid_t child_pid);
|
|
|
|
|
|
|
|
|
|
void SetStoppedByVForkDone();
|
|
|
|
|
|
2015-07-23 09:09:29 +00:00
|
|
|
void SetStoppedWithNoReason();
|
2014-06-30 21:05:18 +00:00
|
|
|
|
2020-11-09 13:36:26 -08:00
|
|
|
void SetStoppedByProcessorTrace(llvm::StringRef description);
|
|
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
void SetExited();
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status RequestStop();
|
2015-05-11 10:03:10 +00:00
|
|
|
|
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
|
|
|
void SetStopped();
|
|
|
|
|
|
2021-04-12 15:40:32 +01:00
|
|
|
/// Extend m_stop_description with logical and allocation tag values.
|
|
|
|
|
/// If there is an error along the way just add the information we were able
|
|
|
|
|
/// to get.
|
2023-03-09 14:32:52 +00:00
|
|
|
void AnnotateSyncTagCheckFault(lldb::addr_t fault_addr);
|
2021-04-12 15:40:32 +01:00
|
|
|
|
2014-06-30 21:05:18 +00:00
|
|
|
// Member Variables
|
|
|
|
|
lldb::StateType m_state;
|
|
|
|
|
ThreadStopInfo m_stop_info;
|
Clean up NativeRegisterContext
Summary:
This commit removes the concrete_frame_idx member from
NativeRegisterContext and related functions, which was always set to
zero and never used.
I also change the native thread class to store a NativeRegisterContext
as a unique_ptr (documenting the ownership) and make sure it is always
initialized (most of the code was already blindly dereferencing the
register context pointer, assuming it would always be present -- this
makes its treatment consistent).
Reviewers: eugene, clayborg, krytarowski
Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits
Differential Revision: https://reviews.llvm.org/D39837
llvm-svn: 317881
2017-11-10 11:05:49 +00:00
|
|
|
std::unique_ptr<NativeRegisterContextLinux> m_reg_context_up;
|
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;
|
2017-02-24 13:27:31 +00:00
|
|
|
WatchpointIndexMap m_hw_break_index_map;
|
2017-02-16 18:12:04 +00:00
|
|
|
std::unique_ptr<SingleStepWorkaround> m_step_workaround;
|
2014-06-30 21:05:18 +00:00
|
|
|
};
|
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_
|