File: RegisterRef.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 (44 lines) | stat: -rw-r--r-- 1,153 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

// inspired from code from mozilla: https://github.com/mozilla/rr/blob/master/src/Registers.cc

#ifndef REGISTER_REF_H_20191119_
#define REGISTER_REF_H_20191119_

#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstring>

class RegisterRef {
public:
	constexpr RegisterRef(const char *name, const void *ptr, std::size_t size)
		: name_(name), ptr_(ptr), size_(size) {
	}

	constexpr RegisterRef()          = default;
	RegisterRef(const RegisterRef &) = default;
	RegisterRef &operator=(const RegisterRef &) = default;

public:
	const void *data() const { return ptr_; }

public:
	bool operator==(const RegisterRef &rhs) const { return size_ == rhs.size_ && std::memcmp(ptr_, rhs.ptr_, size_) == 0; }
	bool operator!=(const RegisterRef &rhs) const { return size_ != rhs.size_ || std::memcmp(ptr_, rhs.ptr_, size_) != 0; }

public:
	bool valid() const { return ptr_ != nullptr; }

public:
	// The name of this register.
	const char *name_ = nullptr;

	// The ptr to register in state structure.
	const void *ptr_ = nullptr;

	// The size of the register. 0 means we cannot read it.
	std::size_t size_ = 0;
};

#endif