1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/*
Copyright (C) 2017 Ruslan Kabatsayev
b7.1010111@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLATFORM_STATE_H_20170806_
#define PLATFORM_STATE_H_20170806_
#include "IState.h"
#include "PrStatus.h"
#include "Types.h"
#include "edb.h"
#include <cstddef>
#include <sys/user.h>
#include <vector>
namespace DebuggerCorePlugin {
using std::size_t;
static constexpr size_t GPR_COUNT = 16;
static constexpr size_t VFPR_COUNT = 32;
struct user_vfp {
unsigned long long fpregs[32];
unsigned long fpscr;
};
class PlatformState final : public IState {
Q_DECLARE_TR_FUNCTIONS(PlatformThread)
friend class DebuggerCore;
friend class PlatformThread;
public:
PlatformState();
public:
std::unique_ptr<IState> clone() const override;
QString flagsToString() const override;
QString flagsToString(edb::reg_t flags) const override;
Register value(const QString ®) const override;
Register instructionPointerRegister() const override;
Register flagsRegister() const override;
edb::address_t framePointer() const override;
edb::address_t instructionPointer() const override;
edb::address_t stackPointer() const override;
edb::reg_t debugRegister(size_t n) const override;
edb::reg_t flags() const override;
void adjustStack(int bytes) override;
void clear() override;
bool empty() const override;
void setDebugRegister(size_t n, edb::reg_t value) override;
void setFlags(edb::reg_t flags) override;
void setInstructionPointer(edb::address_t value) override;
void setRegister(const Register ®) override;
void setRegister(const QString &name, edb::reg_t value) override;
Register gpRegister(size_t n) const override;
Register archRegister(uint64_t type, size_t n) const override {
return Register();
}
void fillFrom(const user_regs ®s);
void fillFrom(const user_vfp ®s);
void fillStruct(user_regs ®s) const;
void fillStruct(user_vfp ®s) const;
private:
struct GPR {
enum NamedGPRIndex : size_t {
SB = 9, // historical name, but still printed by modern disassemblers
SL = 10, // historical name, but still printed by modern disassemblers
FP = 11, // conventionally, but much like rBP on x86
IP = 12, // conventionally, intra-procedure scratch register
SP = 13,
LR = 14,
PC = 15,
};
using RegNameVariants = std::vector<const char *>;
static const std::array<RegNameVariants, GPR_COUNT> GPRegNames;
bool filled = false;
std::array<edb::reg_t, GPR_COUNT> GPRegs;
edb::reg_t cpsr;
public:
void clear();
bool empty() const;
} gpr;
struct VFP {
std::array<edb::value64, VFPR_COUNT> d;
edb::value32 fpscr;
bool filled = false;
} vfp;
private:
auto findGPR(const QString &name) const -> decltype(gpr.GPRegNames.begin());
};
}
#endif
|