brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · c55771e Raw
57 lines · c
1//===-- SingleStepCheck.h ------------------------------------- -*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef liblldb_SingleStepCheck_H_10#define liblldb_SingleStepCheck_H_11 12#include <memory>13#include <sched.h>14#include <sys/types.h>15 16namespace lldb_private {17namespace process_linux {18 19// arm64 linux had a bug which prevented single-stepping and watchpoints from20// working on non-boot cpus, due to them being incorrectly initialized after21// coming out of suspend.  This issue is particularly affecting android M, which22// uses suspend ("doze mode") quite aggressively. This code detects that23// situation and makes single-stepping work by doing all the step operations on24// the boot cpu.25//26// The underlying issue has been fixed in android N and linux 4.4. This code can27// be removed once these systems become obsolete.28 29#if defined(__arm64__) || defined(__aarch64__)30class SingleStepWorkaround {31  ::pid_t m_tid;32  cpu_set_t m_original_set;33 34  SingleStepWorkaround(const SingleStepWorkaround &) = delete;35  void operator=(const SingleStepWorkaround &) = delete;36 37public:38  SingleStepWorkaround(::pid_t tid, cpu_set_t original_set)39      : m_tid(tid), m_original_set(original_set) {}40  ~SingleStepWorkaround();41 42  static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid);43};44#else45class SingleStepWorkaround {46public:47  static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid) {48    return nullptr;49  }50};51#endif52 53} // end namespace process_linux54} // end namespace lldb_private55 56#endif // #ifndef liblldb_SingleStepCheck_H_57