Otawa  0.10
Process.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Process class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2003-8, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_PROGRAM_PROCESS_H
23 #define OTAWA_PROGRAM_PROCESS_H
24 
25 #include <elm/string.h>
26 #include <elm/system/Path.h>
27 #include <elm/util/AutoPtr.h>
28 #include <elm/genstruct/Vector.h>
29 #include <otawa/instruction.h>
30 #include <otawa/proc/Feature.h>
31 #include <otawa/prog/features.h>
32 #include <elm/stree/Tree.h>
33 
34 namespace elm { namespace xom {
35  class Element;
36 } } // elm::xom
37 
38 namespace otawa {
39 
40 using namespace elm::genstruct;
41 
42 // Pre-definition
43 class File;
44 namespace hard {
45  class Platform;
46  class CacheConfiguration;
47 }
48 class Loader;
49 class Manager;
50 class Processor;
51 class Process;
52 namespace sim {
53  class Simulator;
54 }
55 class Symbol;
56 class TextDecoder;
57 
58 
59 // ProcessException class
60 class ProcessException: public Exception {
61 public:
62  inline ProcessException(Process *process): proc(process)
63  { ASSERTP(process, "null process passed"); }
64  inline ProcessException(Process *process, const string& message): Exception(message), proc(process)
65  { ASSERTP(process, "null process passed"); }
66  inline Process *process(void) const { return proc; }
67  virtual String message(void);
68 
69 private:
71 };
72 
73 
74 // UnsupportedFeatureException class
76 public:
77 
79  Process *proc,
80  const AbstractFeature& feature
81  ): ProcessException(proc), f(feature) { }
82 
84  : ProcessException(0), f(feature) { }
85 
86  inline const AbstractFeature& feature(void) const { return f; }
87  virtual String message(void);
88 private:
90 };
91 
92 
93 // OutOfSegmentException class
95 public:
97  : ProcessException(proc), addr(address) { }
98  inline Address address(void) const { return addr; }
99  virtual String message(void);
100 private:
102 };
103 
104 
105 // DecodingException class
107 public:
108  DecodingException(const string& message);
109 };
110 
111 
112 // SimState class
113 class SimState {
114 public:
115  SimState(Process *process);
116  virtual ~SimState(void);
117  inline Process *process(void) const { return proc; }
118  virtual Inst *execute(Inst *inst) = 0;
119 
120  // register access
121  virtual void setSP(const Address& addr);
122  virtual t::uint32 getReg(hard::Register *r);
123  virtual void setReg(hard::Register *r, t::uint32 v);
124 
125  // memory accesses
126  virtual Address lowerRead(void);
127  virtual Address upperRead(void);
128  virtual Address lowerWrite(void);
129  virtual Address upperWrite(void);
130 
131 private:
133 };
134 
135 // Process class
136 class Process: public PropList, public Lock {
137 public:
138  Process(Manager *manager, const PropList& props = EMPTY, File *program = 0);
139  virtual ~Process(void);
140 
141  // Accessors
142  virtual hard::Platform *platform(void) = 0;
143  inline Manager *manager(void) { return man; }
144  virtual const hard::CacheConfiguration& cache(void);
145  virtual Inst *start(void) = 0;
146  virtual Inst *findInstAt(address_t addr);
147  virtual address_t findLabel(const string& label);
148  virtual Inst *findInstAt(const string& label);
149  inline File *program(void) const { return prog; }
150  virtual int instSize(void) const = 0;
151  virtual Processor *decoder(void);
152  virtual Loader *loader(void) const;
153  Symbol *findSymbol(const string& name);
154  Symbol *findSymbolAt(const Address& address);
155  virtual Address initialSP(void) const;
156  virtual Inst *newNOp(Address addr = Address::null);
157  virtual void deleteNop(Inst *inst);
158  virtual int maxTemp(void) const;
159 
160  // Memory access
161  virtual void get(Address at, t::int8& val);
162  virtual void get(Address at, t::uint8& val);
163  virtual void get(Address at, t::int16& val);
164  virtual void get(Address at, t::uint16& val);
165  virtual void get(Address at, t::int32& val);
166  virtual void get(Address at, t::uint32& val);
167  virtual void get(Address at, t::int64& val);
168  virtual void get(Address at, t::uint64& val);
169  virtual void get(Address at, Address& val);
170  virtual void get(Address at, float& val);
171  virtual void get(Address at, double& val);
172  virtual void get(Address at, long double& val);
173  virtual void get(Address at, string& str);
174  virtual void get(Address at, char *buf, int size);
175 
176  // LineNumber feature
177  virtual Option<Pair<cstring, int> > getSourceLine(Address addr)
179  virtual void getAddresses(cstring file, int line,
180  Vector<Pair<Address, Address> >& addresses)
182 
183  // Simulation management
184  virtual SimState *newState(void);
185  virtual sim::Simulator *simulator(void);
186 
187  // Constructors
188  File *loadProgram(elm::CString path);
189  virtual File *loadFile(elm::CString path) = 0;
190 
191  // loader 1.2.0
192  virtual Address defaultStack(void) const;
193  virtual void semInit(sem::Block& block) const;
194 
195  // FileIterator
196  class FileIter: public Vector<File *>::Iterator {
197  public:
198  inline FileIter(const Process *process)
199  : Vector<File *>::Iterator(process->files) { }
200  inline FileIter(const FileIter& iter)
201  : Vector<File *>::Iterator(iter) { }
202  };
203 
204 protected:
205  friend class WorkSpace;
206  void addFile(File *file);
207  void provide(AbstractFeature& feature);
208 
209 private:
210  void link(WorkSpace *ws);
211  void unlink(WorkSpace *ws);
217 };
218 
219 
220 // Process display
222 
223 } // otawa
224 
225 #endif // OTAWA_PROG_PROCESS_H
struct otawa::sem::inst inst
UnsupportedFeatureException(Process *proc, const AbstractFeature &feature)
Definition: Process.h:78
ProcessException(Process *process, const string &message)
Build a process exception with a message.
Definition: Process.h:64
FileIter(const Process *process)
Definition: Process.h:198
Manager * manager(void)
Get the manager owning this process.
Definition: Process.h:143
Definition: Process.h:196
const AbstractFeature & f
Definition: Process.h:89
int32_t int32
stree::Tree< Address::offset_t, Symbol * > * smap
Definition: Process.h:216
Definition: Process.h:113
Process * process(void) const
Definition: Process.h:117
const int provide
Definition: Registration.h:44
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
StringOption proc(command, 'p',"processor","used processor","path","")
Vector< AbstractFeature * > provided
Definition: Process.h:213
uint32 size
elm::io::IntFormat address(Address addr)
Build a format to display addresses.
Definition: base.cpp:213
The manager class providesfacilities for storing, grouping and retrieving shared resources like loade...
Definition: Manager.h:58
Process * proc
Definition: Process.h:132
Process * proc
Definition: Process.h:70
int16_t int16
This class represents a file involved in the building of a process.
Definition: File.h:43
The processor class is implemented by all code processor.
Definition: Processor.h:49
UnsupportedFeatureException(const AbstractFeature &feature)
Definition: Process.h:83
File * program(void) const
Get the program file, that is, the startup executable of the process.
Definition: Process.h:149
elm::StringBuffer buf
Definition: util_fft_lexer.cc:640
Vector< File * > files
Get the list of files used in this process.
Definition: Process.h:212
const AbstractFeature & feature(void) const
Definition: Process.h:86
An exception generated from a process.
Definition: Process.h:60
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
A process is the realization of a program on a platform.
Definition: Process.h:136
The representation of an address in OTAWA.
Definition: base.h:54
File * prog
Definition: Process.h:214
Manager * man
Definition: Process.h:215
StringOption cache(command, 'c',"cache","used cache","path","")
uint8_t uint8
int64_t int64
sys::SystemOutStream & out
IntFormat f(signed char value)
ProcessException(Process *process)
Definition: Process.h:62
This exception is thrown when a memory access is performed on process with an address that does not p...
Definition: Process.h:94
static Address null
Null address.
Definition: base.h:58
This interface is implemented by all objects that may build and provide a process.
Definition: Loader.h:31
This class records information about the architecture where the processed program will run...
Definition: Platform.h:48
cstring name
Definition: odisasm.cpp:107
FileIter(const FileIter &iter)
Definition: Process.h:200
int8_t int8
This class represents assembly instruction of a piece of code.
Definition: Inst.h:62
OutOfSegmentException(Process *proc, Address address)
Definition: Process.h:96
See Feature.
Definition: AbstractFeature.h:36
This a list of properties.
Definition: PropList.h:63
This exception is thrown by a loader to inform about problems during decoding.
Definition: Process.h:106
Objects of this class are simple machine register, more accurately unbreakable atomic registers...
Definition: Register.h:38
Address addr
Definition: Process.h:101
Address address(void) const
Definition: Process.h:98
This class represents the full configuration of caches of a processor.
Definition: CacheConfiguration.h:37
This class is used to throw an exception when a process does not support an invoked feature...
Definition: Process.h:75
uint16_t uint16
A symbol is a name of a location in a program.
Definition: Symbol.h:21
uint32_t uint32
uint64_t uint64
Process * process(void) const
Get the process where the exception was thrown.
Definition: Process.h:66