Executes the "x" command.
This low-level command prints the data in memory starting at specified addresses addr.
75 {
76 static size_t displayedCount = 1;
77 static size_t lastDisplayedAddress = 0;
78 static size_t MAUsToDisplay = 1;
79
80 const int argumentCount = arguments.size() - 1;
82 return false;
83 }
84
86 return false;
87 }
88
89 bool illegalArguments = false;
90 size_t newDisplayedCount = displayedCount;
91 size_t newMAUCount = MAUsToDisplay;
92 size_t newDisplayedAddress = lastDisplayedAddress + MAUsToDisplay;
93 std::string addressSpaceName = "";
94 std::string fileName = "";
95 for (size_t i = 1; i < arguments.size(); ++i) {
97 if (i == arguments.size() - 1 ||
99 illegalArguments = true;
100 break;
101 }
102 newDisplayedCount =
103 static_cast<size_t>(arguments.at(i + 1).integerValue());
104 ++i;
106 if (i == arguments.size() - 1) {
107 illegalArguments = true;
108 break;
109 }
110 const std::string size = arguments.at(i + 1).stringValue();
112 newMAUCount = 1;
114 newMAUCount = 2;
116 newMAUCount = 4;
117 } else {
118 illegalArguments = true;
119 break;
120 }
121 ++i;
123 if (i == arguments.size() - 1) {
124 illegalArguments = true;
125 break;
126 }
127 addressSpaceName = arguments.at(i + 1).stringValue();
128 ++i;
130 if (i == arguments.size() - 1) {
131 illegalArguments = true;
132 break;
133 }
134 fileName = arguments.at(i + 1).stringValue();
135 ++i;
136 } else if (i == arguments.size() - 1) {
137 const std::string addressString = arguments.at(i).stringValue();
139 addressString, addressSpaceName, newDisplayedAddress)) {
140 return false;
141 }
142 } else {
143 illegalArguments = true;
144 break;
145 }
146 }
147
148 if (illegalArguments) {
153 return false;
154 }
155
156 displayedCount = newDisplayedCount;
157 lastDisplayedAddress = newDisplayedAddress;
158
161 return false;
162 }
163
164 size_t MAUSize;
167 } else {
168 MAUSize =
170 addressSpace(addressSpaceName).width();
171 }
172
175 (boost::format("Maximum printable integer size %d.") %
178 return false;
179 }
180
181 std::ofstream* out = NULL;
182 const bool dumpToFile = fileName != "";
183 if (dumpToFile) {
184 if (MAUSize != sizeof(char)*8) {
186 (boost::format(
187 "Can only dump 8 bit memories to files. The given "
188 "address space is %d.") % MAUSize).str());
190 return false;
191 }
192 newMAUCount = 1;
193 out = new std::ofstream(fileName.c_str(), std::ios::binary);
194 }
195
196 MAUsToDisplay = newMAUCount;
198
199 while (newDisplayedCount > 0) {
200
202 try {
203 memory->read(newDisplayedAddress, MAUsToDisplay, data);
209 return false;
210 }
211
212
213 newDisplayedCount--;
214 newDisplayedAddress += MAUsToDisplay;
215
216 if (!dumpToFile) {
217 const int HEX_DIGITS = MAUSize*newMAUCount/4;
221
222 if (newDisplayedCount > 0) {
224 }
225 } else {
226 *out << (char)data;
227 }
228 }
229
230 if (dumpToFile) {
231 out->close();
232 delete out;
233 out = NULL;
234 }
236 return true;
237}
#define SIMULATOR_MAX_INTWORD_BITWIDTH
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
bool checkUnsignedIntegerArgument(const DataObject &argument)
ScriptInterpreter * interpreter() const
virtual std::string stringValue() const
virtual void setString(std::string value)
boost::shared_ptr< Memory > MemoryPtr
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
virtual void setError(bool state)
virtual void setResult(DataObject *result)
SimulatorFrontend & simulatorFrontend()
bool checkProgramLoaded()
bool setMemoryPointer(MemorySystem::MemoryPtr &memory, const std::string &addressSpaceName)
bool setMemoryAddress(const std::string &addressString, std::string &addressSpaceName, std::size_t &memoryAddress)
MemorySystem & memorySystem(int coreId=-1)
virtual int width() const
@ TXT_ADDRESS_OUT_OF_RANGE