Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,191 @@
//===-- lldb_ARMDefines.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_ARMDefines_h_
#define lldb_ARMDefines_h_
#include <cassert>
#include <cstdint>
// Common definitions for the ARM/Thumb Instruction Set Architecture.
namespace lldb_private {
// ARM shifter types
typedef enum {
SRType_LSL,
SRType_LSR,
SRType_ASR,
SRType_ROR,
SRType_RRX,
SRType_Invalid
} ARM_ShifterType;
// ARM conditions // Meaning (integer) Meaning (floating-point)
// Condition flags
#define COND_EQ \
0x0 // Equal Equal Z == 1
#define COND_NE \
0x1 // Not equal Not equal, or unordered Z == 0
#define COND_CS \
0x2 // Carry set >, ==, or unordered C == 1
#define COND_HS 0x2
#define COND_CC \
0x3 // Carry clear Less than C == 0
#define COND_LO 0x3
#define COND_MI \
0x4 // Minus, negative Less than N == 1
#define COND_PL \
0x5 // Plus, positive or zero >, ==, or unordered N == 0
#define COND_VS \
0x6 // Overflow Unordered V == 1
#define COND_VC \
0x7 // No overflow Not unordered V == 0
#define COND_HI \
0x8 // Unsigned higher Greater than, or unordered C == 1 and Z ==
// 0
#define COND_LS \
0x9 // Unsigned lower or same Less than or equal C == 0 or Z ==
// 1
#define COND_GE \
0xA // Greater than or equal Greater than or equal N == V
#define COND_LT \
0xB // Less than Less than, or unordered N != V
#define COND_GT \
0xC // Greater than Greater than Z == 0 and N ==
// V
#define COND_LE \
0xD // Less than or equal <, ==, or unordered Z == 1 or N !=
// V
#define COND_AL \
0xE // Always (unconditional) Always (unconditional) Any
#define COND_UNCOND 0xF
static inline const char *ARMCondCodeToString(uint32_t CC) {
switch (CC) {
default:
assert(0 && "Unknown condition code");
case COND_EQ:
return "eq";
case COND_NE:
return "ne";
case COND_HS:
return "hs";
case COND_LO:
return "lo";
case COND_MI:
return "mi";
case COND_PL:
return "pl";
case COND_VS:
return "vs";
case COND_VC:
return "vc";
case COND_HI:
return "hi";
case COND_LS:
return "ls";
case COND_GE:
return "ge";
case COND_LT:
return "lt";
case COND_GT:
return "gt";
case COND_LE:
return "le";
case COND_AL:
return "al";
}
}
static inline bool ARMConditionPassed(const uint32_t condition,
const uint32_t cpsr) {
const uint32_t cpsr_n = (cpsr >> 31) & 1u; // Negative condition code flag
const uint32_t cpsr_z = (cpsr >> 30) & 1u; // Zero condition code flag
const uint32_t cpsr_c = (cpsr >> 29) & 1u; // Carry condition code flag
const uint32_t cpsr_v = (cpsr >> 28) & 1u; // Overflow condition code flag
switch (condition) {
case COND_EQ:
return (cpsr_z == 1);
case COND_NE:
return (cpsr_z == 0);
case COND_CS:
return (cpsr_c == 1);
case COND_CC:
return (cpsr_c == 0);
case COND_MI:
return (cpsr_n == 1);
case COND_PL:
return (cpsr_n == 0);
case COND_VS:
return (cpsr_v == 1);
case COND_VC:
return (cpsr_v == 0);
case COND_HI:
return ((cpsr_c == 1) && (cpsr_z == 0));
case COND_LS:
return ((cpsr_c == 0) || (cpsr_z == 1));
case COND_GE:
return (cpsr_n == cpsr_v);
case COND_LT:
return (cpsr_n != cpsr_v);
case COND_GT:
return ((cpsr_z == 0) && (cpsr_n == cpsr_v));
case COND_LE:
return ((cpsr_z == 1) || (cpsr_n != cpsr_v));
case COND_AL:
case COND_UNCOND:
default:
return true;
}
return false;
}
// Bit positions for CPSR
#define CPSR_T_POS 5
#define CPSR_F_POS 6
#define CPSR_I_POS 7
#define CPSR_A_POS 8
#define CPSR_E_POS 9
#define CPSR_J_POS 24
#define CPSR_Q_POS 27
#define CPSR_V_POS 28
#define CPSR_C_POS 29
#define CPSR_Z_POS 30
#define CPSR_N_POS 31
// CPSR mode definitions
#define CPSR_MODE_USR 0x10u
#define CPSR_MODE_FIQ 0x11u
#define CPSR_MODE_IRQ 0x12u
#define CPSR_MODE_SVC 0x13u
#define CPSR_MODE_ABT 0x17u
#define CPSR_MODE_UND 0x1bu
#define CPSR_MODE_SYS 0x1fu
// Masks for CPSR
#define MASK_CPSR_MODE_MASK (0x0000001fu)
#define MASK_CPSR_IT_MASK (0x0600fc00u)
#define MASK_CPSR_T (1u << CPSR_T_POS)
#define MASK_CPSR_F (1u << CPSR_F_POS)
#define MASK_CPSR_I (1u << CPSR_I_POS)
#define MASK_CPSR_A (1u << CPSR_A_POS)
#define MASK_CPSR_E (1u << CPSR_E_POS)
#define MASK_CPSR_GE_MASK (0x000f0000u)
#define MASK_CPSR_J (1u << CPSR_J_POS)
#define MASK_CPSR_Q (1u << CPSR_Q_POS)
#define MASK_CPSR_V (1u << CPSR_V_POS)
#define MASK_CPSR_C (1u << CPSR_C_POS)
#define MASK_CPSR_Z (1u << CPSR_Z_POS)
#define MASK_CPSR_N (1u << CPSR_N_POS)
} // namespace lldb_private
#endif // lldb_ARMDefines_h_

View File

@ -0,0 +1,375 @@
//===-- ARMUtils.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_ARMUtils_h_
#define lldb_ARMUtils_h_
#include "ARMDefines.h"
#include "InstructionUtils.h"
#include "llvm/Support/MathExtras.h" // for SignExtend64 template function
// Common utilities for the ARM/Thumb Instruction Set Architecture.
namespace lldb_private {
static inline uint32_t Align(uint32_t val, uint32_t alignment) {
return alignment * (val / alignment);
}
static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5,
ARM_ShifterType &shift_t) {
switch (type) {
default:
// assert(0 && "Invalid shift type");
case 0:
shift_t = SRType_LSL;
return imm5;
case 1:
shift_t = SRType_LSR;
return (imm5 == 0 ? 32 : imm5);
case 2:
shift_t = SRType_ASR;
return (imm5 == 0 ? 32 : imm5);
case 3:
if (imm5 == 0) {
shift_t = SRType_RRX;
return 1;
} else {
shift_t = SRType_ROR;
return imm5;
}
}
shift_t = SRType_Invalid;
return UINT32_MAX;
}
// A8.6.35 CMP (register) -- Encoding T3
// Convenience function.
static inline uint32_t DecodeImmShiftThumb(const uint32_t opcode,
ARM_ShifterType &shift_t) {
return DecodeImmShift(Bits32(opcode, 5, 4),
Bits32(opcode, 14, 12) << 2 | Bits32(opcode, 7, 6),
shift_t);
}
// A8.6.35 CMP (register) -- Encoding A1
// Convenience function.
static inline uint32_t DecodeImmShiftARM(const uint32_t opcode,
ARM_ShifterType &shift_t) {
return DecodeImmShift(Bits32(opcode, 6, 5), Bits32(opcode, 11, 7), shift_t);
}
static inline uint32_t DecodeImmShift(const ARM_ShifterType shift_t,
const uint32_t imm5) {
ARM_ShifterType dont_care;
return DecodeImmShift(shift_t, imm5, dont_care);
}
static inline ARM_ShifterType DecodeRegShift(const uint32_t type) {
switch (type) {
default:
// assert(0 && "Invalid shift type");
return SRType_Invalid;
case 0:
return SRType_LSL;
case 1:
return SRType_LSR;
case 2:
return SRType_ASR;
case 3:
return SRType_ROR;
}
}
static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount,
uint32_t &carry_out, bool *success) {
if (amount == 0) {
*success = false;
return 0;
}
*success = true;
carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0;
return value << amount;
}
static inline uint32_t LSL(const uint32_t value, const uint32_t amount,
bool *success) {
*success = true;
if (amount == 0)
return value;
uint32_t dont_care;
uint32_t result = LSL_C(value, amount, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount,
uint32_t &carry_out, bool *success) {
if (amount == 0) {
*success = false;
return 0;
}
*success = true;
carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0;
return value >> amount;
}
static inline uint32_t LSR(const uint32_t value, const uint32_t amount,
bool *success) {
*success = true;
if (amount == 0)
return value;
uint32_t dont_care;
uint32_t result = LSR_C(value, amount, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount,
uint32_t &carry_out, bool *success) {
if (amount == 0 || amount > 32) {
*success = false;
return 0;
}
*success = true;
bool negative = BitIsSet(value, 31);
if (amount <= 32) {
carry_out = Bit32(value, amount - 1);
int64_t extended = llvm::SignExtend64<32>(value);
return UnsignedBits(extended, amount + 31, amount);
} else {
carry_out = (negative ? 1 : 0);
return (negative ? 0xffffffff : 0);
}
}
static inline uint32_t ASR(const uint32_t value, const uint32_t amount,
bool *success) {
*success = true;
if (amount == 0)
return value;
uint32_t dont_care;
uint32_t result = ASR_C(value, amount, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount,
uint32_t &carry_out, bool *success) {
if (amount == 0) {
*success = false;
return 0;
}
*success = true;
uint32_t amt = amount % 32;
uint32_t result = Rotr32(value, amt);
carry_out = Bit32(value, 31);
return result;
}
static inline uint32_t ROR(const uint32_t value, const uint32_t amount,
bool *success) {
*success = true;
if (amount == 0)
return value;
uint32_t dont_care;
uint32_t result = ROR_C(value, amount, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in,
uint32_t &carry_out, bool *success) {
*success = true;
carry_out = Bit32(value, 0);
return Bit32(carry_in, 0) << 31 | Bits32(value, 31, 1);
}
static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in,
bool *success) {
*success = true;
uint32_t dont_care;
uint32_t result = RRX_C(value, carry_in, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type,
const uint32_t amount, const uint32_t carry_in,
uint32_t &carry_out, bool *success) {
if (type == SRType_RRX && amount != 1) {
*success = false;
return 0;
}
*success = true;
if (amount == 0) {
carry_out = carry_in;
return value;
}
uint32_t result;
switch (type) {
case SRType_LSL:
result = LSL_C(value, amount, carry_out, success);
break;
case SRType_LSR:
result = LSR_C(value, amount, carry_out, success);
break;
case SRType_ASR:
result = ASR_C(value, amount, carry_out, success);
break;
case SRType_ROR:
result = ROR_C(value, amount, carry_out, success);
break;
case SRType_RRX:
result = RRX_C(value, carry_in, carry_out, success);
break;
default:
*success = false;
break;
}
if (*success)
return result;
else
return 0;
}
static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type,
const uint32_t amount, const uint32_t carry_in,
bool *success) {
// Don't care about carry out in this case.
uint32_t dont_care;
uint32_t result = Shift_C(value, type, amount, carry_in, dont_care, success);
if (*success)
return result;
else
return 0;
}
static inline uint32_t bits(const uint32_t val, const uint32_t msbit,
const uint32_t lsbit) {
return Bits32(val, msbit, lsbit);
}
static inline uint32_t bit(const uint32_t val, const uint32_t msbit) {
return bits(val, msbit, msbit);
}
static uint32_t ror(uint32_t val, uint32_t N, uint32_t shift) {
uint32_t m = shift % N;
return (val >> m) | (val << (N - m));
}
// (imm32, carry_out) = ARMExpandImm_C(imm12, carry_in)
static inline uint32_t ARMExpandImm_C(uint32_t opcode, uint32_t carry_in,
uint32_t &carry_out) {
uint32_t imm32; // the expanded result
uint32_t imm = bits(opcode, 7, 0); // immediate value
uint32_t amt = 2 * bits(opcode, 11, 8); // rotate amount
if (amt == 0) {
imm32 = imm;
carry_out = carry_in;
} else {
imm32 = ror(imm, 32, amt);
carry_out = Bit32(imm32, 31);
}
return imm32;
}
static inline uint32_t ARMExpandImm(uint32_t opcode) {
// 'carry_in' argument to following function call does not affect the imm32
// result.
uint32_t carry_in = 0;
uint32_t carry_out;
return ARMExpandImm_C(opcode, carry_in, carry_out);
}
// (imm32, carry_out) = ThumbExpandImm_C(imm12, carry_in)
static inline uint32_t ThumbExpandImm_C(uint32_t opcode, uint32_t carry_in,
uint32_t &carry_out) {
uint32_t imm32; // the expanded result
const uint32_t i = bit(opcode, 26);
const uint32_t imm3 = bits(opcode, 14, 12);
const uint32_t abcdefgh = bits(opcode, 7, 0);
const uint32_t imm12 = i << 11 | imm3 << 8 | abcdefgh;
if (bits(imm12, 11, 10) == 0) {
switch (bits(imm12, 9, 8)) {
default: // Keep static analyzer happy with a default case
case 0:
imm32 = abcdefgh;
break;
case 1:
imm32 = abcdefgh << 16 | abcdefgh;
break;
case 2:
imm32 = abcdefgh << 24 | abcdefgh << 8;
break;
case 3:
imm32 = abcdefgh << 24 | abcdefgh << 16 | abcdefgh << 8 | abcdefgh;
break;
}
carry_out = carry_in;
} else {
const uint32_t unrotated_value = 0x80 | bits(imm12, 6, 0);
imm32 = ror(unrotated_value, 32, bits(imm12, 11, 7));
carry_out = Bit32(imm32, 31);
}
return imm32;
}
static inline uint32_t ThumbExpandImm(uint32_t opcode) {
// 'carry_in' argument to following function call does not affect the imm32
// result.
uint32_t carry_in = 0;
uint32_t carry_out;
return ThumbExpandImm_C(opcode, carry_in, carry_out);
}
// imm32 = ZeroExtend(i:imm3:imm8, 32)
static inline uint32_t ThumbImm12(uint32_t opcode) {
const uint32_t i = bit(opcode, 26);
const uint32_t imm3 = bits(opcode, 14, 12);
const uint32_t imm8 = bits(opcode, 7, 0);
const uint32_t imm12 = i << 11 | imm3 << 8 | imm8;
return imm12;
}
// imm32 = ZeroExtend(imm7:'00', 32)
static inline uint32_t ThumbImm7Scaled(uint32_t opcode) {
const uint32_t imm7 = bits(opcode, 6, 0);
return imm7 * 4;
}
// imm32 = ZeroExtend(imm8:'00', 32)
static inline uint32_t ThumbImm8Scaled(uint32_t opcode) {
const uint32_t imm8 = bits(opcode, 7, 0);
return imm8 * 4;
}
// This function performs the check for the register numbers 13 and 15 that are
// not permitted for many Thumb register specifiers.
static inline bool BadReg(uint32_t n) { return n == 13 || n == 15; }
} // namespace lldb_private
#endif // lldb_ARMUtils_h_

View File

@ -0,0 +1,66 @@
include_directories(../../../Utility/)
add_lldb_library(lldbPluginProcessUtility PLUGIN
DynamicRegisterInfo.cpp
FreeBSDSignals.cpp
GDBRemoteSignals.cpp
HistoryThread.cpp
HistoryUnwind.cpp
InferiorCallPOSIX.cpp
LinuxSignals.cpp
MipsLinuxSignals.cpp
NativeRegisterContextRegisterInfo.cpp
NetBSDSignals.cpp
RegisterContextDarwin_arm.cpp
RegisterContextDarwin_arm64.cpp
RegisterContextDarwin_i386.cpp
RegisterContextDarwin_x86_64.cpp
RegisterContextDummy.cpp
RegisterContextFreeBSD_i386.cpp
RegisterContextFreeBSD_mips64.cpp
RegisterContextFreeBSD_powerpc.cpp
RegisterContextFreeBSD_x86_64.cpp
RegisterContextHistory.cpp
RegisterContextLinux_i386.cpp
RegisterContextLinux_x86_64.cpp
RegisterContextLinux_mips64.cpp
RegisterContextLinux_mips.cpp
RegisterContextLinux_s390x.cpp
RegisterContextLLDB.cpp
RegisterContextMacOSXFrameBackchain.cpp
RegisterContextMach_arm.cpp
RegisterContextMach_i386.cpp
RegisterContextMach_x86_64.cpp
RegisterContextMemory.cpp
RegisterContextNetBSD_x86_64.cpp
RegisterContextOpenBSD_i386.cpp
RegisterContextOpenBSD_x86_64.cpp
RegisterContextPOSIX_arm.cpp
RegisterContextPOSIX_arm64.cpp
RegisterContextPOSIX_mips64.cpp
RegisterContextPOSIX_powerpc.cpp
RegisterContextPOSIX_ppc64le.cpp
RegisterContextPOSIX_s390x.cpp
RegisterContextPOSIX_x86.cpp
RegisterContextThreadMemory.cpp
RegisterInfoPOSIX_arm.cpp
RegisterInfoPOSIX_arm64.cpp
RegisterInfoPOSIX_ppc64le.cpp
StopInfoMachException.cpp
ThreadMemory.cpp
UnwindLLDB.cpp
UnwindMacOSXFrameBackchain.cpp
LINK_LIBS
lldbBreakpoint
lldbCore
lldbDataFormatters
lldbExpression
lldbHost
lldbSymbol
lldbTarget
lldbUtility
lldbPluginProcessElfCore
LINK_COMPONENTS
Support
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
//===-- DynamicRegisterInfo.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_DynamicRegisterInfo_h_
#define lldb_DynamicRegisterInfo_h_
// C Includes
// C++ Includes
#include <map>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/lldb-private.h"
class DynamicRegisterInfo {
public:
DynamicRegisterInfo();
DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
const lldb_private::ArchSpec &arch);
virtual ~DynamicRegisterInfo();
size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
const lldb_private::ArchSpec &arch);
void AddRegister(lldb_private::RegisterInfo &reg_info,
lldb_private::ConstString &reg_name,
lldb_private::ConstString &reg_alt_name,
lldb_private::ConstString &set_name);
void Finalize(const lldb_private::ArchSpec &arch);
size_t GetNumRegisters() const;
size_t GetNumRegisterSets() const;
size_t GetRegisterDataByteSize() const;
const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i) const;
lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i);
const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const;
uint32_t GetRegisterSetIndexByName(lldb_private::ConstString &set_name,
bool can_create);
uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
uint32_t num) const;
void Dump() const;
void Clear();
protected:
//------------------------------------------------------------------
// Classes that inherit from DynamicRegisterInfo can see and modify these
//------------------------------------------------------------------
typedef std::vector<lldb_private::RegisterInfo> reg_collection;
typedef std::vector<lldb_private::RegisterSet> set_collection;
typedef std::vector<uint32_t> reg_num_collection;
typedef std::vector<reg_num_collection> set_reg_num_collection;
typedef std::vector<lldb_private::ConstString> name_collection;
typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
typedef std::vector<uint8_t> dwarf_opcode;
typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map;
lldb_private::RegisterInfo *
GetRegisterInfo(const lldb_private::ConstString &reg_name);
reg_collection m_regs;
set_collection m_sets;
set_reg_num_collection m_set_reg_nums;
name_collection m_set_names;
reg_to_regs_map m_value_regs_map;
reg_to_regs_map m_invalidate_regs_map;
dynamic_reg_size_map m_dynamic_reg_size_map;
size_t m_reg_data_byte_size; // The number of bytes required to store all
// registers
bool m_finalized;
};
#endif // lldb_DynamicRegisterInfo_h_

View File

@ -0,0 +1,91 @@
//===-- FreeBSDSignals.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "FreeBSDSignals.h"
using namespace lldb_private;
FreeBSDSignals::FreeBSDSignals() : UnixSignals() { Reset(); }
void FreeBSDSignals::Reset() {
UnixSignals::Reset();
// SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
// ====== ============ ======== ====== ======
// ===================================================
AddSignal(32, "SIGTHR", false, false, false, "thread interrupt");
AddSignal(33, "SIGLIBRT", false, false, false,
"reserved by real-time library");
AddSignal(65, "SIGRTMIN", false, false, false, "real time signal 0");
AddSignal(66, "SIGRTMIN+1", false, false, false, "real time signal 1");
AddSignal(67, "SIGRTMIN+2", false, false, false, "real time signal 2");
AddSignal(68, "SIGRTMIN+3", false, false, false, "real time signal 3");
AddSignal(69, "SIGRTMIN+4", false, false, false, "real time signal 4");
AddSignal(70, "SIGRTMIN+5", false, false, false, "real time signal 5");
AddSignal(71, "SIGRTMIN+6", false, false, false, "real time signal 6");
AddSignal(72, "SIGRTMIN+7", false, false, false, "real time signal 7");
AddSignal(73, "SIGRTMIN+8", false, false, false, "real time signal 8");
AddSignal(74, "SIGRTMIN+9", false, false, false, "real time signal 9");
AddSignal(75, "SIGRTMIN+10", false, false, false, "real time signal 10");
AddSignal(76, "SIGRTMIN+11", false, false, false, "real time signal 11");
AddSignal(77, "SIGRTMIN+12", false, false, false, "real time signal 12");
AddSignal(78, "SIGRTMIN+13", false, false, false, "real time signal 13");
AddSignal(79, "SIGRTMIN+14", false, false, false, "real time signal 14");
AddSignal(80, "SIGRTMIN+15", false, false, false, "real time signal 15");
AddSignal(81, "SIGRTMIN+16", false, false, false, "real time signal 16");
AddSignal(82, "SIGRTMIN+17", false, false, false, "real time signal 17");
AddSignal(83, "SIGRTMIN+18", false, false, false, "real time signal 18");
AddSignal(84, "SIGRTMIN+19", false, false, false, "real time signal 19");
AddSignal(85, "SIGRTMIN+20", false, false, false, "real time signal 20");
AddSignal(86, "SIGRTMIN+21", false, false, false, "real time signal 21");
AddSignal(87, "SIGRTMIN+22", false, false, false, "real time signal 22");
AddSignal(88, "SIGRTMIN+23", false, false, false, "real time signal 23");
AddSignal(89, "SIGRTMIN+24", false, false, false, "real time signal 24");
AddSignal(90, "SIGRTMIN+25", false, false, false, "real time signal 25");
AddSignal(91, "SIGRTMIN+26", false, false, false, "real time signal 26");
AddSignal(92, "SIGRTMIN+27", false, false, false, "real time signal 27");
AddSignal(93, "SIGRTMIN+28", false, false, false, "real time signal 28");
AddSignal(94, "SIGRTMIN+29", false, false, false, "real time signal 29");
AddSignal(95, "SIGRTMIN+30", false, false, false, "real time signal 30");
AddSignal(96, "SIGRTMAX-30", false, false, false, "real time signal 31");
AddSignal(97, "SIGRTMAX-29", false, false, false, "real time signal 32");
AddSignal(98, "SIGRTMAX-28", false, false, false, "real time signal 33");
AddSignal(99, "SIGRTMAX-27", false, false, false, "real time signal 34");
AddSignal(100, "SIGRTMAX-26", false, false, false, "real time signal 35");
AddSignal(101, "SIGRTMAX-25", false, false, false, "real time signal 36");
AddSignal(102, "SIGRTMAX-24", false, false, false, "real time signal 37");
AddSignal(103, "SIGRTMAX-23", false, false, false, "real time signal 38");
AddSignal(104, "SIGRTMAX-22", false, false, false, "real time signal 39");
AddSignal(105, "SIGRTMAX-21", false, false, false, "real time signal 40");
AddSignal(106, "SIGRTMAX-20", false, false, false, "real time signal 41");
AddSignal(107, "SIGRTMAX-19", false, false, false, "real time signal 42");
AddSignal(108, "SIGRTMAX-18", false, false, false, "real time signal 43");
AddSignal(109, "SIGRTMAX-17", false, false, false, "real time signal 44");
AddSignal(110, "SIGRTMAX-16", false, false, false, "real time signal 45");
AddSignal(111, "SIGRTMAX-15", false, false, false, "real time signal 46");
AddSignal(112, "SIGRTMAX-14", false, false, false, "real time signal 47");
AddSignal(113, "SIGRTMAX-13", false, false, false, "real time signal 48");
AddSignal(114, "SIGRTMAX-12", false, false, false, "real time signal 49");
AddSignal(115, "SIGRTMAX-11", false, false, false, "real time signal 50");
AddSignal(116, "SIGRTMAX-10", false, false, false, "real time signal 51");
AddSignal(117, "SIGRTMAX-9", false, false, false, "real time signal 52");
AddSignal(118, "SIGRTMAX-8", false, false, false, "real time signal 53");
AddSignal(119, "SIGRTMAX-7", false, false, false, "real time signal 54");
AddSignal(120, "SIGRTMAX-6", false, false, false, "real time signal 55");
AddSignal(121, "SIGRTMAX-5", false, false, false, "real time signal 56");
AddSignal(122, "SIGRTMAX-4", false, false, false, "real time signal 57");
AddSignal(123, "SIGRTMAX-3", false, false, false, "real time signal 58");
AddSignal(124, "SIGRTMAX-2", false, false, false, "real time signal 59");
AddSignal(125, "SIGRTMAX-1", false, false, false, "real time signal 60");
AddSignal(126, "SIGRTMAX", false, false, false, "real time signal 61");
}

View File

@ -0,0 +1,29 @@
//===-- FreeBSDSignals.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_FreeBSDSignals_H_
#define liblldb_FreeBSDSignals_H_
// Project includes
#include "lldb/Target/UnixSignals.h"
namespace lldb_private {
/// FreeBSD specific set of Unix signals.
class FreeBSDSignals : public UnixSignals {
public:
FreeBSDSignals();
private:
void Reset() override;
};
} // namespace lldb_private
#endif // liblldb_FreeBSDSignals_H_

View File

@ -0,0 +1,22 @@
//===-- GDBRemoteSignals.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "GDBRemoteSignals.h"
using namespace lldb_private;
GDBRemoteSignals::GDBRemoteSignals() : UnixSignals() { Reset(); }
GDBRemoteSignals::GDBRemoteSignals(const lldb::UnixSignalsSP &rhs)
: UnixSignals(*rhs) {}
void GDBRemoteSignals::Reset() { m_signals.clear(); }

View File

@ -0,0 +1,34 @@
//===-- GDBRemoteSignals.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_GDBRemoteSignals_H_
#define liblldb_GDBRemoteSignals_H_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Target/UnixSignals.h"
namespace lldb_private {
/// Empty set of Unix signals to be filled by PlatformRemoteGDBServer
class GDBRemoteSignals : public UnixSignals {
public:
GDBRemoteSignals();
GDBRemoteSignals(const lldb::UnixSignalsSP &rhs);
private:
void Reset() override;
};
} // namespace lldb_private
#endif // liblldb_GDBRemoteSignals_H_

View File

@ -0,0 +1,83 @@
//===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-private.h"
#include "Plugins/Process/Utility/HistoryThread.h"
#include "Plugins/Process/Utility/HistoryUnwind.h"
#include "Plugins/Process/Utility/RegisterContextHistory.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrameList.h"
#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
// Constructor
HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
std::vector<lldb::addr_t> pcs, uint32_t stop_id,
bool stop_id_is_valid)
: Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
m_pcs(pcs), m_stop_id(stop_id), m_stop_id_is_valid(stop_id_is_valid),
m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
m_thread_name(), m_originating_unique_thread_id(tid),
m_queue_id(LLDB_INVALID_QUEUE_ID) {
m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid));
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this));
}
// Destructor
HistoryThread::~HistoryThread() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")",
static_cast<void *>(this), GetID());
DestroyThread();
}
lldb::RegisterContextSP HistoryThread::GetRegisterContext() {
RegisterContextSP rctx;
if (m_pcs.size() > 0) {
rctx.reset(new RegisterContextHistory(
*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
}
return rctx;
}
lldb::RegisterContextSP
HistoryThread::CreateRegisterContextForFrame(StackFrame *frame) {
return m_unwinder_ap->CreateRegisterContextForFrame(frame);
}
lldb::StackFrameListSP HistoryThread::GetStackFrameList() {
// FIXME do not throw away the lock after we acquire it..
std::unique_lock<std::mutex> lock(m_framelist_mutex);
lock.unlock();
if (m_framelist.get() == NULL) {
m_framelist.reset(new StackFrameList(*this, StackFrameListSP(), true));
}
return m_framelist;
}
uint32_t HistoryThread::GetExtendedBacktraceOriginatingIndexID() {
if (m_originating_unique_thread_id != LLDB_INVALID_THREAD_ID) {
if (GetProcess()->HasAssignedIndexIDToThread(
m_originating_unique_thread_id)) {
return GetProcess()->AssignIndexIDToThread(
m_originating_unique_thread_id);
}
}
return LLDB_INVALID_THREAD_ID;
}

View File

@ -0,0 +1,102 @@
//===-- HistoryThread.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_HistoryThread_h_
#define liblldb_HistoryThread_h_
// C Includes
// C++ Includes
#include <mutex>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackFrameList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class HistoryThread HistoryThread.h "HistoryThread.h"
/// @brief A thread object representing a backtrace from a previous point in the
/// process execution
///
/// This subclass of Thread is used to provide a backtrace from earlier in
/// process execution. It is given a backtrace list of pc addresses and
/// optionally a stop_id of when those pc addresses were collected, and it will
/// create stack frames for them.
//----------------------------------------------------------------------
class HistoryThread : public lldb_private::Thread {
public:
HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
std::vector<lldb::addr_t> pcs, uint32_t stop_id,
bool stop_id_is_valid);
~HistoryThread() override;
lldb::RegisterContextSP GetRegisterContext() override;
lldb::RegisterContextSP
CreateRegisterContextForFrame(StackFrame *frame) override;
void RefreshStateAfterStop() override {}
bool CalculateStopInfo() override { return false; }
void SetExtendedBacktraceToken(uint64_t token) override {
m_extended_unwind_token = token;
}
uint64_t GetExtendedBacktraceToken() override {
return m_extended_unwind_token;
}
const char *GetQueueName() override { return m_queue_name.c_str(); }
void SetQueueName(const char *name) override { m_queue_name = name; }
lldb::queue_id_t GetQueueID() override { return m_queue_id; }
void SetQueueID(lldb::queue_id_t queue) override { m_queue_id = queue; }
const char *GetThreadName() { return m_thread_name.c_str(); }
uint32_t GetExtendedBacktraceOriginatingIndexID() override;
void SetThreadName(const char *name) { m_thread_name = name; }
const char *GetName() override { return m_thread_name.c_str(); }
void SetName(const char *name) override { m_thread_name = name; }
protected:
virtual lldb::StackFrameListSP GetStackFrameList();
mutable std::mutex m_framelist_mutex;
lldb::StackFrameListSP m_framelist;
std::vector<lldb::addr_t> m_pcs;
uint32_t m_stop_id;
bool m_stop_id_is_valid;
uint64_t m_extended_unwind_token;
std::string m_queue_name;
std::string m_thread_name;
lldb::tid_t m_originating_unique_thread_id;
lldb::queue_id_t m_queue_id;
};
} // namespace lldb_private
#endif // liblldb_HistoryThread_h_

View File

@ -0,0 +1,67 @@
//===-- HistoryUnwind.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-private.h"
#include "Plugins/Process/Utility/HistoryUnwind.h"
#include "Plugins/Process/Utility/RegisterContextHistory.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
using namespace lldb;
using namespace lldb_private;
// Constructor
HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
bool stop_id_is_valid)
: Unwind(thread), m_pcs(pcs), m_stop_id_is_valid(stop_id_is_valid) {}
// Destructor
HistoryUnwind::~HistoryUnwind() {}
void HistoryUnwind::DoClear() {
std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
m_pcs.clear();
m_stop_id_is_valid = false;
}
lldb::RegisterContextSP
HistoryUnwind::DoCreateRegisterContextForFrame(StackFrame *frame) {
RegisterContextSP rctx;
if (frame) {
addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress(
&frame->GetThread()->GetProcess()->GetTarget());
if (pc != LLDB_INVALID_ADDRESS) {
rctx.reset(new RegisterContextHistory(
*frame->GetThread().get(), frame->GetConcreteFrameIndex(),
frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
}
}
return rctx;
}
bool HistoryUnwind::DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
lldb::addr_t &pc) {
// FIXME do not throw away the lock after we acquire it..
std::unique_lock<std::recursive_mutex> guard(m_unwind_mutex);
guard.unlock();
if (frame_idx < m_pcs.size()) {
cfa = frame_idx;
pc = m_pcs[frame_idx];
return true;
}
return false;
}
uint32_t HistoryUnwind::DoGetFrameCount() { return m_pcs.size(); }

View File

@ -0,0 +1,48 @@
//===-- HistoryUnwind.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_HistoryUnwind_h_
#define liblldb_HistoryUnwind_h_
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Target/Unwind.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
class HistoryUnwind : public lldb_private::Unwind {
public:
HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
bool stop_id_is_valid);
~HistoryUnwind() override;
protected:
void DoClear() override;
lldb::RegisterContextSP
DoCreateRegisterContextForFrame(StackFrame *frame) override;
bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
lldb::addr_t &pc) override;
uint32_t DoGetFrameCount() override;
private:
std::vector<lldb::addr_t> m_pcs;
bool m_stop_id_is_valid;
};
} // namespace lldb_private
#endif // liblldb_HistoryUnwind_h_

View File

@ -0,0 +1,238 @@
//===-- InferiorCallPOSIX.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "InferiorCallPOSIX.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Host/Config.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#ifndef LLDB_DISABLE_POSIX
#include <sys/mman.h>
#else
// define them
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#endif
using namespace lldb;
using namespace lldb_private;
bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
addr_t addr, addr_t length, unsigned prot,
unsigned flags, addr_t fd, addr_t offset) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
if (thread == NULL)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count = process->GetTarget().GetImages().FindFunctions(
ConstString("mmap"), eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
if (count > 0) {
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc)) {
const uint32_t range_scope =
eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
EvaluateExpressionOptions options;
options.SetStopOthers(true);
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
options.SetTimeout(std::chrono::milliseconds(500));
options.SetTrapExceptions(false);
addr_t prot_arg;
if (prot == eMmapProtNone)
prot_arg = PROT_NONE;
else {
prot_arg = 0;
if (prot & eMmapProtExec)
prot_arg |= PROT_EXEC;
if (prot & eMmapProtRead)
prot_arg |= PROT_READ;
if (prot & eMmapProtWrite)
prot_arg |= PROT_WRITE;
}
AddressRange mmap_range;
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range,
mmap_range)) {
ClangASTContext *clang_ast_context =
process->GetTarget().GetScratchClangASTContext();
CompilerType clang_void_ptr_type =
clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
const ArchSpec arch = process->GetTarget().GetArchitecture();
MmapArgList args =
process->GetTarget().GetPlatform()->GetMmapArgumentList(
arch, addr, length, prot_arg, flags, fd, offset);
lldb::ThreadPlanSP call_plan_sp(
new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(),
clang_void_ptr_type, args, options));
if (call_plan_sp) {
DiagnosticManager diagnostics;
StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
if (frame) {
ExecutionContext exe_ctx;
frame->CalculateExecutionContext(exe_ctx);
ExpressionResults result = process->RunThreadPlan(
exe_ctx, call_plan_sp, options, diagnostics);
if (result == eExpressionCompleted) {
allocated_addr =
call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
LLDB_INVALID_ADDRESS);
if (process->GetAddressByteSize() == 4) {
if (allocated_addr == UINT32_MAX)
return false;
} else if (process->GetAddressByteSize() == 8) {
if (allocated_addr == UINT64_MAX)
return false;
}
return true;
}
}
}
}
}
}
return false;
}
bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
addr_t length) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
if (thread == NULL)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count = process->GetTarget().GetImages().FindFunctions(
ConstString("munmap"), eFunctionNameTypeFull, include_symbols,
include_inlines, append, sc_list);
if (count > 0) {
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc)) {
const uint32_t range_scope =
eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
EvaluateExpressionOptions options;
options.SetStopOthers(true);
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
options.SetTimeout(std::chrono::milliseconds(500));
options.SetTrapExceptions(false);
AddressRange munmap_range;
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range,
munmap_range)) {
lldb::addr_t args[] = {addr, length};
lldb::ThreadPlanSP call_plan_sp(
new ThreadPlanCallFunction(*thread, munmap_range.GetBaseAddress(),
CompilerType(), args, options));
if (call_plan_sp) {
DiagnosticManager diagnostics;
StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
if (frame) {
ExecutionContext exe_ctx;
frame->CalculateExecutionContext(exe_ctx);
ExpressionResults result = process->RunThreadPlan(
exe_ctx, call_plan_sp, options, diagnostics);
if (result == eExpressionCompleted) {
return true;
}
}
}
}
}
}
return false;
}
// FIXME: This has nothing to do with Posix, it is just a convenience function
// that calls a
// function of the form "void * (*)(void)". We should find a better place to
// put this.
bool lldb_private::InferiorCall(Process *process, const Address *address,
addr_t &returned_func, bool trap_exceptions) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
if (thread == NULL || address == NULL)
return false;
EvaluateExpressionOptions options;
options.SetStopOthers(true);
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
options.SetTimeout(std::chrono::milliseconds(500));
options.SetTrapExceptions(trap_exceptions);
ClangASTContext *clang_ast_context =
process->GetTarget().GetScratchClangASTContext();
CompilerType clang_void_ptr_type =
clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
lldb::ThreadPlanSP call_plan_sp(
new ThreadPlanCallFunction(*thread, *address, clang_void_ptr_type,
llvm::ArrayRef<addr_t>(), options));
if (call_plan_sp) {
DiagnosticManager diagnostics;
StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
if (frame) {
ExecutionContext exe_ctx;
frame->CalculateExecutionContext(exe_ctx);
ExpressionResults result =
process->RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
if (result == eExpressionCompleted) {
returned_func =
call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
LLDB_INVALID_ADDRESS);
if (process->GetAddressByteSize() == 4) {
if (returned_func == UINT32_MAX)
return false;
} else if (process->GetAddressByteSize() == 8) {
if (returned_func == UINT64_MAX)
return false;
}
return true;
}
}
}
return false;
}

View File

@ -0,0 +1,39 @@
//===-- InferiorCallPOSIX.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_InferiorCallPOSIX_h_
#define lldb_InferiorCallPOSIX_h_
// Inferior execution of POSIX functions.
#include "lldb/lldb-types.h"
namespace lldb_private {
class Process;
enum MmapProt {
eMmapProtNone = 0,
eMmapProtExec = 1,
eMmapProtRead = 2,
eMmapProtWrite = 4
};
bool InferiorCallMmap(Process *proc, lldb::addr_t &allocated_addr,
lldb::addr_t addr, lldb::addr_t length, unsigned prot,
unsigned flags, lldb::addr_t fd, lldb::addr_t offset);
bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length);
bool InferiorCall(Process *proc, const Address *address,
lldb::addr_t &returned_func, bool trap_exceptions = false);
} // namespace lldb_private
#endif // lldb_InferiorCallPOSIX_h_

View File

@ -0,0 +1,114 @@
//===-- InstructionUtils.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_InstructionUtils_h_
#define lldb_InstructionUtils_h_
// Common utilities for manipulating instruction bit fields.
namespace lldb_private {
// Return the bit field(s) from the most significant bit (msbit) to the
// least significant bit (lsbit) of a 64-bit unsigned value.
static inline uint64_t Bits64(const uint64_t bits, const uint32_t msbit,
const uint32_t lsbit) {
assert(msbit < 64 && lsbit <= msbit);
return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1);
}
// Return the bit field(s) from the most significant bit (msbit) to the
// least significant bit (lsbit) of a 32-bit unsigned value.
static inline uint32_t Bits32(const uint32_t bits, const uint32_t msbit,
const uint32_t lsbit) {
assert(msbit < 32 && lsbit <= msbit);
return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1);
}
// Return the bit value from the 'bit' position of a 32-bit unsigned value.
static inline uint32_t Bit32(const uint32_t bits, const uint32_t bit) {
return (bits >> bit) & 1u;
}
static inline uint64_t Bit64(const uint64_t bits, const uint32_t bit) {
return (bits >> bit) & 1ull;
}
// Set the bit field(s) from the most significant bit (msbit) to the
// least significant bit (lsbit) of a 32-bit unsigned value to 'val'.
static inline void SetBits32(uint32_t &bits, const uint32_t msbit,
const uint32_t lsbit, const uint32_t val) {
assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
bits &= ~(mask << lsbit);
bits |= (val & mask) << lsbit;
}
// Set the 'bit' position of a 32-bit unsigned value to 'val'.
static inline void SetBit32(uint32_t &bits, const uint32_t bit,
const uint32_t val) {
SetBits32(bits, bit, bit, val);
}
// Rotate a 32-bit unsigned value right by the specified amount.
static inline uint32_t Rotr32(uint32_t bits, uint32_t amt) {
assert(amt < 32 && "Invalid rotate amount");
return (bits >> amt) | (bits << ((32 - amt) & 31));
}
// Rotate a 32-bit unsigned value left by the specified amount.
static inline uint32_t Rotl32(uint32_t bits, uint32_t amt) {
assert(amt < 32 && "Invalid rotate amount");
return (bits << amt) | (bits >> ((32 - amt) & 31));
}
// Create a mask that starts at bit zero and includes "bit"
static inline uint64_t MaskUpToBit(const uint64_t bit) {
if (bit >= 63)
return -1ll;
return (1ull << (bit + 1ull)) - 1ull;
}
// Return an integer result equal to the number of bits of x that are ones.
static inline uint32_t BitCount(uint64_t x) {
// c accumulates the total bits set in x
uint32_t c;
for (c = 0; x; ++c) {
x &= x - 1; // clear the least significant bit set
}
return c;
}
static inline bool BitIsSet(const uint64_t value, const uint64_t bit) {
return (value & (1ull << bit)) != 0;
}
static inline bool BitIsClear(const uint64_t value, const uint64_t bit) {
return (value & (1ull << bit)) == 0;
}
static inline uint64_t UnsignedBits(const uint64_t value, const uint64_t msbit,
const uint64_t lsbit) {
uint64_t result = value >> lsbit;
result &= MaskUpToBit(msbit - lsbit);
return result;
}
static inline int64_t SignedBits(const uint64_t value, const uint64_t msbit,
const uint64_t lsbit) {
uint64_t result = UnsignedBits(value, msbit, lsbit);
if (BitIsSet(value, msbit)) {
// Sign extend
result |= ~MaskUpToBit(msbit - lsbit);
}
return result;
}
} // namespace lldb_private
#endif // lldb_InstructionUtils_h_

View File

@ -0,0 +1,96 @@
//===-- LinuxSignals.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "LinuxSignals.h"
using namespace lldb_private;
LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
void LinuxSignals::Reset() {
m_signals.clear();
// SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION ALIAS
// ===== =========== ======== ===== ======
// ====================================== ======
AddSignal(1, "SIGHUP", false, true, true, "hangup");
AddSignal(2, "SIGINT", true, true, true, "interrupt");
AddSignal(3, "SIGQUIT", false, true, true, "quit");
AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
AddSignal(5, "SIGTRAP", true, true, true,
"trace trap (not reset when caught)");
AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
AddSignal(7, "SIGBUS", false, true, true, "bus error");
AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
AddSignal(9, "SIGKILL", false, true, true, "kill");
AddSignal(10, "SIGUSR1", false, true, true, "user defined signal 1");
AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
AddSignal(12, "SIGUSR2", false, true, true, "user defined signal 2");
AddSignal(13, "SIGPIPE", false, true, true,
"write to pipe with reading end closed");
AddSignal(14, "SIGALRM", false, false, false, "alarm");
AddSignal(15, "SIGTERM", false, true, true, "termination requested");
AddSignal(16, "SIGSTKFLT", false, true, true, "stack fault");
AddSignal(17, "SIGCHLD", false, false, true, "child status has changed",
"SIGCLD");
AddSignal(18, "SIGCONT", false, true, true, "process continue");
AddSignal(19, "SIGSTOP", true, true, true, "process stop");
AddSignal(20, "SIGTSTP", false, true, true, "tty stop");
AddSignal(21, "SIGTTIN", false, true, true, "background tty read");
AddSignal(22, "SIGTTOU", false, true, true, "background tty write");
AddSignal(23, "SIGURG", false, true, true, "urgent data on socket");
AddSignal(24, "SIGXCPU", false, true, true, "CPU resource exceeded");
AddSignal(25, "SIGXFSZ", false, true, true, "file size limit exceeded");
AddSignal(26, "SIGVTALRM", false, true, true, "virtual time alarm");
AddSignal(27, "SIGPROF", false, false, false, "profiling time alarm");
AddSignal(28, "SIGWINCH", false, true, true, "window size changes");
AddSignal(29, "SIGIO", false, true, true, "input/output ready/Pollable event",
"SIGPOLL");
AddSignal(30, "SIGPWR", false, true, true, "power failure");
AddSignal(31, "SIGSYS", false, true, true, "invalid system call");
AddSignal(32, "SIG32", false, false, false,
"threading library internal signal 1");
AddSignal(33, "SIG33", false, false, false,
"threading library internal signal 2");
AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
AddSignal(50, "SIGRTMAX-14", false, false, false,
"real time signal 16"); // switching to SIGRTMAX-xxx to match "kill
// -l" output
AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");
}

View File

@ -0,0 +1,32 @@
//===-- LinuxSignals.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_LinuxSignals_H_
#define liblldb_LinuxSignals_H_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Target/UnixSignals.h"
namespace lldb_private {
/// Linux specific set of Unix signals.
class LinuxSignals : public UnixSignals {
public:
LinuxSignals();
private:
void Reset() override;
};
} // namespace lldb_private
#endif // liblldb_LinuxSignals_H_

View File

@ -0,0 +1,97 @@
//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++
//-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "MipsLinuxSignals.h"
using namespace lldb_private;
MipsLinuxSignals::MipsLinuxSignals() : UnixSignals() { Reset(); }
void MipsLinuxSignals::Reset() {
m_signals.clear();
// SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION ALIAS
// ===== =========== ======== ===== ======
// ====================================== ========
AddSignal(1, "SIGHUP", false, true, true, "hangup");
AddSignal(2, "SIGINT", true, true, true, "interrupt");
AddSignal(3, "SIGQUIT", false, true, true, "quit");
AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
AddSignal(5, "SIGTRAP", true, true, true,
"trace trap (not reset when caught)");
AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
AddSignal(7, "SIGEMT", false, true, true, "terminate process with core dump");
AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
AddSignal(9, "SIGKILL", false, true, true, "kill");
AddSignal(10, "SIGBUS", false, true, true, "bus error");
AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
AddSignal(12, "SIGSYS", false, true, true, "invalid system call");
AddSignal(13, "SIGPIPE", false, true, true,
"write to pipe with reading end closed");
AddSignal(14, "SIGALRM", false, false, false, "alarm");
AddSignal(15, "SIGTERM", false, true, true, "termination requested");
AddSignal(16, "SIGUSR1", false, true, true, "user defined signal 1");
AddSignal(17, "SIGUSR2", false, true, true, "user defined signal 2");
AddSignal(18, "SIGCHLD", false, false, true, "child status has changed",
"SIGCLD");
AddSignal(19, "SIGPWR", false, true, true, "power failure");
AddSignal(20, "SIGWINCH", false, true, true, "window size changes");
AddSignal(21, "SIGURG", false, true, true, "urgent data on socket");
AddSignal(22, "SIGIO", false, true, true, "input/output ready/Pollable event",
"SIGPOLL");
AddSignal(23, "SIGSTOP", true, true, true, "process stop");
AddSignal(24, "SIGTSTP", false, true, true, "tty stop");
AddSignal(25, "SIGCONT", false, true, true, "process continue");
AddSignal(26, "SIGTTIN", false, true, true, "background tty read");
AddSignal(27, "SIGTTOU", false, true, true, "background tty write");
AddSignal(28, "SIGVTALRM", false, true, true, "virtual time alarm");
AddSignal(29, "SIGPROF", false, false, false, "profiling time alarm");
AddSignal(30, "SIGXCPU", false, true, true, "CPU resource exceeded");
AddSignal(31, "SIGXFSZ", false, true, true, "file size limit exceeded");
AddSignal(32, "SIG32", false, false, false,
"threading library internal signal 1");
AddSignal(33, "SIG33", false, false, false,
"threading library internal signal 2");
AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
AddSignal(50, "SIGRTMAX-14", false, false, false,
"real time signal 16"); // switching to SIGRTMAX-xxx to match "kill
// -l" output
AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");
}

View File

@ -0,0 +1,33 @@
//===-- MipsLinuxSignals.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_MipsLinuxSignals_H_
#define liblldb_MipsLinuxSignals_H_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Target/UnixSignals.h"
namespace lldb_private {
/// Linux specific set of Unix signals.
class MipsLinuxSignals : public UnixSignals {
public:
MipsLinuxSignals();
private:
void Reset() override;
};
} // namespace lldb_private
#endif // liblldb_MipsLinuxSignals_H_

Some files were not shown because too many files have changed in this diff Show More