My Project
ghidra_context.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __CONTEXT_GHIDRA__
17 #define __CONTEXT_GHIDRA__
18 
21 
22 #include "globalcontext.hh"
23 #include "ghidra_arch.hh"
24 
32  ArchitectureGhidra *glb;
33  mutable TrackedSet cache;
34  virtual ContextBitRange &getVariable(const string &nm) {
35  throw LowlevelError("getVariable should not be called for GHIDRA"); }
36  virtual const ContextBitRange &getVariable(const string &nm) const {
37  throw LowlevelError("getVariable should not be called for GHIDRA"); }
38  virtual void getRegionForSet(vector<uintm *> &res,const Address &addr1,const Address &addr2,int4 num,uintm mask) {
39  throw LowlevelError("getRegionForSet should not be called for GHIDRA"); }
40  virtual void getRegionToChangePoint(vector<uintm *> &res,const Address &addr,int4 num,uintm mask) {
41  throw LowlevelError("getRegionToChangePoint should not be called for GHIDRA"); }
42  virtual const uintm *getDefaultValue(void) const {
43  throw LowlevelError("getDefaultValue should not be called for GHIDRA"); }
44  virtual uintm *getDefaultValue(void) {
45  throw LowlevelError("getDefaultValue should not be called for GHIDRA"); }
46 public:
48  virtual ~ContextGhidra(void) {}
49 
50  // Routines that are actually implemented
51  virtual const TrackedSet &getTrackedSet(const Address &addr) const;
52 
53  // Ignored routines (taken care of by GHIDRA)
54  virtual void restoreXml(const Element *el,const AddrSpaceManager *manage) {}
55  virtual void restoreFromSpec(const Element *el,const AddrSpaceManager *manage) {}
56 
57  // Unimplemented routines (should never be called)
58  virtual int getContextSize(void) const {
59  throw LowlevelError("getContextSize should not be called for GHIDRA"); }
60  virtual const uintm *getContext(const Address &addr) const {
61  throw LowlevelError("getContext should not be called for GHIDRA"); }
62  virtual const uintm *getContext(const Address &addr,uintb &first,uintb &last) const {
63  throw LowlevelError("getContext should not be called for GHIDRA"); }
64  virtual void registerVariable(const string &nm,int4 sbit,int4 ebit) {
65  throw LowlevelError("registerVariable should not be called for GHIDRA"); }
66  virtual void saveXml(ostream &s) const {
67  throw LowlevelError("context::saveXml should not be called for GHIDRA"); }
68 
69  virtual TrackedSet &createSet(const Address &addr1,const Address &addr2) {
70  throw LowlevelError("createSet should not be called for GHIDRA"); }
71  virtual TrackedSet &getTrackedDefault(void) {
72  throw LowlevelError("getTrackedDefault should not be called for GHIDRA"); }
73 };
74 
75 #endif
vector< TrackedContext > TrackedSet
A set of tracked registers and their values (at one code point)
Definition: globalcontext.hh:74
An implementation of a ContextDatabase obtaining context information via a Ghidra client...
Definition: ghidra_context.hh:31
A manager for different address spaces.
Definition: translate.hh:218
virtual void saveXml(ostream &s) const
Serialize the entire database to an XML stream.
Definition: ghidra_context.hh:66
virtual void registerVariable(const string &nm, int4 sbit, int4 ebit)
Register a new named context variable (as a bit range) with the database.
Definition: ghidra_context.hh:64
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage)
Restore the state of this database object from a serialized XML stream.
Definition: ghidra_context.hh:54
virtual int getContextSize(void) const
Retrieve the number of words (uintm) in a context blob.
Definition: ghidra_context.hh:58
An interface to a database of disassembly/decompiler context information.
Definition: globalcontext.hh:108
ContextGhidra(ArchitectureGhidra *g)
Construct with a specific client.
Definition: ghidra_context.hh:47
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
virtual const uintm * getContext(const Address &addr, uintb &first, uintb &last) const
Get the context blob of values associated with a given address and its bounding offsets.
Definition: ghidra_context.hh:62
virtual const TrackedSet & getTrackedSet(const Address &addr) const
Get the set of tracked register values associated with the given address.
Definition: ghidra_context.cc:18
The lowest level error generated by the decompiler.
Definition: error.hh:44
virtual const uintm * getContext(const Address &addr) const
Get the context blob of values associated with a given address.
Definition: ghidra_context.hh:60
Description of a context variable within the disassembly context blob.
Definition: globalcontext.hh:30
An XML element. A node in the DOM tree.
Definition: xml.hh:150
virtual TrackedSet & getTrackedDefault(void)
Get the set of default values for all tracked registers.
Definition: ghidra_context.hh:71
virtual void restoreFromSpec(const Element *el, const AddrSpaceManager *manage)
Add initial context state from XML tags in compiler/processor specifications.
Definition: ghidra_context.hh:55
virtual TrackedSet & createSet(const Address &addr1, const Address &addr2)
Create a tracked register set that is valid over the given range.
Definition: ghidra_context.hh:69
Ghidra specific architecture information and connection to a Ghidra client.
An implementation of the Architecture interface and connection to a Ghidra client.
Definition: ghidra_arch.hh:60
Utilities for getting address-based context to the disassembler and decompiler.