File: PlatformState.h

package info (click to toggle)
edb-debugger 1.3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,124 kB
  • sloc: cpp: 46,241; xml: 4,998; ansic: 3,088; sh: 52; asm: 33; makefile: 5
file content (147 lines) | stat: -rw-r--r-- 4,018 bytes parent folder | download | duplicates (4)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
Copyright (C) 2006 - 2015 Evan Teran
                          evan.teran@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_20110330_
#define PLATFORM_STATE_H_20110330_

#include "IState.h"
#include "Types.h"
#include <Windows.h>

namespace DebuggerCorePlugin {

class PlatformState : public IState {
	friend class DebuggerCore;
	friend class PlatformThread;

public:
	PlatformState() = default;

public:
	std::unique_ptr<IState> clone() const override;

public:
	long double fpu_register(int n) const;
	quint64 mmx_register(int n) const;
	QByteArray xmm_register(int n) const;

public:
	QString flagsToString() const override;
	QString flagsToString(edb::reg_t flags) const override;
	Register value(const QString &reg) 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 {
		qDebug("TODO: implement PlatformState::empty");
		return true;
	}
	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 QString &name, edb::reg_t value) override;
	void setRegister(const Register &reg) override {
		qDebug("TODO: implement PlatformState::set_register");
	}

	Register archRegister(uint64_t type, size_t n) const override;

	Register mmxRegister(size_t n) const {
		qDebug("TODO: implement PlatformState::mmx_register");
		return Register();
	}

	Register xmmRegister(size_t n) const {
		qDebug("TODO: implement PlatformState::xmm_register");
		return Register();
	}

	Register ymmRegister(size_t n) const {
		qDebug("TODO: implement PlatformState::ymm_register");
		return Register();
	}

	Register gpRegister(size_t n) const override {
		qDebug("TODO: implement PlatformState::gp_register");
		return Register();
	}

	int fpuStackPointer() const override {
		qDebug("TODO: implement PlatformState::fpu_stack_pointer");
		return 0;
	}

	edb::value80 fpuRegister(size_t n) const override {
		qDebug("TODO: implement PlatformState::fpu_register");
		return edb::value80();
	}

	bool fpuRegisterIsEmpty(size_t n) const override {
		qDebug("TODO: implement PlatformState::fpu_register_is_empty");
		return true;
	}

	QString fpuRegisterTagString(size_t n) const override {
		qDebug("TODO: implement PlatformState::fpu_register_tag_string");
		return "";
	}

	edb::value16 fpuControlWord() const override {
		qDebug("TODO: implement PlatformState::fpu_control_word");
		return edb::value16();
	}

	edb::value16 fpuStatusWord() const override {
		qDebug("TODO: implement PlatformState::fpu_status_word");
		return edb::value16();
	}

	edb::value16 fpuTagWord() const override {
		qDebug("TODO: implement PlatformState::fpu_tag_word");
		return edb::value16();
	}

public:
	void getThreadState(HANDLE hThread, bool isWow64);
	void setThreadState(HANDLE hThread) const;

private:
#if defined(EDB_X86_64)
	union {
		CONTEXT context64_ = {};
		WOW64_CONTEXT context32_;
	};

	bool isWow64_ = false;
#else
	CONTEXT context32_;
#endif
	edb::address_t fs_base_ = 0;
	edb::address_t gs_base_ = 0;
};

}

#endif